2020-06-21 19:32:00 +03:00
|
|
|
module Prelude.Uninhabited
|
|
|
|
|
|
|
|
import Builtin
|
|
|
|
import Prelude.Basics
|
|
|
|
|
|
|
|
%default total
|
|
|
|
|
|
|
|
||| A canonical proof that some type is empty.
|
|
|
|
public export
|
|
|
|
interface Uninhabited t where
|
2021-05-06 18:32:51 +03:00
|
|
|
constructor MkUninhabited
|
2020-06-21 19:32:00 +03:00
|
|
|
||| If I have a t, I've had a contradiction.
|
|
|
|
||| @ t the uninhabited type
|
|
|
|
uninhabited : t -> Void
|
|
|
|
|
|
|
|
%extern
|
2021-10-24 14:06:57 +03:00
|
|
|
prim__void : (0 x : Void) -> a
|
|
|
|
|
|
|
|
||| The eliminator for the `Void` type.
|
2020-06-21 19:32:00 +03:00
|
|
|
public export
|
|
|
|
void : (0 x : Void) -> a
|
2021-10-24 14:06:57 +03:00
|
|
|
void = prim__void
|
2020-06-21 19:32:00 +03:00
|
|
|
|
|
|
|
export
|
|
|
|
Uninhabited Void where
|
|
|
|
uninhabited = id
|
|
|
|
|
|
|
|
||| Use an absurd assumption to discharge a proof obligation.
|
|
|
|
||| @ t some empty type
|
|
|
|
||| @ a the goal type
|
|
|
|
||| @ h the contradictory hypothesis
|
|
|
|
public export
|
|
|
|
absurd : Uninhabited t => (h : t) -> a
|
|
|
|
absurd h = void (uninhabited h)
|
2020-07-12 17:54:10 +03:00
|
|
|
|
|
|
|
public export
|
|
|
|
Uninhabited (True = False) where
|
|
|
|
uninhabited Refl impossible
|
|
|
|
|
|
|
|
public export
|
|
|
|
Uninhabited (False = True) where
|
|
|
|
uninhabited Refl impossible
|