Giter VIP home page Giter VIP logo

Comments (1)

davidchambers avatar davidchambers commented on June 8, 2024

Thanks very much for raising this issue, @danr. :)

Until recently Fantasy Land did not define a Filterable type class, so it was necessary to cobble together a filter function from the type classes available at the time. In #2 we introduced two filter functions:

filter :: (Applicative f, Foldable f, Monoid (f a)) => (a -> Boolean, f a) -> f a
filterM :: (Monad m, Monoid (m a)) => (a -> Boolean, m a) -> m a

The goal was to support as many filterable types as possible by providing two different derivations. The functions were necessarily given different names, with the M suffix hinting at the Monad m constraint. Although the M suffix may have been added for the same reason as in Haskell, Sanctuary's filterM was never intended to mirror its Haskell namesake.

In #37 the type of filterM was changed to permit Z.filterM(odd, Just(4)):

-filterM :: (Monad m, Monoid (m a)) => (a -> Boolean, m a) -> m a
+filterM :: (Alternative m, Monad m) => (a -> Boolean, m a) -> m a

Recently, in #80, the two filter functions were replaced with a single unified function:

filter :: Filterable f => (a -> Boolean, f a) -> f a

Now that the name is available we could provide the Sanctuary equivalent of Haskell's filterM. I find your powerset example extremely compelling! If you're interested in working on a pull request for this addition, please say so. :)

from sanctuary-type-classes.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.