base-4.6.0.1: Basic libraries

Portability | portable
Stability | experimental
Maintainer | libraries@haskell.org
Safe Haskell | Safe

Control.Monad.Zip

Description

Monadic zipping (used for monad comprehensions)

Synopsis

- class Monad m => MonadZip m where
  - 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)

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

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 [] |