summaryrefslogtreecommitdiff
path: root/libraries/base/Control/Monad/Zip.hs
diff options
context:
space:
mode:
authorGeorge Giorgidze <giorgidze@gmail.com>2011-07-04 21:01:12 +0200
committerSimon Peyton Jones <simonpj@microsoft.com>2011-07-15 18:13:07 +0100
commit73103cac22a42c619a1f3930d39d9e9ecac796e7 (patch)
tree022113855e42315d087b3bfa409f27dc744b01ae /libraries/base/Control/Monad/Zip.hs
parentac28a24c06ea8608395fe15ee587ce8081b9020c (diff)
downloadhaskell-73103cac22a42c619a1f3930d39d9e9ecac796e7.tar.gz
Move the munzip function in the Zip type class;
Diffstat (limited to 'libraries/base/Control/Monad/Zip.hs')
-rw-r--r--libraries/base/Control/Monad/Zip.hs14
1 files changed, 10 insertions, 4 deletions
diff --git a/libraries/base/Control/Monad/Zip.hs b/libraries/base/Control/Monad/Zip.hs
index 8c431bdbfb..9d71a53878 100644
--- a/libraries/base/Control/Monad/Zip.hs
+++ b/libraries/base/Control/Monad/Zip.hs
@@ -3,6 +3,7 @@
-- |
-- Module : Control.Monad.Zip
-- Copyright : (c) Nils Schweinsberg 2011,
+-- (c) George Giorgidze 2011
-- (c) University Tuebingen 2011
-- License : BSD-style (see the file libraries/base/LICENSE)
-- Maintainer : libraries@haskell.org
@@ -40,8 +41,13 @@ class Monad m => MonadZip m where
mzipWith :: (a -> b -> c) -> m a -> m b -> m c
mzipWith f ma mb = liftM (uncurry f) (mzip ma mb)
-instance MonadZip [] where
- mzip = zip
+ munzip :: m (a,b) -> (m a, m b)
+ munzip mab = (liftM fst mab, liftM snd mab)
+ -- munzip is a member of the class because sometimes
+ -- you can implement it more efficiently than the
+ -- above default code. See Trac #4370 comment by giorgidze
-munzip :: MonadZip m => m (a,b) -> (m a, m b)
-munzip mab = (liftM fst mab, liftM snd mab)
+instance MonadZip [] where
+ mzip = zip
+ mzipWith = zipWith
+ munzip = unzip \ No newline at end of file