-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ new ] module specialised to 0ℓ (#27)
- Loading branch information
Showing
7 changed files
with
447 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{-# OPTIONS --without-K --safe #-} | ||
|
||
module Data.Singleton where | ||
|
||
open import Level using (Level; levelOfType) | ||
open import Data.Empty.Polymorphic using (⊥) | ||
open import Data.Maybe.Base using (Maybe; nothing; just) | ||
open import Data.Sum.Base using (_⊎_; inj₁; inj₂) | ||
|
||
private | ||
variable | ||
a b : Level | ||
A : Set a | ||
B : Set b | ||
|
||
infix 0 _! | ||
data Singleton {A : Set a} : A → Set a where | ||
_! : (a : A) → Singleton a | ||
|
||
fromJust : Maybe A → Set (levelOfType A) | ||
fromJust (just a) = Singleton a | ||
fromJust nothing = ⊥ | ||
|
||
fromInj₁ : A ⊎ B → Set (levelOfType A) | ||
fromInj₁ (inj₁ a) = Singleton a | ||
fromInj₁ (inj₂ _) = ⊥ | ||
|
||
fromInj₂ : A ⊎ B → Set (levelOfType B) | ||
fromInj₂ (inj₁ _) = ⊥ | ||
fromInj₂ (inj₂ b) = Singleton b |
Oops, something went wrong.