deriving
This commit is contained in:
parent
ba3612d836
commit
ce3342f330
6 changed files with 29 additions and 62 deletions
|
@ -6,8 +6,11 @@ import Quox.Pretty
|
|||
|
||||
import Decidable.Equality
|
||||
import Control.Function
|
||||
import Generics.Derive
|
||||
|
||||
%default total
|
||||
%language ElabReflection
|
||||
%hide SOP.from; %hide SOP.to
|
||||
|
||||
|
||||
public export
|
||||
|
@ -17,11 +20,7 @@ data DimConst = Zero | One
|
|||
private DCRepr : Type
|
||||
DCRepr = Nat
|
||||
|
||||
private %inline dcrepr : DimConst -> DCRepr
|
||||
dcrepr e = case e of Zero => 0; One => 1
|
||||
|
||||
export Eq DimConst where (==) = (==) `on` dcrepr
|
||||
export Ord DimConst where compare = compare `on` dcrepr
|
||||
%runElab derive "DimConst" [Generic, Meta, Eq, Ord, DecEq, Show]
|
||||
|
||||
|
||||
public export
|
||||
|
@ -30,11 +29,10 @@ data Dim : Nat -> Type where
|
|||
B : Var d -> Dim d
|
||||
%name Dim.Dim p, q
|
||||
|
||||
private DRepr : Type
|
||||
DRepr = Nat
|
||||
|
||||
private %inline drepr : Dim n -> DRepr
|
||||
drepr p = case p of K i => dcrepr i; B i => 2 + i.nat
|
||||
private %inline
|
||||
drepr : Dim n -> Either DimConst (Var n)
|
||||
drepr (K k) = Left k
|
||||
drepr (B x) = Right x
|
||||
|
||||
export Eq (Dim n) where (==) = (==) `on` drepr
|
||||
export Ord (Dim n) where compare = compare `on` drepr
|
||||
|
@ -86,8 +84,8 @@ export Uninhabited (One = Zero) where uninhabited _ impossible
|
|||
export Uninhabited (B i = K e) where uninhabited _ impossible
|
||||
export Uninhabited (K e = B i) where uninhabited _ impossible
|
||||
|
||||
public export %inline Injective B where injective Refl = Refl
|
||||
public export %inline Injective K where injective Refl = Refl
|
||||
public export %inline Injective Dim.B where injective Refl = Refl
|
||||
public export %inline Injective Dim.K where injective Refl = Refl
|
||||
|
||||
public export
|
||||
DecEq DimConst where
|
||||
|
|
|
@ -3,22 +3,17 @@ module Quox.Syntax.Qty
|
|||
import Quox.Pretty
|
||||
|
||||
import Data.Fin
|
||||
import Generics.Derive
|
||||
|
||||
%default total
|
||||
%language ElabReflection
|
||||
|
||||
|
||||
public export
|
||||
data Qty = Zero | One | Any
|
||||
%name Qty.Qty pi, rh
|
||||
|
||||
private Repr : Type
|
||||
Repr = Fin 3
|
||||
|
||||
private %inline repr : Qty -> Repr
|
||||
repr pi = case pi of Zero => 0; One => 1; Any => 2
|
||||
|
||||
export Eq Qty where (==) = (==) `on` repr
|
||||
export Ord Qty where compare = compare `on` repr
|
||||
%runElab derive "Qty" [Generic, Meta, Eq, Ord, DecEq, Show]
|
||||
|
||||
|
||||
export
|
||||
|
|
|
@ -3,8 +3,10 @@ module Quox.Syntax.Universe
|
|||
import Quox.Pretty
|
||||
|
||||
import Data.Fin
|
||||
import Generics.Derive
|
||||
|
||||
%default total
|
||||
%language ElabReflection
|
||||
|
||||
|
||||
||| `UAny` doesn't show up in programs, but when checking something is
|
||||
|
@ -13,14 +15,7 @@ public export
|
|||
data Universe = U Nat | UAny
|
||||
%name Universe l
|
||||
|
||||
private Repr : Type
|
||||
Repr = (Fin 2, Nat)
|
||||
|
||||
private %inline repr : Universe -> Repr
|
||||
repr u = case u of U i => (0, i); UAny => (1, 0)
|
||||
|
||||
export Eq Universe where (==) = (==) `on` repr
|
||||
export Ord Universe where compare = compare `on` repr
|
||||
%runElab derive "Universe" [Generic, Meta, Eq, Ord, DecEq, Show]
|
||||
|
||||
export
|
||||
PrettyHL Universe where
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue