Skip to content

Commit f021299

Browse files
committed
added Everything.agda, cleaned examples
1 parent f213051 commit f021299

File tree

6 files changed

+97
-209
lines changed

6 files changed

+97
-209
lines changed

Everything.agda

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
module Everything where
2+
3+
import Generics.Prelude
4+
import Generics.Telescope
5+
import Generics.Telescope.Equality
6+
import Generics.Desc
7+
import Generics.All
8+
import Generics.HasDesc
9+
import Generics.Accessibility
10+
import Generics.Helpers
11+
import Generics.Reflection
12+
13+
import Generics.Mu
14+
import Generics.Mu.All
15+
import Generics.Mu.Elim
16+
import Generics.Mu.Fold
17+
import Generics.Mu.Conversion
18+
19+
import Generics.Constructions.Case
20+
import Generics.Constructions.Cong
21+
import Generics.Constructions.DecEq
22+
import Generics.Constructions.Elim
23+
import Generics.Constructions.Fold
24+
import Generics.Constructions.Mu
25+
import Generics.Constructions.Recursion
26+
import Generics.Constructions.Show
27+
28+
import Generics
29+
30+
-- Work In Progress
31+
---------------------------------
32+
33+
-- import Generics.Mu.NoConfusion
34+
-- import Generics.Constructions.Injective

examples/Elim.agda

-78
This file was deleted.

examples/Parametrized.agda

