| Safe Haskell | None |
|---|---|
| Language | GHC2024 |
Proarrow.Tools.SMC.Internal.Do
Description
Internal module of Proarrow.Tools.SMC: do notation, including rec blocks. It exports
everything, also what the public module keeps hidden.
Synopsis
- class Bind (p :: CAT k) m t cont r | m -> p where
- (>>=) :: m -> (t -> cont) -> r
- class TupleProfunctor (ts :: [Type]) (p :: CAT k) | ts -> p
- class BindTerm (p :: CAT k) t m cont r where
- bindTerm :: m -> (t -> cont) -> r
- class Interp c ~ Dual (Interp y) => Negative (c :: SYN k) (y :: SYN k)
- newtype Ret t x = Ret x
- unRet :: Ret t x -> x
- class RecVars k t where
- class AnyDepth t t'
- return :: forall k t (d :: Nat) (p :: CAT k). (Monoidal k, Promonad p, RecVars k t, KnownCtx (Vars k t)) => t -> Ret t (TermP p d (Vars k t) (Mul (Vars k t)))
- data Rec (p :: CAT k) (d :: Nat) t (g :: Ctx k) where
- mfix :: forall {k} t (d :: Nat) (g :: Ctx k) (p :: CAT k). RecVars k t => (t -> Ret t (TermP p d g (Mul (Vars k t)))) -> Rec p d t g
- type family RecDepth (d :: Nat) (g :: Ctx k) :: Nat where ...
- fail :: a
Documentation
class Bind (p :: CAT k) m t cont r | m -> p where Source Github #
A bind in a do block: a term, constant or tuple taken apart by a pattern, or the variables
of a rec block.
Methods
(>>=) :: m -> (t -> cont) -> r Source Github #
Bind the right hand side to the pattern of the continuation.
Instances
| (TupleProfunctor '[x, y] p, ToTerm p (x, y) d g a, Bind p (TermP p d g a) t cont r) => Bind (p :: CAT k) (x, y) t cont r Source Github # | Convert a tuple before binding it. At least one component must identify the promonad. |
Defined in Proarrow.Tools.SMC.Internal.Do | |
| (p ~ q, a ~ (Unit :: k), Bind p (TermP p d ('[] :: [(Nat, SYN k)]) ('F b)) t cont r) => Bind (p :: CAT k) (q a b) t cont r Source Github # | Bind a constant arrow, computing it once before the continuation. |
Defined in Proarrow.Tools.SMC.Internal.Do | |
| Bind p ((x, y), z) t cont r => Bind (p :: CAT k) (x, y, z) t cont r Source Github # | |
Defined in Proarrow.Tools.SMC.Internal.Do | |
| Bind p ((w, x, y), z) t cont r => Bind (p :: CAT k) (w, x, y, z) t cont r Source Github # | |
Defined in Proarrow.Tools.SMC.Internal.Do | |
| (Promonad p, MonoidalProfunctor p, Costrong (Tensor :: k -> (k, k) -> Type) p, SymMonoidal k, RecVars k t, AnyDepth t t', AnyDepth t' t, RecVars k t', ToTerm p cont (RecDepth d (Vars k t)) gc c, r ~ TermP p d (Union (Minus gc (Vars k t)) (Minus g (Vars k t))) c, Unmerge (Inter g (Vars k t)) (Minus g (Vars k t)), Union (Inter g (Vars k t)) (Minus g (Vars k t)) ~ g, Thin (Vars k t) (Union (Inter g (Vars k t)) (Inter gc (Vars k t))), Merge (Inter g (Vars k t)) (Inter gc (Vars k t)), Merge (Minus gc (Vars k t)) (Minus g (Vars k t)), Unmerge (Minus gc (Vars k t)) (Inter gc (Vars k t)), Union (Minus gc (Vars k t)) (Inter gc (Vars k t)) ~ gc) => Bind (p :: CAT k) (Rec p d t g) t' cont r Source Github # | The rest of the |
| (p ~ Hom k, Dialogue k, KnownObj y, Merge g r, Negative (TyOf cont :: SYN k) y, Binds p d r a (TyOf cont :: SYN k) t cont, r' ~ TermP p d (Union g r) ('Not y)) => Bind (p :: CAT k) (TermP p d g ('Not ('Not a))) t cont r' Source Github # | A computation on the right hand side runs first, and the rest of the block is negative. |
| BindTerm p t (TermP p d g a) cont r => Bind (p :: CAT k) (TermP p d g a) t cont r Source Github # | A term on the right hand side is taken apart by the pattern. Incoherent, so that it is chosen as soon as the right hand side is known, unless the right hand side is a computation. |
| Bind p ((v, w, x, y), z) t cont r => Bind (p :: CAT k) (v, w, x, y, z) t cont r Source Github # | |
Defined in Proarrow.Tools.SMC.Internal.Do | |
| (Bind p (TermP p d g a) t cont r', r ~ Ret tt r') => Bind (p :: CAT k) (TermP p d g a) t (Ret tt cont) r Source Github # | The statement of a |
| Bind p ((u, v, w, x, y), z) t cont r => Bind (p :: CAT k) (u, v, w, x, y, z) t cont r Source Github # | |
Defined in Proarrow.Tools.SMC.Internal.Do | |
class TupleProfunctor (ts :: [Type]) (p :: CAT k) | ts -> p Source Github #
Instances
class BindTerm (p :: CAT k) t m cont r where Source Github #
A bind of a term, by its pattern. A variable pattern binds a new variable, so that the right hand side is computed once however often the variable is used. The other patterns take the right hand side apart into new variables already.
Instances
| BindPat p (TermP p d g a) () cont r => BindTerm (p :: CAT k) () (TermP p d g a) cont r Source Github # | |
| (Promonad p, MonoidalProfunctor p, Binds p d r a b t cont, Merge r g, r' ~ TermP p d (Union r g) b) => BindTerm (p :: CAT k) t (TermP p d g a) cont r' Source Github # | |
| BindPat p (TermP p d g a) (x, y) cont r => BindTerm (p :: CAT k) (x, y) (TermP p d g a) cont r Source Github # | |
| BindPat p (TermP p d g a) (x, y, z) cont r => BindTerm (p :: CAT k) (x, y, z) (TermP p d g a) cont r Source Github # | |
| BindPat p (TermP p d g a) (w, x, y, z) cont r => BindTerm (p :: CAT k) (w, x, y, z) (TermP p d g a) cont r Source Github # | |
| BindPat p (TermP p d g a) (v, w, x, y, z) cont r => BindTerm (p :: CAT k) (v, w, x, y, z) (TermP p d g a) cont r Source Github # | |
| BindPat p (TermP p d g a) (u, v, w, x, y, z) cont r => BindTerm (p :: CAT k) (u, v, w, x, y, z) (TermP p d g a) cont r Source Github # | |
newtype Ret t x Source Github #
The body of a rec block, tagged with the tuple of its variables. GHC's translation passes
that tuple to both return and mfix, and this tag is what makes them the same.
Constructors
| Ret x |
Instances
class RecVars k t where Source Github #
The variables of a rec block, as GHC tuples them up.
Instances
| RecVars k () Source Github # | |||||
Defined in Proarrow.Tools.SMC.Internal.Do Associated Types
| |||||
| (RecVars k x, RecVars k y) => RecVars k (x, y) Source Github # | |||||
| (RecVars k x, RecVars k y, RecVars k z) => RecVars k (x, y, z) Source Github # | |||||
| (RecVars k x, RecVars k y, RecVars k z, RecVars k w) => RecVars k (x, y, z, w) Source Github # | |||||
| (Promonad p, KnownObj a) => RecVars k (TermP p d '['(n, a)] a) Source Github # | |||||
| (RecVars k x, RecVars k y, RecVars k z, RecVars k w, RecVars k v) => RecVars k (x, y, z, w, v) Source Github # | |||||
| (RecVars k x, RecVars k y, RecVars k z, RecVars k w, RecVars k v, RecVars k u) => RecVars k (x, y, z, w, v, u) Source Github # | |||||
class AnyDepth t t' Source Github #
The variables of a rec block again, at a depth of their own: the rest of the block uses them
deeper than the block did. It is asked for both ways, so that what is known about the variables
on either side of the block determines the other.
Instances
return :: forall k t (d :: Nat) (p :: CAT k). (Monoidal k, Promonad p, RecVars k t, KnownCtx (Vars k t)) => t -> Ret t (TermP p d (Vars k t) (Mul (Vars k t))) Source Github #
The end of a rec block: all its variables, as the tensor of their context.
data Rec (p :: CAT k) (d :: Nat) t (g :: Ctx k) where Source Github #
A rec block before tracing: its body, from its context g to all its variables. Which of them
are fed back and which are passed on is only known with the rest of the block, see the Bind
instance.
Constructors
| Rec :: forall {k} (p :: CAT k) (d :: Nat) t (g :: Ctx k). p (Interp (Mul g)) (Interp (Mul (Vars k t))) -> Rec p d t g |
Instances
| (Promonad p, MonoidalProfunctor p, Costrong (Tensor :: k -> (k, k) -> Type) p, SymMonoidal k, RecVars k t, AnyDepth t t', AnyDepth t' t, RecVars k t', ToTerm p cont (RecDepth d (Vars k t)) gc c, r ~ TermP p d (Union (Minus gc (Vars k t)) (Minus g (Vars k t))) c, Unmerge (Inter g (Vars k t)) (Minus g (Vars k t)), Union (Inter g (Vars k t)) (Minus g (Vars k t)) ~ g, Thin (Vars k t) (Union (Inter g (Vars k t)) (Inter gc (Vars k t))), Merge (Inter g (Vars k t)) (Inter gc (Vars k t)), Merge (Minus gc (Vars k t)) (Minus g (Vars k t)), Unmerge (Minus gc (Vars k t)) (Inter gc (Vars k t)), Union (Minus gc (Vars k t)) (Inter gc (Vars k t)) ~ gc) => Bind (p :: CAT k) (Rec p d t g) t' cont r Source Github # | The rest of the |
mfix :: forall {k} t (d :: Nat) (g :: Ctx k) (p :: CAT k). RecVars k t => (t -> Ret t (TermP p d g (Mul (Vars k t)))) -> Rec p d t g Source Github #
The body of a rec block, to be traced by the bind after it.