0 | module Derive.FromChar
2 | import Language.Reflection.Util
11 | fromChrClaim : Visibility -> (fun : Name) -> (p : ParamTypeInfo) -> Decl
12 | fromChrClaim vis fun p =
13 | let arg := p.applied
14 | tpe := piAll `(Char -> ~(arg)) (allImplicits p "FromChar")
15 | in simpleClaim vis fun tpe
20 | chrImplClaim : Visibility -> (impl : Name) -> (p : ParamTypeInfo) -> Decl
21 | chrImplClaim v impl p = implClaimVis v impl (implType "FromChar" p)
27 | chrImplDef : (fd, impl : Name) -> Decl
28 | chrImplDef fd impl =
29 | def impl [patClause (var impl) (appNames "MkFromChar" [fd])]
32 | fromChrDef : Name -> Con n vs -> Decl
34 | let t := `(fromChar n
)
35 | in def f [patClause (var f `app` bindVar "n") (injArgs explicit (const t) c)]
49 | FromCharVis : Visibility -> List Name -> ParamTypeInfo -> Res (List TopLevel)
50 | FromCharVis vis nms p = case p.info.cons of
52 | let fun := funName p "fromChar"
53 | impl := implName p "FromChar"
55 | [ TL (fromChrClaim vis fun p) (fromChrDef fun c)
56 | , TL (chrImplClaim vis impl p) (chrImplDef fun impl)
58 | _ => failRecord "FromChar"
62 | FromChar : List Name -> ParamTypeInfo -> Res (List TopLevel)
63 | FromChar = FromCharVis Public