\begin{code}

{-# OPTIONS --safe --without-K #-} --

module MLTT.Maybe where

open import MLTT.Spartan

data Maybe {๐“ค : Universe} (A : ๐“ค ฬ‡ ) : ๐“ค ฬ‡ where
 Nothing : Maybe A
 Just    : A โ†’ Maybe A

{-# BUILTIN MAYBE Maybe #-}

Just-is-not-Nothing : {A : ๐“ค ฬ‡ } {a : A} โ†’ Just a โ‰  Nothing
Just-is-not-Nothing ()

Nothing-is-isolated : {A : ๐“ค ฬ‡ } (x : Maybe A) โ†’ is-decidable (Nothing ๏ผ x)
Nothing-is-isolated Nothing  = inl refl
Nothing-is-isolated (Just a) = inr (ฮป (p : Nothing ๏ผ Just a) โ†’ Just-is-not-Nothing (p โปยน))

Nothing-is-isolated' : {A : ๐“ค ฬ‡ } (x : Maybe A) โ†’ is-decidable (x ๏ผ Nothing)
Nothing-is-isolated' Nothing  = inl refl
Nothing-is-isolated' (Just a) = inr Just-is-not-Nothing

open import UF.DiscreteAndSeparated
open import UF.Equiv
open import UF.EquivalenceExamples
open import UF.Subsingletons

Nothing-is-h-isolated : {A : ๐“ค ฬ‡ } (x : Maybe A) โ†’ is-prop (Nothing ๏ผ x)
Nothing-is-h-isolated x = isolated-points-are-h-isolated Nothing Nothing-is-isolated

Nothing-is-h-isolated' : {A : ๐“ค ฬ‡ } (x : Maybe A) โ†’ is-prop (x ๏ผ Nothing)
Nothing-is-h-isolated' x = equiv-to-prop ๏ผ-flip (Nothing-is-h-isolated x)

\end{code}