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

Michael Mossey mpm at alumni.caltech.edu
Sun Jun 27 01:58:07 EDT 2010

Is there a way to write the function

process :: [(Location,Item)] -> [(Location,ValuableItem)]

given a function indicating which Item's to keep

transform :: Item -> Maybe ValuableItem

using functors and arrows? The value for location stays with any item that 
is kept.

What I have is

process inp = catMaybes (map g inp)
   where g (l,i) = case transform i of
     Nothing -> Nothing
     Just v  -> Just (l,v)

This looks like an arrow situation to me because you want to make a 
function that acts on the second value in a tuple, and a little bit like a 
Maybe functor.


More information about the Beginners mailing list