
On 28/11/2008, at 15:46, Simon Peyton-Jones wrote:
The $f2 comes from the instance Monad (IterateeGM ...). print_lines uses a specialised version of that instance, namely Monad (IterateeGM el IO) The fact that print_lines uses it makes GHC generate a specialised version of the instance decl.
Even in the absence of print_lines you can generate the specialised instance thus
instance Monad m => Monad (IterateeGM el m) where {-# SPECIALISE instance Monad (IterateeGM el IO) #-} ... methods...
does that help?
Once Simon and Neil dig the issue and analyze it, the reason seems evident. But this thread reminds of why writing high performance Haskell code is regarded as a black art outside the community (well, and sometimes inside too). Wouldn't a JIT version of GHC be a great thing to have? Or would a backend for LLVM be already beneficial enough? Cheers pepe