[Haskell-cafe] wondering about a MonadIO instance for a heap data type

Brandon Allbery allbery.b at gmail.com
Thu Jul 12 02:12:42 CEST 2012

On Wed, Jul 11, 2012 at 8:00 PM, Qi Qi <qiqi789 at gmail.com> wrote:

> List [] is a monad, why not for heap data. Heap data could be an instance
> of Monad too.

Only if you can define a meaningful semantics for it.  Lists aren't a monad
because of liftIO, but because the monad pattern means something
(backtracking/multiple evaluation).  What does the monad pattern mean for
your heap?

I'm not saying there *isn't* one; I'm saying that you must *have* one in
order to make a monad.  Monads are not simply some sneaky way to slipstream
I/O into expressions; IO is just one possible monad, and many programs make
heavier use of other monads such as state and reader.  And in particular,
most applications of the list monad don't involve any I/O.  (Almost
necessarily, since the standard ListT is actually broken but can't be fixed
for backward compatibility reasons.)

brandon s allbery                                      allbery.b at gmail.com
wandering unix systems administrator (available)     (412) 475-9364 vm/sms
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20120711/533be1bf/attachment.htm>

More information about the Haskell-Cafe mailing list