Parameter order of runReader, evalState (Was: expanded standard lib)

Josef Svenningsson josef.svenningsson at gmail.com
Thu Nov 22 07:12:58 EST 2007


On Nov 22, 2007 12:49 PM, Henning Thielemann
<lemming at henning-thielemann.de> wrote:
>
> On Tue, 20 Nov 2007, Ross Paterson wrote:
>
> > On Mon, Nov 19, 2007 at 11:31:51PM +0100, Bjorn Bringert wrote:
> > > On Nov 19, 2007, at 23:13 , Henning Thielemann wrote:
> > >> I like to see MTL split into a Haskell98 part and an advanced part. I
> > >> mostly use functionality which would nicely fit into a Haskell98 interface
> > >> and find it annoying that by importing MTL my code becomes less portable.
> > >
> > > Yes! Please!
> >
> > You mean something like http://darcs.haskell.org/packages/mtl-split ?
> > The plan is to split Control.Monad.Identity, Control.Monad.Trans and
> > Control.Monad.Trans.* off into a separate portable, low-level package.
>
> I noticed that I frequently use (flip runReader, flip evalState) for
> point-free programming. What was the reason to choose the current order?
> What is the experience of other programmers?

The order of the run* functions comes from the fact that they are
record selectors. This implies that they need to take the monadic
computaion as their first argument. An example:
newtype StateT s m a = StateT { runStateT :: s -> m (a,s) }

I'm guessing that evalState and the other derived functions inherited
the argument order from the run* functions.

I also tend to the other order, with the monadic computation last.

Cheers,

Josef


More information about the Libraries mailing list