let ( let* ) = flat_map;
let (let+) = (m, f) => map(f, m);
let (and+) = (m1, m2) => map2((a, b) => (a, b), m1, m2);
But we probably don't want to define (and+) in terms of map2, since map2 is likely going away (#119). So instead, we should probably just add a let pair function that does exactly what (and+) wants, and we can define it in terms of apply.
Then decoders can be used like:
let decode = {
open Decode;
let+ company = field("company_id", string)
and+ employee = field("employee_id", string);
{employee, company};
};
The checklist:
[x] Use Melange to build
[x] Add the functions outlined above
[x] Add tests
[x] Make sure the docs clearly explain this new preferred way to build up complex decoders
I think this is basically all we need to do:
But we probably don't want to define
(and+)
in terms ofmap2
, sincemap2
is likely going away (#119). So instead, we should probably just add alet pair
function that does exactly what(and+)
wants, and we can define it in terms ofapply
.Then decoders can be used like:
The checklist: