[Haskell-cafe] [announcement] filtrable: class of filtrable containers
M Farkas-Dyck
m.farkasdyck at gmail.com
Thu Feb 18 07:01:58 UTC 2016
On 17/02/2016, Chris Wong <lambda.fairy at gmail.com> wrote:
> On Thu, Feb 18, 2016 at 1:57 PM, martin <monkleyon at googlemail.com> wrote:
>> The only need for the functor requirement is in the default definition
>> of mapMaybe - so why not drop it?
>
> Since fmap can be defined in terms of mapMaybe:
>
> fmap f = mapMaybe (Just . f)
>
> Filtrable should imply Functor in the same way that Traversable
> implies Foldable.
I think the notion is to make mapMaybe not a class method, and rather
define it on its own:
mapMaybe f :: (Functor f, Filtrable f) => (a -> Maybe b) -> f a -> f b
mapMaybe f = catMaybes . fmap f
I like this idea, but worry what the laws would be...
More information about the Haskell-Cafe
mailing list