Copyright | (c) 2023 Yamada Ryo |
---|---|
License | MPL-2.0 (see the file LICENSE) |
Maintainer | ymdfield@outlook.jp |
Stability | experimental |
Portability | portable |
Safe Haskell | Safe-Inferred |
Language | GHC2021 |
This module re-exports the HFunctor
type class and related definitions from the compdata
package, which are required for the Heftia effect handler system. For more details, please refer to
CEP-03 and
the compdata
documentation.
Synopsis
- class HFunctor (h :: (Type -> Type) -> Type -> Type) where
- makeHFunctor :: Name -> Q [Dec]
- class RemA (s :: (Type -> Type) -> Type -> Type) (s' :: (Type -> Type) -> Type -> Type) | s -> s' where
- class DistAnn (s :: (Type -> Type) -> Type -> Type) p (s' :: (Type -> Type) -> Type -> Type) | s' -> s, s' -> p where
- data ((f :: (Type -> Type) -> k -> Type) :&: a) (g :: Type -> Type) (e :: k) = (f g e) :&: a
- type (:=:) (f :: (Type -> Type) -> Type -> Type) (g :: (Type -> Type) -> Type -> Type) = (f :<: g, g :<: f)
- type (:<:) (f :: (Type -> Type) -> Type -> Type) (g :: (Type -> Type) -> Type -> Type) = Subsume (ComprEmb (Elem f g)) f g
- class Subsume (e :: Emb) (f :: (Type -> Type) -> Type -> Type) (g :: (Type -> Type) -> Type -> Type) where
- type family Elem (f :: (Type -> Type) -> Type -> Type) (g :: (Type -> Type) -> Type -> Type) :: Emb where ...
- data ((f :: (Type -> Type) -> k -> Type) :+: (g :: (Type -> Type) -> k -> Type)) (h :: Type -> Type) (e :: k)
- caseH :: forall {k} f (a :: Type -> Type) (b :: k) c g. (f a b -> c) -> (g a b -> c) -> (f :+: g) a b -> c
- inj :: forall (f :: (Type -> Type) -> Type -> Type) (g :: (Type -> Type) -> Type -> Type) (a :: Type -> Type). f :<: g => f a :-> g a
- proj :: forall (f :: (Type -> Type) -> Type -> Type) (g :: (Type -> Type) -> Type -> Type) (a :: Type -> Type). f :<: g => NatM Maybe (g a) (f a)
- spl :: forall (f :: (Type -> Type) -> Type -> Type) (f1 :: (Type -> Type) -> Type -> Type) (f2 :: (Type -> Type) -> Type -> Type) (a :: Type -> Type) (b :: Type -> Type). f :=: (f1 :+: f2) => (f1 a :-> b) -> (f2 a :-> b) -> f a :-> b
Documentation
class HFunctor (h :: (Type -> Type) -> Type -> Type) where #
This class represents higher-order functors (Johann, Ghani, POPL '08) which are endofunctors on the category of endofunctors.
hfmap :: forall (f :: Type -> Type) (g :: Type -> Type). (f :-> g) -> h f :-> h g #
A higher-order functor f
also maps a natural transformation
g :-> h
to a natural transformation f g :-> f h
makeHFunctor :: Name -> Q [Dec] #
Derive an instance of HFunctor
for a type constructor of any higher-order
kind taking at least two arguments.
class RemA (s :: (Type -> Type) -> Type -> Type) (s' :: (Type -> Type) -> Type -> Type) | s -> s' where #
class DistAnn (s :: (Type -> Type) -> Type -> Type) p (s' :: (Type -> Type) -> Type -> Type) | s' -> s, s' -> p where #
This class defines how to distribute an annotation over a sum of signatures.
injectA :: forall (a :: Type -> Type). p -> s a :-> s' a #
This function injects an annotation over a signature.
projectA :: forall (a :: Type -> Type). s' a :-> (s a :&: p) #
data ((f :: (Type -> Type) -> k -> Type) :&: a) (g :: Type -> Type) (e :: k) infixr 7 #
This data type adds a constant product to a signature. Alternatively, this could have also been defined as
data (f :&: a) (g :: Type -> Type) e = f g e :&: a e
This is too general, however, for example for productHHom
.
(f g e) :&: a infixr 7 |
Instances
DistAnn f p (f :&: p) | |
HFoldable f => HFoldable (f :&: a) | |
Defined in Data.Comp.Multi.Ops hfold :: Monoid m => (f :&: a) (K m) :=> m # hfoldMap :: forall m (a0 :: Type -> Type). Monoid m => (a0 :=> m) -> (f :&: a) a0 :=> m # hfoldr :: forall (a0 :: Type -> Type) b. (a0 :=> (b -> b)) -> b -> (f :&: a) a0 :=> b # hfoldl :: forall b (a0 :: Type -> Type). (b -> a0 :=> b) -> b -> (f :&: a) a0 :=> b # | |
HFunctor f => HFunctor (f :&: a) | |
HTraversable f => HTraversable (f :&: a) | |
Defined in Data.Comp.Multi.Ops | |
RemA (f :&: p) f | |
DistAnn s p s' => DistAnn (f :+: s) p ((f :&: p) :+: s') | |
RemA s s' => RemA ((f :&: p) :+: s) (f :+: s') | |
type (:=:) (f :: (Type -> Type) -> Type -> Type) (g :: (Type -> Type) -> Type -> Type) = (f :<: g, g :<: f) infixl 5 #
type (:<:) (f :: (Type -> Type) -> Type -> Type) (g :: (Type -> Type) -> Type -> Type) = Subsume (ComprEmb (Elem f g)) f g infixl 5 #
A constraint f :<: g
expresses that the signature f
is
subsumed by g
, i.e. f
can be used to construct elements in g
.
class Subsume (e :: Emb) (f :: (Type -> Type) -> Type -> Type) (g :: (Type -> Type) -> Type -> Type) where #
inj' :: forall (a :: Type -> Type). Proxy e -> f a :-> g a #
prj' :: forall (a :: Type -> Type). Proxy e -> NatM Maybe (g a) (f a) #
type family Elem (f :: (Type -> Type) -> Type -> Type) (g :: (Type -> Type) -> Type -> Type) :: Emb where ... #
data ((f :: (Type -> Type) -> k -> Type) :+: (g :: (Type -> Type) -> k -> Type)) (h :: Type -> Type) (e :: k) infixr 6 #
Data type defining coproducts.
Instances
Subsume ('Found p) f g => Subsume ('Found ('Le p)) f (g :+: g') | |
Subsume ('Found p) f g => Subsume ('Found ('Ri p)) f (g' :+: g) | |
(Subsume ('Found p1) f1 g, Subsume ('Found p2) f2 g) => Subsume ('Found ('Sum p1 p2)) (f1 :+: f2) g | |
(EqHF f, EqHF g) => EqHF (f :+: g) |
|
(HFoldable f, HFoldable g) => HFoldable (f :+: g) | |
Defined in Data.Comp.Multi.Ops hfold :: Monoid m => (f :+: g) (K m) :=> m # hfoldMap :: forall m (a :: Type -> Type). Monoid m => (a :=> m) -> (f :+: g) a :=> m # hfoldr :: forall (a :: Type -> Type) b. (a :=> (b -> b)) -> b -> (f :+: g) a :=> b # hfoldl :: forall b (a :: Type -> Type). (b -> a :=> b) -> b -> (f :+: g) a :=> b # | |
(HFunctor f, HFunctor g) => HFunctor (f :+: g) | |
(HTraversable f, HTraversable g) => HTraversable (f :+: g) | |
Defined in Data.Comp.Multi.Ops | |
(OrdHF f, OrdHF g) => OrdHF (f :+: g) |
|
DistAnn s p s' => DistAnn (f :+: s) p ((f :&: p) :+: s') | |
RemA s s' => RemA ((f :&: p) :+: s) (f :+: s') | |
caseH :: forall {k} f (a :: Type -> Type) (b :: k) c g. (f a b -> c) -> (g a b -> c) -> (f :+: g) a b -> c #
Utility function to case on a higher-order functor sum, without exposing the internal representation of sums.
inj :: forall (f :: (Type -> Type) -> Type -> Type) (g :: (Type -> Type) -> Type -> Type) (a :: Type -> Type). f :<: g => f a :-> g a #