6 | import public Language.Reflection
28 | isTyCon : NameInfo -> Bool
29 | isTyCon $
MkNameInfo $
TyCon {} = True
33 | getMk' : (t : ty) -> Elab (FC, Name)
37 | let IVar _ name = expr
38 | | IPrimVal {} => failAt fc "Expression must not be a primitive value or type"
39 | | expr => failAt fc "Expression must be just a name"
40 | [(name, _)] <- getInfo name <&> filter (isTyCon . snd)
41 | | [] => failAt fc "Expression must be an unambiguous type"
42 | | _::_::_ => failAt fc "Given name `\{show name}` is ambiguous type"
43 | [conName] <- getCons name
44 | | [] => failAt fc "No constructors found for `\{show name}`"
45 | | _::_::_ => failAt fc "Given type `\{show name}` has more than one constructor"
49 | getMk : (t : ty) -> Elab Name
50 | getMk = map snd . getMk'
52 | export %macro %inline
53 | Mk : (t : ty) -> Elab a
55 | (fc, conName) <- getMk' t
56 | check $
IVar fc conName