| Safe Haskell | None |
|---|---|
| Language | GHC2024 |
Free.Agent.Hyper
Description
The hypergraph generators for posts and agents (stage 3 of endgame-path).
A hypergraph category lets wires fork and merge. At the stream level
the generators are copyP (fork: duplicate a stream) and mergeP
(merge: append two streams); braidP swaps the two middle blocks —
the permutation whose block-versus-wire confusion was the bug this
library family grew out of. With append as merge the bialgebra law
holds for streams of posts exactly:
copyP (mergeP (xs, ys)) == merge2 (braidP (copy2 (xs, ys))) -- both sides are (xs ++ ys, xs ++ ys)
At the agent level, both is the merge of two agents — the join of
the extension semilattice, dual to sequencing: both agents see the
same input (copy), their outputs are appended (merge). This is the
combinator form of graph overlay / a two-seat roster.
Semantics on record
Merge is bag semantics: 'both a a' double-posts. Idempotence is name-keyed, not structural — seat registries dedupe by name; streams do not dedupe at all. Bag at the wire, set at the name.
Synopsis
- copyP :: [a] -> ([a], [a])
- copy2 :: ([a], [b]) -> (([a], [a]), ([b], [b]))
- mergeP :: ([a], [a]) -> [a]
- merge2 :: (([a], [a]), ([a], [a])) -> ([a], [a])
- braidP :: ((a, b), (c, d)) -> ((a, c), (b, d))
- silent :: System (->) () (Mono a [b])
- both :: System (->) s1 (Mono a [b]) -> System (->) s2 (Mono a [b]) -> System (->) (s1, s2) (Mono a [b])
Documentation
merge2 :: (([a], [a]), ([a], [a])) -> ([a], [a]) Source #
Merge two stream-pairs componentwise: each inner pair is appended.
This is mergeP ⊗ mergeP, the merge half of the bialgebra.
braidP :: ((a, b), (c, d)) -> ((a, c), (b, d)) Source #
Swap the two middle blocks: ((a,b),(c,d)) → ((a,c),(b,d)).
silent :: System (->) () (Mono a [b]) Source #
The silent agent: emits nothing. Additive zero for both.
both :: System (->) s1 (Mono a [b]) -> System (->) s2 (Mono a [b]) -> System (->) (s1, s2) (Mono a [b]) Source #
Merge two bundle-output agents: both see the same input, outputs are appended in left-then-right order. The state is the pair.
Laws (oracle-pinned): commutative up to output bag; silent is a zero
on either side; not idempotent — both a a double-posts (bag at the
wire).