[Haskell-cafe] Re: Difference in Runtime but no explanation

Daniel Fischer daniel.is.fischer at web.de
Tue Dec 15 17:03:38 EST 2009

Am Dienstag 15 Dezember 2009 21:50:22 schrieb Johann Höchtl:
> It's b, compiled without optimisations.

Don't do that. Maybe if you have huge projects with large compile times. But without 
optimisations, small variations can incur huge performance costs (as we see here).

> >
> > If a) or b), it's because the second has one more function call per list
> > element, first ($!) is called and then seq via that, while the first
> > calls seq directly.
> Ah, ok, I was not aware that this is realy a function call. I thought
> this is syntactic sugar only and would be rewritten into a call to
> `seq`. I think to much of a macro in this case.

It's a real function, defined in Haskell. Unfortunately, without -O, ghc is not keen to 
inline across module boundaries. It would be inlined within the same module. 
seq is a primitive from GHC.prim, thus it's special and doesn't produce a function call.

More information about the Haskell-Cafe mailing list