Skip to content

Some design documentation (here: level polymorphism) #2322

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions doc/README/Design/LevelPolymorphism.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
* Level polymorphism

`⊥` in `Data.Empty` and `⊤` in `Data.Unit` are not `Level`-polymorphic as that
tends to lead to unsolved metas (see discussion at issue #312). This is understandable
as very often the level of (say) `⊤` is under-determined by its surrounding context,
leading to unsolved metas. This is frequent enough that it makes sense for the default
versions to be monomorphic (at Level 0).

But there are other cases where exactly the opposite is needed. for that purpose,
there are level-polymorphic versions in `Data.Empty.Polymorphic` and
`Data.Unit.Polymorphic` respectively.

The same issue happens in `Relation.Unary` which defines `Ø` and `U` at `Level` 0, else
a lot of unsolved metas appear (for example in `Relation.Unary.Properties`). For that
purpose, `Relation.Unary.Polymorphic` exists.
2 changes: 1 addition & 1 deletion src/Data/Empty.agda
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
------------------------------------------------------------------------
-- The Agda standard library
--
-- Empty type, judgementally proof irrelevant
-- Empty type, judgementally proof irrelevant, Level-monomorphic
------------------------------------------------------------------------

{-# OPTIONS --cubical-compatible --safe #-}
Expand Down
2 changes: 1 addition & 1 deletion src/Data/Unit.agda
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
------------------------------------------------------------------------
-- The Agda standard library
--
-- The unit type
-- The unit type, Level-monomorphic version
------------------------------------------------------------------------

{-# OPTIONS --cubical-compatible --safe #-}
Expand Down
3 changes: 3 additions & 0 deletions src/Relation/Unary.agda
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ Pred A ℓ = A → Set ℓ
-- Special sets

-- The empty set.
-- Explicitly not level polymorphic as this often causes unsolved metas;
-- see `Relation.Unary.Polymorphic` for a level-polymorphic version.

∅ : Pred A 0ℓ
∅ = λ _ → ⊥
Expand All @@ -52,6 +54,7 @@ Pred A ℓ = A → Set ℓ
{ x } = x ≡_

-- The universal set.
-- Explicitly not level polymorphic (see comments for `∅` for more details)

U : Pred A 0ℓ
U = λ _ → ⊤
Expand Down