[Haskell-beginners] Lambda Functions
Felipe Lessa
felipe.lessa at gmail.com
Thu Feb 26 17:51:32 EST 2009
On Thu, Feb 26, 2009 at 7:25 PM, Thomas Davie <tom.davie at gmail.com> wrote:
> I'm not 100% certain here, so someone may correct me, but I think this is
> what's going on:
[snip]
Yep, that's right. Is it just me or the monomorphism restriction
suddenly became the hot topic here on beginners?
> Another way to write it ofc would simply be uncurry (==).
Better yet, write a type signature. I highly recommend writing type
signatures for *all* top-level definitions, including non-exported
ones:
- You avoid most cases where the monomorphism restriction would bother you.
- You avoid type errors on other functions (sometimes you make a
mistake but the code type checks with a wrong signature, and the type
error shows up only when you use the function elsewhere).
- It gives you some insights before implementing, and helps whoever
reads your code.
- It allows you to specialize the code when polymorphism is not needed.
Probably there are other reasons as well, but these are the most prominent.
--
Felipe.
More information about the Beginners
mailing list