generics-sop-0.3.2.0: Generic Programming using True Sums of Products

Safe HaskellSafe
LanguageHaskell2010

Generics.SOP.BasicFunctors

Contents

Description

Basic functors.

Definitions of the type-level equivalents of const, id, and (.), and a definition of the lifted function space.

These datatypes are generally useful, but in this library, they're primarily used as parameters for the NP, NS, POP, and SOP types.

We define own variants of Const, Identity and Compose for various reasons.

Synopsis

Basic functors

newtype K (a :: *) (b :: k) Source #

The constant type functor.

Like Constant, but kind-polymorphic in its second argument and with a shorter name.

Constructors

K a 

Instances

Eq2 (K *) Source #

Since: 0.2.4.0

Methods

liftEq2 :: (a -> b -> Bool) -> (c -> d -> Bool) -> K * a c -> K * b d -> Bool #

Ord2 (K *) Source #

Since: 0.2.4.0

Methods

liftCompare2 :: (a -> b -> Ordering) -> (c -> d -> Ordering) -> K * a c -> K * b d -> Ordering #

Read2 (K *) Source #

Since: 0.2.4.0

Methods

liftReadsPrec2 :: (Int -> ReadS a) -> ReadS [a] -> (Int -> ReadS b) -> ReadS [b] -> Int -> ReadS (K * a b) #

liftReadList2 :: (Int -> ReadS a) -> ReadS [a] -> (Int -> ReadS b) -> ReadS [b] -> ReadS [K * a b] #

liftReadPrec2 :: ReadPrec a -> ReadPrec [a] -> ReadPrec b -> ReadPrec [b] -> ReadPrec (K * a b) #

liftReadListPrec2 :: ReadPrec a -> ReadPrec [a] -> ReadPrec b -> ReadPrec [b] -> ReadPrec [K * a b] #

Show2 (K *) Source #

Since: 0.2.4.0

Methods

liftShowsPrec2 :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> (Int -> b -> ShowS) -> ([b] -> ShowS) -> Int -> K * a b -> ShowS #

liftShowList2 :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> (Int -> b -> ShowS) -> ([b] -> ShowS) -> [K * a b] -> ShowS #

NFData2 (K *) Source #

Since: 0.2.5.0

Methods

liftRnf2 :: (a -> ()) -> (b -> ()) -> K * a b -> () #

Functor (K * a) Source # 

Methods

fmap :: (a -> b) -> K * a a -> K * a b #

(<$) :: a -> K * a b -> K * a a #

Monoid a => Applicative (K * a) Source # 

Methods

pure :: a -> K * a a #

(<*>) :: K * a (a -> b) -> K * a a -> K * a b #

liftA2 :: (a -> b -> c) -> K * a a -> K * a b -> K * a c #

(*>) :: K * a a -> K * a b -> K * a b #

(<*) :: K * a a -> K * a b -> K * a a #

Foldable (K * a) Source # 

Methods

fold :: Monoid m => K * a m -> m #

foldMap :: Monoid m => (a -> m) -> K * a a -> m #

foldr :: (a -> b -> b) -> b -> K * a a -> b #

foldr' :: (a -> b -> b) -> b -> K * a a -> b #

foldl :: (b -> a -> b) -> b -> K * a a -> b #

foldl' :: (b -> a -> b) -> b -> K * a a -> b #

foldr1 :: (a -> a -> a) -> K * a a -> a #

foldl1 :: (a -> a -> a) -> K * a a -> a #

toList :: K * a a -> [a] #

null :: K * a a -> Bool #

length :: K * a a -> Int #

elem :: Eq a => a -> K * a a -> Bool #

maximum :: Ord a => K * a a -> a #

minimum :: Ord a => K * a a -> a #

sum :: Num a => K * a a -> a #

product :: Num a => K * a a -> a #

Traversable (K * a) Source # 

Methods

traverse :: Applicative f => (a -> f b) -> K * a a -> f (K * a b) #

sequenceA :: Applicative f => K * a (f a) -> f (K * a a) #

mapM :: Monad m => (a -> m b) -> K * a a -> m (K * a b) #

