[Haskell] Re: Long live Edison

Paul Johnson paul at cogito.org.uk
Tue Feb 21 02:53:39 EST 2006

Robert Dockins <robdockins at fastmail.fm> wrote:

> Consistency.  Almost all the other API functions take the data  
> structure argument last.  This seems to be a kind of de facto  
> standard and deviations from it are likely to cause confusion.

I'd always assumed that the reason that data structure functions take the data structure last is because of the commonest case of partial application, where you want a function of the form Struct -> Struct.

For instance suppose you had:

   type MyState = State (Sequence Int)

   myStateFunc1:: MyState ()
   myStateFunc1 = do
      x <- someThing
      modify $ lcons x

Now you want the equivalent for rcons:

   myStateFunc2 :: MyState ()
   myStateFunc2 = do
      x <- someThing
      modify $ (flip rcons) x

The extra "flip" is confusing and distracting.  It gets worse for functions of more than two arguments: you wind up needing a lambda.

(BTW I haven't checked the code against the reference manual, so sorry if I've got it a bit wrong).


More information about the Haskell mailing list