-
Notifications
You must be signed in to change notification settings - Fork 479
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
Add Plutus implementation of mapM_ (fix #3203). #3209
Conversation
plutus-tx/src/PlutusTx/Foldable.hs
Outdated
{-# INLINABLE mapM_ #-} | ||
mapM_ :: (Foldable t, Monad m) => (a -> m b) -> t a -> m () | ||
mapM_ f = foldr c (return ()) | ||
-- See Note [List fusion and continuations in 'c'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is this note? And does it apply to Plutus?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was looking at https://hackage.haskell.org/package/base-4.15.0.0/docs/src/Data-Foldable.html#mapM_
Yeah, not sure about Plutus, removed.
@@ -201,3 +209,10 @@ find p = getFirst . foldMap (\ x -> First (if p x then Just x else Nothing)) | |||
(#.) :: Coercible b c => (b -> c) -> (a -> b) -> (a -> c) | |||
(#.) _f = coerce | |||
{-# INLINE (#.) #-} | |||
|
|||
{-# INLINABLE mapM_ #-} | |||
mapM_ :: (Foldable t, Monad m) => (a -> m b) -> t a -> m () |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haddocks: "Plutus version of 'Control.Monad.mapM_'
We should probably also add mapM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, fixed, but to Data.Foldable.mapM_
because that's the original location. And mapM
is already in PlutusTx.Traversable
.
fd5e2a9
to
338c855
Compare
@michaelpj I have rebased the PR, should be possible to merge now. |
The problem in #3203 is that PlutusTx.Prelude re-exports Prelude.mapM_ which fails to compile. The fix is to add Plutus's own implementation.
Pre-submit checklist:
Pre-merge checklist: