| Safe Haskell | None | 
|---|---|
| Language | Haskell2010 | 
Data.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.
- Constand- Composebecome kind polymorphic only in- base-4.9.0.0(- transformers-0.5.0.0).
- Shorter names are convenient, and pattern synonyms aren't (yet) powerful enough, particularly exhaustiveness check doesn't work properly. See https://ghc.haskell.org/trac/ghc/ticket/8779.
Synopsis
- newtype K a (b :: k) = K a
- unK :: forall {k} a (b :: k). K a b -> a
- newtype I a = I a
- unI :: I a -> a
- newtype ((f :: l -> Type) :.: (g :: k -> l)) (p :: k) = Comp (f (g p))
- unComp :: forall {l} {k} f (g :: k -> l) (p :: k). (f :.: g) p -> f (g p)
- mapII :: (a -> b) -> I a -> I b
- mapIK :: forall {k} a b (c :: k). (a -> b) -> I a -> K b c
- mapKI :: forall {k} a b (c :: k). (a -> b) -> K a c -> I b
- mapKK :: forall {k1} {k2} a b (c :: k1) (d :: k2). (a -> b) -> K a c -> K b d
- mapIII :: (a -> b -> c) -> I a -> I b -> I c
- mapIIK :: forall {k} a b c (d :: k). (a -> b -> c) -> I a -> I b -> K c d
- mapIKI :: forall {k} a b c (d :: k). (a -> b -> c) -> I a -> K b d -> I c
- mapIKK :: forall {k1} {k2} a b c (d :: k1) (e :: k2). (a -> b -> c) -> I a -> K b d -> K c e
- mapKII :: forall {k} a b c (d :: k). (a -> b -> c) -> K a d -> I b -> I c
- mapKIK :: forall {k1} {k2} a b c (d :: k1) (e :: k2). (a -> b -> c) -> K a d -> I b -> K c e
- mapKKI :: forall {k1} {k2} a b c (d :: k1) (e :: k2). (a -> b -> c) -> K a d -> K b e -> I c
- mapKKK :: forall {k1} {k2} {k3} a b c (d :: k1) (e :: k2) (f :: k3). (a -> b -> c) -> K a d -> K b e -> K c f
Basic functors
The constant type functor.
Like Constant, but kind-polymorphic
 in its second argument and with a shorter name.
Constructors
| K a | 
Instances
| Eq2 (K :: Type -> Type -> Type) # | Since: 0.2.4.0 | ||||
| Ord2 (K :: Type -> Type -> Type) # | Since: 0.2.4.0 | ||||
| Defined in Data.SOP.BasicFunctors | |||||
| Read2 (K :: Type -> Type -> Type) # | Since: 0.2.4.0 | ||||
| Defined in Data.SOP.BasicFunctors 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 :: Type -> Type -> Type) # | Since: 0.2.4.0 | ||||
| NFData2 (K :: Type -> Type -> Type) # | Since: 0.2.5.0 | ||||
| Defined in Data.SOP.BasicFunctors | |||||
| Eq a => Eq1 (K a :: Type -> Type) # | Since: 0.2.4.0 | ||||
| Ord a => Ord1 (K a :: Type -> Type) # | Since: 0.2.4.0 | ||||
| Defined in Data.SOP.BasicFunctors | |||||
| Read a => Read1 (K a :: Type -> Type) # | Since: 0.2.4.0 | ||||
| Defined in Data.SOP.BasicFunctors | |||||
| Show a => Show1 (K a :: Type -> Type) # | Since: 0.2.4.0 | ||||
| NFData a => NFData1 (K a :: Type -> Type) # | Since: 0.2.5.0 | ||||
| Defined in Data.SOP.BasicFunctors | |||||
| Monoid a => Applicative (K a :: Type -> Type) # | |||||
| Functor (K a :: Type -> Type) # | |||||
| Foldable (K a :: Type -> Type) # | |||||
| Defined in Data.SOP.BasicFunctors Methods fold :: Monoid m => K a m -> m # foldMap :: Monoid m => (a0 -> m) -> K a a0 -> m # foldMap' :: Monoid m => (a0 -> m) -> K a a0 -> m # foldr :: (a0 -> b -> b) -> b -> K a a0 -> b # foldr' :: (a0 -> b -> b) -> b -> K a a0 -> b # foldl :: (b -> a0 -> b) -> b -> K a a0 -> b # foldl' :: (b -> a0 -> b) -> b -> K a a0 -> b # foldr1 :: (a0 -> a0 -> a0) -> K a a0 -> a0 # foldl1 :: (a0 -> a0 -> a0) -> K a a0 -> a0 # elem :: Eq a0 => a0 -> K a a0 -> Bool # maximum :: Ord a0 => K a a0 -> a0 # minimum :: Ord a0 => K a a0 -> a0 # | |||||
| Traversable (K a :: Type -> Type) # | |||||
| NFData a => NFData (K a b) # | Since: 0.2.5.0 | ||||
| Defined in Data.SOP.BasicFunctors | |||||
| Monoid a => Monoid (K a b) # | Since: 0.4.0.0 | ||||
| Semigroup a => Semigroup (K a b) # | Since: 0.4.0.0 | ||||
| Generic (K a b) # | |||||
| Defined in Data.SOP.BasicFunctors Associated Types 
 | |||||
