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

Brandon S. Allbery KF8NH allbery at ece.cmu.edu
Mon May 10 07:06:11 EDT 2010


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 at kf8nh.com
system administrator [openafs,heimdal,too many hats] allbery at ece.cmu.edu
electrical and computer engineering, carnegie mellon university    KF8NH


-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 195 bytes
Desc: This is a digitally signed message part
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100510/d3f4fd8e/PGP.bin


More information about the Haskell-Cafe mailing list