2019-06-13 15:23:21 +03:00
|
|
|
module Builtin
|
|
|
|
|
|
|
|
-- The most primitive data types; things which are used by desugaring
|
|
|
|
|
|
|
|
-- Totality assertions
|
|
|
|
%inline
|
|
|
|
public export
|
|
|
|
assert_total : {0 a : _} -> a -> a
|
|
|
|
assert_total x = x
|
|
|
|
|
|
|
|
%inline
|
|
|
|
public export
|
|
|
|
assert_smaller : {0 a, b : _} -> (x : a) -> (y : b) -> b
|
|
|
|
assert_smaller x y = y
|
|
|
|
|
|
|
|
-- Unit type and pairs
|
|
|
|
|
|
|
|
public export
|
|
|
|
data Unit = MkUnit
|
|
|
|
|
|
|
|
public export
|
|
|
|
data Pair : Type -> Type -> Type where
|
|
|
|
MkPair : {0 a, b : Type} -> (1 x : a) -> (1 y : b) -> Pair a b
|
|
|
|
|
|
|
|
public export
|
|
|
|
fst : {0 a, b : Type} -> (a, b) -> a
|
|
|
|
fst (x, y) = x
|
|
|
|
|
|
|
|
public export
|
|
|
|
snd : {0 a, b : Type} -> (a, b) -> b
|
|
|
|
snd (x, y) = y
|
|
|
|
|
|
|
|
-- This directive tells auto implicit search what to use to look inside pairs
|
|
|
|
%pair Pair fst snd
|
|
|
|
|
|
|
|
namespace DPair
|
|
|
|
public export
|
2019-07-02 18:53:41 +03:00
|
|
|
record DPair a (p : a -> Type) where
|
|
|
|
constructor MkDPair
|
|
|
|
fst : a
|
|
|
|
snd : p fst
|
2019-06-13 15:23:21 +03:00
|
|
|
|
|
|
|
-- The empty type
|
|
|
|
|
|
|
|
public export
|
|
|
|
data Void : Type where
|
|
|
|
|
|
|
|
-- Equality
|
|
|
|
|
|
|
|
public export
|
|
|
|
data Equal : forall a, b . a -> b -> Type where
|
|
|
|
Refl : {0 x : a} -> Equal x x
|
|
|
|
|
|
|
|
%name Equal prf
|
|
|
|
|
2019-07-05 13:26:45 +03:00
|
|
|
infix 9 ===, ~=~
|
2019-07-01 01:54:50 +03:00
|
|
|
|
|
|
|
-- An equality type for when you want to assert that each side of the
|
|
|
|
-- equality has the same type, but there's not other evidence available
|
|
|
|
-- to help with unification
|
|
|
|
public export
|
|
|
|
(===) : (x : a) -> (y : a) -> Type
|
|
|
|
(===) = Equal
|
|
|
|
|
2019-07-05 13:26:45 +03:00
|
|
|
public export
|
|
|
|
(~=~) : (x : a) -> (y : b) -> Type
|
|
|
|
(~=~) = Equal
|
|
|
|
|
|
|
|
|
2019-06-13 15:23:21 +03:00
|
|
|
%inline
|
|
|
|
public export
|
2019-10-26 00:24:25 +03:00
|
|
|
rewrite__impl : {0 x, y : a} -> (0 p : _) ->
|
2019-06-13 15:23:21 +03:00
|
|
|
(0 rule : x = y) -> (1 val : p y) -> p x
|
|
|
|
rewrite__impl p Refl prf = prf
|
|
|
|
|
|
|
|
%rewrite Equal rewrite__impl
|
|
|
|
|
|
|
|
%inline
|
|
|
|
public export
|
|
|
|
replace : forall x, y, p . (0 rule : x = y) -> p x -> p y
|
|
|
|
replace Refl prf = prf
|
|
|
|
|
|
|
|
%inline
|
|
|
|
public export
|
|
|
|
sym : (0 rule : x = y) -> y = x
|
|
|
|
sym Refl = Refl
|
|
|
|
|
|
|
|
%inline
|
|
|
|
public export
|
|
|
|
trans : forall a, b, c . (0 l : a = b) -> (0 r : b = c) -> a = c
|
|
|
|
trans Refl Refl = Refl
|
|
|
|
|
|
|
|
public export
|
|
|
|
believe_me : a -> b
|
|
|
|
believe_me = prim__believe_me _ _
|