Idris2/libs/prelude/Prelude/Uninhabited.idr
Edwin Brady 6a53e0177c Reorganise prelude into multiple files
This is partly to tidy things up, but also a good test for 'import as'.
Requires some internal changes since there are parts of reflection,
unelaboration and a compiler hack that rely on where things are in the
Prelude.
2020-07-12 16:55:48 +01:00

40 lines
803 B
Idris

module Prelude.Uninhabited
import Builtin
import Prelude.Basics
%default total
||| A canonical proof that some type is empty.
public export
interface Uninhabited t where
||| If I have a t, I've had a contradiction.
||| @ t the uninhabited type
uninhabited : t -> Void
||| The eliminator for the `Void` type.
%extern
public export
void : (0 x : Void) -> a
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)
public export
Uninhabited (True = False) where
uninhabited Refl impossible
public export
Uninhabited (False = True) where
uninhabited Refl impossible