[commit: ghc] master: Set default-impl of `mapM`/`sequence` methods to `traverse`/`sequenceA` (f636faa)
git at git.haskell.org
git at git.haskell.org
Sat Sep 27 21:07:32 UTC 2014
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/f636faa7b2b7fc1d0663f994ad08f365d39a746d/ghc
>---------------------------------------------------------------
commit f636faa7b2b7fc1d0663f994ad08f365d39a746d
Author: Herbert Valerio Riedel <hvr at gnu.org>
Date: Sat Sep 27 22:55:19 2014 +0200
Set default-impl of `mapM`/`sequence` methods to `traverse`/`sequenceA`
This is made possible by the AMP, as we don't need the `WrappedMonad`
helper for that anymore.
Approved-by: Edward Kmett <ekmett at gmail.com>
>---------------------------------------------------------------
f636faa7b2b7fc1d0663f994ad08f365d39a746d
libraries/base/Data/Traversable.hs | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/libraries/base/Data/Traversable.hs b/libraries/base/Data/Traversable.hs
index eb5123d..1c8b605 100644
--- a/libraries/base/Data/Traversable.hs
+++ b/libraries/base/Data/Traversable.hs
@@ -46,7 +46,7 @@ module Data.Traversable (
foldMapDefault,
) where
-import Control.Applicative ( Const(..), WrappedMonad(..) )
+import Control.Applicative ( Const(..) )
import Data.Either ( Either(..) )
import Data.Foldable ( Foldable )
import Data.Functor
@@ -157,12 +157,12 @@ class (Functor t, Foldable t) => Traversable t where
-- | Map each element of a structure to a monadic action, evaluate
-- these actions from left to right, and collect the results.
mapM :: Monad m => (a -> m b) -> t a -> m (t b)
- mapM f = unwrapMonad . traverse (WrapMonad . f)
+ mapM = traverse
-- | Evaluate each monadic action in the structure from left to right,
-- and collect the results.
sequence :: Monad m => t (m a) -> m (t a)
- sequence = mapM id
+ sequence = sequenceA
{-# MINIMAL traverse | sequenceA #-}
-- instances for Prelude types
More information about the ghc-commits
mailing list