[Haskell-cafe] lambda abstraction
Brandon Allbery
allbery.b at gmail.com
Sun Jun 5 19:33:36 CEST 2011
On Sun, Jun 5, 2011 at 07:45, Patrick Browne <patrick.browne at dit.ie> wrote:
> Are the following two functions equivalent? (i.e. do they describe the
> same computation)
>
> let add1 a = a + 2
> let add2 = \ a -> a + 2
Mostly. The monomorphism restriction can cause Haskell to restrict
the type of the second to "Integer -> Integer". Otherwise,
conceptually the first is turned into the second; this is the basis of
partial application (think
> let addN = \a -> \b -> a + b
which makes it clear that supplying "a" results in "\b -> supplied'a +
b" being returned).
More information about the Haskell-Cafe
mailing list