3import Language.Reflection
4import Language.Reflection.Errors
5import Language.Reflection.Utils
7%language ErrorReflection
11data Ty = TUnit | TFun Ty Ty
15 show (TFun t1 t2) = "(" ++ show t1 ++ " => " ++ show t2 ++ ")"
17using (n : Nat, G : Vect n Ty)
18 data HasType : Vect n Ty -> Ty -> Type where
19 Here : HasType (t::G) t
20 There : HasType G t -> HasType (t' :: G) t
22 data Tm : Vect n Ty -> Ty -> Type where
24 Var : HasType G t -> Tm G t
25 Lam : Tm (t :: G) t' -> Tm G (TFun t t')
26 App : Tm G (TFun t t') -> Tm G t -> Tm G t'
28-- Extract the type from a reflected term type
33 | TVar Int String -- To show in unification failures
35 instance Show Ty' where
37 show (TFun x y) = "(" ++ show x ++ " => " ++ show y ++ ")"
38 show (TVar i n) = n ++ "(" ++ cast i ++ ")"
40getTmTy : TT -> Maybe TT
41getTmTy (App (App (App (P (TCon _ _) (NS (UN "Tm") _) _) _) _) ty) = Just ty
45reifyTy : TT -> Maybe Ty'
46reifyTy (P (DCon _ _) (NS (UN "TUnit") _) _) = Just TUnit
47reifyTy (App (App (P (DCon _ _) (NS (UN "TFun") _) _) t1) t2) = do ty1 <- reifyTy t1
50reifyTy (P _ (MN i n) _) = Just (TVar i n)
53-- Friendly error reporting
56dslerr : Err -> Maybe (List ErrorReportPart)
57dslerr (CantUnify _ tm1 tm2 _ _ _) = do tm1' <- getTmTy tm1
61 Just [TextPart $ "DSL type error: " ++ (show ty1) ++ " doesn't match " ++(show ty2)]
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