Simon Peyton-Jones wrote:
| The source code has explicit monomorphic types all over it; I would
| expect GHC to be able to optimise out any method calls. (OTOH, I'm not a
| GHC expert... Simon? Don?)
Full monomorphisation is a whole-program optimisation and GHC isn't (yet) a
whole-program compiler. Overloaded functions are indeed specialised for the
types at which they are called *in the module they are defined*.
Simon
What I'm trying to say is, I would have expected, say,
resultant :: [Vector2] -> Vector2
resultant = sum
to run faster than
resultant = sum
In the latter case, we have resultant :: (Num n) => [n] -> n. I'm no
expert, but I would expect that this requires a method lookup on each
call, whereas with the more restrictive type I would expect the compiler
to be able to just link directly to the correct method implementation.
Am I mistaken?
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe