haskell-cafe@haskell.org
[Top] [All Lists]

Re: [Haskell-cafe] Type of (>>= f) where f :: a -> m b

Subject: Re: [Haskell-cafe] Type of (>>= f) where f :: a -> m b
From: "Brandon S. Allbery KF8NH"
Date: Mon, 10 May 2010 07:06:11 -0400
On May 10, 2010, at 05:51 , Milind Patil wrote:
There seems to something special about (>>=) apart from its type. And whats (Monad ((->) b))? I am new to Haskell and I may have gaps in my understanding of
type inference in Haskell.


Everyone else having answered the first question, I'll take this one: ((->) r) is the monad of functions with a single argument (and therefore all functions, as Haskell curries all functions: that is, "f a b c" is a function which takes an a and returns a function that takes a b, which in turn produces a function that takes a c and produces the final result). It's also known as the Reader monad. The syntax is the function form of the section (r ->) (which I think is otherwise illegal, since -> is actually syntax rather than an operator); understand this as a partial application of (r -> x), a function which takes an r and produces an x.

--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@xxxxxxxxx
system administrator [openafs,heimdal,too many hats] allbery@xxxxxxxxxxx
electrical and computer engineering, carnegie mellon university    KF8NH


_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@xxxxxxxxxxx
http://www.haskell.org/mailman/listinfo/haskell-cafe
<Prev in Thread] Current Thread [Next in Thread>