Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
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.
Const
andCompose
become kind polymorphic only inbase-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 :: Type) (b :: k) = K a
- unK :: K a b -> a
- newtype I (a :: Type) = I a
- unI :: I a -> a
- newtype ((f :: l -> Type) :.: (g :: k -> l)) (p :: k) = Comp (f (g p))
- unComp :: (f :.: g) p -> f (g p)
- mapII :: (a -> b) -> I a -> I b
- mapIK :: (a -> b) -> I a -> K b c
- mapKI :: (a -> b) -> K a c -> I b
- mapKK :: (a -> b) -> K a c -> K b d
- mapIII :: (a -> b -> c) -> I a -> I b -> I c
- mapIIK :: (a -> b -> c) -> I a -> I b -> K c d
- mapIKI :: (a -> b -> c) -> I a -> K b d -> I c
- mapIKK :: (a -> b -> c) -> I a -> K b d -> K c e
- mapKII :: (a -> b -> c) -> K a d -> I b -> I c
- mapKIK :: (a -> b -> c) -> K a d -> I b -> K c e
- mapKKI :: (a -> b -> c) -> K a d -> K b e -> I c
- mapKKK :: (a -> b -> c) -> K a d -> K b e -> K c f
Basic functors
newtype K (a :: Type) (b :: k) Source #
The constant type functor.
Like Constant
, but kind-polymorphic
in its second argument and with a shorter name.
K a |
Instances
Eq2 (K :: Type -> * -> *) Source # | Since: sop-core-0.2.4.0 |
Ord2 (K :: Type -> * -> *) Source # | Since: sop-core-0.2.4.0 |
Defined in Data.SOP.BasicFunctors | |
Read2 (K :: Type -> * -> *) Source # | Since: sop-core-0.2.4.0 |
Defined in Data.SOP.BasicFunctors 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 -> * -> *) Source # | Since: sop-core-0.2.4.0 |
NFData2 (K :: Type -> * -> *) Source # | Since: sop-core-0.2.5.0 |
Defined in Data.SOP.BasicFunctors | |
Functor (K a :: * -> *) Source # | |
Monoid a => Applicative (K a :: * -> *) Source # | |
Foldable (K a :: * -> *) Source # | |
Defined in Data.SOP.BasicFunctors fold :: Monoid m => K a m -> 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 :: * -> *) Source # | |
Eq a => Eq1 (K a :: * -> *) Source # | Since: sop-core-0.2.4.0 |
Ord a => Ord1 (K a :: * -> *) Source # | Since: sop-core-0.2.4.0 |
Defined in Data.SOP.BasicFunctors | |
Read a => Read1 (K a :: * -> *) Source # | Since: sop-core-0.2.4.0 |
Defined in Data.SOP.BasicFunctors | |
Show a => Show1 (K a :: * -> *) Source # | Since: sop-core-0.2.4.0 |
NFData a => NFData1 (K a :: * -> *) Source # | Since: sop-core-0.2.5.0 |
Defined in Data.SOP.BasicFunctors | |
Eq a => Eq (K a b) Source # | |
Ord a => Ord (K a b) Source # | |
Read a => Read (K a b) Source # | |
Show a => Show (K a b) Source # | |
Generic (K a b) Source # | |
Semigroup a => Semigroup (K a b) Source # | Since: sop-core-0.4.0.0 |
Monoid a => Monoid (K a b) Source # | Since: sop-core-0.4.0.0 |
NFData a => NFData (K a b) Source # | Since: sop-core-0.2.5.0 |
Defined in Data.SOP.BasicFunctors | |
type Rep (K a b) Source # | |
Defined in Data.SOP.BasicFunctors |
newtype I (a :: Type) Source #
The identity type functor.
Like Identity
, but with a shorter name.
I a |
Instances
Monad I Source # | |
Functor I Source # | |
Applicative I Source # | |
Foldable I Source # | |
Defined in Data.SOP.BasicFunctors 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 # elem :: Eq a => a -> I a -> Bool # maximum :: Ord a => I a -> a # | |
Traversable I Source # | |
Eq1 I Source # | Since: sop-core-0.2.4.0 |
Ord1 I Source # | Since: sop-core-0.2.4.0 |
Defined in Data.SOP.BasicFunctors | |
Read1 I Source # | Since: sop-core-0.2.4.0 |
Show1 I Source # | Since: sop-core-0.2.4.0 |
NFData1 I Source # | Since: sop-core-0.2.5.0 |
Defined in Data.SOP.BasicFunctors | |
Eq a => Eq (I a) Source # | |
Ord a => Ord (I a) Source # | |
Read a => Read (I a) Source # | |
Show a => Show (I a) Source # | |
Generic (I a) Source # | |
Semigroup a => Semigroup (I a) Source # | Since: sop-core-0.4.0.0 |
Monoid a => Monoid (I a) Source # | Since: sop-core-0.4.0.0 |
NFData a => NFData (I a) Source # | Since: sop-core-0.2.5.0 |
Defined in Data.SOP.BasicFunctors | |
type Rep (I a) Source # | |
Defined in Data.SOP.BasicFunctors |
newtype ((f :: l -> Type) :.: (g :: k -> l)) (p :: k) infixr 7 Source #
Composition of functors.
Like Compose
, but kind-polymorphic
and with a shorter name.
Comp (f (g p)) |
Instances
(Functor f, Functor g) => Functor (f :.: g) Source # | |
(Applicative f, Applicative g) => Applicative (f :.: g) Source # | Since: sop-core-0.2.5.0 |
(Foldable f, Foldable g) => Foldable (f :.: g) Source # | Since: sop-core-0.2.5.0 |
Defined in Data.SOP.BasicFunctors 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] # 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) Source # | Since: sop-core-0.2.5.0 |
Defined in Data.SOP.BasicFunctors | |
(Eq1 f, Eq1 g) => Eq1 (f :.: g) Source # | Since: sop-core-0.2.4.0 |
(Ord1 f, Ord1 g) => Ord1 (f :.: g) Source # | Since: sop-core-0.2.4.0 |
Defined in Data.SOP.BasicFunctors | |
(Read1 f, Read1 g) => Read1 (f :.: g) Source # | Since: sop-core-0.2.4.0 |
Defined in Data.SOP.BasicFunctors | |
(Show1 f, Show1 g) => Show1 (f :.: g) Source # | Since: sop-core-0.2.4.0 |
(NFData1 f, NFData1 g) => NFData1 (f :.: g) Source # | Since: sop-core-0.2.5.0 |
Defined in Data.SOP.BasicFunctors | |
(Eq1 f, Eq1 g, Eq a) => Eq ((f :.: g) a) Source # | |
(Ord1 f, Ord1 g, Ord a) => Ord ((f :.: g) a) Source # | |
Defined in Data.SOP.BasicFunctors | |
(Read1 f, Read1 g, Read a) => Read ((f :.: g) a) Source # | |
(Show1 f, Show1 g, Show a) => Show ((f :.: g) a) Source # | |
Generic ((f :.: g) p) Source # | |
Semigroup (f (g x)) => Semigroup ((f :.: g) x) Source # | Since: sop-core-0.4.0.0 |
Monoid (f (g x)) => Monoid ((f :.: g) x) Source # | Since: sop-core-0.4.0.0 |
NFData (f (g a)) => NFData ((f :.: g) a) Source # | Since: sop-core-0.2.5.0 |
Defined in Data.SOP.BasicFunctors | |
type Rep ((f :.: g) p) Source # | |
Defined in Data.SOP.BasicFunctors |
Mapping functions
mapIII :: (a -> b -> c) -> I a -> I b -> I c Source #
Lift the given function.
Since: sop-core-0.2.5.0
mapIIK :: (a -> b -> c) -> I a -> I b -> K c d Source #
Lift the given function.
Since: sop-core-0.2.5.0
mapIKI :: (a -> b -> c) -> I a -> K b d -> I c Source #
Lift the given function.
Since: sop-core-0.2.5.0
mapIKK :: (a -> b -> c) -> I a -> K b d -> K c e Source #
Lift the given function.
Since: sop-core-0.2.5.0
mapKII :: (a -> b -> c) -> K a d -> I b -> I c Source #
Lift the given function.
Since: sop-core-0.2.5.0
mapKIK :: (a -> b -> c) -> K a d -> I b -> K c e Source #
Lift the given function.
Since: sop-core-0.2.5.0