| Safe Haskell | None |
|---|---|
| Language | GHC2024 |
Proarrow.Tools.HypergraphRewrite.Free
Description
Compile free syntax into typed hypergraphs. Each structure box connects its outer endpoints to the endpoints of its immediate children. Composition shares nodes, and identity is a wire. No interpretation of the structures in the hypergraph category is required. A structure box's inputs are its outer input followed by its child outputs; its outputs are its outer output followed by its child inputs. These connections keep child boundaries distinct from the surrounding composition and expose the children to matching.
freeLawRules compiles laws with object variables and whole-arrow parameters.
Object matching uses the reflected free-object grammar, so variables can bind
compound objects without adding graph-specific instances of the structures.
Synopsis
- class CategoryOf k => NamedArrows k where
- namedArrow :: forall (a :: k) (b :: k). (Ob a, Ob b) => String -> a ~> b
- data family Struct (c :: Kind -> Constraint) :: CAT (FREE cs p)
- type FREE_OB = SUBCAT (Typeable :: FREE_SHAPE -> Constraint)
- type FreeWire (a :: FREE cs p) = Wires '['SUB ('FO (Proxy a)) :: SUBCAT (Typeable :: FREE_SHAPE -> Constraint)] :: OPENHG (SUBCAT (Typeable :: FREE_SHAPE -> Constraint)) l
- data StructureBox (cs :: [Kind -> Constraint])
- fromFreeWith :: forall {k} {cs :: [Kind -> Constraint]} {p} l (a :: FREE cs p) (b :: FREE cs p). (Typeable k, Typeable cs, Typeable p, forall (x :: k). Ob x => Typeable x, Discrete k, All cs (FREE cs p), Show2 p, Elem NamedArrows cs) => (forall (x :: k) (y :: k). (Ob x, Ob y) => p x y -> l) -> (String -> l) -> Free a b -> (FreeWire a :: OPENHG FREE_OB (Either (StructureBox cs) l)) ~> (FreeWire b :: OPENHG FREE_OB (Either (StructureBox cs) l))
- freeLawRule :: forall (laws :: [Kind -> Constraint]) (cs :: [Kind -> Constraint]) a. (Laws laws, Typeable cs, All cs (ObjectSyntax cs), All laws (ObjectSyntax cs), Elem NamedArrows cs, Eq a) => String -> Either String (Rule FREE_OB (Either (StructureBox cs) a))
- freeLawRuleWithDirection :: forall (laws :: [Kind -> Constraint]) (cs :: [Kind -> Constraint]) a. (Laws laws, Typeable cs, All cs (ObjectSyntax cs), All laws (ObjectSyntax cs), Elem NamedArrows cs, Eq a) => String -> Direction -> Either String (Rule FREE_OB (Either (StructureBox cs) a))
- freeLawRules :: forall (laws :: [Kind -> Constraint]) (cs :: [Kind -> Constraint]) a. (Laws laws, Typeable cs, All cs (ObjectSyntax cs), All laws (ObjectSyntax cs), Elem NamedArrows cs, Eq a) => Either String [(String, Rule FREE_OB (Either (StructureBox cs) a))]
Documentation
class CategoryOf k => NamedArrows k where Source Github #
Named generators with arbitrary free-object endpoints, including compound
objects. Unlike Emb, these are not restricted to embedded base objects.
Instances
| Elem NamedArrows cs => NamedArrows (FREE cs p) Source Github # | |
data family Struct (c :: Kind -> Constraint) :: CAT (FREE cs p) Source Github #
Instances
| WithShow a => Show (Struct Monoidal a b) Source Github # | |
| Show (Struct SymMonoidal a b) Source Github # | |
Defined in Proarrow.Category.Monoidal | |
| Show (Struct Cartesian a b) Source Github # | |
| WithShow a => Show (Struct Closed a b) Source Github # | |
| Show (Struct CompactClosed a b) Source Github # | |
Defined in Proarrow.Category.Monoidal.CompactClosed | |
| WithShow a => Show (Struct Dialogue a b) Source Github # | |
| Show (Struct Distributive a b) Source Github # | |
Defined in Proarrow.Category.Monoidal.Distributive | |
| Show (Struct IsoMix a b) Source Github # | |
| WithShow a => Show (Struct StarAutonomous a b) Source Github # | |
Defined in Proarrow.Category.Monoidal.StarAutonomous | |
| WithShow a => Show (Struct HasBinaryCoproducts a b) Source Github # | |
Defined in Proarrow.Colimit.BinaryCoproduct | |
| Show (Struct HasInitialObject a b) Source Github # | |
Defined in Proarrow.Colimit.Initial | |
| WithShow a => Show (Struct HasBinaryProducts a b) Source Github # | |
Defined in Proarrow.Limit.BinaryProduct | |
| Show (Struct HasTerminalObject a b) Source Github # | |
Defined in Proarrow.Limit.Terminal | |
| Show (Struct Semicartesian a b) Source Github # | |
Defined in Proarrow.Limit.Terminal | |
| Show (Struct (Supplies Comonoid) a b) Source Github # | |
| Show (Struct (Supplies Monoid) a b) Source Github # | |
| Show (Struct NamedArrows a b) Source Github # | |
Defined in Proarrow.Tools.HypergraphRewrite.Free | |
| data Struct Monoidal (i :: FREE cs p) (o :: FREE cs p) Source Github # | |
Defined in Proarrow.Category.Monoidal data Struct Monoidal (i :: FREE cs p) (o :: FREE cs p) where
| |
| data Struct SymMonoidal (i :: FREE cs p) (o :: FREE cs p) Source Github # | |
Defined in Proarrow.Category.Monoidal | |
| data Struct Cartesian (i :: FREE cs p) (o :: FREE cs p) Source Github # | |
Defined in Proarrow.Category.Monoidal.Cartesian data Struct Cartesian (i :: FREE cs p) (o :: FREE cs p) where
| |
| data Struct Closed (a :: FREE cs p) (b :: FREE cs p) Source Github # | |
Defined in Proarrow.Category.Monoidal.Closed data Struct Closed (a :: FREE cs p) (b :: FREE cs p) where
| |
| data Struct CompactClosed (a :: FREE cs p) (b :: FREE cs p) Source Github # | |
Defined in Proarrow.Category.Monoidal.CompactClosed data Struct CompactClosed (a :: FREE cs p) (b :: FREE cs p) where
| |
| data Struct Dialogue (a :: FREE cs p) (b :: FREE cs p) Source Github # | |
Defined in Proarrow.Category.Monoidal.Dialogue data Struct Dialogue (a :: FREE cs p) (b :: FREE cs p) where
| |
| data Struct Distributive (i :: FREE cs p) (o :: FREE cs p) Source Github # | |
Defined in Proarrow.Category.Monoidal.Distributive data Struct Distributive (i :: FREE cs p) (o :: FREE cs p) where
| |
| data Struct IsoMix (a :: FREE cs p) (b :: FREE cs p) Source Github # | |
Defined in Proarrow.Category.Monoidal.IsoMix | |
| data Struct StarAutonomous (a :: FREE cs p) (b :: FREE cs p) Source Github # | |
Defined in Proarrow.Category.Monoidal.StarAutonomous | |
| data Struct HasBinaryCoproducts (i :: FREE cs p) (o :: FREE cs p) Source Github # | |
Defined in Proarrow.Colimit.BinaryCoproduct data Struct HasBinaryCoproducts (i :: FREE cs p) (o :: FREE cs p) where
| |
| data Struct HasInitialObject (a :: FREE cs p) (b :: FREE cs p) Source Github # | |
Defined in Proarrow.Colimit.Initial data Struct HasInitialObject (a :: FREE cs p) (b :: FREE cs p) where
| |
| data Struct HasBinaryProducts (i :: FREE cs p) (o :: FREE cs p) Source Github # | |
Defined in Proarrow.Limit.BinaryProduct data Struct HasBinaryProducts (i :: FREE cs p) (o :: FREE cs p) where
| |
| data Struct HasTerminalObject (a :: FREE cs p) (b :: FREE cs p) Source Github # | |
Defined in Proarrow.Limit.Terminal data Struct HasTerminalObject (a :: FREE cs p) (b :: FREE cs p) where
| |
| data Struct Semicartesian (a :: FREE cs p) (b :: FREE cs p) Source Github # | |
Defined in Proarrow.Limit.Terminal data Struct Semicartesian (a :: FREE cs p) (b :: FREE cs p) where
| |
| data Struct NamedArrows (a :: FREE cs p) (b :: FREE cs p) Source Github # | |
Defined in Proarrow.Tools.HypergraphRewrite.Free data Struct NamedArrows (a :: FREE cs p) (b :: FREE cs p) where
| |
| data Struct (Supplies Comonoid) (i :: FREE cs p) (o :: FREE cs p) Source Github # | |
| data Struct (Supplies Monoid) (i :: FREE cs p) (o :: FREE cs p) Source Github # | |
type FREE_OB = SUBCAT (Typeable :: FREE_SHAPE -> Constraint) Source Github #
Discrete sorts for reflected free objects.
type FreeWire (a :: FREE cs p) = Wires '['SUB ('FO (Proxy a)) :: SUBCAT (Typeable :: FREE_SHAPE -> Constraint)] :: OPENHG (SUBCAT (Typeable :: FREE_SHAPE -> Constraint)) l Source Github #
One wire carrying the exact source object, including its syntax category.
data StructureBox (cs :: [Kind -> Constraint]) Source Github #
A structural operation distinguished by its signature's position in cs.
Child arrows do not participate in equality; their graph connections do.
Instances
| Show (StructureBox cs) Source Github # | |
Defined in Proarrow.Tools.HypergraphRewrite.Free | |
| Eq (StructureBox cs) Source Github # | |
Defined in Proarrow.Tools.HypergraphRewrite.Free Methods (==) :: StructureBox cs -> StructureBox cs -> Bool Github # (/=) :: StructureBox cs -> StructureBox cs -> Bool Github # | |
fromFreeWith :: forall {k} {cs :: [Kind -> Constraint]} {p} l (a :: FREE cs p) (b :: FREE cs p). (Typeable k, Typeable cs, Typeable p, forall (x :: k). Ob x => Typeable x, Discrete k, All cs (FREE cs p), Show2 p, Elem NamedArrows cs) => (forall (x :: k) (y :: k). (Ob x, Ob y) => p x y -> l) -> (String -> l) -> Free a b -> (FreeWire a :: OPENHG FREE_OB (Either (StructureBox cs) l)) ~> (FreeWire b :: OPENHG FREE_OB (Either (StructureBox cs) l)) Source Github #
Compile syntax, mapping base generators and named generators to labels.
Host and rule syntax must use the same cs and p, so their reflected wire
sorts agree. Named generators can be mapped to parameters when compiling laws.
The base is discrete, and all structures must have instances on the source
free category.
freeLawRule :: forall (laws :: [Kind -> Constraint]) (cs :: [Kind -> Constraint]) a. (Laws laws, Typeable cs, All cs (ObjectSyntax cs), All laws (ObjectSyntax cs), Elem NamedArrows cs, Eq a) => String -> Either String (Rule FREE_OB (Either (StructureBox cs) a)) Source Github #
Compile a named law with object variables and whole-arrow parameters. One rule handles every instantiation of its five object variables, including compound objects. Repeated variables must have the same object shape. Named arrows capture connected subdiagrams with their own input and output, including anchored identities. Repeated names require boundary-preserving graph isomorphism; substitution does not compare diagrams modulo other laws. Complete matches contain at least one box, and identical replacements are skipped.
freeLawRuleWithDirection :: forall (laws :: [Kind -> Constraint]) (cs :: [Kind -> Constraint]) a. (Laws laws, Typeable cs, All cs (ObjectSyntax cs), All laws (ObjectSyntax cs), Elem NamedArrows cs, Eq a) => String -> Direction -> Either String (Rule FREE_OB (Either (StructureBox cs) a)) Source Github #
Like freeLawRule, with an explicit orientation. Arrow parameters on the
right must occur on the left; an unbound right-side object rejects a match.
freeLawRules :: forall (laws :: [Kind -> Constraint]) (cs :: [Kind -> Constraint]) a. (Laws laws, Typeable cs, All cs (ObjectSyntax cs), All laws (ObjectSyntax cs), Elem NamedArrows cs, Eq a) => Either String [(String, Rule FREE_OB (Either (StructureBox cs) a))] Source Github #
Compile all laws with freeLawRule's object and whole-arrow parameters,
retaining their names for a shared compileRules.
>>>import Proarrow.Limit.BinaryProduct (HasBinaryProducts)>>>type ProductStructures = '[NamedArrows, HasBinaryProducts]>>>fmap (map fst) (freeLawRules @'[HasBinaryProducts] @ProductStructures @String)Right ["fst","snd","pairing naturality","pairing the projections","pairing uniqueness"]