Nested bind operator #617
Replies: 3 comments 1 reply
-
Hi @shtefanntz one main issue with that operator would be that monads don't compose. It will be tricky if not impossible to specify the behaviour of such operator. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the answer! I guess this topic has already an answer in the community, but not diving too much into category theory, I wasn't even aware of the details of the problem :) Would you have any books or courses to recommend on category theory that are applicable in day to day FP? |
Beta Was this translation helpful? Give feedback.
-
I would recommend reading the Typeclassopedia which I find a bit more intuitive and applicable to F# and many other languages. To me it's a bit like the GoF Design Patterns but for FP and at another level of course. |
Beta Was this translation helpful? Give feedback.
-
Hi everyone! this library is super useful for working with f# monads. As I'm still at the surface with the whole functional toolkit, could we implement a nested bind operator
>>>=
?I'm trying to do it like this, but the compiler complains about missing constraints:
` type IMonad<'T> =
static abstract member (>>=): IMonad<'T> * ('T -> IMonad<'U>) -> IMonad<'U>
let inline (>>>=)<'UU, 'TT, 'T, 'U when 'T :> IMonad<IMonad<'TT>> and 'U :> IMonad<IMonad<'UU>>>
(source: 'T)
(binder: 'TT -> 'U)
: 'U =
source >>= (fun (s: IMonad<'TT>) -> s >>= (fun (ss: 'TT) -> binder ss))`
Beta Was this translation helpful? Give feedback.
All reactions