Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add letops support #127

Closed
4 tasks done
Tracked by #116 ...
mlms13 opened this issue Apr 8, 2023 · 1 comment
Closed
4 tasks done
Tracked by #116 ...

Add letops support #127

mlms13 opened this issue Apr 8, 2023 · 1 comment
Labels
enhancement New feature or request
Milestone

Comments

@mlms13
Copy link
Owner

mlms13 commented Apr 8, 2023

I think this is basically all we need to do:

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:

  • Use Melange to build
  • Add the functions outlined above
  • Add tests
  • Make sure the docs clearly explain this new preferred way to build up complex decoders
@mlms13 mlms13 mentioned this issue Apr 8, 2023
14 tasks
@mlms13 mlms13 added the enhancement New feature or request label Apr 8, 2023
@mlms13 mlms13 added this to the v2.0-alpha.1 milestone Apr 8, 2023
@mlms13
Copy link
Owner Author

mlms13 commented Apr 12, 2023

This was fixed in #136

@mlms13 mlms13 closed this as completed Apr 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant