base-4.10.1.0: Basic libraries

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
Stability | experimental
Portability | portable
Safe Haskell | Safe
Language | Haskell2010

Control.Monad.Zip

Description

Monadic zipping (used for monad comprehensions)

Synopsis

- class Monad m => MonadZip m where

# Documentation

class Monad m => MonadZip m where #

`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) #

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

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

Instances

MonadZip [] # | Since: 4.3.1.0
Methods mzip :: [a] -> [b] -> [(a, b)] # mzipWith :: (a -> b -> c) -> [a] -> [b] -> [c] # munzip :: [(a, b)] -> ([a], [b]) #
MonadZip Maybe # | Since: 4.8.0.0
Methods mzip :: Maybe a -> Maybe b -> Maybe (a, b) # mzipWith :: (a -> b -> c) -> Maybe a -> Maybe b -> Maybe c # munzip :: Maybe (a, b) -> (Maybe a, Maybe b) #
MonadZip Par1 # | Since: 4.9.0.0
Methods mzip :: Par1 a -> Par1 b -> Par1 (a, b) # mzipWith :: (a -> b -> c) -> Par1 a -> Par1 b -> Par1 c # munzip :: Par1 (a, b) -> (Par1 a, Par1 b) #
MonadZip Last # | Since: 4.8.0.0
Methods mzip :: Last a -> Last b -> Last (a, b) # mzipWith :: (a -> b -> c) -> Last a -> Last b -> Last c # munzip :: Last (a, b) -> (Last a, Last b) #
MonadZip First # | Since: 4.8.0.0
Methods mzip :: First a -> First b -> First (a, b) # mzipWith :: (a -> b -> c) -> First a -> First b -> First c # munzip :: First (a, b) -> (First a, First b) #
MonadZip Product # | Since: 4.8.0.0
Methods mzip :: Product a -> Product b -> Product (a, b) # mzipWith :: (a -> b -> c) -> Product a -> Product b -> Product c # munzip :: Product (a, b) -> (Product a, Product b) #
MonadZip Sum # | Since: 4.8.0.0
Methods mzip :: Sum a -> Sum b -> Sum (a, b) # mzipWith :: (a -> b -> c) -> Sum a -> Sum b -> Sum c # munzip :: Sum (a, b) -> (Sum a, Sum b) #
MonadZip Dual # | Since: 4.8.0.0
Methods mzip :: Dual a -> Dual b -> Dual (a, b) # mzipWith :: (a -> b -> c) -> Dual a -> Dual b -> Dual c # munzip :: Dual (a, b) -> (Dual a, Dual b) #
MonadZip Identity # | Since: 4.8.0.0
Methods mzip :: Identity a -> Identity b -> Identity (a, b) # mzipWith :: (a -> b -> c) -> Identity a -> Identity b -> Identity c # munzip :: Identity (a, b) -> (Identity a, Identity b) #
MonadZip NonEmpty # | Since: 4.9.0.0
Methods mzip :: NonEmpty a -> NonEmpty b -> NonEmpty (a, b) # mzipWith :: (a -> b -> c) -> NonEmpty a -> NonEmpty b -> NonEmpty c # munzip :: NonEmpty (a, b) -> (NonEmpty a, NonEmpty b) #
MonadZip (U1 *) # | Since: 4.9.0.0
Methods mzip :: U1 * a -> U1 * b -> U1 * (a, b) # mzipWith :: (a -> b -> c) -> U1 * a -> U1 * b -> U1 * c # munzip :: U1 * (a, b) -> (U1 * a, U1 * b) #
MonadZip (Proxy *) # | Since: 4.9.0.0
Methods mzip :: Proxy * a -> Proxy * b -> Proxy * (a, b) # mzipWith :: (a -> b -> c) -> Proxy * a -> Proxy * b -> Proxy * c # munzip :: Proxy * (a, b) -> (Proxy * a, Proxy * b) #
MonadZip f => MonadZip (Rec1 * f) # | Since: 4.9.0.0
Methods mzip :: Rec1 * f a -> Rec1 * f b -> Rec1 * f (a, b) # mzipWith :: (a -> b -> c) -> Rec1 * f a -> Rec1 * f b -> Rec1 * f c # munzip :: Rec1 * f (a, b) -> (Rec1 * f a, Rec1 * f b) #
MonadZip f => MonadZip (Alt * f) # | Since: 4.8.0.0
Methods mzip :: Alt * f a -> Alt * f b -> Alt * f (a, b) # mzipWith :: (a -> b -> c) -> Alt * f a -> Alt * f b -> Alt * f c # munzip :: Alt * f (a, b) -> (Alt * f a, Alt * f b) #
(MonadZip f, MonadZip g) => MonadZip ((:*:) * f g) # | Since: 4.9.0.0
Methods mzip :: (* :*: f) g a -> (* :*: f) g b -> (* :*: f) g (a, b) # mzipWith :: (a -> b -> c) -> (* :*: f) g a -> (* :*: f) g b -> (* :*: f) g c # munzip :: (* :*: f) g (a, b) -> ((* :*: f) g a, (* :*: f) g b) #
(MonadZip f, MonadZip g) => MonadZip (Product * f g) # | Since: 4.9.0.0
Methods mzip :: Product * f g a -> Product * f g b -> Product * f g (a, b) # mzipWith :: (a -> b -> c) -> Product * f g a -> Product * f g b -> Product * f g c # munzip :: Product * f g (a, b) -> (Product * f g a, Product * f g b) #
MonadZip f => MonadZip (M1 * i c f) # | Since: 4.9.0.0
Methods mzip :: M1 * i c f a -> M1 * i c f b -> M1 * i c f (a, b) # mzipWith :: (a -> b -> c) -> M1 * i c f a -> M1 * i c f b -> M1 * i c f c # munzip :: M1 * i c f (a, b) -> (M1 * i c f a, M1 * i c f b) #