-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathTypeSystemForCC.hs
32 lines (24 loc) · 1.07 KB
/
TypeSystemForCC.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
module TypeSystemForCC where
import TypeSystem
import Static
dyntype :: Term
dyntype = (Constructor "dyn" [])
blame :: Term -> Term
blame label = (Constructor "blame" [label])
typeOfCC :: String
typeOfCC = typeOf ++ "CC"
sig_castCalculus :: [SignatureEntry]
sig_castCalculus = [Decl typeOfCC "o" Nothing Nothing [Simple "term", Simple "typ"],
Decl "cast" "term" Nothing (Just [(1, [])]) [(Simple "term"), (Simple "typ"), (Simple "label"), (Simple "typ")],
Decl "blame" "term" Nothing Nothing [(Simple "label")]
]
castR :: [Rule]
castR = [(Rule
[(Formula "typeOf" [] [(Var "E")] [(Var "T1")])]
(Formula "typeOf" [] [(Constructor "cast" [(Var "E"),(Var "T1"),(Var "L"), (Var "T2")])] [(Var "T2")])),
(Rule
[]
(Formula "typeOf" [] [(Constructor "blame" [(Var "L")])] [(Var "T")])
)]
toTypeSystemForCC :: TypeSystem -> TypeSystem
toTypeSystemForCC (Ts sig rules) = (Ts (sig ++ sig_castCalculus) (map (renamingInRule typeOf typeOfCC) (rules ++ castR)))