Safe Haskell | Safe-Inferred |
---|---|
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.
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.
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 | |
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 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 # | |
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 | |
Eq a => Eq (K a b) Source # | |
Ord a => Ord (K a b) Source # | |
Read a => Read (K a b) Source # | |
Defined in Data.SOP.BasicFunctors | |
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 type Rep (K a b) = D1 ('MetaData "K" "Data.SOP.BasicFunctors" "sop-core-0.5.0.1-DRjYElI1EPTKAV573Fpd8I" 'True) (C1 ('MetaCons "K" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a))) |
newtype I (a :: Type) Source #
The identity type functor.
Like Identity
, but with a shorter name.
Constructors
I a |
Instances
Monad I Source # | |
Functor I Source # | |
Applicative 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 # | |
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 | |
Eq a => Eq (I a) Source # | |
Ord a => Ord (I a) Source # | |
Read a => Read (I a) Source # | |
Defined in Data.SOP.BasicFunctors | |
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 type Rep (I a) = D1 ('MetaData "I" "Data.SOP.BasicFunctors" "sop-core-0.5.0.1-DRjYElI1EPTKAV573Fpd8I" '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
(Functor f, Functor g) => Functor (f :.: g) Source # | |
(Applicative f, Applicative g) => Applicative (f :.: g) Source # | Since: 0.2.5.0 |
(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 | |
(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 | |
(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 # | |
Defined in Data.SOP.BasicFunctors | |
(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 type Rep ((f :.: g) p) = D1 ('MetaData ":.:" "Data.SOP.BasicFunctors" "sop-core-0.5.0.1-DRjYElI1EPTKAV573Fpd8I" 'True) (C1 ('MetaCons "Comp" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (f (g p))))) |