[Haskell] why I need so much memory????

P.C.Callaghan p.c.callaghan at durham.ac.uk
Thu Nov 10 06:48:17 EST 2005


> You can write "any (==p) r", using a partial application of the equality
> predicate.  Reads better IMHO.

OR: you could write the slightly better (see below) version

	any (p==) r

Notice that this is directly partial application, rather than a shorthand
for "(flip (==) p)". The compiler probably shouldn't be relied upon to
spot that the operator is commutative and substitute the simpler version.
Hugs certainly doesn't do this, and the "(p==)"  version is noticeably
cheaper. I've not tested this on any other implementation.

Of course, switching to my version won't reduce the max heap size much!

As to whether either version reads better, that's a question to take to
the Cafe? I prefer to avoid sections in lectures - there's enough syntax
already, and it is good practice in using nameless functions!


More information about the Haskell mailing list