[Haskell-cafe] lambda abstraction

Yves Parès limestrael at gmail.com
Sun Jun 5 14:10:53 CEST 2011


Well, yes add1 and add2 are equivalent. You can use either one or the other.

The type annotation can be read:
for all type 'a' such as 'a' is an instance of class Num, there exists a
function add1 that takes an 'a' and returns an 'a'.

2011/6/5 Patrick Browne <patrick.browne at dit.ie>

> Are the following two functions equivalent? (i.e. do they describe the
> same computation)
>
> let add1 a  = a + 2
> let add2 = \ a -> a + 2
>
> :t add1
> add1 :: forall a. (Num a) => a -> a
>
> :t add2
> add2 :: forall a. (Num a) => a -> a
>
>
> Does Haskell interpreter convert all functions in the form of add1 to
> the lambda form of add2?
>
> Does this lambda form represent the operational semantics of Haskell?
>
>
> How should I translate the type information into English?
>
>
> Thanks
> Pat
>
>
>
>
> This message has been scanned for content and viruses by the DIT
> Information Services E-Mail Scanning Service, and is believed to be clean.
> http://www.dit.ie
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20110605/1bc8ce08/attachment.htm>


More information about the Haskell-Cafe mailing list