@@ -3,17 +3,17 @@ module Language.Reflection.Utils
3import Language.Reflection
3import Language.Reflection
4import Language.Reflection.Errors
4import Language.Reflection.Errors
8--------------------------------------------------------
6--------------------------------------------------------
9-- Tactic construction conveniences
7-- Tactic construction conveniences
10--------------------------------------------------------
8--------------------------------------------------------
12seq : List Tactic -> Tactic
11seq : List Tactic -> Tactic
13seq [] = GoalType "This is an impossible case" Trivial
12seq [] = GoalType "This is an impossible case" Trivial
14seq [t] = t
13seq [t] = t
15seq (t::ts) = t `Seq` seq ts
14seq (t::ts) = t `Seq` seq ts
17try : List Tactic -> Tactic
17try : List Tactic -> Tactic
18try [] = GoalType "This is an impossible case" Trivial
18try [] = GoalType "This is an impossible case" Trivial
19try [t] = t
19try [t] = t
@@ -23,6 +23,7 @@ try (t::ts) = t `Try` seq ts
23--------------------------------------------------------
23--------------------------------------------------------
24-- For use in tactic scripts
24-- For use in tactic scripts
25--------------------------------------------------------
25--------------------------------------------------------
26mkPair : a -> b -> (a, b)
27mkPair : a -> b -> (a, b)
27mkPair a b = (a, b)
28mkPair a b = (a, b)
@@ -30,22 +31,25 @@ mkPair a b = (a, b)
30--------------------------------------------------------
31--------------------------------------------------------
31-- Tools for constructing proof terms directly
32-- Tools for constructing proof terms directly
32--------------------------------------------------------
33--------------------------------------------------------
34getUName : TTName -> Maybe String
35getUName : TTName -> Maybe String
35getUName (UN n) = Just n
36getUName (UN n) = Just n
36getUName (NS n ns) = getUName n
37getUName (NS n ns) = getUName n
37getUName _ = Nothing
38getUName _ = Nothing
39unApply : TT -> (TT, List TT)
41unApply : TT -> (TT, List TT)
40unApply t = unA t []
42unApply t = unA t []
41 where unA : TT -> List TT -> (TT, List TT)
43 where unA : TT -> List TT -> (TT, List TT)
42 unA (App fn arg) args = unA fn (arg::args)
44 unA (App fn arg) args = unA fn (arg::args)
43 unA tm args = (tm, args)
45 unA tm args = (tm, args)
45mkApp : TT -> List TT -> TT
48mkApp : TT -> List TT -> TT
46mkApp tm [] = tm
49mkApp tm [] = tm
47mkApp tm (a::as) = mkApp (App tm a) as
50mkApp tm (a::as) = mkApp (App tm a) as
49binderTy : (Eq t) => Binder t -> t
53binderTy : (Eq t) => Binder t -> t
50binderTy (Lam t) = t
54binderTy (Lam t) = t
51binderTy (Pi t _) = t
55binderTy (Pi t _) = t