[Haskell-cafe] lambda abstraction

wren ng thornton wren at freegeek.org
Mon Jun 6 04:52:28 CEST 2011


On 6/5/11 1:33 PM, Brandon Allbery wrote:
> 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".

Also, in GHC 7 they may have different behavior with regards to 
inlining. That is, GHC 7 changed its rules to only inline when the 
arguments to the left of "=" have been saturated (I'm not sure how this 
interacts with the INLINE or INLINEABLE pragma).

Whether this operational difference would count as "different" depends 
on how fine-grained you want your operational semantics to be. It 
wouldn't show up in the denotational semantics side of things.

-- 
Live well,
~wren



More information about the Haskell-Cafe mailing list