[Haskell-cafe] Library design question

Henning Thielemann lemming at henning-thielemann.de
Thu Sep 18 18:01:14 EDT 2008

On Thu, 18 Sep 2008, Andre Nathan wrote:

> On Thu, 2008-09-18 at 21:15 +0200, Henning Thielemann wrote:
>> Think of the state monad as processing a graph in-place. Which graph is
>> addressed is declared when running the State monad using runState or
>> evalState.
> Interesting. Is it good practice then to do something like
>  type GraphM a b = State (Graph a b)
> to hide from the user that I'm using the State monad underneath?

'type' won't hide anything but reduces writing. With 'newtype' you could 
hide the State monad. You could do this, if you plan to change the 
representation of a Graph to something based on mutable structures. On the 
other hand with 'newtype GraphM' the user could not easily work on several 
states of the graph simultaneously.

More information about the Haskell-Cafe mailing list