Skip to content

Commit 21f6e7d

Browse files
authored
Moved _⇒_ and ∀[_] from Size to Relation.Unary.Sized
1 parent da286d0 commit 21f6e7d

File tree

4 files changed

+58
-35
lines changed

4 files changed

+58
-35
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,15 @@ New modules
7070
* Added `Reflection.Annotated.Free` implementing free variable annotations for
7171
reflected terms.
7272

73+
* Added `Relation.Unary.Sized` for unary relations over sized types now that `Size` lives in it's own universe since Agda 2.6.2.
74+
7375
Other major changes
7476
-------------------
7577

7678
Other minor additions
7779
---------------------
80+
81+
* Added new type in `Size`:
82+
```agda
83+
SizedSet ℓ = Size → Set ℓ
84+
```

src/Codata/Thunk.agda

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,30 @@
88

99
module Codata.Thunk where
1010

11-
open import Size; open SizedType
11+
open import Size
12+
open import Relation.Unary.Sized
1213

1314
------------------------------------------------------------------------
1415
-- Basic types.
1516

16-
record Thunk {ℓ} (F : Size Set ℓ) (i : Size) : Setwhere
17+
record Thunk {ℓ} (F : SizedSet ℓ) (i : Size) : Setwhere
1718
coinductive
1819
field force : {j : Size< i} F j
1920
open Thunk public
2021

21-
Thunk^P : {f p} {F : Size Set f} (P : Size F ∞ Set p)
22+
Thunk^P : {f p} {F : SizedSet f} (P : Size F ∞ Set p)
2223
(i : Size) (tf : Thunk F ∞) Set p
2324
Thunk^P P i tf = Thunk (λ i P i (tf .force)) i
2425

25-
Thunk^R : {f g r} {F : Size Set f} {G : Size Set g}
26+
Thunk^R : {f g r} {F : SizedSet f} {G : SizedSet g}
2627
(R : Size F ∞ G ∞ Set r)
2728
(i : Size) (tf : Thunk F ∞) (tg : Thunk G ∞) Set r
2829
Thunk^R R i tf tg = Thunk (λ i R i (tf .force) (tg .force)) i
2930

3031
------------------------------------------------------------------------
3132
-- Syntax
3233

33-
Thunk-syntax : {ℓ} (Size Set ℓ) Size Set
34+
Thunk-syntax : {ℓ} SizedSet ℓ Size Set
3435
Thunk-syntax = Thunk
3536

3637
syntax Thunk-syntax (λ j e) i = Thunk[ j < i ] e
@@ -39,28 +40,28 @@ syntax Thunk-syntax (λ j → e) i = Thunk[ j < i ] e
3940
-- Basic functions.
4041

4142
-- Thunk is a functor
42-
module _ {p q} {P : Size Set p} {Q : Size Set q} where
43+
module _ {p q} {P : SizedSet p} {Q : SizedSet q} where
4344

4445
map : ∀[ P ⇒ Q ] ∀[ Thunk P ⇒ Thunk Q ]
4546
map f p .force = f (p .force)
4647

4748
-- Thunk is a comonad
48-
module _ {p} {P : Size Set p} where
49+
module _ {p} {P : SizedSet p} where
4950

5051
extract : ∀[ Thunk P ] P ∞
5152
extract p = p .force
5253

5354
duplicate : ∀[ Thunk P ⇒ Thunk (Thunk P) ]
5455
duplicate p .force .force = p .force
5556

56-
module _ {p q} {P : Size Set p} {Q : Size Set q} where
57+
module _ {p q} {P : SizedSet p} {Q : SizedSet q} where
5758

5859
infixl 1 _<*>_
5960
_<*>_ : ∀[ Thunk (P ⇒ Q) ⇒ Thunk P ⇒ Thunk Q ]
6061
(f <*> p) .force = f .force (p .force)
6162

6263
-- We can take cofixpoints of functions only making Thunk'd recursive calls
63-
module _ {p} (P : Size Set p) where
64+
module _ {p} (P : SizedSet p) where
6465

6566
cofix : ∀[ Thunk P ⇒ P ] ∀[ P ]
6667
cofix f = f λ where .force cofix f

src/Relation/Unary/Sized.agda

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
------------------------------------------------------------------------
2+
-- The Agda standard library
3+
--
4+
-- Indexed unary relations over sized types
5+
------------------------------------------------------------------------
6+
7+
-- Sized types live in the special sort `SizeUniv` and therefore are no
8+
-- longer compatible with the ordinary combinators defined in
9+
-- `Relation.Unary`.
10+
11+
{-# OPTIONS --without-K --safe --sized-types #-}
12+
13+
module Relation.Unary.Sized where
14+
15+
open import Level
16+
open import Size
17+
18+
private
19+
variable
20+
ℓ ℓ₁ ℓ₂ : Level
21+
22+
infixr 8 _⇒_
23+
_⇒_ : SizedSet ℓ₁ SizedSet ℓ₂ SizedSet (ℓ₁ ⊔ ℓ₂)
24+
F ⇒ G = λ i F i G i
25+
26+
∀[_] : SizedSet ℓ Set
27+
∀[ F ] = {i} F i

src/Size.agda

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,34 +8,22 @@
88

99
module Size where
1010

11-
open import Agda.Builtin.Size public
12-
using ( SizeUniv -- sort SizeUniv
13-
; Size -- Size : SizeUniv
14-
; Size<_ -- Size<_ : Size → SizeUniv
15-
; ↑_ -- ↑_ : Size → Size
16-
; _⊔ˢ_ -- _⊔ˢ_ : Size → Size → Size
17-
; ∞ -- ∞ : Size
18-
)
19-
2011
open import Level
2112

22-
private
23-
variable
24-
ℓ ℓ₁ ℓ₂ : Level
25-
26-
-- Concept of sized type
27-
28-
SizedType : (ℓ : Level) Set (suc ℓ)
29-
SizedType ℓ = Size Set
30-
31-
-- Type constructors involving SizedType
32-
33-
module SizedType where
13+
------------------------------------------------------------------------
14+
-- Re-export builtins
3415

35-
infixr 8 _⇒_
16+
open import Agda.Builtin.Size public using
17+
( SizeUniv -- sort SizeUniv
18+
; Size -- : SizeUniv
19+
; Size<_ -- : Size → SizeUniv
20+
; ↑_ -- : Size → Size
21+
; _⊔ˢ_ -- : Size → Size → Size
22+
; ∞ -- : Size
23+
)
3624

37-
_⇒_ : SizedType ℓ₁ SizedType ℓ₂ SizedType (ℓ₁ ⊔ ℓ₂)
38-
F ⇒ G = λ i F i G i
25+
------------------------------------------------------------------------
26+
-- Concept of sized type
3927

40-
∀[_] : SizedType ℓ Set
41-
∀[ F ] = {i} F i
28+
SizedSet : (ℓ : Level) Set (suc ℓ)
29+
SizedSet ℓ = Size Set

0 commit comments

Comments
 (0)