[haskell-cafe] Monad and kinds

Yitzchak Gale gale at sefer.org
Wed Sep 3 05:19:36 EDT 2008

Ramin wrote:
> ...no matter how many tutorials I read, I find the only
> kind of monad I can write is the monad that I copied
> and pasted from the tutorial...
> I am writing a mini-database...
> The query itself is stateful...
> The query may also make updates to the records.
> I also
> thought of trying to re-write my query algorithm to somehow use
> "Control.Monad.State.Strict" instead of my own query type, but then I
> wouldn't get to write my own monad!

Just Control.Monad.State should work fine.

Daniel Fischer wrote:
> But this looks very much like an application well suited for the State monad
> (or a StateT). So why not use that?

I agree with Daniel.

If you want to learn about the deeper theory of the inner
workings of monads, that's great - go ahead, and have fun!

But to solve your problem in practice, you don't need that level of
knowledge. All you need to know about is get, put, modify,
and liftIO. The StateT monad is really simple to use.

In general, practical software is higher quality when it uses
existing standard libraries. There is no more reason to re-invent
the StateT monad than there is to re-invent anything else
in the libraries.

Among the multitude of monad tutorials out there, I wonder how
many of them draw a clear line between what you need to
understand to design monads, and what you need to understand
just to use them. There's a huge difference in complexity.
Like most things, it is best to use monads for a while and
get comfortable with them before trying to learn how to design
them and build them.


More information about the Haskell-Cafe mailing list