[Haskell-cafe] Re: help with Haskell programming

Jason Dagit dagit at codersbase.com
Mon Apr 19 12:11:32 EDT 2010

On Sun, Apr 18, 2010 at 10:25 AM, Sean Leather <leather at cs.uu.nl> wrote:

>> This is the annoying part about Haskell . I can not understand composition
>> .
> One of the ways of understanding composition (and many other functions in
> Haskell) is by trying to understand its type. Here it is shown by looking at
> the type in the interpreter GHCi.
> *Main> :t (.)
> (.) :: (b -> c) -> (a -> b) -> a -> c
> It's a function that takes three arguments, the first two of which are
> functions, and the third is something else.

As you mention below the function arrow (->), is right associative.  For
this reason I like to think of the above function as binary, instead of a
function of 3 arguments.  Making the associativity explicit we can rewrite
(.) :: (b -> c) -> (a -> b) -> (a -> c)

Now we can see that it is a binary function on functions.  You're mileage
may vary, but I find this form more intuitive.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100419/56771051/attachment.html

More information about the Haskell-Cafe mailing list