Skip to content
Open
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
1 change: 1 addition & 0 deletions doc/standard-library-doc.agda-lib
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ name: standard-library-doc
include: . ../src
flags:
--warning=noUnsupportedIndexedMatch
--prop
18 changes: 13 additions & 5 deletions src/Data/Empty.agda
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,31 @@ open import Data.Irrelevant using (Irrelevant)
-- universe polymorphic variant.

private
data Empty : Set where
data Empty : Prop where

-- ⊥ is defined via Data.Irrelevant (a record with a single irrelevant
-- field) so that Agda can judgementally declare that all proofs of ⊥
-- are equal to each other. In particular this means that all functions
-- returning a proof of ⊥ are equal.

⊥ : Set
⊥ = Irrelevant Empty
record ⊥ : Set where
constructor [_]
field
empty : Empty
open ⊥ public

{-# DISPLAY Irrelevant Empty = ⊥ #-}

------------------------------------------------------------------------
-- Functions

private
empty-elim : ∀ {w} {Whatever : Set w} → .Empty → Whatever
empty-elim ()

⊥-elim : ∀ {w} {Whatever : Set w} → ⊥ → Whatever
⊥-elim ()
⊥-elim x = empty-elim (empty x)

⊥-elim-irr : ∀ {w} {Whatever : Set w} → .⊥ → Whatever
⊥-elim-irr ()
⊥-elim-irr x = empty-elim (empty x)

14 changes: 8 additions & 6 deletions src/Data/Irrelevant.agda
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
module Data.Irrelevant where

open import Level using (Level)
open import Data.Squash as Squash using (Squash; squash)

private
variable
Expand All @@ -27,25 +28,26 @@ private

record Irrelevant (A : Set a) : Set a where
constructor [_]
field .irrelevant : A
field
irrelevant : Squash A
open Irrelevant public

------------------------------------------------------------------------
-- Algebraic structure: Functor, Appplicative and Monad-like

map : (A → B) → Irrelevant A → Irrelevant B
map f [ a ] = [ f a ]
map f [ a ] = [ Squash.map f a ]

pure : A → Irrelevant A
pure x = [ x ]
pure x = [ squash x ]

infixl 4 _<*>_
_<*>_ : Irrelevant (A → B) → Irrelevant A → Irrelevant B
[ f ] <*> [ a ] = [ f a ]
[ f ] <*> [ a ] = [ f Squash.<*> a ]

infixl 1 _>>=_
_>>=_ : Irrelevant A → (.A → Irrelevant B) → Irrelevant B
[ a ] >>= f = f a
_>>=_ : Irrelevant A → (A → Irrelevant B) → Irrelevant B
[ a ] >>= f = [ a Squash.>>= (λ x → irrelevant (f x)) ]

------------------------------------------------------------------------
-- Other functions
Expand Down
44 changes: 44 additions & 0 deletions src/Data/Squash.agda
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
------------------------------------------------------------------------
-- The Agda standard library
--
-- Wrapper for the proof irrelevance modality
--
-- This allows us to store proof irrelevant witnesses in a record and
-- use projections to manipulate them without having to turn on the
-- unsafe option --irrelevant-projections.
-- Cf. Data.Refinement for a use case
------------------------------------------------------------------------

{-# OPTIONS --cubical-compatible --safe #-}

module Data.Squash where

open import Level using (Level)

private
variable
a b c : Level
A : Set a
B : Set b
C : Set c

------------------------------------------------------------------------
-- Type

data Squash (A : Set a) : Prop a where
squash : A → Squash A

------------------------------------------------------------------------
-- Algebraic structure: Functor, Appplicative and Monad-like

map : (A → B) → Squash A → Squash B
map f (squash x) = squash (f x)

infixl 4 _<*>_
_<*>_ : Squash (A → B) → Squash A → Squash B
squash f <*> squash x = squash (f x)

infixl 1 _>>=_
_>>=_ : Squash A → (A → Squash B) → Squash B
squash x >>= f = f x

11 changes: 3 additions & 8 deletions src/Relation/Nullary/Recomputable.agda
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
module Relation.Nullary.Recomputable where

open import Data.Empty using (⊥)
open import Data.Irrelevant using (Irrelevant; irrelevant; [_])
open import Data.Irrelevant using (Irrelevant; [_])
open import Data.Product.Base using (_×_; _,_; proj₁; proj₂)
open import Level using (Level)
open import Relation.Nullary.Negation.Core using (¬_)
Expand All @@ -29,15 +29,10 @@ open import Relation.Nullary.Recomputable.Core public
------------------------------------------------------------------------
-- Constructions

-- Irrelevant types are Recomputable

irrelevant-recompute : Recomputable (Irrelevant A)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the removal of this function seems to be the biggest change, as far as 'breaking changes' go. Though if this is new to v2.4, it is fine, since that is as-yet unreleased.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

irrelevant (irrelevant-recompute [ a ]) = a

-- Corollary: so too is ⊥
-- ⊥ is Recomputable

⊥-recompute : Recomputable ⊥
⊥-recompute = irrelevant-recompute
⊥-recompute ()

_×-recompute_ : Recomputable A → Recomputable B → Recomputable (A × B)
(rA ×-recompute rB) p = rA (p .proj₁) , rB (p .proj₂)
Expand Down
1 change: 1 addition & 0 deletions standard-library.agda-lib
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ name: standard-library-2.4
include: src
flags:
--warning=noUnsupportedIndexedMatch
--prop
Loading