Generics.SOP.BasicFunctors

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

Safe Haskell | Safe
Language | Haskell2010

Generics.SOP.BasicFunctors

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.

Synopsis

- newtype K a b = K a
- unK :: K a b -> a
- newtype I a = I a
- unI :: I a -> a
- newtype (f :.: g) p = Comp (f (g p))
- unComp :: (f :.: g) p -> f (g p)

# Documentation

newtype K a b #

The constant type functor.

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

Constructors

K a |

Instances

Functor (K * a) # |
Methods fmap :: (a -> b) -> K * a a -> K * a b # (<$) :: a -> K * a b -> K * a a #
Monoid a => Applicative (K * a) # |
Methods pure :: a -> K * a a # (<*>) :: K * a (a -> b) -> K * a a -> K * a b # (*>) :: K * a a -> K * a b -> K * a b # (<*) :: K * a a -> K * a b -> K * a a #
Foldable (K * a) # |
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) # |
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) #
Show a => Show (K k a b) # |
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) # |
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 #
type Rep (K k a b) # |
type Rep (K k a b) = D1 (MetaData "K" "Generics.SOP.BasicFunctors" "generics-sop-0.2.2.0-9w3u9oOObG6ENcL8IZfj8x" True) (C1 (MetaCons "K" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 a)))
type Code (K * a0 b0) # |
type Code (K * a0 b0) = (:) [*] ((:) * a0 ([] *)) ([] [*])

unK :: K a b -> a #

Extract the contents of a `K` value.

newtype I a #

The identity type functor.

Like `Identity`, but with a shorter name.

Constructors

I a |

Instances

Monad I # |
Methods (>>=) :: I a -> (a -> I b) -> I b # (>>) :: I a -> I b -> I b # return :: a -> I a # fail :: String -> I a #
Functor I # |
Methods fmap :: (a -> b) -> I a -> I b # (<$) :: a -> I b -> I a #
Applicative I # |
Methods pure :: a -> I a # (<*>) :: I (a -> b) -> I a -> I b # (*>) :: I a -> I b -> I b # (<*) :: I a -> I b -> I a #
Foldable I # |
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 # |
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) #
Show a => Show (I a) # |
Methods showsPrec :: Int -> I a -> ShowS # show :: I a -> String # showList :: [I a] -> ShowS #
Generic (I a) # |
Associated Types type Rep (I a) :: * -> * # Methods from :: I a -> Rep (I a) x # to :: Rep (I a) x -> I a #
type Rep (I a) # |
type Rep (I a) = D1 (MetaData "I" "Generics.SOP.BasicFunctors" "generics-sop-0.2.2.0-9w3u9oOObG6ENcL8IZfj8x" True) (C1 (MetaCons "I" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 a)))
type Code (I a0) # |
type Code (I a0) = (:) [*] ((:) * a0 ([] *)) ([] [*])

unI :: I a -> a #

Extract the contents of an `I` value.

newtype (f :.: g) p infixr 7 #

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) # |
Methods fmap :: (a -> b) -> (* :.: *) f g a -> (* :.: *) f g b # (<$) :: a -> (* :.: *) f g b -> (* :.: *) f g a #
Show (f (g p)) => Show ((:.:) k l f g p) # |
Methods showsPrec :: Int -> (k :.: l) f g p -> ShowS # show :: (k :.: l) f g p -> String # showList :: [(k :.: l) f g p] -> ShowS #
Generic ((:.:) k l f g p) # |
Associated Types type Rep ((:.:) k l f g p) :: * -> * # Methods from :: (k :.: l) f g p -> Rep ((k :.: l) f g p) x # to :: Rep ((k :.: l) f g p) x -> (k :.: l) f g p #
type Rep ((:.:) k l f g p) # |
type Rep ((:.:) k l f g p) = D1 (MetaData ":.:" "Generics.SOP.BasicFunctors" "generics-sop-0.2.2.0-9w3u9oOObG6ENcL8IZfj8x" True) (C1 (MetaCons "Comp" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (f (g p)))))
type Code ((:.:) * * f0 g0 p0) # |
type Code ((:.:) * * f0 g0 p0) = (:) [*] ((:) * (f0 (g0 p0)) ([] *)) ([] [*])

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

Extract the contents of a `Comp` value.