-
Notifications
You must be signed in to change notification settings - Fork 139
mapMaybeM #183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Have you seen the witherable package?
…On Tue, Aug 29, 2017 at 10:13 AM Andrew Martin ***@***.***> wrote:
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
<https://hackage.haskell.org/package/monad-extras-0.6.0/docs/Control-Monad-Extra.html#v:mapMaybeM>,
extra
<https://hackage.haskell.org/package/extra-1.6/docs/Control-Monad-Extra.html#v:mapMaybeM>,
and in stack
<https://hackage.haskell.org/package/stack-1.0.0/docs/src/Data.Maybe.Extra.html>.
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.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#183>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAAQwsq4PplMJdQOTB0QpMvTg2edcbgfks5sdBx7gaJpZM4PGAYH>
.
|
I have. Still, a more direct definition of |
Sorry... what do you mean by more definition ?
…On Tue, Aug 29, 2017 at 7:24 PM Andrew Martin ***@***.***> wrote:
I have. Still, the more definition of mapMaybeM would be more efficient
that using witherM.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#183 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAAQwlQT105_I9lhnIWKte0lVisQYpOwks5sdJ3GgaJpZM4PGAYH>
.
|
Sorry, I corrected my comment on github. I meant to say that we could define a mapMaybeM in vector that is more efficient than witherM specialized to Vector and Maybe.
…Sent from my iPhone
On Aug 29, 2017, at 11:12 PM, Carter Tazio Schonwald ***@***.***> wrote:
Sorry... what do you mean by more definition ?
On Tue, Aug 29, 2017 at 7:24 PM Andrew Martin ***@***.***>
wrote:
> I have. Still, the more definition of mapMaybeM would be more efficient
> that using witherM.
>
> —
> You are receiving this because you commented.
>
>
> Reply to this email directly, view it on GitHub
> <#183 (comment)>, or mute
> the thread
> <https://github.com/notifications/unsubscribe-auth/AAAQwlQT105_I9lhnIWKte0lVisQYpOwks5sdJ3GgaJpZM4PGAYH>
> .
>
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Also witherable instance couldn't be defined for both unboxed and storable vectors |
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? |
Sure.
I’m hapoy to help with making sure we have a. Decent stream fusion rep if
needed.
One question is if a witherable style interface can be supported too?
…On Wed, Apr 4, 2018 at 5:46 PM Andrew Martin ***@***.***> wrote:
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?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#183 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAAQwkvnM-Gxaqc6vA5j4Fhc7HDSBCxgks5tlT9NgaJpZM4PGAYH>
.
|
What do you mean by a witherable-style interface? Currently,
What I'm proposing is:
My constraint is stronger, but my understanding is that |
Add ```haskell mapMaybeM :: Monad m => (a -> m (Maybe b)) -> Vector a -> m (Vector b) imapMaybeM :: Monad m => (Int -> a -> m (Maybe b)) -> Vector a -> m (Vector b) ``` `mapMaybeM` is similar to `wither`, but the stream fusion framework seems to require that we use a `Monad` constraint rather than an `Applicative` one to get good performance. `imapMaybeM` is the indexed variant. Resolves haskell#183
Add ```haskell mapMaybeM :: Monad m => (a -> m (Maybe b)) -> Vector a -> m (Vector b) imapMaybeM :: Monad m => (Int -> a -> m (Maybe b)) -> Vector a -> m (Vector b) ``` `mapMaybeM` is similar to `wither`, but the stream fusion framework seems to require that we use a `Monad` constraint rather than an `Applicative` one to get good performance. `imapMaybeM` is the indexed variant. Resolves #183
Add ```haskell mapMaybeM :: Monad m => (a -> m (Maybe b)) -> Vector a -> m (Vector b) imapMaybeM :: Monad m => (Int -> a -> m (Maybe b)) -> Vector a -> m (Vector b) ``` `mapMaybeM` is similar to `wither`, but the stream fusion framework seems to require that we use a `Monad` constraint rather than an `Applicative` one to get good performance. `imapMaybeM` is the indexed variant. Resolves #183
Can I add
mapMaybeM
tovector
? The type signature would be:Although the list-equivalent of
mapMaybeM
is not inbase
, it's a pretty common thing for people to write. I can see from some googling that it exists inmonad-extras
,extra
, and instack
. 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.The text was updated successfully, but these errors were encountered: