
Excellent list. It seems like every time I hear about a problem with the
MMR, I go "wow, how come I never ran across that? oh yeah, because I write
type signatures..."
On Thu, Feb 26, 2009 at 5:51 PM, Felipe Lessa
On Thu, Feb 26, 2009 at 7:25 PM, Thomas Davie
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. _______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners