Debian Codegraph @

src/Data/Maybe.agda

raw
1 ------------------------------------------------------------------------
2 -- The Agda standard library
3 --
4 -- The Maybe type
5 ------------------------------------------------------------------------
6
7 {-# OPTIONS --cubical-compatible --safe #-}
8
9 module Data.Maybe where
10
11 open import Data.Empty using (⊥)
12 open import Data.Unit.Base using (⊤)
13 open import Data.Bool.Base using (T)
14 open import Data.Maybe.Relation.Unary.All using (All)
15 open import Data.Maybe.Relation.Unary.Any using (Any; just)
16 open import Level using (Level)
17
18 private
19 variable
20 a : Level
21 A : Set a
22
23 ------------------------------------------------------------------------
24 -- The base type and some operations
25
26 open import Data.Maybe.Base public
27
28 ------------------------------------------------------------------------
29 -- Using Any and All to define Is-just and Is-nothing
30
31 Is-just : Maybe A → Set _
32 Is-just = Any (λ _ → ⊤)
33
34 Is-nothing : Maybe A → Set _
35 Is-nothing = All (λ _ → ⊥)
36
37 to-witness : ∀ {m : Maybe A} → Is-just m → A
38 to-witness (just {x = p} _) = p
39
40 to-witness-T : ∀ (m : Maybe A) → T (is-just m) → A
41 to-witness-T (just p) _ = p