Skip to content

Commit

Permalink
update: deprecate mapN, nel, resultOf
Browse files Browse the repository at this point in the history
  • Loading branch information
mlms13 committed Apr 8, 2023
1 parent c89e464 commit 8242290
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Decode_AsOption.re
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[@ocaml.warning "-3"]
module OptionTransform:
Decode_ParseError.TransformError with type t('a) = option('a) = {
type t('a) = option('a);
Expand Down
1 change: 1 addition & 0 deletions src/Decode_AsResult_OfParseError.re
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module NonEmptyList = Relude.NonEmpty.List;
module ParseError = Decode_ParseError;

[@ocaml.warning "-3"]
module Result =
ParseError.ResultOf({
type t = ParseError.base;
Expand Down
7 changes: 7 additions & 0 deletions src/Decode_AsResult_OfParseError.rei
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[@deprecated
"NonEmptyList helpers shouldn't be needed, but you can find them in Relude"
]
module NonEmptyList: Decode_NonEmptyList.Nel;
module ParseError = Decode_ParseError;

Expand All @@ -13,6 +16,7 @@ let apply:
) =>
result('b, ParseError.failure);

[@deprecated "Will be removed in 2.0 with the addition of and+"]
let map2:
(
('a, 'b) => 'c,
Expand All @@ -22,6 +26,7 @@ let map2:
) =>
result('c, ParseError.failure);

[@deprecated "Will be removed in 2.0 with the addition of and+"]
let map3:
(
('a, 'b, 'c) => 'd,
Expand All @@ -32,6 +37,7 @@ let map3:
) =>
result('d, ParseError.failure);

[@deprecated "Will be removed in 2.0 with the addition of and+"]
let map4:
(
('a, 'b, 'c, 'd) => 'e,
Expand All @@ -43,6 +49,7 @@ let map4:
) =>
result('e, ParseError.failure);

[@deprecated "Will be removed in 2.0 with the addition of and+"]
let map5:
(
('a, 'b, 'c, 'd, 'e) => 'f,
Expand Down
1 change: 1 addition & 0 deletions src/Decode_AsResult_OfStringNel.re
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ module ResultUtil = {
let pure = Result.pure;
let flat_map = Result.bind;

[@ocaml.warning "-3"]
module Transform:
ParseError.TransformError with
type t('a) = result('a, NonEmptyList.t(string)) = {
Expand Down
1 change: 1 addition & 0 deletions src/Decode_Base.re
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ open BsBastet.Interface;

module ParseError = Decode_ParseError;

[@ocaml.warning "-3"]
module Make =
(T: ParseError.TransformError, M: MONAD with type t('a) = T.t('a)) => {
type t('a) = Js.Json.t => M.t('a);
Expand Down
4 changes: 4 additions & 0 deletions src/Decode_ParseError.rei
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ and objError('a) =

type failure = t(base);

[@deprecated "Extending the result type is deprecated"]
module type TransformError = {
type t('a);
let valErr: (base, Js.Json.t) => t('a);
Expand All @@ -42,11 +43,14 @@ let toDebugString:

let failureToDebugString: t(base) => string;

[@deprecated "Extending the result type is deprecated"]
module type ValError = {
type t;
let handle: base => t;
};

[@deprecated "Extending the result type is deprecated"]
[@ocaml.warning "-3"]
module ResultOf:
(Err: ValError) =>
{
Expand Down
1 change: 1 addition & 0 deletions test/Decode_AsResult_OfCustom_test.re
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module Sample = Decode_TestSampleData;

type customError = [ ParseError.base | `InvalidColor | `InvalidShape];

[@ocaml.warning "-3"]
module ResultCustom =
Decode.ParseError.ResultOf({
type t = customError;
Expand Down
4 changes: 4 additions & 0 deletions test/Decode_AsResult_OfParseError_test.re
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ describe("Inner decoders", () => {
});

describe("Large, nested decoder", () => {
[@ocaml.warning "-3"]
let decodeJob =
Decode.(
map4(
Expand Down Expand Up @@ -362,18 +363,21 @@ describe("Parse error combinations", () => {
let objError = Decode.ParseError.(objPure("x", MissingField));

test("combine Val/Val", () =>
[@ocaml.warning "-3"]
expect(Decode.(map2(combine, string, boolean, Sample.jsonNull)))
|> toEqual(valErr(`ExpectedString, Sample.jsonNull))
);

test("combine Arr/Val", () =>
[@ocaml.warning "-3"]
expect(
Decode.(map2(combine, list(boolean), boolean, Sample.jsonArrayString)),
)
|> toEqual(Result.error(arrError))
);

test("combine Obj/Val", () =>
[@ocaml.warning "-3"]
expect(
Decode.(
map2(combine, field("x", boolean), boolean, Sample.jsonDictEmpty)
Expand Down

0 comments on commit 8242290

Please sign in to comment.