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
Use Do from fp-ts-contrib to reduce nesting #1143
Conversation
eed997c
to
123a28e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely improves readability for someone not-yet-FP-literate like me, too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Do is so cool. It simplifies a lot in a civilized way. I left few comments and I'm tentatively approving. Good luck with release!
During my daily Haskell reading I discovered the Do notation that such language has and how it simplifies a lot the dealing with multiple Monads when you have to, yes, chain the things together but you do not want to lose the previous value after a chain.
Such situation is not manageable in fp-ts and we've been doing some hacks (well they're not hacks frankly, it's just the way it should be done) — and so here we are.
After learning about Haskell, I started to look into various alternatives to see if there'd be a way to accumulate the results over time and having better code.
I found what I was looking for in
fp-ts-contribpackage. I won't go in detail in this code, I think it's self explanatory and you can see how the readability has improved significantly. To understand a little bit more about the feature, point your browser to this article: https://paulgray.net/do-syntax-in-typescript/I am pretty sure I have covered all the parts in Prism — but I might have missed some we can refactor as we move on Prism.
I am happy.