Help understanding type signature of flatMap
in section 6.1?
#84
-
Hi 🙂 Many thanks to the author for creating this tutorial, it's been very useful for me in trying to grasp some of the typeclasses in haskell! I was hoping I could get some help understanding something? I was trying to do the exercise where the reader is asked to provide an implementation of The type signature given for learn-haskell-blog-generator/src/06-errors_and_files/01-either.md Lines 350 to 351 in a0dac9c and I was having trouble understanding the second arg type and the return type; namely, that they both have only one type parameter filled-in for the I was trying to reason through it in my head, and I was half-wondering if this should maybe be: flatMap :: (a -> Either e b) -> Either e a -> Either e b
flatMap func val = flatten (fmap func val) One reason I thought this might be the case is that this would make the kind of both of them be I was also thinking that, since
that the return type of learn-haskell-blog-generator/src/06-errors_and_files/01-either.md Lines 325 to 329 in a0dac9c whose return type is of kind The above reasoning kinda makes sense to me, but I'm not at all confident in this... 😅 Would anyone be able to help me understand this? Thanks again! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
No, you are right. The text is wrong. This should be as you said: flatMap :: (a -> Either e b) -> Either e a -> Either e b
flatMap func val = flatten (fmap func val) Thanks for spotting and reporting. Will fix this momentarily. |
Beta Was this translation helpful? Give feedback.
No, you are right. The text is wrong. This should be as you said:
Thanks for spotting and reporting. Will fix this momentarily.