base-4.21.0.0: Core data structures and operations
Copyright(c) Ross Paterson 2014
LicenseBSD-style (see the file LICENSE)
Maintainerlibraries@haskell.org
Stabilitystable
Portabilityportable
Safe HaskellSafe
LanguageHaskell2010

Data.Functor.Sum

Description

Sums, lifted to functors.

Since: base-4.9.0.0

Synopsis

Documentation

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

Lifted sum of functors.

Examples

Expand
>>> fmap (+1) (InL (Just 1))  :: Sum Maybe [] Int
InL (Just 2)
>>> fmap (+1) (InR [1, 2, 3]) :: Sum Maybe [] Int
InR [2,3,4]

Constructors

InL (f a) 
InR (g a) 

Instances

Instances details
Generic1 (Sum f g :: k -> Type) Source # 
Instance details

Defined in Data.Functor.Sum

Associated Types

type Rep1 (Sum f g :: k -> Type)

Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Sum

type Rep1 (Sum f g :: k -> Type) = D1 ('MetaData "Sum" "Data.Functor.Sum" "base-4.21.0.0-f4b0" 'False) (C1 ('MetaCons "InL" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec1 f)) :+: C1 ('MetaCons "InR" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec1 g)))

Methods

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

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

(Foldable1 f, Foldable1 g) => Foldable1 (Sum f g) Source #

Since: base-4.18.0.0

Instance details

Defined in Data.Foldable1

Methods

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

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

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

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

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

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

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

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

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

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

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

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

(Eq1 f, Eq1 g) => Eq1 (Sum f g) Source #

Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Sum

Methods

liftEq :: (a -> b -> Bool) -> Sum f g a -> Sum f g b -> Bool Source #

(Ord1 f, Ord1 g) => Ord1 (Sum f g) Source #

Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Sum

Methods

liftCompare :: (a -> b -> Ordering) -> Sum f g a -> Sum f g b -> Ordering Source #

(Read1 f, Read1 g) => Read1 (Sum f g) Source #

Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Sum

Methods

liftReadsPrec :: (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (Sum f g a) Source #

liftReadList :: (Int -> ReadS a) -> ReadS [a] -> ReadS [Sum f g a] Source #

liftReadPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec (Sum f g a) Source #

liftReadListPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec [Sum f g a] Source #

(Show1 f, Show1 g) => Show1 (Sum f g) Source #

Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Sum

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Sum f g a -> ShowS Source #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [Sum f g a] -> ShowS Source #

(Contravariant f, Contravariant g) => Contravariant (Sum f g) Source # 
Instance details

Defined in Data.Functor.Contravariant

Methods

contramap :: (a' -> a) -> Sum f g a -> Sum f g a' Source #

(>$) :: b -> Sum f g b -> Sum f g a Source #

(Functor f, Functor g) => Functor (Sum f g) Source #

Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Sum

Methods

fmap :: (a -> b) -> Sum f g a -> Sum f g b Source #

(<$) :: a -> Sum f g b -> Sum f g a Source #

(Foldable f, Foldable g) => Foldable (Sum f g) Source #

Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Sum

Methods

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

(Traversable f, Traversable g) => Traversable (Sum f g) Source #

Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Sum

Methods

traverse :: Applicative f0 => (a -> f0 b) -> Sum f g a -> f0 (Sum f g b) Source #

sequenceA :: Applicative f0 => Sum f g (f0 a) -> f0 (Sum f g a) Source #

mapM :: Monad m => (a -> m b) -> Sum f g a -> m (Sum f g b) Source #

sequence :: Monad m => Sum f g (m a) -> m (Sum f g a) Source #

(Typeable a, Typeable f, Typeable g, Typeable k, Data (f a), Data (g a)) => Data (Sum f g a) Source #

Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Sum

Methods

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Generic (Sum f g a) Source # 
Instance details

Defined in Data.Functor.Sum

Associated Types

type Rep (Sum f g a)

Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Sum

type Rep (Sum f g a) = D1 ('MetaData "Sum" "Data.Functor.Sum" "base-4.21.0.0-f4b0" 'False) (C1 ('MetaCons "InL" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (f a))) :+: C1 ('MetaCons "InR" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (g a))))

Methods

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

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

(Read (f a), Read (g a)) => Read (Sum f g a) Source #

Since: base-4.18.0.0

Instance details

Defined in Data.Functor.Sum

Methods

readsPrec :: Int -> ReadS (Sum f g a) Source #

readList :: ReadS [Sum f g a] Source #

readPrec :: ReadPrec (Sum f g a) Source #

readListPrec :: ReadPrec [Sum f g a] Source #

(Show (f a), Show (g a)) => Show (Sum f g a) Source #

Since: base-4.18.0.0

Instance details

Defined in Data.Functor.Sum

Methods

showsPrec :: Int -> Sum f g a -> ShowS Source #

show :: Sum f g a -> String Source #

showList :: [Sum f g a] -> ShowS Source #

(Eq (f a), Eq (g a)) => Eq (Sum f g a) Source #

Since: base-4.18.0.0

Instance details

Defined in Data.Functor.Sum

Methods

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

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

(Ord (f a), Ord (g a)) => Ord (Sum f g a) Source #

Since: base-4.18.0.0

Instance details

Defined in Data.Functor.Sum

Methods

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

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

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

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

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

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

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

type Rep1 (Sum f g :: k -> Type) Source #

Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Sum

type Rep1 (Sum f g :: k -> Type) = D1 ('MetaData "Sum" "Data.Functor.Sum" "base-4.21.0.0-f4b0" 'False) (C1 ('MetaCons "InL" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec1 f)) :+: C1 ('MetaCons "InR" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec1 g)))
type Rep (Sum f g a) Source #

Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Sum

type Rep (Sum f g a) = D1 ('MetaData "Sum" "Data.Functor.Sum" "base-4.21.0.0-f4b0" 'False) (C1 ('MetaCons "InL" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (f a))) :+: C1 ('MetaCons "InR" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (g a))))