Safe Haskell | None |
---|---|
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 -> Type -> Type ) Source # |
Since: 0.2.4.0 |
Ord2 ( K :: Type -> Type -> Type ) Source # |
Since: 0.2.4.0 |
Defined in Data.SOP.BasicFunctors |
|
Read2 ( K :: Type -> Type -> Type ) Source # |
Since: 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) Source # liftReadList2 :: ( Int -> ReadS a) -> ReadS [a] -> ( Int -> ReadS b) -> ReadS [b] -> ReadS [ K a b] Source # liftReadPrec2 :: ReadPrec a -> ReadPrec [a] -> ReadPrec b -> ReadPrec [b] -> ReadPrec ( K a b) Source # liftReadListPrec2 :: ReadPrec a -> ReadPrec [a] -> ReadPrec b -> ReadPrec [b] -> ReadPrec [ K a b] Source # |
|
Show2 ( K :: Type -> Type -> Type ) Source # |
Since: 0.2.4.0 |
Defined in Data.SOP.BasicFunctors |
|
NFData2 ( K :: Type -> Type -> Type ) Source # |
Since: 0.2.5.0 |
Defined in Data.SOP.BasicFunctors |
|
Functor ( K a :: Type -> Type ) Source # | |
Monoid a => Applicative ( K a :: Type -> Type ) Source # | |
Foldable ( K a :: Type -> Type ) Source # | |
Defined in Data.SOP.BasicFunctors fold :: Monoid m => K a m -> m Source # foldMap :: Monoid m => (a0 -> m) -> K a a0 -> m Source # foldMap' :: Monoid m => (a0 -> m) -> K a a0 -> m Source # foldr :: (a0 -> b -> b) -> b -> K a a0 -> b Source # foldr' :: (a0 -> b -> b) -> b -> K a a0 -> b Source # foldl :: (b -> a0 -> b) -> b -> K a a0 -> b Source # foldl' :: (b -> a0 -> b) -> b -> K a a0 -> b Source # foldr1 :: (a0 -> a0 -> a0) -> K a a0 -> a0 Source # foldl1 :: (a0 -> a0 -> a0) -> K a a0 -> a0 Source # toList :: K a a0 -> [a0] Source # null :: K a a0 -> Bool Source # length :: K a a0 -> Int Source # elem :: Eq a0 => a0 -> K a a0 -> Bool Source # maximum :: Ord a0 => K a a0 -> a0 Source # minimum :: Ord a0 => K a a0 -> a0 Source # |
|
Traversable ( K a :: Type -> Type ) Source # | |
Eq a => Eq1 ( K a :: Type -> Type ) Source # |
Since: 0.2.4.0 |
Ord a => Ord1 ( K a :: Type -> Type ) Source # |
Since: 0.2.4.0 |
Defined in Data.SOP.BasicFunctors |
|
Read a => Read1 ( K a :: Type -> Type ) Source # |
Since: 0.2.4.0 |
Defined in Data.SOP.BasicFunctors liftReadsPrec :: ( Int -> ReadS a0) -> ReadS [a0] -> Int -> ReadS ( K a a0) Source # liftReadList :: ( Int -> ReadS a0) -> ReadS [a0] -> ReadS [ K a a0] Source # liftReadPrec :: ReadPrec a0 -> ReadPrec [a0] -> ReadPrec ( K a a0) Source # liftReadListPrec :: ReadPrec a0 -> ReadPrec [a0] -> ReadPrec [ K a a0] Source # |
|
Show a => Show1 ( K a :: Type -> Type ) Source # |
Since: 0.2.4.0 |
NFData a => NFData1 ( K a :: Type -> Type ) Source # |
Since: 0.2.5.0 |
Defined in Data.SOP.BasicFunctors |
|
Eq a => Eq ( K a b) Source # | |
Ord a => Ord ( K a b) Source # | |
Defined in Data.SOP.BasicFunctors |
|
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: 0.4.0.0 |
Monoid a => Monoid ( K a b) Source # |
Since: 0.4.0.0 |
NFData a => NFData ( K a b) Source # |
Since: 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 Source # foldMap :: Monoid m => (a -> m) -> I a -> m Source # foldMap' :: Monoid m => (a -> m) -> I a -> m Source # foldr :: (a -> b -> b) -> b -> I a -> b Source # foldr' :: (a -> b -> b) -> b -> I a -> b Source # foldl :: (b -> a -> b) -> b -> I a -> b Source # foldl' :: (b -> a -> b) -> b -> I a -> b Source # foldr1 :: (a -> a -> a) -> I a -> a Source # foldl1 :: (a -> a -> a) -> I a -> a Source # elem :: Eq a => a -> I a -> Bool Source # maximum :: Ord a => I a -> a Source # minimum :: Ord a => I a -> a Source # |
|
Traversable I Source # | |
Eq1 I Source # |
Since: 0.2.4.0 |
Ord1 I Source # |
Since: 0.2.4.0 |
Defined in Data.SOP.BasicFunctors |
|
Read1 I Source # |
Since: 0.2.4.0 |
Defined in Data.SOP.BasicFunctors |
|
Show1 I Source # |
Since: 0.2.4.0 |
NFData1 I Source # |
Since: 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: 0.4.0.0 |
Monoid a => Monoid ( I a) Source # |
Since: 0.4.0.0 |
NFData a => NFData ( I a) Source # |
Since: 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: 0.2.5.0 |
Defined in Data.SOP.BasicFunctors |
|
( Foldable f, Foldable g) => Foldable (f :.: g) Source # |
Since: 0.2.5.0 |
Defined in Data.SOP.BasicFunctors fold :: Monoid m => (f :.: g) m -> m Source # foldMap :: Monoid m => (a -> m) -> (f :.: g) a -> m Source # foldMap' :: Monoid m => (a -> m) -> (f :.: g) a -> m Source # foldr :: (a -> b -> b) -> b -> (f :.: g) a -> b Source # foldr' :: (a -> b -> b) -> b -> (f :.: g) a -> b Source # foldl :: (b -> a -> b) -> b -> (f :.: g) a -> b Source # foldl' :: (b -> a -> b) -> b -> (f :.: g) a -> b Source # foldr1 :: (a -> a -> a) -> (f :.: g) a -> a Source # foldl1 :: (a -> a -> a) -> (f :.: g) a -> a Source # toList :: (f :.: g) a -> [a] Source # null :: (f :.: g) a -> Bool Source # length :: (f :.: g) a -> Int Source # elem :: Eq a => a -> (f :.: g) a -> Bool Source # maximum :: Ord a => (f :.: g) a -> a Source # minimum :: Ord a => (f :.: g) a -> a Source # |
|
( Traversable f, Traversable g) => Traversable (f :.: g) Source # |
Since: 0.2.5.0 |
Defined in Data.SOP.BasicFunctors traverse :: Applicative f0 => (a -> f0 b) -> (f :.: g) a -> f0 ((f :.: g) b) Source # sequenceA :: Applicative f0 => (f :.: g) (f0 a) -> f0 ((f :.: g) a) Source # mapM :: Monad m => (a -> m b) -> (f :.: g) a -> m ((f :.: g) b) Source # sequence :: Monad m => (f :.: g) (m a) -> m ((f :.: g) a) Source # |
|
( Eq1 f, Eq1 g) => Eq1 (f :.: g) Source # |
Since: 0.2.4.0 |
( Ord1 f, Ord1 g) => Ord1 (f :.: g) Source # |
Since: 0.2.4.0 |
Defined in Data.SOP.BasicFunctors |
|
( Read1 f, Read1 g) => Read1 (f :.: g) Source # |
Since: 0.2.4.0 |
Defined in Data.SOP.BasicFunctors liftReadsPrec :: ( Int -> ReadS a) -> ReadS [a] -> Int -> ReadS ((f :.: g) a) Source # liftReadList :: ( Int -> ReadS a) -> ReadS [a] -> ReadS [(f :.: g) a] Source # liftReadPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec ((f :.: g) a) Source # liftReadListPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec [(f :.: g) a] Source # |
|
( Show1 f, Show1 g) => Show1 (f :.: g) Source # |
Since: 0.2.4.0 |
( NFData1 f, NFData1 g) => NFData1 (f :.: g) Source # |
Since: 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 compare :: (f :.: g) a -> (f :.: g) a -> Ordering Source # (<) :: (f :.: g) a -> (f :.: g) a -> Bool Source # (<=) :: (f :.: g) a -> (f :.: g) a -> Bool Source # (>) :: (f :.: g) a -> (f :.: g) a -> Bool Source # (>=) :: (f :.: g) a -> (f :.: g) a -> Bool Source # |
|
( 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: 0.4.0.0 |
Monoid (f (g x)) => Monoid ((f :.: g) x) Source # |
Since: 0.4.0.0 |
NFData (f (g a)) => NFData ((f :.: g) a) Source # |
Since: 0.2.5.0 |
Defined in Data.SOP.BasicFunctors |
|
type Rep ((f :.: g) p) Source # | |
Defined in Data.SOP.BasicFunctors |