Andreas Abel | 12 Jun 16:45 2014
Picon
Picon

List.or, List.any and List.elem

Curious on whether I should prefer

   List.any f

over

   List.or . List.map f

I consulted the source code at

http://www.haskell.org/ghc/docs/latest/html/libraries/base/src/GHC-List.html

I found that according to the Report, they are identical, but there are 
fusion rules for List.any which look like I should prefer it to the said 
composition.

What puzzled me is that later,

   List.elem x

is

   List.any (x ==)

according to the Report, but GHC defines it recursively, *without* 
fusion rules.  I wonder

Q1: Should I prefer List.any (x==) then, since it gives opportunity to 
fusion?

(Continue reading)


Gmane