Skip to content

Commit 49a343b

Browse files
committed
[ admin ] port to 2.5.4.2 and v0.17
1 parent 12cd287 commit 49a343b

20 files changed

Lines changed: 97 additions & 90 deletions

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ A Scope-and-Type Safe Universe of Syntaxes with Binding, Their Semantics and Pro
66
[![Travis Status](https://api.travis-ci.org/gallais/generic-syntax.svg?branch=master)](https://travis-ci.org/gallais/generic-syntax)
77

88
To check this development, you'll need:
9-
* Agda 2.5.4
10-
* Agda's Standard Library 0.16
9+
* Agda 2.5.4.2
10+
* Agda's Standard Library 0.17

src/Generic/AltSyntax.agda

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,18 @@ module Generic.AltSyntax where
22

33
open import Level
44
open import Size
5+
open import Category.Monad
6+
57
open import Data.Bool
68
open import Data.List.All
79
open import Data.List.All.Properties
810
open import Data.List.Base as L hiding ([_])
9-
open import Data.Product as P hiding (,_)
11+
open import Data.Maybe.Base hiding (All)
12+
import Data.Maybe.Categorical as MC
13+
open import Data.Product
14+
open import Data.String
15+
open import Data.String.Unsafe as String using (_≟_)
16+
1017
open import Function hiding (case_of_)
1118
open import Function.Equality
1219
open import Function.Inverse
@@ -39,8 +46,6 @@ module ToPHOAS {I : Set} {V : I → Set} where
3946
binders [] i kr = kr
4047
binders Δ@(_ ∷ _) i kr = λ vs kr (base vl^Var) ((λ v v) E.<$> vs)
4148

42-
open import Data.String as String
43-
4449
Names : {I : Set} (I Set) List I I ─Scoped
4550
Names T [] j Γ = T j
4651
Names T Δ j Γ = All (κ String) Δ × T j
@@ -49,12 +54,9 @@ data Raw {I : Set} (d : Desc I) : Size → I → Set where
4954
`var : {s σ} String Raw d (↑ s) σ
5055
`con : {s σ} ⟦ d ⟧ (Names (Raw d s)) σ [] Raw d (↑ s) σ
5156

52-
open import Data.Maybe hiding (All)
53-
open import Category.Monad
54-
5557
module ScopeCheck {I : Set} {d : Desc I} (I-dec : (i j : I) Dec (i ≡ j)) where
5658

57-
open RawMonad (monad {zero})
59+
open RawMonad (MC.monad {zero})
5860

5961
varCheck : String σ Γ All (κ String) Γ Maybe (Var σ Γ)
6062
varCheck str σ [] [] = nothing

src/Generic/Examples/ElaborationType.agda

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
module Generic.Examples.ElaborationType where
22

3+
import Level
34
open import Size
45
open import Function
6+
import Category.Monad as CM
57
open import Data.Bool
6-
open import Data.Product as P hiding (,_)
8+
open import Data.Product as Prod
79
open import Data.List hiding ([_] ; lookup)
810
open import Data.List.All as All hiding (lookup)
911
open import Data.Maybe as Maybe hiding (All)
12+
import Data.Maybe.Categorical as MC
1013

1114

1215
open import indexed
@@ -15,9 +18,7 @@ open import environment hiding (_<$>_)
1518
open import Generic.Syntax
1619
open import Generic.Semantics
1720

18-
import Category.Monad as CM
19-
import Level
20-
module M = CM.RawMonad (Maybe.monad {Level.zero})
21+
module M = CM.RawMonad (MC.monad {Level.zero})
2122
open M
2223

2324
open import Relation.Binary.PropositionalEquality hiding ([_])

src/Generic/Examples/SystemF.agda

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
module Generic.Examples.SystemF where
22

3+
import Level
34
open import Size
5+
import Category.Monad as CM
6+
7+
open import Codata.Thunk
8+
open import Codata.Colist
9+
410
open import Data.Unit
511
open import Data.Bool
612
open import Data.Product
7-
open import Data.List.Base hiding ([_] ; lookup)
13+
open import Data.List.Base hiding ([_]; lookup)
14+
open import Data.Maybe.Base using (Maybe; just; nothing)
15+
import Data.Maybe.Categorical as MC
816
open import Function
917
open import Relation.Binary.PropositionalEquality hiding ([_])
1018

@@ -16,6 +24,9 @@ open import Generic.Syntax
1624
open import Generic.Semantics
1725
open import Generic.Semantics.Syntactic
1826

27+
--------------------------------------------------------------------------------
28+
-- Syntax
29+
1930
data Kind : Set where
2031
Term Type : Kind
2132

@@ -39,6 +50,13 @@ pattern Lam b = `con (false , false , false , false , false , b , refl)
3950
SF : Kind List Kind Set
4051
SF = Tm system-F ∞
4152

53+
`id : SF Term []
54+
`id = Lam (lam (`var z))
55+
56+
--------------------------------------------------------------------------------
57+
-- Small step evaluator
58+
59+
-- Path to a redex
4260
data Redex: List Kind} : SF Term Γ Set where
4361
applam : (b : SF Term (Term ∷ Γ)) (u : SF Term Γ) Redex (app (lam b) u)
4462
AppLam : (b : SF Term (Type ∷ Γ)) (u : SF Type Γ) Redex (App (Lam b) u)
@@ -49,11 +67,9 @@ data Redex {Γ : List Kind} : SF Term Γ → Set where
4967
[App] : {f : SF Term Γ} Redex f (t : SF Type Γ) Redex (App f t)
5068
[Lam] : {b : SF Term (Type ∷ Γ)} Redex b Redex (Lam b)
5169

