quox/lib/Quox/OPE/Length.idr

25 lines
438 B
Idris

module Quox.OPE.Length
import Quox.OPE.Basics
%default total
public export
data Length : Scope a -> Type where
Z : Length [<]
S : (s : Length xs) -> Length (xs :< x)
%name Length s
%builtin Natural Length
public export
(.nat) : Length xs -> Nat
(Z).nat = Z
(S s).nat = S s.nat
%transform "Length.nat" Length.(.nat) xs = believe_me xs
export
0 ok : (s : Length xs) -> s.nat = length xs
ok Z = Refl
ok (S s) = cong S $ ok s