Skip to content

mapMaybeM #183

Description

@andrewthad

Can I add mapMaybeM to vector? The type signature would be:

mapMaybeM :: (a -> m (Maybe b)) -> Vector a -> m (Vector b)

Although the list-equivalent of mapMaybeM is not in base, it's a pretty common thing for people to write. I can see from some googling that it exists in monad-extras, extra, and in stack. I bring this up because I think it highlights the utility of such a function and the common expected semantics people seem to have for it.

Activity

  1. cartazio commented on Aug 29, 2017

    @cartazio
    Contributor
  2. andrewthad commented on Aug 29, 2017

    @andrewthad
    ContributorAuthor

    I have. Still, a more direct definition of mapMaybeM would be more efficient that using witherM.

  3. cartazio commented on Aug 30, 2017

    @cartazio
    Contributor
  4. andrewthad commented on Aug 30, 2017

    @andrewthad
    ContributorAuthor
  5. Shimuuar commented on Oct 14, 2017

    @Shimuuar
    Contributor

    Also witherable instance couldn't be defined for both unboxed and storable vectors

  6. andrewthad commented on Apr 4, 2018

    @andrewthad
    ContributorAuthor

    I just noticed the absence of these functions again when I was working on something. Is it alright for me to add these to vector?

  7. cartazio commented on Apr 5, 2018

    @cartazio
    Contributor
  8. andrewthad commented on Apr 5, 2018

    @andrewthad
    ContributorAuthor

    What do you mean by a witherable-style interface? Currently, wither is defined as:

    wither :: Applicative f => (a -> f (Maybe b)) -> t a -> f (t b)
    

    What I'm proposing is:

    mapMaybeM :: Monad m => (a -> m (Maybe b)) -> Vector a -> m (Vector b)
    

    My constraint is stronger, but my understanding is that vector's stream fusion only works with a Monad constraint. So, I don't think that the witherable interface can be supported.

  9. added a commit that references this issue on Nov 5, 2018
    41f2393
  10. added this to the 0.13 milestone on Jun 11, 2020
  11. added a commit that references this issue on Oct 10, 2020
    ba4de94
  12. added a commit that references this issue on Jan 16, 2021
    8318efd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions