base-4.9.0.0: Basic libraries

Copyright(c) Nils Schweinsberg 2011, (c) George Giorgidze 2011 (c) University Tuebingen 2011
LicenseBSD-style (see the file libraries/base/LICENSE)
Maintainerlibraries@haskell.org
Stabilityexperimental
Portabilityportable
Safe HaskellSafe
LanguageHaskell2010

Control.Monad.Zip

Description

Monadic zipping (used for monad comprehensions)

Synopsis

Documentation

class Monad m => MonadZip m where Source

MonadZip type class. Minimal definition: mzip or mzipWith

Instances should satisfy the laws:

  • Naturality :
liftM (f *** g) (mzip ma mb) = mzip (liftM f ma) (liftM g mb)
  • Information Preservation:
liftM (const ()) ma = liftM (const ()) mb
==>
munzip (mzip ma mb) = (ma, mb)

Minimal complete definition

mzip | mzipWith

Methods

mzip :: m a -> m b -> m (a, b) Source

mzipWith :: (a -> b -> c) -> m a -> m b -> m c Source

munzip :: m (a, b) -> (m a, m b) Source

Instances

MonadZip [] 

Methods

mzip :: [a] -> [b] -> [(a, b)] Source

mzipWith :: (a -> b -> c) -> [a] -> [b] -> [c] Source

munzip :: [(a, b)] -> ([a], [b]) Source

MonadZip Maybe 

Methods

mzip :: Maybe a -> Maybe b -> Maybe (a, b) Source

mzipWith :: (a -> b -> c) -> Maybe a -> Maybe b -> Maybe c Source

munzip :: Maybe (a, b) -> (Maybe a, Maybe b) Source

MonadZip Last 

Methods

mzip :: Last a -> Last b -> Last (a, b) Source

mzipWith :: (a -> b -> c) -> Last a -> Last b -> Last c Source

munzip :: Last (a, b) -> (Last a, Last b) Source

MonadZip First 

Methods

mzip :: First a -> First b -> First (a, b) Source

mzipWith :: (a -> b -> c) -> First a -> First b -> First c Source

munzip :: First (a, b) -> (First a, First b) Source

MonadZip Product 

Methods

mzip :: Product a -> Product b -> Product (a, b) Source

mzipWith :: (a -> b -> c) -> Product a -> Product b -> Product c Source

munzip :: Product (a, b) -> (Product a, Product b) Source

MonadZip Sum 

Methods

mzip :: Sum a -> Sum b -> Sum (a, b) Source

mzipWith :: (a -> b -> c) -> Sum a -> Sum b -> Sum c Source

munzip :: Sum (a, b) -> (Sum a, Sum b) Source

MonadZip Dual 

Methods

mzip :: Dual a -> Dual b -> Dual (a, b) Source

mzipWith :: (a -> b -> c) -> Dual a -> Dual b -> Dual c Source

munzip :: Dual (a, b) -> (Dual a, Dual b) Source

MonadZip NonEmpty 

Methods

mzip :: NonEmpty a -> NonEmpty b -> NonEmpty (a, b) Source

mzipWith :: (a -> b -> c) -> NonEmpty a -> NonEmpty b -> NonEmpty c Source

munzip :: NonEmpty (a, b) -> (NonEmpty a, NonEmpty b) Source

MonadZip Identity 

Methods

mzip :: Identity a -> Identity b -> Identity (a, b) Source

mzipWith :: (a -> b -> c) -> Identity a -> Identity b -> Identity c Source

munzip :: Identity (a, b) -> (Identity a, Identity b) Source

MonadZip f => MonadZip (Alt (TYPE Lifted) f) 

Methods

mzip :: Alt (TYPE Lifted) f a -> Alt (TYPE Lifted) f b -> Alt (TYPE Lifted) f (a, b) Source

mzipWith :: (a -> b -> c) -> Alt (TYPE Lifted) f a -> Alt (TYPE Lifted) f b -> Alt (TYPE Lifted) f c Source

munzip :: Alt (TYPE Lifted) f (a, b) -> (Alt (TYPE Lifted) f a, Alt (TYPE Lifted) f b) Source

(MonadZip f, MonadZip g) => MonadZip (Product (TYPE Lifted) f g) 

Methods

mzip :: Product (TYPE Lifted) f g a -> Product (TYPE Lifted) f g b -> Product (TYPE Lifted) f g (a, b) Source

mzipWith :: (a -> b -> c) -> Product (TYPE Lifted) f g a -> Product (TYPE Lifted) f g b -> Product (TYPE Lifted) f g c Source

munzip :: Product (TYPE Lifted) f g (a, b) -> (Product (TYPE Lifted) f g a, Product (TYPE Lifted) f g b) Source