1 | module Deriving.SpecialiseData.Codegen.Claims
3 | import Deriving.SpecialiseData.Common
4 | import Deriving.SpecialiseData.Helpers
5 | import Deriving.SpecialiseData.Task
6 | import Deriving.SpecialiseData.TaskFormation
7 | import Deriving.SpecialiseData.Unification
8 | import Deriving.SpecialiseData.Utils.Quantifiers
9 | import Deriving.SpecialiseData.Utils.TypeInfo
10 | import Language.Reflection.Compat
11 | import Language.Reflection.Expr
17 | parameters (t : SpecTask)
20 | mkMToPImplClaim : Decl
21 | mkMToPImplClaim = public' "mToPImpl" $
forallMTArgs t $
arg t.specInvocation .-> t.fullInvocation
26 | mkMToPClaim = interfaceHint Public "mToP" $
forallMTArgs t $
`(Cast
~(t.specInvocation) ~(t.fullInvocation))
30 | mkDecEqImplClaim : Decl
32 | let tInv = t.specInvocation
33 | in public' "decEqImpl" $
forallMTArgs t $
35 | `(Dec
(Equal
{a = ~tInv} {b = ~tInv} x1 x2
))
36 | [ MkArg MW AutoImplicit Nothing `(DecEq
~(t.fullInvocation))
37 | , MkArg MW ExplicitArg (Just "x1") tInv
38 | , MkArg MW ExplicitArg (Just "x2") tInv
43 | mkDecEqClaim = interfaceHint Public "decEq'" $
forallMTArgs t `(DecEq
~(t.fullInvocation) => DecEq
~(t.specInvocation))
46 | mkShowClaims : List Decl
48 | [ public' "showImpl" $
50 | `(Show
~(t.fullInvocation) => ~(t.specInvocation) -> String)
51 | , public' "showPrecImpl" $
53 | `(Show
~(t.fullInvocation) => Prec
-> ~(t.specInvocation) -> String)
54 | , interfaceHint Public "show'" $
forallMTArgs t $
55 | `(Show
~(t.fullInvocation) => Show
~(t.specInvocation))
59 | mkEqClaims : List Decl
61 | let tInv = t.specInvocation
62 | [ public' "eqImpl" $
forallMTArgs t
63 | `(Eq
~(t.fullInvocation) => ~tInv -> ~tInv -> Bool
)
64 | , public' "neqImpl" $
forallMTArgs t
65 | `(Eq
~(t.fullInvocation) => ~tInv -> ~tInv -> Bool
)
66 | , interfaceHint Public "eq'" $
forallMTArgs t $
67 | `(Eq
~(t.fullInvocation) => Eq
~tInv)
72 | mkPToMImplClaim : Decl
73 | mkPToMImplClaim = public' "pToMImpl" $
forallMTArgs t $
arg t.fullInvocation .-> t.specInvocation
79 | interfaceHint Public "pToM" $
forallMTArgs t $
`(Cast
~(t.fullInvocation) ~(t.specInvocation))
82 | mkFromStringClaims : List Decl
83 | mkFromStringClaims = do
84 | let tInv = t.specInvocation
85 | [ public' "fromStringImpl" $
87 | `(FromString
~(t.fullInvocation) => String -> ~tInv)
88 | , interfaceHint Public "fromString'" $
89 | forallMTArgs t `(FromString
~(t.fullInvocation) => FromString
~tInv)
93 | mkNumClaims : List Decl
95 | let tInv = t.specInvocation
96 | [ public' "numImpl" $
98 | `(Num
~(t.fullInvocation) => Integer -> ~tInv)
99 | , public' "plusImpl" $
101 | `(Num
~(t.fullInvocation) => ~tInv -> ~tInv -> ~tInv)
102 | , public' "starImpl" $
104 | `(Num
~(t.fullInvocation) => ~tInv -> ~tInv -> ~tInv)
105 | , interfaceHint Public "num'" $
106 | forallMTArgs t `(Num
~(t.fullInvocation) => Num
~tInv)
110 | standardClaims : List Decl
122 | decidedClaims : List Decl
127 | [ mkFromStringClaims