I'm struggling to understand the decoding example in the tests
let decode: Js.Json.t => Belt.Result.t(t, string) =
json => {
make
<$> JD.intFor("userId", json)
<*> JD.intFor("id", json)
<*> JD.stringFor("title", json)
<*> JD.boolFor("completed", json)
|> Relude.Result.fromValidation
|> Relude.Result.mapError(_ => "Decode failed");
};
Would this be equal to the following?
let decode: Js.Json.t => Belt.Result.t(t, string) =
json => {
make
|> map(JD.intFor("userId", json))
|> ap(JD.intFor("id", json))
|> ap(JD.stringFor("title", json))
|> ap(JD.boolFor("completed", json))
|> Relude.Result.fromValidation
|> Relude.Result.mapError(_ => "Decode failed");
};
With some direction, I'd be glad to open a PR adding examples sans infix operators. It would be nice to able to see the two versions side by side for mere mortals like I.
I'm struggling to understand the decoding example in the tests
Would this be equal to the following?
With some direction, I'd be glad to open a PR adding examples sans infix operators. It would be nice to able to see the two versions side by side for mere mortals like I.