sequence :: Monad m => K * a (m a) -> m (K * a a) #

Eq a => Eq1 (K * a) Source #

Since: 0.2.4.0

Methods

liftEq :: (a -> b -> Bool) -> K * a a -> K * a b -> Bool #

Ord a => Ord1 (K * a) Source #

Since: 0.2.4.0

Methods

liftCompare :: (a -> b -> Ordering) -> K * a a -> K * a b -> Ordering #

Read a => Read1 (K * a) Source #

Since: 0.2.4.0

Methods

liftReadsPrec :: (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (K * a a) #

liftReadList :: (Int -> ReadS a) -> ReadS [a] -> ReadS [K * a a] #

liftReadPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec (K * a a) #

liftReadListPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec [K * a a] #

Show a => Show1 (K * a) Source #

Since: 0.2.4.0

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> K * a a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [K * a a] -> ShowS #

NFData a => NFData1 (K * a) Source #

Since: 0.2.5.0

Methods

liftRnf :: (a -> ()) -> K * a a -> () #

Eq a => Eq (K k a b) Source # 

Methods

(==) :: K k a b -> K k a b -> Bool #

(/=) :: K k a b -> K k a b -> Bool #

Ord a => Ord (K k a b) Source # 

Methods

compare :: K k a b -> K k a b -> Ordering #

(<) :: K k a b -> K k a b -> Bool #

(<=) :: K k a b -> K k a b -> Bool #

(>) :: K k a b -> K k a b -> Bool #

(>=) :: K k a b -> K k a b -> Bool #

max :: K k a b -> K k a b -> K k a b #

min :: K k a b -> K k a b -> K k a b #

Read a => Read (K k a b) Source # 

Methods

readsPrec :: Int -> ReadS (K k a b) #

readList :: ReadS [K k a b] #

readPrec :: ReadPrec (K k a b) #

readListPrec :: ReadPrec [K k a b] #

Show a => Show (K k a b) Source # 

Methods

showsPrec :: Int -> K k a b -> ShowS #

show :: K k a b -> String #

showList :: [K k a b] -> ShowS #

Generic (K k a b) Source # 

Associated Types

type Rep (K k a b) :: * -> * #

Methods

from :: K k a b -> Rep (K k a b) x #

to :: Rep (K k a b) x -> K k a b #

NFData a => NFData (K k a b) Source #

Since: 0.2.5.0

Methods

rnf :: K k a b -> () #

type Rep (K k a b) Source # 
type Rep (K k a b) = D1 * (MetaData "K" "Generics.SOP.BasicFunctors" "generics-sop-0.3.2.0-DVZ1EAz7WZT3T0121HR4y2" True) (C1 * (MetaCons "K" PrefixI False) (S1 * (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * a)))
type DatatypeInfoOf (K * a b) Source # 
type DatatypeInfoOf (K * a b) = Newtype "Generics.SOP.BasicFunctors" "K" (Constructor "K")
type Code (K * a b) Source # 
type Code (K * a b) = (:) [*] ((:) * a ([] *)) ([] [*])

unK :: K a b -> a Source #

Extract the contents of a K value.

newtype I (a :: *) Source #

The identity type functor.

Like Identity, but with a shorter name.

Constructors

I a 

Instances

Monad I Source # 

Methods

(>>=) :: I a -> (a -> I b) -> I b #

(>>) :: I a -> I b -> I b #

return :: a -> I a #

fail :: String -> I a #

Functor I Source # 

Methods

fmap :: (a -> b) -> I a -> I b #

(<$) :: a -> I b -> I a #

Applicative I Source # 

Methods

pure :: a -> I a #

(<*>) :: I (a -> b) -> I a -> I b #

liftA2 :: (a -> b -> c) -> I a -> I b -> I c #

(*>) :: I a -> I b -> I b #

(<*) :: I a -> I b -> I a #

Foldable I Source # 

Methods

fold :: Monoid m => I m -> m #

foldMap :: Monoid m => (a -> m) -> I a -> m #

foldr :: (a -> b -> b) -> b -> I a -> b #

foldr' :: (a -> b -> b) -> b -> I a -> b #

foldl :: (b -> a -> b) -> b -> I a -> b #

foldl' :: (b -> a -> b) -> b -> I a -> b #

foldr1 :: (a -> a -> a) -> I a -> a #

foldl1 :: (a -> a -> a) -> I a -> a #

toList :: I a -> [a] #

null :: I a -> Bool #

length :: I a -> Int #

elem :: Eq a => a -> I a -> Bool #

maximum :: Ord a => I a -> a #

minimum :: Ord a => I a -> a #

sum :: Num a => I a -> a #

product :: Num a => I a -> a #

Traversable I Source # 

Methods

traverse :: Applicative f => (a -> f b) -> I a -> f (I b) #

sequenceA :: Applicative f => I (f a) -> f (I a) #

mapM :: Monad m => (a -> m b) -> I a -> m (I b) #

sequence :: Monad m => I (m a) -> m (I a) #

Eq1 I Source #

Since: 0.2.4.0

Methods

liftEq :: (a -> b -> Bool) -> I a -> I b -> Bool #

Ord1 I Source #

Since: 0.2.4.0

Methods

liftCompare :: (a -> b -> Ordering) -> I a -> I b -> Ordering #

Read1 I Source #

Since: 0.2.4.0

Methods

liftReadsPrec :: (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (I a) #

liftReadList :: (Int -> ReadS a) -> ReadS [a] -> ReadS [I a] #

liftReadPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec (I a) #

liftReadListPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec [I a] #

Show1 I Source #

Since: 0.2.4.0

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> I a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [I a] -> ShowS #

NFData1 I Source #

Since: 0.2.5.0

Methods

liftRnf :: (a -> ()) -> I a -> () #

Eq a => Eq (I a) Source # 

Methods

(==) :: I a -> I a -> Bool #

(/=) :: I a -> I a -> Bool #

Ord a => Ord (I a) Source # 

Methods

compare :: I a -> I a -> Ordering #

(<) :: I a -> I a -> Bool #

(<=) :: I a -> I a -> Bool #

(>) :: I a -> I a -> Bool #

(>=) :: I a -> I a -> Bool #

max :: I a -> I a -> I a #

min :: I a -> I a -> I a #

Read a => Read (I a) Source # 

Methods

readsPrec :: Int -> ReadS (I a) #

readList :: ReadS [I a] #

readPrec :: ReadPrec (I a) #

readListPrec :: ReadPrec [I a] #

Show a => Show (I a) Source # 

Methods

showsPrec :: Int -> I a -> ShowS #

show :: I a -> String #

showList :: [I a] -> ShowS #

Generic (I a) Source # 

Associated Types

type Rep (I a) :: * -> * #

Methods

from :: I a -> Rep (I a) x #

to :: Rep (I a) x -> I a #

NFData a => NFData (I a) Source #

Since: 0.2.5.0

Methods

rnf :: I a -> () #

type Rep (I a) Source # 
type Rep (I a) = D1 * (MetaData "I" "Generics.SOP.BasicFunctors" "generics-sop-0.3.2.0-DVZ1EAz7WZT3T0121HR4y2" True) (C1 * (MetaCons "I" PrefixI False) (S1 * (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * a)))
type DatatypeInfoOf (I a) Source # 
type DatatypeInfoOf (I a) = Newtype "Generics.SOP.BasicFunctors" "I" (Constructor "I")
type Code (I a) Source # 
type Code (I a) = (:) [*] ((:) * a ([] *)) ([] [*])

unI :: I a -> a Source #

Extract the contents of an I value.

newtype ((f :: l -> *) :.: (g :: k -> l)) (p :: k) infixr 7 Source #

Composition of functors.

Like Compose, but kind-polymorphic and with a shorter name.

Constructors

Comp (f (g p)) 

Instances

(Functor f, Functor g) => Functor ((:.:) * * f g) Source # 

Methods

fmap :: (a -> b) -> (* :.: *) f g a -> (* :.: *) f g b #

(<$) :: a -> (* :.: *) f g b -> (* :.: *) f g a #

(Applicative f, Applicative g) => Applicative ((:.:) * * f g) Source #

Since: 0.2.5.0

Methods

pure :: a -> (* :.: *) f g a #

(<*>) :: (* :.: *) f g (a -> b) -> (* :.: *) f g a -> (* :.: *) f g b #

liftA2 :: (a -> b -> c) -> (* :.: *) f g a -> (* :.: *) f g b -> (* :.: *) f g c #

(*>) :: (* :.: *) f g a -> (* :.: *) f g b -> (* :.: *) f g b #

(<*) :: (* :.: *) f g a -> (* :.: *) f g b -> (* :.: *) f g a #

(Foldable f, Foldable g) => Foldable ((:.:) * * f g) Source #

Since: 0.2.5.0

Methods

fold :: Monoid m => (* :.: *) f g m -> m #

foldMap :: Monoid m => (a -> m) -> (* :.: *) f g a -> m #

foldr :: (a -> b -> b) -> b -> (* :.: *) f g a -> b #

foldr' :: (a -> b -> b) -> b -> (* :.: *) f g a -> b #

foldl :: (b -> a -> b) -> b -> (* :.: *) f g a -> b #

foldl' :: (b -> a -> b) -> b -> (* :.: *) f g a -> b #

foldr1 :: (a -> a -> a) -> (* :.: *) f g a -> a #

foldl1 :: (a -> a -> a) -> (* :.: *) f g a -> a #

toList :: (* :.: *) f g a -> [a] #

null :: (* :.: *) f g a -> Bool #

length :: (* :.: *) f g a -> Int #

elem :: Eq a => a -> (* :.: *) f g a -> Bool #

maximum :: Ord a => (* :.: *) f g a -> a #

minimum :: Ord a => (* :.: *) f g a -> a #

sum :: Num a => (* :.: *) f g a -> a #

product :: Num a => (* :.: *) f g a -> a #

(Traversable f, Traversable g) => Traversable ((:.:) * * f g) Source #

Since: 0.2.5.0

Methods

traverse :: Applicative f => (a -> f b) -> (* :.: *) f g a -> f ((* :.: *) f g b) #

sequenceA :: Applicative f => (* :.: *) f g (f a) -> f ((* :.: *) f g a) #

mapM :: Monad m => (a -> m b) -> (* :.: *) f g a -> m ((* :.: *) f g b) #

sequence :: Monad m => (* :.: *) f g (m a) -> m ((* :.: *) f g a) #

(Eq1 f, Eq1 g) => Eq1 ((:.:) * * f g) Source #

Since: 0.2.4.0

Methods

liftEq :: (a -> b -> Bool) -> (* :.: *) f g a -> (* :.: *) f g b -> Bool #

(Ord1 f, Ord1 g) => Ord1 ((:.:) * * f g) Source #

Since: 0.2.4.0

Methods

liftCompare :: (a -> b -> Ordering) -> (* :.: *) f g a -> (* :.: *) f g b -> Ordering #

(Read1 f, Read1 g) => Read1 ((:.:) * * f g) Source #

Since: 0.2.4.0

Methods

liftReadsPrec :: (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS ((* :.: *) f g a) #

liftReadList :: (Int -> ReadS a) -> ReadS [a] -> ReadS [(* :.: *) f g a] #

liftReadPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec ((* :.: *) f g a) #

liftReadListPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec [(* :.: *) f g a] #

(Show1 f, Show1 g) => Show1 ((:.:) * * f g) Source #

Since: 0.2.4.0

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> (* :.: *) f g a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [(* :.: *) f g a] -> ShowS #

(NFData1 f, NFData1 g) => NFData1 ((:.:) * * f g) Source #

Since: 0.2.5.0

Methods

liftRnf :: (a -> ()) -> (* :.: *) f g a -> () #

(Eq1 f, Eq1 g, Eq a) => Eq ((:.:) * * f g a) Source # 

Methods

(==) :: (* :.: *) f g a -> (* :.: *) f g a -> Bool #

(/=) :: (* :.: *) f g a -> (* :.: *) f g a -> Bool #

(Ord1 f, Ord1 g, Ord a) => Ord ((:.:) * * f g a) Source # 

Methods

compare :: (* :.: *) f g a -> (* :.: *) f g a -> Ordering #

(<) :: (* :.: *) f g a -> (* :.: *) f g a -> Bool #

(<=) :: (* :.: *) f g a -> (* :.: *) f g a -> Bool #

(>) :: (* :.: *) f g a -> (* :.: *) f g a -> Bool #

(>=) :: (* :.: *) f g a -> (* :.: *) f g a -> Bool #

max :: (* :.: *) f g a -> (* :.: *) f g a -> (* :.: *) f g a #

min :: (* :.: *) f g a -> (* :.: *) f g a -> (* :.: *) f g a #

(Read1 f, Read1 g, Read a) => Read ((:.:) * * f g a) Source # 

Methods

readsPrec :: Int -> ReadS ((* :.: *) f g a) #

readList :: ReadS [(* :.: *) f g a] #

readPrec :: ReadPrec ((* :.: *) f g a) #

readListPrec :: ReadPrec [(* :.: *) f g a] #

(Show1 f, Show1 g, Show a) => Show ((:.:) * * f g a) Source # 

Methods

showsPrec :: Int -> (* :.: *) f g a -> ShowS #

show :: (* :.: *) f g a -> String #

showList :: [(* :.: *) f g a] -> ShowS #

Generic ((:.:) l k f g p) Source # 

Associated Types

type Rep ((l :.: k) f g p) :: * -> * #

Methods

from :: (l :.: k) f g p -> Rep ((l :.: k) f g p) x #

to :: Rep ((l :.: k) f g p) x -> (l :.: k) f g p #

NFData (f (g a)) => NFData ((:.:) l k f g a) Source #

Since: 0.2.5.0

Methods

rnf :: (l :.: k) f g a -> () #

type Rep ((:.:) l k f g p) Source # 
type Rep ((:.:) l k f g p) = D1 * (MetaData ":.:" "Generics.SOP.BasicFunctors" "generics-sop-0.3.2.0-DVZ1EAz7WZT3T0121HR4y2" True) (C1 * (MetaCons "Comp" PrefixI False) (S1 * (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * (f (g p)))))
type DatatypeInfoOf ((:.:) * * f g p) Source # 
type DatatypeInfoOf ((:.:) * * f g p) = Newtype "Generics.SOP.BasicFunctors" ":.:" (Constructor "Comp")
type Code ((:.:) * * f g p) Source # 
type Code ((:.:) * * f g p) = (:) [*] ((:) * (f (g p)) ([] *)) ([] [*])

unComp :: (f :.: g) p -> f (g p) Source #

Extract the contents of a Comp value.

Mapping functions

mapII :: (a -> b) -> I a -> I b Source #

Lift the given function.

Since: 0.2.5.0

mapIK :: (a -> b) -> I a -> K b c Source #

Lift the given function.

Since: 0.2.5.0

mapKI :: (a -> b) -> K a c -> I b Source #

Lift the given function.

Since: 0.2.5.0

mapKK :: (a -> b) -> K a c -> K b d Source #

Lift the given function.

Since: 0.2.5.0

mapIII :: (a -> b -> c) -> I a -> I b -> I c Source #

Lift the given function.

Since: 0.2.5.0

mapIIK :: (a -> b -> c) -> I a -> I b -> K c d Source #

Lift the given function.

Since: 0.2.5.0

mapIKI :: (a -> b -> c) -> I a -> K b d -> I c Source #

Lift the given function.

Since: 0.2.5.0

mapIKK :: (a -> b -> c) -> I a -> K b d -> K c e Source #

Lift the given function.

Since: 0.2.5.0

mapKII :: (a -> b -> c) -> K a d -> I b -> I c Source #

Lift the given function.

Since: 0.2.5.0

mapKIK :: (a -> b -> c) -> K a d -> I b -> K c e Source #

Lift the given function.

Since: 0.2.5.0

mapKKI :: (a -> b -> c) -> K a d -> K b e -> I c Source #

Lift the given function.

Since: 0.2.5.0

mapKKK :: (a -> b -> c) -> K a d -> K b e -> K c f Source #

Lift the given function.

Since: 0.2.5.0