On May 22, 2007, at 22:35 , PR Stanley wrote:
Could you perhaps demonstrate how you can apply parts of curried functions in other functions in Haskell?

A trivial example:

Prelude> map (+1) [1..10]
[2,3,4,5,6,7,8,9,10,11]

(Strictly speaking (+1) is a section, but that's just a syntactic special case of currying.)

More usefully, the same thing can be used in a State monad with the "modify" function:

Prelude Control.Monad.State> runState (modify (+1)) 1
((),2)

While this is again a trivial example, you can use modify with a curried function or a section in more complicated examples to modify the state "in place".

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


_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to