base-4.20.2.0: Core data structures and operations

Copyright | (c) Ross Paterson 2010
License | BSD-style (see the file LICENSE)
Maintainer | libraries@haskell.org
Stability | stable
Portability | portable
Safe Haskell | Safe
Language | Haskell2010

Data.Functor.Product

Description

Products, lifted to functors.

Since: base-4.9.0.0

Synopsis

- data Product (f :: k -> Type) (g :: k -> Type) (a :: k) = Pair (f a) (g a)

# Documentation

data Product (f :: k -> Type) (g :: k -> Type) (a :: k) Source #

Lifted product of functors.

#### Examples

Expand

    >>> fmap (+1) (Pair [1, 2, 3] (Just 0))
    Pair [2,3,4] (Just 1)

    >>> Pair "Hello, " (Left 'x') <> Pair "World" (Right 'y')
    Pair "Hello, World" (Right 'y')

Constructors

Pair (f a) (g a) |

#### Instances

Instances details

Generic1 (Product f g :: k -> Type) Source # |

Instance details

Defined in Data.Functor.Product

Associated Types

type Rep1 (Product f g :: k -> Type) | Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Product

type Rep1 (Product f g :: k -> Type) = D1 ('MetaData "Product" "Data.Functor.Product" "base" 'False) (C1 ('MetaCons "Pair" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec1 f) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec1 g)))

Methods

from1 :: forall (a :: k). Product f g a -> Rep1 (Product f g) a Source #

to1 :: forall (a :: k). Rep1 (Product f g) a -> Product f g a Source #

(MonadZip f, MonadZip g) => MonadZip (Product f g) Source # | Since: base-4.9.0.0
Instance details Defined in Data.Functor.Product Methods mzip :: Product f g a -> Product f g b -> Product f g (a, b) Source # mzipWith :: (a -> b -> c) -> Product f g a -> Product f g b -> Product f g c Source # munzip :: Product f g (a, b) -> (Product f g a, Product f g b) Source #
(Foldable1 f, Foldable1 g) => Foldable1 (Product f g) Source # | It would be enough for either half of a product to be `Foldable1`. Other could be `Foldable`.

Instance details

Defined in Data.Foldable1

Methods

fold1 :: Semigroup m => Product f g m -> m Source #

foldMap1 :: Semigroup m => (a -> m) -> Product f g a -> m Source #

foldMap1' :: Semigroup m => (a -> m) -> Product f g a -> m Source #

toNonEmpty :: Product f g a -> NonEmpty a Source #

maximum :: Ord a => Product f g a -> a Source #

minimum :: Ord a => Product f g a -> a Source #

head :: Product f g a -> a Source #

last :: Product f g a -> a Source #

foldrMap1 :: (a -> b) -> (a -> b -> b) -> Product f g a -> b Source #

foldlMap1' :: (a -> b) -> (b -> a -> b) -> Product f g a -> b Source #

foldlMap1 :: (a -> b) -> (b -> a -> b) -> Product f g a -> b Source #

foldrMap1' :: (a -> b) -> (a -> b -> b) -> Product f g a -> b Source #

(Eq1 f, Eq1 g) => Eq1 (Product f g) Source # | Since: base-4.9.0.0
Instance details Defined in Data.Functor.Product Methods liftEq :: (a -> b -> Bool) -> Product f g a -> Product f g b -> Bool Source #
(Ord1 f, Ord1 g) => Ord1 (Product f g) Source # | Since: base-4.9.0.0
Instance details Defined in Data.Functor.Product Methods liftCompare :: (a -> b -> Ordering) -> Product f g a -> Product f g b -> Ordering Source #
(Read1 f, Read1 g) => Read1 (Product f g) Source # | Since: base-4.9.0.0
Instance details Defined in Data.Functor.Product Methods liftReadsPrec :: (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (Product f g a) Source # liftReadList :: (Int -> ReadS a) -> ReadS [a] -> ReadS [Product f g a] Source # liftReadPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec (Product f g a) Source # liftReadListPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec [Product f g a] Source #
(Show1 f, Show1 g) => Show1 (Product f g) Source # | Since: base-4.9.0.0
Instance details Defined in Data.Functor.Product Methods liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Product f g a -> ShowS Source # liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [Product f g a] -> ShowS Source #
(Contravariant f, Contravariant g) => Contravariant (Product f g) Source # |
Instance details Defined in Data.Functor.Contravariant Methods contramap :: (a' -> a) -> Product f g a -> Product f g a' Source # (>$) :: b -> Product f g b -> Product f g a Source #
(Alternative f, Alternative g) => Alternative (Product f g) Source # | Since: base-4.9.0.0
Instance details Defined in Data.Functor.Product Methods empty :: Product f g a Source # (<|>) :: Product f g a -> Product f g a -> Product f g a Source # some :: Product f g a -> Product f g [a] Source # many :: Product f g a -> Product f g [a] Source #
(Applicative f, Applicative g) => Applicative (Product f g) Source # | Since: base-4.9.0.0
Instance details Defined in Data.Functor.Product Methods pure :: a -> Product f g a Source # (<*>) :: Product f g (a -> b) -> Product f g a -> Product f g b Source # liftA2 :: (a -> b -> c) -> Product f g a -> Product f g b -> Product f g c Source # (*>) :: Product f g a -> Product f g b -> Product f g b Source # (<*) :: Product f g a -> Product f g b -> Product f g a Source #
(Functor f, Functor g) => Functor (Product f g) Source # | Since: base-4.9.0.0
Instance details Defined in Data.Functor.Product Methods fmap :: (a -> b) -> Product f g a -> Product f g b Source # (<$) :: a -> Product f g b -> Product f g a Source #
(Monad f, Monad g) => Monad (Product f g) Source # | Since: base-4.9.0.0
Instance details Defined in Data.Functor.Product Methods (>>=) :: Product f g a -> (a -> Product f g b) -> Product f g b Source # (>>) :: Product f g a -> Product f g b -> Product f g b Source # return :: a -> Product f g a Source #
(MonadPlus f, MonadPlus g) => MonadPlus (Product f g) Source # | Since: base-4.9.0.0
Instance details Defined in Data.Functor.Product Methods mzero :: Product f g a Source # mplus :: Product f g a -> Product f g a -> Product f g a Source #
(MonadFix f, MonadFix g) => MonadFix (Product f g) Source # | Since: base-4.9.0.0
Instance details Defined in Data.Functor.Product Methods mfix :: (a -> Product f g a) -> Product f g a Source #
(Foldable f, Foldable g) => Foldable (Product f g) Source # | Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Product

Methods

fold :: Monoid m => Product f g m -> m Source #

foldMap :: Monoid m => (a -> m) -> Product f g a -> m Source #

foldMap' :: Monoid m => (a -> m) -> Product f g a -> m Source #

foldr :: (a -> b -> b) -> b -> Product f g a -> b Source #

foldr' :: (a -> b -> b) -> b -> Product f g a -> b Source #

foldl :: (b -> a -> b) -> b -> Product f g a -> b Source #

foldl' :: (b -> a -> b) -> b -> Product f g a -> b Source #

foldr1 :: (a -> a -> a) -> Product f g a -> a Source #

foldl1 :: (a -> a -> a) -> Product f g a -> a Source #

toList :: Product f g a -> [a] Source #

null :: Product f g a -> Bool Source #

length :: Product f g a -> Int Source #

elem :: Eq a => a -> Product f g a -> Bool Source #

maximum :: Ord a => Product f g a -> a Source #

minimum :: Ord a => Product f g a -> a Source #

sum :: Num a => Product f g a -> a Source #

product :: Num a => Product f g a -> a Source #

(Traversable f, Traversable g) => Traversable (Product f g) Source # | Since: base-4.9.0.0
Instance details Defined in Data.Functor.Product Methods traverse :: Applicative f0 => (a -> f0 b) -> Product f g a -> f0 (Product f g b) Source # sequenceA :: Applicative f0 => Product f g (f0 a) -> f0 (Product f g a) Source # mapM :: Monad m => (a -> m b) -> Product f g a -> m (Product f g b) Source # sequence :: Monad m => Product f g (m a) -> m (Product f g a) Source #
(Monoid (f a), Monoid (g a)) => Monoid (Product f g a) Source # | Since: base-4.16.0.0
Instance details Defined in Data.Functor.Product Methods mempty :: Product f g a Source # mappend :: Product f g a -> Product f g a -> Product f g a Source # mconcat :: [Product f g a] -> Product f g a Source #
(Semigroup (f a), Semigroup (g a)) => Semigroup (Product f g a) Source # | Since: base-4.16.0.0
Instance details Defined in Data.Functor.Product Methods (<>) :: Product f g a -> Product f g a -> Product f g a Source # sconcat :: NonEmpty (Product f g a) -> Product f g a Source # stimes :: Integral b => b -> Product f g a -> Product f g a Source #
(Typeable a, Typeable f, Typeable g, Typeable k, Data (f a), Data (g a)) => Data (Product f g a) Source # | Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Product

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g0. g0 -> c g0) -> Product f g a -> c (Product f g a) Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Product f g a) Source #

toConstr :: Product f g a -> Constr Source #

dataTypeOf :: Product f g a -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Product f g a)) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Product f g a)) Source #

