[Haskell-cafe] generic filter through MonadPlus
jason.dusek at gmail.com
Thu May 21 22:13:32 EDT 2009
It seems reasonable that filter should be generic. The
underlying container need only support some kind of traversal,
a zero element and a concatenation that eliminates zeroes.
A `Monad` provides traversal via `join` and `fmap`; the
remaining qualities are satisfied by `MonadPlus`. I've put
together an implementation of `filter` for `MonadPlus` that
works well enough for lists (though it presents somewhat
greater obstacles to efficient compilation).
I'm not sure whether `filter` is important enough to warrant
its own generics package -- it's one of many collection
operations that need to be generified. I'd like to know what
folks think about the use of `MonadPlus` in this case.
|...an implementation of `filter`...|
More information about the Haskell-Cafe