I was reading through Scrap your type classes. This provides an alternatives for type classes. However, I was stuck with a comment by Paul Chiusano which talked about recovering the do notation syntax.
Frankly I could not understand how
return :: a -> (Monad f -> f a)
(>>=) :: (Monad f -> f a) -> (a -> (Monad f -> f b)) -> (Monad f -> f b)
would help recover do notation
You can implement all the monadic combinators like this, and desugar do notation to them. The do block evaluates to a function that accepts the monad dictionary, so you can even conveniently write code that's polymorphic in the choice of monad, without having to thread the dictionary around manually.
And especially, how it would fit int he context of GADT style approach mentioned in the above article?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With