@@ -129,11 +129,11 @@ val _ = app lextest [
129
129
];
130
130
131
131
val _ = app fptest [
132
- (“nTy”, " [Int ]" , “astType nTy”, “listTy intTy”),
132
+ (“nTy”, " [Integer ]" , “astType nTy”, “listTy intTy”),
133
133
(“nTy”, " a -> B" , “astType nTy”, “funTy (tyVar " a" ) (tyOp " B" [])”),
134
134
(“nTy”, " (Tree a, B)" , “astType nTy”, “tyTup [tyOp " Tree" [tyVar " a" ];
135
135
tyOp " B" []]”),
136
- (“nTy”, " [Int -> ()]" , “astType nTy”, “listTy (funTy intTy $ tyTup [])”),
136
+ (“nTy”, " [Integer -> ()]" , “astType nTy”, “listTy (funTy intTy $ tyTup [])”),
137
137
(“nExp”, " f 2 x" , “astExp nExp”, “‹f› ⬝ 𝕀 2 ⬝ ‹x›”),
138
138
(“nExp”, " \\ x y -> y x" , “astExp nExp”,
139
139
“expAbs (patVar " x" ) (expAbs (patVar " y" ) (‹y› ⬝ ‹x›))”),
@@ -202,7 +202,7 @@ val _ = app fptest [
202
202
“App () (𝕍u «f») [𝕍u «y»; 𝕁 3 ] >>=
203
203
Lam () [«x»] (App () (𝕍u «foo») [𝕍u «x»])”),
204
204
(“nExp”, " do let y = 10\n \
205
- \ f :: Int -> Int \n \
205
+ \ f :: Integer -> Integer \n \
206
206
\ f z = z + 1\n \
207
207
\ x <- g (f y) 3\n \
208
208
\ foo x" ,
@@ -237,18 +237,18 @@ val _ = app fptest [
237
237
(“nExp”, " case e of h : t -> 3" ,
238
238
“CEXP”,
239
239
“Case () (𝕍 «e») «» [(«::», [«h»; «t»], 𝕁 3 )] NONE ”),
240
- (“nDecl”, " f :: a -> Int " , “astDecl”,
241
- “declTysig " f" (funTy (tyVar " a" ) (tyOp " Int " []) )”),
240
+ (“nDecl”, " f :: a -> Integer " , “astDecl”,
241
+ “declTysig " f" (funTy (tyVar " a" ) intTy )”),
242
242
(“nDecl”, " f x y = x + y" , “astDecl”,
243
243
“declFunbind " f" [patVar " x" ; patVar " y" ] (‹+› ⬝ ‹x› ⬝ ‹y›)”),
244
244
(“nDecl”, " h:t = f e" , “astDecl”,
245
245
“declPatbind (patApp " ::" [patVar " h" ; patVar " t" ]) (‹f› ⬝ ‹e›)”),
246
- (“nDecl”, " data Foo a = C a Int | D [Int ]" , “astDecl”,
247
- “declData " Foo" [" a" ] [(" C" , [tyVar " a" ; tyOp " Int " [] ]);
248
- (" D" , [tyOp " []" [tyOp " Int " [] ]])]”),
249
- (“nDecls”, " data Bar = C | D Int Bar\n f:: Bar -> Int " , “astDecls”,
250
- “[declData " Bar" [] [(" C" , []); (" D" , [tyOp " Int " [] ; tyOp " Bar" []])];
251
- declTysig " f" (funTy (tyOp " Bar" []) (tyOp " Int " []) )]”),
246
+ (“nDecl”, " data Foo a = C a Integer | D [Integer ]" , “astDecl”,
247
+ “declData " Foo" [" a" ] [(" C" , [tyVar " a" ; intTy ]);
248
+ (" D" , [tyOp " []" [intTy ]])]”),
249
+ (“nDecls”, " data Bar = C | D Integer Bar\n f:: Bar -> Integer " , “astDecls”,
250
+ “[declData " Bar" [] [(" C" , []); (" D" , [intTy ; tyOp " Bar" []])];
251
+ declTysig " f" (funTy (tyOp " Bar" []) intTy )]”),
252
252
(“nDecls”, " data Bar = C | D Integer Bar\n f:: Bar -> Integer" , “CDECLS”,
253
253
“(Letrec () [] CMAIN,
254
254
[(1n, [(«[]»,[]); («::»,[TypeVar 0 ; TypeCons 0 [TypeVar 0 ]])]);
@@ -304,13 +304,20 @@ val _ = app convtest [
304
304
[(1n,[(«[]»,[]); («::»,[TypeVar 0 ; TypeCons 0 [TypeVar 0 ]])])])”)
305
305
]
306
306
307
+
308
+ val handle_inferResult_def = Define‘
309
+ handle_inferResult ires =
310
+ case ires of
311
+ OK x => SOME x
312
+ | Err _ => NONE
313
+ ’
307
314
val upto_demands_def = Define‘
308
- upto_demands s =
315
+ upto_demands (opts:compiler_opts) s =
309
316
do
310
317
(e1,ns) <- string_to_cexp s;
311
- e2 <<- transform_cexp e1;
312
- infer_types ns e2;
313
- return e2
318
+ e2 <<- transform_cexp opts e1;
319
+ handle_inferResult $ infer_types ns e2 ;
320
+ return e2;
314
321
od
315
322
’;
316
323
@@ -451,13 +458,13 @@ fun string_check s c f =
451
458
end ;
452
459
453
460
val with_demands_def = Define‘
454
- with_demands s =
461
+ with_demands opts s =
455
462
do
456
463
(e1,ns) <- string_to_cexp s;
457
- e2 <<- transform_cexp e1;
458
- infer_types ns e2;
459
- e3 <<- demands_analysis e2;
460
- infer_types ns e3;
464
+ e2 <<- transform_cexp opts e1;
465
+ handle_inferResult $ infer_types ns e2;
466
+ e3 <<- demands_analysis opts e2;
467
+ handle_inferResult $ infer_types ns e3;
461
468
return e3
462
469
od
463
470
’;
@@ -483,10 +490,10 @@ val wd = wd0 THENC
483
490
PURE_REWRITE_CONV[optionTheory.OPTION_IGNORE_BIND_thm]
484
491
485
492
val notypes_def = Define‘
486
- notypes s =
493
+ notypes opts s =
487
494
do
488
495
(e1,ns) <- string_to_cexp s;
489
- e2 <<- transform_cexp e1;
496
+ e2 <<- transform_cexp opts e1;
490
497
return e2
491
498
od
492
499
’;
0 commit comments