[Haskell-cafe] monomorphism restriction
dons at galois.com
Wed Jun 11 23:24:02 EDT 2008
> Definition of f:
> f = foldr (+) 0
> 0 :: (Num t) => t
> foldr (+) 0 :: Num a => [a] -> a
> f :: [Integer] -> Integer
> Please remind me, again, of the advantages of f being something different
> from the formula defining it.
Overloaded 'constants' take a dictionary as an argument, so while you
think the value might be computed only once, it make actually be
recomputed each time. This can be a killer performance penalty for
overloaded numeric constants.
Of course, disabling this is pretty simple.
More information about the Haskell-Cafe