What is the difference between lambda abstractions?

  • A+
Category:Languages

What is the different between those expression:

z n = n + 1 

and

z = /n -> n  + 1  

?

 


The second declaration uses a simple binding z = ..., so it is affected by the monomorphism restriction. The first one uses a function binding z x = ..., so it is not affected.

Apart from that, there is no difference.

Adding an explicit type signature would remove even the difference about the monomorphism restriction, which would not apply to any of the declarations. The same holds if we disable the MR in GHC using a flag or LANGUAGE pragma, of course.

Comment

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: