Skip to content

Commit

Permalink
Add forM_ compat definition (#12209)
Browse files Browse the repository at this point in the history
I keep confusing myself because of this and I expect I’m not the only
one. We have this for forM already so this only seems natural.

The definition is in DA.Foldable rather than DA.Internal.Compatible
since it doesn’t make sense to have it imported when you don’t import forA_.

changelog_begin
changelog_end
  • Loading branch information
cocreature authored Dec 20, 2021
1 parent 99f9776 commit 0142c6a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions compiler/damlc/daml-stdlib-src/DA/Foldable.daml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ mapA_ f = foldr ((*>) . f) (pure ())
forA_ : (Foldable t, Applicative f) => t a -> (a -> f b) -> f ()
forA_ = flip mapA_

{-# DEPRECATED forM_ "Daml compatibility helper, use 'forA_' instead of 'forM_'" #-}
forM_ : (Foldable t, Applicative f) => t a -> (a -> f b) -> f ()
forM_ = forA_

-- | Evaluate each action in the structure from left to right,
-- and ignore the results. For a version that doesn't ignore the
-- results see 'DA.Traversable.sequence'.
Expand Down
7 changes: 7 additions & 0 deletions compiler/damlc/tests/daml-test-files/ActionCompat.daml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-- @WARN use 'forA_' instead of 'forM_'
module ActionCompat where

import DA.Foldable

test : Update ()
test = forM_ [0..3] $ \i -> debug i

0 comments on commit 0142c6a

Please sign in to comment.