[Haskell-cafe] monomorphism restriction

Ryan Ingram ryani.spam at gmail.com
Mon Jun 16 17:22:55 EDT 2008

On 6/11/08, Jonathan Cast <jonathanccast at fastmail.fm> wrote:
> This doesn't apply to f, though --- it has a function type, so the user
> presumably already knows it won't be subject to updating, no?
> Distinguishing functions from variables by the form of declaration,
> rather than the type, seems somewhat questionable to me.

Not necessarily, contrast these two definitions:

f = foldr (+) 0
f_expensive = let n = head $ drop 100000 $ fibs 1 1 in foldr (+) n

With the monomorphism restriction in place, f_expensive only
calculates n once.  Without, it gets calculated each time f is

  -- ryan

More information about the Haskell-Cafe mailing list