52-
open import Category.Monad
53-
open import Data.Maybe
54-
import Level
55-
open RawMonadPlus (monadPlus {Level.zero})
70+
open CM.RawMonadPlus (MC.monadPlus {Level.zero})
5671

72+
-- Finding the leftmost redex
5773
redex :: List Kind} (t : SF Term Γ) Maybe (Redex t)
5874
redex (app (lam b) u) = just (applam b u)
5975
redex (App (Lam b) u) = just (AppLam b u)
@@ -63,6 +79,7 @@ redex (App f t) = flip [App] t <$> redex f
6379
redex (Lam b) = [Lam] <$> redex b
6480
redex _ = nothing
6581

82+
-- Reducing a redex
6683
fire :: List Kind} {t : SF Term Γ} Redex t SF Term Γ
6784
fire (applam b u) = sub (base vl^Tm ∙ u) b
6885
fire (AppLam b u) = sub (base vl^Tm ∙ u) b
@@ -72,17 +89,8 @@ fire ([lam] b) = lam (fire b)
7289
fire ([App] f t) = App (fire f) t
7390
fire ([Lam] b) = Lam (fire b)
7491

75-
open import Coinduction
76-
open import Data.Colist
77-
78-
eval :: List Kind) (t : SF Term Γ) Colist (SF Term Γ)
92+
-- Evaluation as repeated evaluation of the leftmost redex
93+
eval : {i} (Γ : List Kind) (t : SF Term Γ) Colist (SF Term Γ) i
7994
eval Γ t with redex t
80-
... | just r = t ∷ ♯ eval Γ (fire r)
81-
... | nothing = t ∷ ♯ []
82-
83-
`id : SF Term []
84-
`id = Lam (lam (`var z))
85-
86-
_ : eval [] (lam (lam (app (lam (app (`var z) (`var z))) (lam (`var z)))))
87-
≈ (_ ∷ ♯ (_ ∷ ♯ (lam (lam (lam (`var z))) ∷ ♯ [])))
88-
_ = _ ∷ ♯ (_ ∷ ♯ (_ ∷ ♯ []))
95+
... | just r = t ∷ λ where .force eval Γ (fire r)
96+
... | nothing = t ∷ λ where .force []

src/Generic/Fusion/Specialised/Propositional.agda

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ open import Generic.Identity
2525
open import Size
2626
open import Function
2727
open import Data.Sum
28-
open import Data.Product hiding (,_)
28+
open import Data.Product
2929
open import Data.List.Base hiding (lookup)
3030
open import Relation.Binary.PropositionalEquality hiding ([_])
3131
open ≡-Reasoning

src/Generic/Fusion/Specialised/Replication.agda

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ open import Generic.Identity
3131
open import Size
3232
open import Function
3333
open import Data.Sum
34-
open import Data.Product hiding (,_)
34+
open import Data.Product
3535
open import Data.List.Base hiding (lookup)
3636
open import Relation.Binary.PropositionalEquality hiding ([_])
3737
open ≡-Reasoning

src/Generic/Identity.agda

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ module _ {I : Set} {d : Desc I} where
5151
≅⇒≡ (`var eq) = cong `var eq
5252
≅⇒≡ (`con eq) = cong `con (⟨ d ⟩≅⇒≡ eq)
5353

54-
⟨ `σ A d ⟩≅⇒≡ (refl , eq) = cong ,_ (⟨ d _ ⟩≅⇒≡ eq)
54+
⟨ `σ A d ⟩≅⇒≡ (refl , eq) = cong -,_ (⟨ d _ ⟩≅⇒≡ eq)
5555
⟨ `X Δ j d ⟩≅⇒≡ (≅-pr , eq) = cong₂ _,_ (≅⇒≡ ≅-pr) (⟨ d ⟩≅⇒≡ eq)
56-
⟨ `∎ i ⟩≅⇒≡ eq = proof-irrelevance _ _
56+
⟨ `∎ i ⟩≅⇒≡ eq = -irrelevance _ _
5757

5858
-- We can now prove a lemma stating that t[id] ≅ t and we will obtain t[id] ≡ t as
5959
-- a corrolary.

src/Generic/Semantics/NbyE.agda

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
module Generic.Semantics.NbyE where
22

3+
import Level
34
open import Size
5+
import Category.Monad as CM
46
open import Data.Unit
57
open import Data.Bool
6-
open import Data.Product hiding (,_)
8+
open import Data.Product
79
open import Data.List.Base hiding ([_])
10+
open import Data.Maybe.Base
11+
open import Data.Maybe.Categorical as MC
812
open import Function
913
open import Relation.Binary.PropositionalEquality hiding ([_])
1014

@@ -32,11 +36,7 @@ module _ {I : Set} {d : Desc I} where
3236
vl^Dm : {s : Size} VarLike (Dm d s)
3337
vl^Dm = record { new = V z ; th^𝓥 = th^Dm }
3438

35-
36-
open import Data.Maybe as Maybe
37-
import Category.Monad as CM
38-
import Level
39-
module M = CM.RawMonad (Maybe.monad {Level.zero})
39+
module M = CM.RawMonad (MC.monad {Level.zero})
4040
open M
4141

4242
module _ {I : Set} {d : Desc I} where
@@ -48,7 +48,7 @@ module _ {I : Set} {d : Desc I} where
4848
norm alg = reify^Dm ∘ Sem.sem (nbe alg) (base vl^Dm)
4949

5050
reify^Dm (V k) = just (`var k)
51-
reify^Dm (C v) = `con M.<$> traverse (CM.RawMonad.rawIApplicative Maybe.monad) d
51+
reify^Dm (C v) = `con M.<$> traverse (CM.RawMonad.rawIApplicative MC.monad) d
5252
(fmap d (λ Θ i reify^Dm ∘ reify vl^Dm Θ i) v)
5353
reify^Dm ⊥ = nothing
5454

src/Generic/Semantics/Printing.agda

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,26 @@
11
module Generic.Semantics.Printing where
22

3-
open import Coinduction
3+
open import Codata.Thunk
4+
open import Codata.Stream as Stream using (Stream; _∷_)
5+
46
open import Data.Unit
57
open import Data.Bool
68
open import Data.Product
79
open import Data.Nat.Base
810
open import Data.Nat.Show as Nat
9-
open import Data.List.Base as L hiding ([_] ; _++_ ; lookup)
11+
open import Data.List.Base using (List; []; _∷_)
12+
open import Data.List.NonEmpty as List⁺ using (List⁺; _∷_)
1013
open import Data.Char
1114
open import Data.String using (String ; _++_ ; fromList ; toList)
12-
open import Data.Stream as Str hiding (_++_ ; lookup)
1315
open import Category.Monad
1416
open import Category.Monad.State
1517
open import Function
1618

1719

1820
-- The Printing Monad we are working with: a state containing a stream
1921
-- of *distinct* Strings.
20-
open module ST = RawMonadState (StateMonadState (Stream String))
21-
M = State (Stream String)
22+
open module ST = RawMonadState (StateMonadState (Stream String _))
23+
M = State (Stream String _)
2224

2325
open import var hiding (get)
2426
open import environment as E
@@ -45,15 +47,15 @@ module _ {I : Set} where
4547
module _ {I : Set} where
4648

4749
fresh : {i : I} {Γ : List I} M (Name i Γ)
48-
fresh = get >>= λ nms
49-
put (tail nms) >>= λ _
50-
return $ mkN $ head nms
50+
fresh = get >>= λ nms
51+
put (Stream.tail nms) >>= λ _
52+
return $ mkN $ Stream.head nms
5153

5254
-- Names are varlike in the monad M: we use the state to generate fresh
5355
-- ones. Closure under thinning is a matter of wrapping / unwrapping the
5456
-- name.
5557

56-
vl^StName : VarLike (λ i Γ State (Stream String) (Name i Γ))
58+
vl^StName : VarLike (λ i Γ M (Name i Γ))
5759
new vl^StName = fresh
5860
th^𝓥 vl^StName = λ st _ mkN ∘ getN ST.<$> st
5961

@@ -104,23 +106,16 @@ module _ {I : Set} {d : Desc I} where
104106
print : Display d {i : I} TM d i String
105107
print dis t = proj₁ $ getP (Sem.closed (printing dis) t) names where
106108

107-
flatten : {A : Set} Stream (A × List A) Stream A
108-
flatten ((a , as) Str.∷ aass) = go a as (♭ aass) where
109-
go : {A : Set} A List A Stream (A × List A) Stream A
110-
go a [] aass = a ∷ ♯ flatten aass
111-
go a (b ∷ as) aass = a ∷ ♯ go b as aass
112-
113-
names : Stream String
114-
names = flatten $ Str.zipWith cons letters
115-
$ "" ∷ ♯ Str.map Nat.show (allNatsFrom 0)
116-
where
117-
118-
cons : (Char × List Char) String (String × List String)
119-
cons (c , cs) suffix = appendSuffix c , L.map appendSuffix cs where
120-
appendSuffix : Char String
121-
appendSuffix c = fromList (c ∷ []) ++ suffix
109+
alphabetWithSuffix : String List⁺ String
110+
alphabetWithSuffix suffix = List⁺.map (λ c fromList (c ∷ []) ++ suffix)
111+
$′ 'a' ∷ toList "bcdefghijklmnopqrstuvwxyz"
122112

123-
letters = Str.repeat $ 'a' , toList "bcdefghijklmnopqrstuvwxyz"
113+
allNats : Stream ℕ _
114+
allNats = cofix (λ i Stream ℕ i) step 0 where
115+
step : {i} Thunk _ i Stream ℕ i
116+
step rec k = k ∷ λ where .force rec .force (suc k)
124117

125-
allNatsFrom : Stream ℕ
126-
allNatsFrom k = k ∷ ♯ allNatsFrom (1 + k)
118+
names : Stream String _
119+
names = Stream.concat
120+
$′ Stream.map alphabetWithSuffix
121+
$′ ""λ where .force Stream.map Nat.show allNats

src/Generic/Semantics/TypeChecking.agda

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
module Generic.Semantics.TypeChecking where
22

3+
import Level
4+
import Category.Monad as CM
35
open import Data.Unit
46
open import Data.Bool
5-
open import Data.Product as P hiding (,_)
7+
open import Data.Product
68
open import Data.List hiding ([_])
7-
open import Data.Maybe as Maybe hiding (All)
9+
open import Data.Maybe.Base
10+
open import Data.Maybe.Categorical as MC
811
open import Function
912

1013
open import indexed
@@ -15,9 +18,7 @@ open import Generic.Semantics
1518

1619
open import Generic.Syntax.Bidirectional
1720

18-
import Category.Monad as CM
19-
import Level
20-
module M = CM.RawMonad (Maybe.monad {Level.zero})
21+
module M = CM.RawMonad (MC.monad {Level.zero})
2122
open M
2223

2324
open import Relation.Binary.PropositionalEquality hiding ([_])

0 commit comments

Comments
 (0)