[Haskell-cafe] Profiling nested case

Brandon S. Allbery KF8NH allbery at ece.cmu.edu
Fri Jul 11 20:39:41 EDT 2008


On 2008 Jul 11, at 19:46, Mitar wrote:

> It is somehow award that passing function as an argument slow down the
> program so much. Is not Haskell a functional language and this such
> (functional) code reuse is one of its main points?

That is in fact the case; GHC's version of various Prelude functions  
refactors them to avoid passing functional arguments.  IIRC the  
problem is that, while Haskell is indeed functional, passing a  
polymorphic function as an argument causes the runtime to have to look  
up which type is needed for every call, whereas if it's factored out  
it can be computed only once and (implicitly) let-bound.

-- 
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery at kf8nh.com
system administrator [openafs,heimdal,too many hats] allbery at ece.cmu.edu
electrical and computer engineering, carnegie mellon university    KF8NH




More information about the Haskell-Cafe mailing list