3 ms·
What's most interesting to me here is that this article uses JavaScript for all its examples. Also, this may well be the thing that finally helps me understand
by sdegutis 10y ago
What's most interesting to me here is that this article uses JavaScript for all its examples.
Also, this may well be the thing that finally helps me understand what the crap Monads are.
- jstimpfle 10y agoIt's not a bad example but lacking generality and more importantly explicit types. It's really all about connecting types like LEGO blocks, so the important thing is to show the type signatures. "bind" is the function required from Haskell's Monad typeclass, but not a good choice to explain monads. It's much cleaner to explain monads as functors with "join" and ("inject" aka return). map :: (a -> b) -> (M a -> M b) join :: M (M a) -> M a inject :: a -> M a With these guys you can easily compose "dirty" asymmetric operations like (readFile :: FilePath -> IO Bytes)
- jethrolarson 10y agoIt's hard to capture monad in a paragraph and a couple examples. The utility of chain/flatmap doesn't get too interesting until you apply it to the Option Type or Promises but I didn't want to require readers to come with knowledge of them. Maybe a promise-based example isn't asking too much though