Debian Codegraph @

src/Codata/Musical/M/Indexed.agda

raw
1 ------------------------------------------------------------------------
2 -- The Agda standard library
3 --
4 -- Indexed M-types (the dual of indexed W-types aka Petersson-Synek
5 -- trees).
6 ------------------------------------------------------------------------
7
8 {-# OPTIONS --cubical-compatible --safe --guardedness #-}
9
10 module Codata.Musical.M.Indexed where
11
12 open import Level using (Level; _⊔_)
13 open import Codata.Musical.Notation using (♭; ∞; ♯_)
14 open import Data.Product.Base using (_,_; proj₁; proj₂)
15 open import Data.Container.Indexed.Core
16 open import Function.Base using (_∘_)
17 open import Relation.Unary using (Pred; _⊆_)
18
19 -- The family of indexed M-types.
20
21 module _ {ℓ c r} {O : Set ℓ} (C : Container O O c r) where
22
23 data M (o : O) : Set (ℓ ⊔ c ⊔ r) where
24 inf : ⟦ C ⟧ (∞ ∘ M) o → M o
25
26 open Container C
27
28 -- Projections.
29
30 head : M ⊆ Command
31 head (inf (c , _)) = c
32
33 tail : ∀ {o} (m : M o) (r : Response (head m)) → M (next (head m) r)
34 tail (inf (_ , k)) r = ♭ (k r)
35
36 force : M ⊆ ⟦ C ⟧ M
37 force (inf (c , k)) = c , λ r → ♭ (k r)
38
39 -- Coiteration.
40
41 coit : ∀ {ℓ} {X : Pred O ℓ} → X ⊆ ⟦ C ⟧ X → X ⊆ M
42 coit ψ x = inf (proj₁ cs , λ r → ♯ coit ψ (proj₂ cs r))
43 where
44 cs = ψ x