| Read a => Read (K a b) # | |||||
| Show a => Show (K a b) # | |||||
| Eq a => Eq (K a b) # | |||||
| Ord a => Ord (K a b) # | |||||
| type Rep (K a b) # | |||||
| Defined in Data.SOP.BasicFunctors | |||||
The identity type functor.
Like Identity, but with a shorter name.
Constructors
| I a | 
Instances
| Eq1 I # | Since: 0.2.4.0 | ||||
| Ord1 I # | Since: 0.2.4.0 | ||||
| Defined in Data.SOP.BasicFunctors | |||||
| Read1 I # | Since: 0.2.4.0 | ||||
| Defined in Data.SOP.BasicFunctors | |||||
| Show1 I # | Since: 0.2.4.0 | ||||
| NFData1 I # | Since: 0.2.5.0 | ||||
| Defined in Data.SOP.BasicFunctors | |||||
| Applicative I # | |||||
| Functor I # | |||||
| Monad I # | |||||
| Foldable I # | |||||
| Defined in Data.SOP.BasicFunctors Methods fold :: Monoid m => I m -> m # foldMap :: Monoid m => (a -> m) -> I a -> 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 # elem :: Eq a => a -> I a -> Bool # maximum :: Ord a => I a -> a # | |||||
| Traversable I # | |||||
| NFData a => NFData (I a) # | Since: 0.2.5.0 | ||||
| Defined in Data.SOP.BasicFunctors | |||||
| Monoid a => Monoid (I a) # | Since: 0.4.0.0 | ||||
| Semigroup a => Semigroup (I a) # | Since: 0.4.0.0 | ||||
| Generic (I a) # | |||||
| Defined in Data.SOP.BasicFunctors Associated Types 
 | |||||
| Read a => Read (I a) # | |||||
| Show a => Show (I a) # | |||||
| Eq a => Eq (I a) # | |||||
| Ord a => Ord (I a) # | |||||
| type Rep (I a) # | |||||
| Defined in Data.SOP.BasicFunctors | |||||
newtype ((f :: l -> Type) :.: (g :: k -> l)) (p :: k) infixr 7 #
Composition of functors.
Like Compose, but kind-polymorphic
 and with a shorter name.
Constructors
| Comp (f (g p)) | 
Instances
| (Eq1 f, Eq1 g) => Eq1 (f :.: g) # | Since: 0.2.4.0 | ||||
| (Ord1 f, Ord1 g) => Ord1 (f :.: g) # | Since: 0.2.4.0 | ||||
| Defined in Data.SOP.BasicFunctors | |||||
| (Read1 f, Read1 g) => Read1 (f :.: g) # | Since: 0.2.4.0 | ||||
| Defined in Data.SOP.BasicFunctors | |||||
| (Show1 f, Show1 g) => Show1 (f :.: g) # | Since: 0.2.4.0 | ||||
| (NFData1 f, NFData1 g) => NFData1 (f :.: g) # | Since: 0.2.5.0 | ||||
| Defined in Data.SOP.BasicFunctors | |||||
| (Applicative f, Applicative g) => Applicative (f :.: g) # | Since: 0.2.5.0 | ||||
| (Functor f, Functor g) => Functor (f :.: g) # | |||||
| (Foldable f, Foldable g) => Foldable (f :.: g) # | Since: 0.2.5.0 | ||||
| Defined in Data.SOP.BasicFunctors Methods fold :: Monoid m => (f :.: g) m -> m # foldMap :: Monoid m => (a -> m) -> (f :.: g) a -> 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] # 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 # | |||||
| (Traversable f, Traversable g) => Traversable (f :.: g) # | Since: 0.2.5.0 | ||||
| Defined in Data.SOP.BasicFunctors | |||||
| NFData (f (g a)) => NFData ((f :.: g) a) # | Since: 0.2.5.0 | ||||
| Defined in Data.SOP.BasicFunctors | |||||
| Monoid (f (g x)) => Monoid ((f :.: g) x) # | Since: 0.4.0.0 | ||||
| Semigroup (f (g x)) => Semigroup ((f :.: g) x) # | Since: 0.4.0.0 | ||||
| Generic ((f :.: g) p) # | |||||
| Defined in Data.SOP.BasicFunctors Associated Types 
 | |||||
| (Read1 f, Read1 g, Read a) => Read ((f :.: g) a) # | |||||
| (Show1 f, Show1 g, Show a) => Show ((f :.: g) a) # | |||||
| (Eq1 f, Eq1 g, Eq a) => Eq ((f :.: g) a) # | |||||
| (Ord1 f, Ord1 g, Ord a) => Ord ((f :.: g) a) # | |||||
| Defined in Data.SOP.BasicFunctors | |||||
| type Rep ((f :.: g) p) # | |||||
| Defined in Data.SOP.BasicFunctors | |||||
unComp :: forall {l} {k} f (g :: k -> l) (p :: k). (f :.: g) p -> f (g p) #
Extract the contents of a Comp value.
Mapping functions
mapKK :: forall {k1} {k2} a b (c :: k1) (d :: k2). (a -> b) -> K a c -> K b d #
Lift the given function.
Since: 0.2.5.0
mapIIK :: forall {k} a b c (d :: k). (a -> b -> c) -> I a -> I b -> K c d #
Lift the given function.
Since: 0.2.5.0
mapIKI :: forall {k} a b c (d :: k). (a -> b -> c) -> I a -> K b d -> I c #
Lift the given function.
Since: 0.2.5.0
mapIKK :: forall {k1} {k2} a b c (d :: k1) (e :: k2). (a -> b -> c) -> I a -> K b d -> K c e #
Lift the given function.
Since: 0.2.5.0
mapKII :: forall {k} a b c (d :: k). (a -> b -> c) -> K a d -> I b -> I c #
Lift the given function.
Since: 0.2.5.0
mapKIK :: forall {k1} {k2} a b c (d :: k1) (e :: k2). (a -> b -> c) -> K a d -> I b -> K c e #
Lift the given function.
Since: 0.2.5.0