Safe Haskell | None |
---|---|
Language | Haskell2010 |
Typeclass hierarchy of functors from k -> Type
to Type
.
The naming convention Functor10
comes from the fact that it's a functor
from the category of objects with one type parameter to the category of
objects with zero type parameters. See
http://hackage.haskell.org/package/hakaru-0.4.0/docs/src/Language.Hakaru.Syntax.IClasses.html
for precedent for this naming convention.
In this, the argument morphisms are of the form forall a. m a -> n a
, and
the result morphisms are of the form f m -> f n
.
The main parts of this are:
Functor10
and the other similarly-named typeclasses, which are essentially just translations ofFunctor
et al. to kind(k -> Type) -> Type
. These are essentiallyFunctor
s with additional "tag" types available at each occurrence of the argument. Applying them toIdentity
, you get essentially normal records, but other type parameters give other interesting objects.- (
:**
) andExists
(two stockFunctor10
types) plus appropriate instances for products, sums, and compositions of functors as provided by GHC.Generics: (:*:
), (:+:
), and (:.:
). Entails
, which uses a GADT-like value to retrieve instances for its type parameter. This adds a lot of power to the otherwise-pretty-weakFunctor10
class hierarchy, since without access to corresponding instances, all the input morphisms are unable to do anything whatsoever with the "tag" types. WithEntails
, though, one can use the fact that every occurrence ofm a
inf m
satisfiesc a
to make instances ofc
available while mappingfoldingtraversing/etc. anf m
.
The provided GHC.Generics-based deriving functionality is meant to be used
with the DerivingVia extension. To get the full suite of classes on a
generic-record type, make sure every field is either an Ap10
, another
nested generic-record, or an instance of Update
applied to
one of the above. Then, just add the deriving clauses:
data MyType f = MyType { _mrInt :: Ap10 Int f, _mrBool :: Ap10 Bool f } deriving Generic1 deriving ( Functor10, Foldable10, Traversable10 , Applicative10, Representable10, Update10, Constrained10 c ) via Wrapped1 Generic1 MyType deriving ( Functor10WithIndex, Foldable10WithIndex, Traversable10WithIndex ) via Wrapped1 Representable10 MyType type instance Index10 MyType = Rep10 MyType
Synopsis
- module Data.Ten.Functor
- module Data.Ten.Functor.WithIndex
- module Data.Ten.Foldable
- module Data.Ten.Foldable.WithIndex
- module Data.Ten.Traversable
- module Data.Ten.Traversable.WithIndex
- module Data.Ten.Applicative
- module Data.Ten.Representable
- module Data.Ten.Update
- module Data.Ten.Entails
- module Data.Ten.Ap
- module Data.Ten.Exists
- module Data.Ten.Field
- module Data.Ten.Sigma
- newtype ((f :: k2 -> Type) :.: (g :: k1 -> k2)) (p :: k1) = Comp1 {
- unComp1 :: f (g p)
- data ((f :: k -> Type) :*: (g :: k -> Type)) (p :: k) = (f p) :*: (g p)
- data ((f :: k -> Type) :+: (g :: k -> Type)) (p :: k)
Typeclasses
Functor10
module Data.Ten.Functor
module Data.Ten.Functor.WithIndex
Foldable10
module Data.Ten.Foldable
module Data.Ten.Foldable.WithIndex
Traversable10
module Data.Ten.Traversable
Applicative10
module Data.Ten.Applicative
Representable10
module Data.Ten.Representable
Update10
module Data.Ten.Update
Entails
module Data.Ten.Entails
Standard Functor10
s
module Data.Ten.Ap
module Data.Ten.Exists
module Data.Ten.Field
module Data.Ten.Sigma
newtype ((f :: k2 -> Type) :.: (g :: k1 -> k2)) (p :: k1) infixr 7 #
Composition of functors
Instances
(Applicative f, Constrained10 c g) => Constrained10 (c :: k -> Constraint) (f :.: g :: (k -> Type) -> Type) Source # | |
Defined in Data.Ten.Field constrained10 :: (f :.: g) (Dict1 c) Source # | |
Functor f => Generic1 (f :.: g :: k -> Type) | Since: base-4.9.0.0 |
(NFData1 f, GNFData One g) => GNFData One (f :.: g) | |
Defined in Control.DeepSeq | |
(Foldable f, Foldable10 g) => Foldable10 (f :.: g :: (k -> Type) -> Type) Source # | |
(Functor f, Functor10 g) => Functor10 (f :.: g :: (k -> Type) -> Type) Source # | |
(Functor g, Functor10WithIndex f) => Functor10WithIndex (g :.: f :: (k -> Type) -> Type) Source # | |
(Foldable g, Foldable10WithIndex f) => Foldable10WithIndex (g :.: f :: (k -> Type) -> Type) Source # | |
Defined in Data.Ten.Foldable.WithIndex | |
(Applicative f, Applicative10 g) => Applicative10 (f :.: g :: (k -> Type) -> Type) Source # | |
Defined in Data.Ten.Applicative | |
(Traversable f, Traversable10 g) => Traversable10 (f :.: g :: (k -> Type) -> Type) Source # | |
Defined in Data.Ten.Traversable mapTraverse10 :: forall f0 m n r. Applicative f0 => ((f :.: g) n -> r) -> (forall (a :: k0). m a -> f0 (n a)) -> (f :.: g) m -> f0 r Source # | |
(Traversable g, Traversable10WithIndex f) => Traversable10WithIndex (g :.: f :: (k -> Type) -> Type) Source # | |
Defined in Data.Ten.Traversable.WithIndex imapTraverse10 :: Applicative g0 => ((g :.: f) n -> r) -> (forall (a :: k0). Index10 (g :.: f) a -> m a -> g0 (n a)) -> (g :.: f) m -> g0 r Source # | |
(Functor f, FieldPaths f, GFieldPaths10 g) => GFieldPaths10 (f :.: g :: (k -> Type) -> Type) Source # | |
Defined in Data.Ten.Field gfieldPaths10 :: (forall (a :: k0). [PathComponent] -> r a) -> (f :.: g) r Source # | |
(Representable f, GTabulate10 g) => GTabulate10 (f :.: g :: (k -> Type) -> Type) Source # | |
Defined in Data.Ten.Representable | |
(Update f, GUpdate10 g) => GUpdate10 (f :.: g :: (k -> Type) -> Type) Source # | |
Defined in Data.Ten.Update | |
(Functor f, Functor g) => Functor (f :.: g) | Since: base-4.9.0.0 |
(Applicative f, Applicative g) => Applicative (f :.: g) | Since: base-4.9.0.0 |
(Foldable f, Foldable g) => Foldable (f :.: g) | Since: base-4.9.0.0 |
Defined in Data.Foldable 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: base-4.9.0.0 |
(Distributive a, Distributive b) => Distributive (a :.: b) | |
Defined in Data.Distributive | |
(Functor f, Contravariant g) => Contravariant (f :.: g) | |
(Representable f, Representable g) => Representable (f :.: g) | |
(Alternative f, Applicative g) => Alternative (f :.: g) | Since: base-4.9.0.0 |
(Representable f, GIndex g) => GIndex (f :.: g) | |
Defined in Data.Functor.Rep | |
(Representable f, GTabulate g) => GTabulate (f :.: g) | |
Defined in Data.Functor.Rep gtabulate' :: (GRep' (f :.: g) -> a) -> (f :.: g) a | |
(GTabulate f, GTabulate g) => GTabulate (f :.: g) Source # | |
(GFieldPaths f, GFieldPaths g) => GFieldPaths (f :.: g) Source # | |
Defined in Data.Functor.Field gfieldPaths :: ([PathComponent] -> r) -> (f :.: g) r Source # | |
(GUpdate f, GUpdate g) => GUpdate (f :.: g) Source # | |
Eq (f (g p)) => Eq ((f :.: g) p) | Since: base-4.7.0.0 |
Ord (f (g p)) => Ord ((f :.: g) p) | Since: base-4.7.0.0 |
Read (f (g p)) => Read ((f :.: g) p) | Since: base-4.7.0.0 |
Show (f (g p)) => Show ((f :.: g) p) | Since: base-4.7.0.0 |
Generic ((f :.: g) p) | Since: base-4.7.0.0 |
Semigroup (f (g p)) => Semigroup ((f :.: g) p) | Since: base-4.12.0.0 |
Monoid (f (g p)) => Monoid ((f :.: g) p) | Since: base-4.12.0.0 |
type Rep1 (f :.: g :: k -> Type) | |
Defined in GHC.Generics | |
type Index10 (g :.: f :: (k -> Type) -> Type) Source # | |
type Rep (f :.: g) | |
Defined in Data.Functor.Rep | |
type GRep' (f :.: g) | |
Defined in Data.Functor.Rep | |
type Rep ((f :.: g) p) | |
Defined in GHC.Generics |
data ((f :: k -> Type) :*: (g :: k -> Type)) (p :: k) infixr 6 #
Products: encode multiple arguments to constructors
(f p) :*: (g p) infixr 6 |
Instances
(Constrained10 c f, Constrained10 c g) => Constrained10 (c :: k -> Constraint) (f :*: g :: (k -> Type) -> Type) Source # | |
Defined in Data.Ten.Field constrained10 :: (f :*: g) (Dict1 c) Source # | |
Generic1 (f :*: g :: k -> Type) | Since: base-4.9.0.0 |
(GPortrayProduct f, GPortrayProduct g) => GPortrayProduct (f :*: g :: k -> Type) | |
Defined in Data.Portray gportrayProduct :: forall (a :: k0). (f :*: g) a -> [FactorPortrayal Portrayal] -> [FactorPortrayal Portrayal] # | |
(GSemigroup f, GSemigroup g) => GSemigroup (f :*: g :: k -> Type) | |
(GMonoid f, GMonoid g) => GMonoid (f :*: g :: k -> Type) | |
Defined in Data.Wrapped | |
(GNFData arity a, GNFData arity b) => GNFData arity (a :*: b) | |
Defined in Control.DeepSeq | |
(Foldable10 f, Foldable10 g) => Foldable10 (f :*: g :: (k -> Type) -> Type) Source # | |
(Functor10 f, Functor10 g) => Functor10 (f :*: g :: (k -> Type) -> Type) Source # | |
(Applicative10 f, Applicative10 g) => Applicative10 (f :*: g :: (k -> Type) -> Type) Source # | |
Defined in Data.Ten.Applicative | |
(Traversable10 f, Traversable10 g) => Traversable10 (f :*: g :: (k -> Type) -> Type) Source # | |
Defined in Data.Ten.Traversable mapTraverse10 :: forall f0 m n r. Applicative f0 => ((f :*: g) n -> r) -> (forall (a :: k0). m a -> f0 (n a)) -> (f :*: g) m -> f0 r Source # | |
(GFieldPaths10 f, GFieldPaths10 g) => GFieldPaths10 (f :*: g :: (k -> Type) -> Type) Source # | |
Defined in Data.Ten.Field gfieldPaths10 :: (forall (a :: k0). [PathComponent] -> r a) -> (f :*: g) r Source # | |
(GTabulate10 f, GTabulate10 g) => GTabulate10 (f :*: g :: (k -> Type) -> Type) Source # | |
Defined in Data.Ten.Representable | |
(GUpdate10 f, GUpdate10 g) => GUpdate10 (f :*: g :: (k -> Type) -> Type) Source # | |
Defined in Data.Ten.Update | |
(Monad f, Monad g) => Monad (f :*: g) | Since: base-4.9.0.0 |
(Functor f, Functor g) => Functor (f :*: g) | Since: base-4.9.0.0 |
(Applicative f, Applicative g) => Applicative (f :*: g) | Since: base-4.9.0.0 |
(Foldable f, Foldable g) => Foldable (f :*: g) | Since: base-4.9.0.0 |
Defined in Data.Foldable 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: base-4.9.0.0 |
(Distributive a, Distributive b) => Distributive (a :*: b) | |
Defined in Data.Distributive | |
(Contravariant f, Contravariant g) => Contravariant (f :*: g) | |
(Representable f, Representable g) => Representable (f :*: g) | |
(Alternative f, Alternative g) => Alternative (f :*: g) | Since: base-4.9.0.0 |
(MonadPlus f, MonadPlus g) => MonadPlus (f :*: g) | Since: base-4.9.0.0 |
(GDefault a, GDefault b) => GDefault (a :*: b) | |
Defined in Data.Default.Class | |
(GDiffCtor f, GDiffCtor g) => GDiffCtor (f :*: g) | |
(GDiffRecord f, GDiffRecord g) => GDiffRecord (f :*: g) | |
Defined in Data.Portray.Diff gdiffRecord :: (f :*: g) x -> (f :*: g) x -> DList (FactorPortrayal Portrayal) | |
(GIndex f, GIndex g) => GIndex (f :*: g) | |
Defined in Data.Functor.Rep | |
(GTabulate f, GTabulate g) => GTabulate (f :*: g) | |
Defined in Data.Functor.Rep gtabulate' :: (GRep' (f :*: g) -> a) -> (f :*: g) a | |
(GTabulate f, GTabulate g) => GTabulate (f :*: g) Source # | |
(GFieldPaths f, GFieldPaths g) => GFieldPaths (f :*: g) Source # | |
Defined in Data.Functor.Field gfieldPaths :: ([PathComponent] -> r) -> (f :*: g) r Source # | |
(GUpdate f, GUpdate g) => GUpdate (f :*: g) Source # | |
(Eq (f p), Eq (g p)) => Eq ((f :*: g) p) | Since: base-4.7.0.0 |
(Ord (f p), Ord (g p)) => Ord ((f :*: g) p) | Since: base-4.7.0.0 |
(Read (f p), Read (g p)) => Read ((f :*: g) p) | Since: base-4.7.0.0 |
(Show (f p), Show (g p)) => Show ((f :*: g) p) | Since: base-4.7.0.0 |
Generic ((f :*: g) p) | Since: base-4.7.0.0 |
(Semigroup (f p), Semigroup (g p)) => Semigroup ((f :*: g) p) | Since: base-4.12.0.0 |
(Monoid (f p), Monoid (g p)) => Monoid ((f :*: g) p) | Since: base-4.12.0.0 |
type Rep1 (f :*: g :: k -> Type) | |
Defined in GHC.Generics type Rep1 (f :*: g :: k -> Type) = D1 ('MetaData ":*:" "GHC.Generics" "base" 'False) (C1 ('MetaCons ":*:" ('InfixI 'RightAssociative 6) 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec1 f) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec1 g))) | |
type Rep (f :*: g) | |
type GRep' (f :*: g) | |
Defined in Data.Functor.Rep | |
type Rep ((f :*: g) p) | |
Defined in GHC.Generics type Rep ((f :*: g) p) = D1 ('MetaData ":*:" "GHC.Generics" "base" 'False) (C1 ('MetaCons ":*:" ('InfixI 'RightAssociative 6) 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (f p)) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (g p)))) |
data ((f :: k -> Type) :+: (g :: k -> Type)) (p :: k) infixr 5 #
Sums: encode choice between constructors
Instances
Generic1 (f :+: g :: k -> Type) | Since: base-4.9.0.0 |
(GPortray f, GPortray g) => GPortray (f :+: g :: k -> Type) | |
Defined in Data.Portray | |
(GNFData arity a, GNFData arity b) => GNFData arity (a :+: b) | |
Defined in Control.DeepSeq | |
(Portray a, GDiff a f, GDiff a g) => GDiff a (f :+: g) | |
(GSum arity a, GSum arity b) => GSum arity (a :+: b) | |
(Foldable10 f, Foldable10 g) => Foldable10 (f :+: g :: (k -> Type) -> Type) Source # | |
(Functor10 f, Functor10 g) => Functor10 (f :+: g :: (k -> Type) -> Type) Source # | |
(Traversable10 f, Traversable10 g) => Traversable10 (f :+: g :: (k -> Type) -> Type) Source # | |
Defined in Data.Ten.Traversable mapTraverse10 :: forall f0 m n r. Applicative f0 => ((f :+: g) n -> r) -> (forall (a :: k0). m a -> f0 (n a)) -> (f :+: g) m -> f0 r Source # | |
(Functor f, Functor g) => Functor (f :+: g) | Since: base-4.9.0.0 |
(Foldable f, Foldable g) => Foldable (f :+: g) | Since: base-4.9.0.0 |
Defined in Data.Foldable 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: base-4.9.0.0 |
(Contravariant f, Contravariant g) => Contravariant (f :+: g) | |
(SumSize a, SumSize b) => SumSize (a :+: b) | |
Defined in Data.Hashable.Generic.Instances | |
(GSumGet a, GSumGet b) => GSumGet (a :+: b) | |
(SumSize a, SumSize b) => SumSize (a :+: b) | |
Defined in Data.Binary.Generic | |
(GSumPut a, GSumPut b) => GSumPut (a :+: b) | |
(Eq (f p), Eq (g p)) => Eq ((f :+: g) p) | Since: base-4.7.0.0 |
(Ord (f p), Ord (g p)) => Ord ((f :+: g) p) | Since: base-4.7.0.0 |
(Read (f p), Read (g p)) => Read ((f :+: g) p) | Since: base-4.7.0.0 |
(Show (f p), Show (g p)) => Show ((f :+: g) p) | Since: base-4.7.0.0 |
Generic ((f :+: g) p) | Since: base-4.7.0.0 |
type Rep1 (f :+: g :: k -> Type) | |
Defined in GHC.Generics type Rep1 (f :+: g :: k -> Type) = D1 ('MetaData ":+:" "GHC.Generics" "base" 'False) (C1 ('MetaCons "L1" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec1 f)) :+: C1 ('MetaCons "R1" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec1 g))) | |
type Rep ((f :+: g) p) | |
Defined in GHC.Generics type Rep ((f :+: g) p) = D1 ('MetaData ":+:" "GHC.Generics" "base" 'False) (C1 ('MetaCons "L1" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (f p))) :+: C1 ('MetaCons "R1" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (g p)))) |