5import Language.Reflection
6import Language.Reflection.Utils
10||| A "function" that returns where it is called in the source
11getLoc : {default tactics { sourceLocation } x : SourceLocation} -> SourceLocation
15fromRHS : SourceLocation
18||| Testing getting source locations from RHS proof scripts
19fromProofScript : SourceLocation
20fromProofScript = proof sourceLocation
22||| Testing getting source locations from deferred proofs.
23fromMetavar : SourceLocation
26--- Testing that getting source locations in ASTs constructed with DSL notation
27data Ty = U | Arr Ty Ty
31interp (Arr x y) = interp x -> Either SourceLocation (interp y)
33using (ctxt : Vect n Ty)
34 data Tm : Vect n Ty -> Ty -> Type where
36 Var : (i : Fin n) -> Tm ctxt (index i ctxt)
37 Lam : Tm (t::ctxt) t' -> Tm ctxt (Arr t t')
38 App : Tm ctxt (Arr t t') -> Tm ctxt t -> Tm ctxt t'
39 ||| A term that makes the program halt and print where it halted
40 Die : {default tactics { sourceLocation } loc : SourceLocation} -> Tm ctxt t
42 data Env : Vect n Ty -> Type where
44 (::) : interp t -> Env ctxt -> Env (t::ctxt)
46 index : (i : Fin n) -> Env ctxt -> interp (index i ctxt)
48 index (FS i) (x::env) = index i env
50 run : Tm ctxt t -> Env ctxt -> Either SourceLocation (interp t)
52 run (Var i) env = pure $ index i env
53 run (Lam bdy) env = pure $ \x => run bdy (x::env)
54 run (App f x) env = !(run f env) !(run x env)
55 run (Die {loc}) _ = Left loc
58exec : Tm [] t -> IO ()
59exec tm = case run tm [] of
60 Left loc => putStrLn $ "Error at " ++ show loc
61 Right _ => putStrLn $ "Success!"
69testTerm1 : Tm [] (Arr U U)
70testTerm1 = lang (\x=>Die)
73testTerm2 = App testTerm1 MkU
75testTerm3 : Tm [] (Arr U U)
76testTerm3 = lang (\x => MkU)
79testTerm4 = App testTerm3 MkU
83 main = do putStrLn "Testing using definition"
85 putStrLn "Testing using inline tactics"
87 putStrLn "Testing using metavariable with later definition"
89 putStrLn "-----------------------"
90 sequence_ $ with List [ exec testTerm1
95---------- Proofs ----------
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list