gmapT :: (forall b. Data b => b -> b) -> Product f g a -> Product f g a Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Product f g a -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Product f g a -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> Product f g a -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Product f g a -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Product f g a -> m (Product f g a) Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Product f g a -> m (Product f g a) Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Product f g a -> m (Product f g a) Source #

Generic (Product f g a) Source # |

Instance details

Defined in Data.Functor.Product

Associated Types

type Rep (Product f g a) | Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Product

type Rep (Product f g a) = D1 ('MetaData "Product" "Data.Functor.Product" "base" 'False) (C1 ('MetaCons "Pair" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (f a)) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (g a))))

Methods

from :: Product f g a -> Rep (Product f g a) x Source #

to :: Rep (Product f g a) x -> Product f g a Source #

(Read (f a), Read (g a)) => Read (Product f g a) Source # | Since: base-4.18.0.0
Instance details Defined in Data.Functor.Product Methods readsPrec :: Int -> ReadS (Product f g a) Source # readList :: ReadS [Product f g a] Source # readPrec :: ReadPrec (Product f g a) Source # readListPrec :: ReadPrec [Product f g a] Source #
(Show (f a), Show (g a)) => Show (Product f g a) Source # | Since: base-4.18.0.0
Instance details Defined in Data.Functor.Product Methods showsPrec :: Int -> Product f g a -> ShowS Source # show :: Product f g a -> String Source # showList :: [Product f g a] -> ShowS Source #
(Eq (f a), Eq (g a)) => Eq (Product f g a) Source # | Since: base-4.18.0.0
Instance details Defined in Data.Functor.Product Methods (==) :: Product f g a -> Product f g a -> Bool Source # (/=) :: Product f g a -> Product f g a -> Bool Source #
(Ord (f a), Ord (g a)) => Ord (Product f g a) Source # | Since: base-4.18.0.0

Instance details

Defined in Data.Functor.Product

Methods

compare :: Product f g a -> Product f g a -> Ordering Source #

(<) :: Product f g a -> Product f g a -> Bool Source #

(<=) :: Product f g a -> Product f g a -> Bool Source #

(>) :: Product f g a -> Product f g a -> Bool Source #

(>=) :: Product f g a -> Product f g a -> Bool Source #

max :: Product f g a -> Product f g a -> Product f g a Source #

min :: Product f g a -> Product f g a -> Product f g a Source #

type Rep1 (Product f g :: k -> Type) Source # | Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Product

type Rep1 (Product f g :: k -> Type) = D1 ('MetaData "Product" "Data.Functor.Product" "base" 'False) (C1 ('MetaCons "Pair" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec1 f) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec1 g)))

type Rep (Product f g a) Source # | Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Product

type Rep (Product f g a) = D1 ('MetaData "Product" "Data.Functor.Product" "base" 'False) (C1 ('MetaCons "Pair" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (f a)) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (g a))))