| 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.
ConstandComposebecome 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 (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) Source # | Since: 0.2.4.0 | ||||
Defined in Data.SOP.BasicFunctors | |||||
| Ord2 (K :: Type -> Type -> Type) Source # | Since: 0.2.4.0 | ||||
Defined in Data.SOP.BasicFunctors Methods liftCompare2 :: (a -> b -> Ordering) -> (c -> d -> Ordering) -> K a c -> K b d -> Ordering | |||||
| Read2 (K :: Type -> Type -> Type) Source # | 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) Source # | Since: 0.2.4.0 | ||||
Defined in Data.SOP.BasicFunctors 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 :: Type -> Type -> Type) Source # | Since: 0.2.5.0 | ||||
Defined in Data.SOP.BasicFunctors | |||||
| Eq a => Eq1 (K a :: Type -> Type) Source # | Since: 0.2.4.0 | ||||
Defined in Data.SOP.BasicFunctors | |||||
| Ord a => Ord1 (K a :: Type -> Type) Source # | Since: 0.2.4.0 | ||||
Defined in Data.SOP.BasicFunctors Methods liftCompare :: (a0 -> b -> Ordering) -> K a a0 -> K a b -> Ordering | |||||
| Read a => Read1 (K a :: Type -> Type) Source # | Since: 0.2.4.0 | ||||
Defined in Data.SOP.BasicFunctors Methods liftReadsPrec :: (Int -> ReadS a0) -> ReadS [a0] -> Int -> ReadS (K a a0) liftReadList :: (Int -> ReadS a0) -> ReadS [a0] -> ReadS [K a a0] liftReadPrec :: ReadPrec a0 -> ReadPrec [a0] -> ReadPrec (K a a0) liftReadListPrec :: ReadPrec a0 -> ReadPrec [a0] -> ReadPrec [K a a0] | |||||
| Show a => Show1 (K a :: Type -> Type) Source # | Since: 0.2.4.0 | ||||
Defined in Data.SOP.BasicFunctors Methods liftShowsPrec :: (Int -> a0 -> ShowS) -> ([a0] -> ShowS) -> Int -> K a a0 -> ShowS liftShowList :: (Int -> a0 -> ShowS) -> ([a0] -> ShowS) -> [K a a0] -> ShowS | |||||
| NFData a => NFData1 (K a :: Type -> Type) Source # | Since: 0.2.5.0 | ||||
Defined in Data.SOP.BasicFunctors | |||||
| Monoid a => Applicative (K a :: Type -> Type) Source # | |||||
| Functor (K a :: Type -> Type) Source # | |||||
| Foldable (K a :: Type -> Type) Source # | |||||
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 | |||||
| Traversable (K a :: Type -> Type) Source # | |||||
| NFData a => NFData (K a b) Source # | Since: 0.2.5.0 | ||||
Defined in Data.SOP.BasicFunctors | |||||
| Monoid a => Monoid (K a b) Source # | Since: 0.4.0.0 | ||||
| Semigroup a => Semigroup (K a b) Source # | Since: 0.4.0.0 | ||||
| Generic (K a b) Source # | |||||
Defined in Data.SOP.BasicFunctors Associated Types
| |||||
| Read a => Read (K a b) Source # | |||||
Defined in Data.SOP.BasicFunctors | |||||
| Show a => Show (K a b) Source # | |||||
| Eq a => Eq (K a b) Source # | |||||
| Ord a => Ord (K a b) Source # | |||||
| type Rep (K a b) Source # | |||||
Defined in Data.SOP.BasicFunctors type Rep (K a b) = D1 ('MetaData "K" "Data.SOP.BasicFunctors" "sop-core-0.5.0.2-IXrfWCRaeymCJBZx7ZHwMr" 'True) (C1 ('MetaCons "K" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a))) | |||||
The identity type functor.
Like Identity, but with a shorter name.
Constructors
| I a |
Instances
| Eq1 I Source # | Since: 0.2.4.0 | ||||
Defined in Data.SOP.BasicFunctors | |||||
| Ord1 I Source # | Since: 0.2.4.0 | ||||
Defined in Data.SOP.BasicFunctors Methods liftCompare :: (a -> b -> Ordering) -> I a -> I b -> Ordering | |||||
| Read1 I Source # | Since: 0.2.4.0 | ||||
Defined in Data.SOP.BasicFunctors 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 | ||||
Defined in Data.SOP.BasicFunctors 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 | ||||
Defined in Data.SOP.BasicFunctors | |||||
| Applicative I Source # | |||||
| Functor I Source # | |||||
| Monad I Source # | |||||
| Foldable I Source # | |||||
Defined in Data.SOP.BasicFunctors Methods 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 | |||||
| Traversable I Source # | |||||
| NFData a => NFData (I a) Source # | Since: 0.2.5.0 | ||||
Defined in Data.SOP.BasicFunctors | |||||
| Monoid a => Monoid (I a) Source # | Since: 0.4.0.0 | ||||
| Semigroup a => Semigroup (I a) Source # | Since: 0.4.0.0 | ||||
| Generic (I a) Source # | |||||
Defined in Data.SOP.BasicFunctors Associated Types
| |||||
| Read a => Read (I a) Source # | |||||
Defined in Data.SOP.BasicFunctors | |||||
| Show a => Show (I a) Source # | |||||
| Eq a => Eq (I a) Source # | |||||
| Ord a => Ord (I a) Source # | |||||
| type Rep (I a) Source # | |||||
Defined in Data.SOP.BasicFunctors type Rep (I a) = D1 ('MetaData "I" "Data.SOP.BasicFunctors" "sop-core-0.5.0.2-IXrfWCRaeymCJBZx7ZHwMr" 'True) (C1 ('MetaCons "I" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a))) | |||||
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.
Constructors
| Comp (f (g p)) |
Instances
| (Eq1 f, Eq1 g) => Eq1 (f :.: g) Source # | Since: 0.2.4.0 | ||||
Defined in Data.SOP.BasicFunctors | |||||
| (Ord1 f, Ord1 g) => Ord1 (f :.: g) Source # | Since: 0.2.4.0 | ||||
Defined in Data.SOP.BasicFunctors 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 | ||||
Defined in Data.SOP.BasicFunctors 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 | ||||
Defined in Data.SOP.BasicFunctors 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 | ||||
Defined in Data.SOP.BasicFunctors | |||||
| (Applicative f, Applicative g) => Applicative (f :.: g) Source # | Since: 0.2.5.0 | ||||
| (Functor f, Functor g) => Functor (f :.: g) Source # | |||||
| (Foldable f, Foldable g) => Foldable (f :.: g) Source # | 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 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: 0.2.5.0 | ||||
Defined in Data.SOP.BasicFunctors | |||||
| NFData (f (g a)) => NFData ((f :.: g) a) Source # | Since: 0.2.5.0 | ||||
Defined in Data.SOP.BasicFunctors | |||||
| Monoid (f (g x)) => Monoid ((f :.: g) x) Source # | Since: 0.4.0.0 | ||||
| Semigroup (f (g x)) => Semigroup ((f :.: g) x) Source # | Since: 0.4.0.0 | ||||
| Generic ((f :.: g) p) Source # | |||||
Defined in Data.SOP.BasicFunctors Associated Types
| |||||
| (Read1 f, Read1 g, Read a) => Read ((f :.: g) a) Source # | |||||
Defined in Data.SOP.BasicFunctors | |||||
| (Show1 f, Show1 g, Show a) => Show ((f :.: g) a) Source # | |||||
| (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 | |||||
| type Rep ((f :.: g) p) Source # | |||||
Defined in Data.SOP.BasicFunctors type Rep ((f :.: g) p) = D1 ('MetaData ":.:" "Data.SOP.BasicFunctors" "sop-core-0.5.0.2-IXrfWCRaeymCJBZx7ZHwMr" 'True) (C1 ('MetaCons "Comp" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (f (g p))))) | |||||
unComp :: forall {l} {k} f (g :: k -> l) (p :: k). (f :.: g) p -> f (g p) Source #
Extract the contents of a Comp value.
Mapping functions
mapIK :: forall {k} a b (c :: k). (a -> b) -> I a -> K b c Source #
Lift the given function.
Since: 0.2.5.0
mapKI :: forall {k} a b (c :: k). (a -> b) -> K a c -> I b Source #
Lift the given function.
Since: 0.2.5.0
mapKK :: forall {k1} {k2} a b (c :: k1) (d :: k2). (a -> b) -> K a c -> K b d Source #
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 Source #
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 Source #
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 Source #
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 Source #
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 Source #
Lift the given function.
Since: 0.2.5.0