[Haskell-cafe] a simple question about types

Daniel Fischer daniel.is.fischer at web.de
Wed Nov 17 14:28:06 EST 2010

On Wednesday 17 November 2010 20:19:17, Ryan Ingram wrote:
> Now of course, the followup question is "what the heck is a
> monomorphism restriction and why would I want it?"
> Here is a simple example:
> But if you give g the more general type signature, the
> expensiveComputation has to get run *every time g is called*.  This is
> because there's no way to create a single storage cell for c; there's
> a possible answer for every single type that is an instance of Num.
> f makes it clear; c does not get evaluated until the arguments are
> saturated and is locally allocated.  So it's alright to give it the
> polymorphic type.
>   -- ryan

That's a most excellent example, thanks.
I hope I find it the next time the topic comes up.

More information about the Haskell-Cafe mailing list