SLIDE 16 16
31
Reusable Monadic S emant ics of P rogramming Languages - J . E. Labra
Bicatamorphisms
- Several syntactic mutually revursive categories
(motivating example: expressions and commands)
- Requires: n-sorted algebras (in this presentation, we take n=2)
BiFunctor F
bimapF : (a ? c) ? (b ? d) ? (F a b ? F c d)
Fixed-point of two bifunctors ? 1FG ? I n1 (F ? 1FG ? 2FG)
? 2FG ? I n
2 (G ? 1FG ? 2FG)
Sum of bifunctors ( F ¢ G) a b ? F a b || G a b S e c ? Seq c c A e c ? Name := e W e c ? While e c I e c ? I F e c c
Commands BiFunct or C = S ¢ A ¢ W ¢ I
F1
2
F2
2a b ? F b
From functor to bifunctor a b ? F a
L I mp ? ? 2 EC Imperative Language Expr essions BiFunct or
E ? (T ? P ? V)1
2
Generic Programming
32
Reusable Monadic S emant ics of P rogramming Languages - J . E. Labra
Bicatamorphisms
F ? 1FG ? 2FG ? 1 FG I n1 F a b a ? 1 ? ? 1,? 2?
1
bimapF ? ? 1,? 2?
1
G ? 1 FG ? 2 FG ? 2 FG I n2 G a b b ? 2 ? ? 1,? 2?
2
bimapG ? ? 1,? 2?
2
bicatamorphism
FG-bialgebra
? ?1:F a b ? a, ? 2 : G a b ? b ?
Inicial FG-bialgebra:
?I n1: F ? 1FG ? 2FG? ? 1 FG, I n2: G ? 1FG ? 2FG ? ? 2 FG ? ? ? 1,? 2?
1 : (F a b ?
a) ? (G a b ? b) ? ? 1FG ? a ? ? 1,? 2?
2 : (F a b ?
a) ? (G a b ? b) ? ? 2FG ? b
FG-bialgebras over the sum of bifunctors
¢ 1
: (F a b ?
a)? (G a b ? a)? (F ¢ G) a b ? a ¢ 2 :(F a b ? b)? (G a b ? b)? (F ¢ G) a b ? b
From algebras to bialgebras
? 1
2 : (F a ?
a) ? ( F1
2 a b ?
a )
: (F a ?
a) ? ( a b ? a ) ? 2
2
F2
2
Auxiliary Functions
Generic Programming