top | item 46134474

(no title)

doyougnu | 2 months ago

Couldn't have said it better myself. But IIUC Andrew stated that its not a monad because it does not build up a computation and then run. Rather, its as if every function runs a `runIO#` or `runReader` every time the io parameter is used.

discuss

order

tome|2 months ago

Is it necessary that a monad "builds up a computation and then runs"? In fact it's very hard for a monad to do that because the type of bind is

    (>>=) :: m a -> (a -> m b) -> m b
so you can really only make progress if you first build a bit (`m a`), then run it (to get `a`) then build the next bit (applying `a` to `a -> m b`), then run that. So "building" and "running" must necessarily be interleaved. It's an odd myth that "Haskell's IO purely builds an impure computation to run".

AndyKelley|2 months ago

Are you saying "monad" is a synonym of "interface"?

tylerhou|2 months ago

Monads do not need to build up a computation. The identity functor is a monad.