+45-50
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,22 @@
11
{-# OPTIONS --safe #-}
2-
open import Generics.Prelude hiding (lookup; _≟_)
3-
open import Generics.HasDesc
4-
open import Generics.Desc
5-
open import Generics.Telescope
6-
open import Generics.Reflection
7-
8-
open import Generics.Constructions.Show as Show
9-
open import Generics.Constructions.Case
10-
open import Generics.Constructions.Elim
11-
open import Generics.Constructions.Fold
12-
open import Generics.Constructions.Cong
13-
open import Generics.Helpers
14-
-- open import Generics.Constructions.DecEq
2+
3+
module Parametrized where
4+
5+
open import Generics
6+
7+
open import Agda.Primitive
8+
open import Function.Base
9+
open import Data.Nat.Base hiding (pred)
10+
open import Data.Fin.Base hiding (pred; _+_)
11+
open import Data.List.Base hiding (sum; length)
1512

1613
open import Relation.Nullary
1714
open import Relation.Nullary.Decidable as Decidable
1815
open import Relation.Binary.HeterogeneousEquality.Core using (_≅_; refl)
16+
open import Relation.Binary.PropositionalEquality
1917

2018
open import Data.String hiding (show; _≟_; length)
2119
open import Data.Maybe.Base
22-
open import Data.Nat.Base using (_*_)
23-
24-
25-
module Parametrized where
26-
27-
open Show.Show ⦃...⦄
2820

2921

3022
module Nat where
@@ -36,11 +28,13 @@ module Nat where
3628
---------------------------
3729
-- Deriving the eliminator
3830

31+
elimℕ = deriveElim natD
32+
3933
plus :
40-
plus n = elim (const ℕ) n (const suc)
34+
plus n = elimℕ (const ℕ) n suc
4135

4236
mult :
43-
mult n = elim (const ℕ) 0 (const (plus n))
37+
mult n = elimℕ (const ℕ) 0 (plus n)
4438

4539
-- things defined with the eliminator reduce properly on open terms
4640

@@ -93,23 +87,23 @@ module Nat where
9387
congℕ = deriveCong natD
9488

9589
ze≅ze : 00
96-
ze≅ze = congℕ Fin.zero
90+
ze≅ze = congℕ zero
9791

9892
su≅su : {n m} n ≅ m suc n ≅ suc m
9993
su≅su = congℕ (suc zero)
10094

101-
10295
-------------------------------
10396
-- Deriving decidable equality
10497

105-
-- instance decℕ : DecEq ℕ
106-
-- decℕ = deriveDecEq natD
98+
instance decℕ : DecEq ℕ
99+
decℕ = deriveDecEq natD
107100

108-
-- _ : 33 ≡ yes refl
109-
-- _ = refl
101+
_ : 33 ≡ yes refl
102+
_ = refl
103+
104+
_ : 32 ≡ no _
105+
_ = refl
110106

111-
-- _ : 32 ≡ no _
112-
-- _ = refl
113107

114108
module ListDemo where
115109

@@ -134,39 +128,40 @@ module ListDemo where
134128
mul : list ℕ
135129
mul = foldList 1 _*_
136130

137-
module Vek where
131+
132+
module Vec where
138133
private variable A : Set
139134
n :
140135

141-
data Vek (A : Set) : Set where
142-
nil : Vek A 0
143-
cons : {n} A Vek A n Vek A (suc n)
136+
data Vec (A : Set) : Set where
137+
nil : Vec A 0
138+
cons : {n} A Vec A n Vec A (suc n)
144139

145140
instance
146-
vekD : HasDesc Vek
147-
vekD = deriveDesc Vek
141+
vekD : HasDesc Vec
142+
vekD = deriveDesc Vec
148143

149144
---------------------------
150145
-- Deriving the eliminator
151146

152-
elimVek = deriveElim vekD
147+
elimVec = deriveElim vekD
153148

154-
length : Vek A n
155-
length = elimVek (const ℕ) 0 (λ x xs n suc n)
149+
length : Vec A n
150+
length = elimVec (const ℕ) 0 (const suc)
156151

157-
length0 : length (nil {A = A}) ≡ 0
152+
length0 : length (nil {A}) ≡ 0
158153
length0 = refl
159154

160-
lengthP : (x : Vek A n) length x ≡ n
161-
lengthP = elimVek (λ {n} x length x ≡ n) refl λ x xs Pxs cong suc Pxs
155+
lengthP : (x : Vec A n) length x ≡ n
156+
lengthP = elimVec (λ {n} x length x ≡ n) refl (const (cong suc))
162157

163158
---------------------------
164159
-- Deriving fold
165160

166-
foldVek = deriveFold vekD
161+
foldVec = deriveFold vekD
167162

168-
vekToList : {A n} Vek A n List A
169-
vekToList = foldVek [] _∷_
163+
vekToList : {A n} Vec A n List A
164+
vekToList = foldVec [] _∷_
170165

171166
-----------------------
172167
-- Deriving congruence
@@ -176,7 +171,7 @@ module Vek where
176171
[]≅[] : {A} nil {A} ≅ nil {A}
177172
[]≅[] = congV zero
178173

179-
cong-cons : {A n} {x y : A} x ≅ y {xs ys : Vek A n} xs ≅ ys
174+
cong-cons : {A n} {x y : A} x ≅ y {xs ys : Vec A n} xs ≅ ys
180175
cons x xs ≅ cons y ys
181176
cong-cons = congV (suc zero) refl
182177

@@ -196,14 +191,15 @@ module WType where
196191
-- Deriving the eliminator
197192

198193
elimW : (Pr : W A B Set c)
199-
( x g ( y Pr (g y)) Pr (node x g) )
194+
( x {g} ( y Pr (g y)) Pr (node x g) )
200195
x Pr x
201196
elimW = deriveElim wD
202197

203198
elimW-node
204199
: {Pr : W A B Set c}
205-
(M : x g ( y Pr (g y)) Pr (node x g) )
206-
{x g} elimW Pr M (node x g) ≡ M x g (λ y elimW Pr M (g y))
200+
(M : x {g} ( y Pr (g y)) Pr (node x g) )
201+
{x g}
202+
elimW Pr M (node x g) ≡ M x (λ y elimW Pr M (g y))
207203
elimW-node M = refl
208204

209205

@@ -230,6 +226,5 @@ module Irrelevance where
230226
instance showSquash : {A} Show (Squash A)
231227
showSquash = deriveShow squashD
232228

233-
-- Indeed, we use the argument name when printing irrelevant args
234-
_ : show (squash 3) ≡ "squash (.x)"
229+
_ : show (squash 3) ≡ "squash (._)"
235230
_ = refl

examples/Playground.agda

-81
This file was deleted.

src/Generics.agda

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{-# OPTIONS --safe #-}
2+
module Generics where
3+
4+
open import Data.Unit public using (⊤; tt)
5+
open import Generics.Prelude public using (liftω; liftω-inst)
6+
open import Generics.HasDesc public using (HasDesc)
7+
open import Generics.Reflection public using (deriveDesc)
8+
open import Generics.Helpers public
9+
10+
open import Generics.Constructions.Case public using (deriveCase)
11+
open import Generics.Constructions.Cong public using (deriveCong)
12+
open import Generics.Constructions.DecEq public using (DecEq; _≟_; deriveDecEq)
13+
open import Generics.Constructions.Elim public using (deriveElim)
14+
open import Generics.Constructions.Fold public using (deriveFold)
15+
open import Generics.Constructions.Recursion public using (rec; Below)
16+
open import Generics.Constructions.Show public using (Show; show; deriveShow)

0 commit comments

Comments
 (0)