[Haskell-cafe] Re: A bit of a shock - Memoizing functions

Jonathan Cast jonathanccast at fastmail.fm
Fri Mar 27 17:32:26 EDT 2009

On Fri, 2009-03-27 at 14:26 -0700, Kirk Martinez wrote:
> Your powersOfTwo function, since it gets memoized automatically (is
> this the case for all functions of zero arguments?),

It is the case for all functions which have zero arguments *at the time
they are presented to the code generator*.  The infamous evil
monomorphism restriction arises from the fact that overloaded
expressions, such as

    negative_one = exp(pi * sqrt(-1))

look like functions of zero arguments, but are not, and hence do not get
memoized.  This behavior was considered sufficiently surprising, when it
was discovered in early Haskell compilers, that the construct was
outlawed from the language entirely.


More information about the Haskell-Cafe mailing list