3 ms·
This paper calls attention to my biggest source of discomfort with Haskell's approach to monads: They end up hiding so much under the covers that everything sta
by bunderbunder 9y ago
This paper calls attention to my biggest source of discomfort with Haskell's approach to monads: They end up hiding so much under the covers that everything starts to look the same. The author leaned on this particularly hard for rhetorical effect in the article, but it's not always so different in the real world. It really harms readability. I've noticed, for example, that it's not unheard of for someone to come asking for help with a do-block's behavior, and the first response they get is someone having to ask what monad that do-block is using.
F#'s approach (which it calls computation expressions) makes a small tweak that makes all the difference in the world - instead of always using the word "do", you start a block with the name of the monad you want.
So instead of
do { ... }
do { ... }
do { ... }
everywhere, you get:
maybe { ... }
seq { ... }
async { ... }
- tome 9y agoFirstly, that's almost never a problem as you almost always have a type signature to hand. Secondly, F#'s approach is not a small tweak. It's forced on them by a lack of higher-kinded types. Thirdly, if it really bothers you use TypeApplications to write with @Maybe $ do { ... } with @[] $ do { ... } with @Cont $ do { ... }
- dllthomas 9y agoI assume `with :: forall m a. m a -> m a; with = id` - is that defined somewhere?