Skip to content

Commit

Permalink
chore: add remaining deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
mlms13 committed Mar 24, 2023
1 parent faa9f68 commit ba6224c
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@
"relude": "^0.66.1"
},
"jest": {
"testPathIgnorePatterns": [
"./test/output",
"_build",
"_opam"
],
"coveragePathIgnorePatterns": [
"./test"
],
Expand Down
2 changes: 2 additions & 0 deletions src/Decode.re
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ module Make = Base.Make;

module ParseError = Decode_ParseError;

[@deprecated "Use Decode.ParseError instead"]
module AsOption = Decode_AsOption;

module AsResult = {
module OfParseError = Decode_AsResult_OfParseError;

Expand Down
7 changes: 7 additions & 0 deletions src/Decode_AsResult_OfParseError.rei
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,21 @@ let literalFloat: (float, Js.Json.t) => result(float, ParseError.failure);
let stringUnion:
((string, 'a), list((string, 'a)), Js.Json.t) =>
result('a, ParseError.failure);

[@deprecated "Use literal instead"]
let variantFromJson:
(
Js.Json.t => result('a, ParseError.failure),
'a => option('b),
Js.Json.t
) =>
result('b, ParseError.failure);

[@deprecated "Use stringUnion instead"]
let variantFromString:
(string => option('a), Js.Json.t) => result('a, ParseError.failure);

[@deprecated "Use literalInt and alt/oneOf instead"]
let variantFromInt:
(int => option('a), Js.Json.t) => result('a, ParseError.failure);

Expand Down Expand Up @@ -213,6 +219,7 @@ let dict:
(Js.Json.t => result('a, ParseError.failure), Js.Json.t) =>
result(Js.Dict.t('a), ParseError.failure);

[@deprecated "Use dict instead, and convert the Dict to a Map"]
let stringMap:
(Js.Json.t => result('a, ParseError.failure), Js.Json.t) =>
result(Belt.Map.String.t('a), ParseError.failure);
Expand Down
1 change: 1 addition & 0 deletions src/Decode_Base.re
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ module Make =
let mkDecode = ((s, v)) => literalString(s) |> map(_ => v);
first |> mkDecode |> oneOf(_, rest |> List.map(mkDecode));
};

let variantFromJson = (jsonToJs, jsToVariant) =>
jsonToJs
|> map(jsToVariant)
Expand Down
1 change: 1 addition & 0 deletions test/Decode_AsOption_test.re
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ open Jest;
open Expect;
open Relude.Globals;

[@ocaml.warning "-3"]
module Decode = Decode.AsOption;
module Sample = Decode_TestSampleData;

Expand Down
1 change: 1 addition & 0 deletions test/Decode_AsResult_OfParseError_test.re
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ describe("Simple decoders", () => {
);

test("variant", () =>
[@ocaml.warning "-3"]
expect(Decode.variantFromString(Sample.colorFromJs, Sample.jsonString))
|> toEqual(valErr(`ExpectedValidOption, Sample.jsonString))
);
Expand Down

0 comments on commit ba6224c

Please sign in to comment.