4 ms·
I think it's a matter of perspective. I tried to user Either, but without proper pattern matching and syntactic sugar for monadic operations, I didn't quite lik
by valenterry 4y ago
I think it's a matter of perspective. I tried to user Either, but without proper pattern matching and syntactic sugar for monadic operations, I didn't quite like it.
That being said, I think the authors did a great job to make it as good as possible given the limitations.
- epolanski 4y agoCould you show the limitations you're speaking of? I know fp-ts very well and it does not have those limitations you're speaking of. Either admits all of the functor, bifunctor, monad, apply, applicative and traversable instances in fp-ts (so do all the other bifunctors) so there's no shortage of combinators.
- valenterry 4y agoEssentially, I want do write things in the style of (pseudocode) do { result1 <- either1 result2 <- either2 result3 <- fooReturningEither(result1, resul2) } yield result1 + result3 and so on. This gets very noisy without syntactic sugar.
- epolanski 4y ago@valenterry (I can't reply further), you can do that: https://codesandbox.io/s/wispy-shadow-7789p6?file=/src/index.ts https://codesandbox.io/s/wispy-shadow-7789p6?file=/src/index... In whatever ways you want to complicate it (with exceptions, asynchronous operations, with or without Do syntax) you can easily do that in fp-ts.
- valenterry 4y agoYou can click on the timestamp of the post to reply next time ;)
- epolanski 4y agoToday I learned, thank you.
- valenterry 4y ago(edited) That's actually not too bad!
- valenterry 4y agoIf you are still here: any resources on how to build those other things that you mentioned myself? For example, if I would like to combine either and reader into a single monad, how would that look like? Now I'm kinda thrilled!