[Haskell-beginners] maybe use for functors or arrows?

Stephen Tetley stephen.tetley at gmail.com
Sun Jun 27 03:38:31 EDT 2010

Hi Michael

The /case transform i of .../ code should be able to be rephrased with
fmap as it is "putting back" the first element of the tuple if
/transform/ produces a (Just) value.

fmap (\a -> (a,v))

Personally, I would look to avoiding building the list of type ::Maybe
(Location,ValuableItem) during the first traversal (via map) to later
filter them out with a second traversal via catMaybes.

The optimization technique "stream fusion" can often collapse
compositions of list functionals (map, filter, etc). into one
traversal. But it isn't available by default - you have to install the
stream-fusion library. Also a composition of functionals isn't
necessarily clearer than a direct implementation.

Best wishes


More information about the Beginners mailing list