String Diagrams for Free Monads
Maciej Pir´
- g, University of Wrocław, Poland
(joint work with Nicolas Wu, University of Bristol, UK) Institute of Cybernetics Tallinn, 8 Dec 2016
String Diagrams for Free Monads og , University of Wrocaw, Poland - - PowerPoint PPT Presentation
String Diagrams for Free Monads og , University of Wrocaw, Poland Maciej Pir (joint work with Nicolas Wu , University of Bristol, UK) Institute of Cybernetics Tallinn, 8 Dec 2016 Practical programming Abstract nonsense Practical
Maciej Pir´
(joint work with Nicolas Wu, University of Bristol, UK) Institute of Cybernetics Tallinn, 8 Dec 2016
data Free f a = Var a | Op (f (Free f a))
newtype FreeT f m a = FreeT (m (Free (f . m) a)
(From an unpublished appendix to M.Pir´
lookup k :: ∀a.List (Key, a) → Maybe a
lookup k :: ∀a.List (Key, a) → Maybe a
lookup k
concat
lookup k
concat
lookup k
concat
lookup k
concat
lookup k
concat
lookup k
concat
lookup k
concat
lookup k
lookup k . concat :: ∀a.List (Key, a) → Maybe a
concat
lookup k
lookup k . concat :: ∀a.List (List (Key, a)) → Maybe a
concat
lookup k
lookup k . concat . fmap reverse :: ∀a.List (List (Key, a)) → Maybe a
lookup k concat reverse
data Free f a = Var a | Op (f (Free f a))
class FreeMonad f a where ???
emb :: ∀a.f a → Free f a
interp :: (Functor f, Monad m) ⇒ (∀x.f x -> m x) -> Free f a → m a
⌊f⌋ : F∗ → M
F M
interp f . emb = f ⌊f⌋ · emb = f
F∗ F
interp emb = id ⌊emb⌋ = id
F
m . interp f = interp (m . f)
F M
F M
⌊emb · f⌋
F G
⌊emb · g⌋ · ⌊emb · f⌋ = ⌊emb · g · f⌋
F G G∗ G H
F G H
F∗ H∗
F G G∗ G H
f g
F∗ H∗
F G G∗ G H
f g
(fusion)
F∗ H∗
F G G∗ G H
f g
F∗ H∗
F G G∗ G H
f g
(fusion)
F∗ H∗
F G G∗ G H
f g
(cancellation)
F∗ H∗
F G H
f g
f : F∗ ◦ G → G ◦ F∗
F F
f · emb = G emb · f
F F∗ F
F
id = id
F
F F F F
F G F
K F F J
K F F J
(From an unpublished appendix to M.Pir´
µ δ η
(unit)
µ δ µ η η
(uniformity)
µ δ µ η η
(associativity)
δ δ µ η η
(fusion)
δ δ µ η η