Skip to content

Commit 5dbca0e

Browse files
authored
Merge pull request #1066 from CakeML/remove-old-datatype
Remove old Datatype` syntax
2 parents 65e1919 + b3a5924 commit 5dbca0e

File tree

74 files changed

+445
-275
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+445
-275
lines changed

basis/fsFFIScript.sml

+9-4
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,15 @@ val _ = option_monadsyntax.temp_add_option_monadsyntax();
1111
(* Logical model of filesystem and I/O streams *)
1212

1313
(* regular files and unnamed streams *)
14-
val _ = Datatype` inode = UStream mlstring | File mlstring`
14+
Datatype:
15+
inode = UStream mlstring | File mlstring
16+
End
1517

1618
Overload isFile = ``λinode. ∃fnm. inode = File fnm``
1719

18-
val _ = Datatype` mode = ReadMode | WriteMode`;
20+
Datatype:
21+
mode = ReadMode | WriteMode
22+
End
1923

2024
(* files: a list of file names and their content.
2125
* infds: descriptor * (filename * mode * position)
@@ -27,13 +31,14 @@ val _ = Datatype` mode = ReadMode | WriteMode`;
2731
* ulimit -n has a usual value of 1024
2832
*)
2933

30-
val _ = Datatype`
34+
Datatype:
3135
IO_fs = <| inode_tbl : (inode # char list) list ;
3236
files : (mlstring # mlstring) list;
3337
infds : (num # (inode # mode # num)) list;
3438
numchars : num llist;
3539
maxFD : num
36-
|>`
40+
|>
41+
End
3742

3843
val IO_fs_component_equality = theorem"IO_fs_component_equality";
3944

basis/pure/mloptionScript.sml

-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ open preamble
55

66
val _ = new_theory"mloption"
77

8-
(*val _ = Datatype `option = *)
9-
108
Definition getOpt_def:
119
(getOpt (SOME v) a = v) /\
1210
(getOpt NONE a = a)

basis/pure/mlstringScript.sml

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ val cpn_nchotomy = TypeBase.nchotomy_of ``:ordering``
1414
(* Defines strings as a separate type from char list. This theory should be
1515
moved into HOL, either as its own theory, or as an addendum to stringTheory *)
1616

17-
val _ = Datatype`mlstring = strlit string`
17+
Datatype:
18+
mlstring = strlit string
19+
End
1820
val _ = add_strliteral_form{inj=``strlit``, ldelim = "«"};
1921

2022
Definition implode_def:

characteristic/cfFFITypeScript.sml

+6-4
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,17 @@ important injectivity (suffix: "_11") are here.
2929
3030
*)
3131

32-
val _ = Datatype `
32+
Datatype:
3333
ffi_inner = iStr string
3434
| iNum num
3535
| iCons ffi_inner ffi_inner
3636
| iList (ffi_inner list)
37-
| iStream (num llist)`
37+
| iStream (num llist)
38+
End
3839

39-
val _ = Datatype `
40-
ffi = FFI_TYPE (ffi_inner -> ffi_inner)`
40+
Datatype:
41+
ffi = FFI_TYPE (ffi_inner -> ffi_inner)
42+
End
4143

4244
Definition ffi_app_def:
4345
ffi_app x n = case x of FFI_TYPE f => f n

characteristic/cfHeapsBaseScript.sml

+12-8
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@ val _ = new_theory "cfHeapsBase"
1111
(** Heaps *)
1212

1313
(* the following is now defined in cfFFITypeTheory
14-
val _ = Datatype `
14+
Datatype:
1515
ffi = Str string
1616
| Num num
1717
| Cons ffi ffi
1818
| List (ffi list)
19-
| Stream (num llist)`
19+
| Stream (num llist)
20+
End
2021
*)
2122

2223
Definition encode_pair_def:
@@ -68,8 +69,9 @@ Proof
6869
Cases \\ Cases \\ rw[encode_int_def]
6970
QED
7071

71-
val _ = Datatype `
72-
ffi_result = FFIreturn (word8 list) 'ffi | FFIdiverge`
72+
Datatype:
73+
ffi_result = FFIreturn (word8 list) 'ffi | FFIdiverge
74+
End
7375

7476
(* make an ffi_next function from base functions and encode/decode *)
7577
Definition mk_ffi_next_def:
@@ -86,20 +88,22 @@ Type loc = ``:num``
8688

8789
Type ffi_next = ``:string -> word8 list -> word8 list -> ffi -> ffi ffi_result option``
8890

89-
val _ = Datatype `
91+
Datatype:
9092
heap_part = Mem loc (v semanticPrimitives$store_v)
9193
| FFI_split
9294
| FFI_part ffi ffi_next (string list) (io_event list)
93-
| FFI_full (io_event list)`
95+
| FFI_full (io_event list)
96+
End
9497

9598
Type heap = ``:heap_part set``
9699
Type hprop = ``:heap -> bool``
97100

98-
val _ = Datatype `
101+
Datatype:
99102
res = Val v
100103
| Exn v
101104
| FFIDiv string (word8 list) (word8 list)
102-
| Div (io_event llist)`
105+
| Div (io_event llist)
106+
End
103107

104108
Type ffi_proj = ``: ('ffi -> (string |-> ffi)) #
105109
((string list # ffi_next) list)``

compiler/backend/ag32/proofs/ag32_progScript.sml

+3-2
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@ QED
2222

2323
(* basic definitions *)
2424

25-
val _ = Datatype `
25+
Datatype:
2626
ag32_el = aState ag32_state
2727
| aMem word32 word8
28-
| aPc word32`;
28+
| aPc word32
29+
End
2930

3031
val ag32_el_11 = DB.fetch "-" "ag32_el_11";
3132
val ag32_el_distinct = DB.fetch "-" "ag32_el_distinct";

compiler/backend/backendScript.sml

+4-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ open jsonLangTheory presLangTheory
2121

2222
val _ = new_theory"backend";
2323

24-
val _ = Datatype`config =
24+
Datatype:
25+
config =
2526
<| source_conf : source_to_flat$config
2627
; clos_conf : clos_to_bvl$config
2728
; bvl_conf : bvl_to_bvi$config
@@ -33,7 +34,8 @@ val _ = Datatype`config =
3334
; symbols : (mlstring # num # num) list
3435
; tap_conf : tap_config
3536
; exported : mlstring list (* field for Pancake entry points - empty for CakeML *)
36-
|>`;
37+
|>
38+
End
3739

3840
val config_component_equality = theorem"config_component_equality";
3941

compiler/backend/backend_commonScript.sml

+3-2
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,13 @@ Definition clos_tag_shift_def:
6666
End
6767

6868
(* Trace of an expression through the compiler, for exploring transformations *)
69-
val _ = Datatype`
69+
Datatype:
7070
tra =
7171
| SourceLoc num (* start-row *) num (* start-col *) num (* end-row *) num (* end-col *)
7272
| Cons tra num
7373
| Union tra tra
74-
| None (* Dead trace, do not make traces at all *)`
74+
| None (* Dead trace, do not make traces at all *)
75+
End
7576

7677
(* The code below replaces "Cons" in hol output with the chosen symbol *)
7778
val _ = set_fixity "" (Infixl 480);

compiler/backend/bviScript.sml

+3-2
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,14 @@ val _ = set_grammar_ancestry ["closLang" (* for op *)]
3838

3939
(* --- Syntax of BVI --- *)
4040

41-
val _ = Datatype `
41+
Datatype:
4242
exp = Var num
4343
| If exp exp exp
4444
| Let (exp list) exp
4545
| Raise exp
4646
| Tick exp
4747
| Call num (num option) (exp list) (exp option)
48-
| Op op (exp list) `
48+
| Op op (exp list)
49+
End
4950

5051
val _ = export_theory();

compiler/backend/bvi_tailrecScript.sml

+6-3
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,16 @@ QED
6464

6565
val _ = export_rewrites ["is_const_def"];
6666

67-
val _ = Datatype `
67+
Datatype:
6868
assoc_op = Plus
6969
| Times
7070
| Append
71-
| Noop`;
71+
| Noop
72+
End
7273

73-
val _ = Datatype `v_ty = Int | List | Any`;
74+
Datatype:
75+
v_ty = Int | List | Any
76+
End
7477

7578
Definition op_type_def:
7679
op_type Append = List /\

compiler/backend/bvlScript.sml

+3-2
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,16 @@ val _ = set_grammar_ancestry [
2626
"closLang", (* for op *) "backend_common" (* for tags *)
2727
]
2828

29-
val _ = Datatype `
29+
Datatype:
3030
exp = Var num
3131
| If exp exp exp
3232
| Let (exp list) exp
3333
| Raise exp
3434
| Handle exp exp
3535
| Tick exp
3636
| Call num (num option) (exp list)
37-
| Op closLang$op (exp list) `
37+
| Op closLang$op (exp list)
38+
End
3839

3940
Definition Bool_def:
4041
Bool b = Op (Cons (bool_to_tag b)) []

compiler/backend/clos_knownScript.sml

+11-7
Original file line numberDiff line numberDiff line change
@@ -274,14 +274,15 @@ End
274274
275275
----------------------------------------------------------------- *)
276276

277-
val _ = Datatype `
277+
Datatype:
278278
val_approx =
279279
ClosNoInline num num (* location in code table, arity *)
280280
| Clos num num exp num (* loc, arity, body, body size *)
281281
| Tuple num (val_approx list) (* conses or tuples *)
282282
| Int int (* used to index tuples *)
283283
| Other (* unknown *)
284-
| Impossible` (* value 'returned' by Raise *)
284+
| Impossible (* value 'returned' by Raise *)
285+
End
285286
val val_approx_size_def = definition "val_approx_size_def"
286287

287288
Definition merge_def[nocompute]:
@@ -446,7 +447,9 @@ Definition clos_gen_noinline_def:
446447
ClosNoInline (n+2*i) a::clos_gen_noinline n (i+1) xs)
447448
End
448449

449-
val _ = Datatype `globalOpt = gO_Int int | gO_NullTuple num | gO_None`
450+
Datatype:
451+
globalOpt = gO_Int int | gO_NullTuple num | gO_None
452+
End
450453

451454
Definition isGlobal_def:
452455
(isGlobal (Global _) ⇔ T) ∧
@@ -479,18 +482,19 @@ Termination
479482
wf_rel_tac `measure (FST o SND o SND)`
480483
End
481484

482-
val _ = Datatype `
485+
Datatype:
483486
inliningDecision = inlD_Nothing
484487
| inlD_Annotate num
485488
| inlD_LetInline exp
486-
`;
489+
End
487490

488-
val _ = Datatype`
491+
Datatype:
489492
config = <| inline_max_body_size : num
490493
; inline_factor : num (* As in 'Inline expansion: when and how?' by Manuel Serrano *)
491494
; initial_inline_factor : num
492495
; val_approx_spt : val_approx spt (* TODO: this could replace the explicit g argument in known_def *)
493-
|>`;
496+
|>
497+
End
494498

495499
Definition default_inline_factor_def:
496500
default_inline_factor = 8n

compiler/backend/clos_to_bvlScript.sml

+3-2
Original file line numberDiff line numberDiff line change
@@ -676,15 +676,16 @@ Proof
676676
\\ CONV_TAC (DEPTH_CONV PairRules.PBETA_CONV) \\ fs []
677677
QED
678678

679-
val _ = Datatype`
679+
Datatype:
680680
config = <| next_loc : num
681681
; start : num
682682
; do_mti : bool
683683
; known_conf : clos_known$config option
684684
; do_call : bool
685685
; call_state : num_set # (num, num # closLang$exp) alist
686686
; max_app : num
687-
|>`;
687+
|>
688+
End
688689

689690
Definition default_config_def:
690691
default_config = <|

compiler/backend/data_to_wordScript.sml

+9-6
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,15 @@ val _ = new_theory "data_to_word";
1313

1414
val _ = patternMatchesLib.ENABLE_PMATCH_CASES();
1515

16-
val _ = Datatype `
16+
Datatype:
1717
(* this configuration is used in data_to_wordProof and stack_alloc *)
1818
gc_kind =
1919
None
2020
| Simple
21-
| Generational (num list) (* sizes of generations, smallest first *)`
21+
| Generational (num list) (* sizes of generations, smallest first *)
22+
End
2223

23-
val _ = Datatype `
24+
Datatype:
2425
config = <| tag_bits : num (* in each pointer *)
2526
; len_bits : num (* in each pointer *)
2627
; pad_bits : num (* in each pointer *)
@@ -31,7 +32,8 @@ val _ = Datatype `
3132
; has_fp_tern : bool (* can compile FMA *)
3233
; be : bool (* bigendian *)
3334
; call_empty_ffi : bool (* emit (T) / omit (F) calls to FFI "" *)
34-
; gc_kind : gc_kind (* GC settings *) |>`
35+
; gc_kind : gc_kind (* GC settings *) |>
36+
End
3537

3638
Definition adjust_var_def:
3739
adjust_var n = 2 * n + 2:num
@@ -150,8 +152,9 @@ Definition real_byte_offset_def:
150152
Shift Lsr (Var r) 2]
151153
End
152154

153-
val _ = Datatype`
154-
word_op_type = Bitwise binop | Carried binop`;
155+
Datatype:
156+
word_op_type = Bitwise binop | Carried binop
157+
End
155158

156159
Definition lookup_word_op_def:
157160
(lookup_word_op Andw = Bitwise And) ∧

compiler/backend/db_varsScript.sml

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@ open preamble;
66

77
val _ = new_theory "db_vars";
88

9-
val _ = Datatype `
9+
Datatype:
1010
db_var_set = Empty
1111
| Var num
1212
| Shift num db_var_set
13-
| Union db_var_set db_var_set`;
13+
| Union db_var_set db_var_set
14+
End
1415

1516
Definition mk_Union_def:
1617
mk_Union t1 t2 =

compiler/backend/flat_patternScript.sml

+4-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ val _ = new_theory "flat_pattern";
1515
val _ = set_grammar_ancestry ["misc","flatLang","sptree",
1616
"pattern_semantics"];
1717

18-
val _ = Datatype `config =
19-
<| pat_heuristic : (* pattern_matching$branch list *) (* unit -> *) num |>`;
18+
Datatype:
19+
config =
20+
<| pat_heuristic : (* pattern_matching$branch list *) (* unit -> *) num |>
21+
End
2022

2123
Definition init_config_def:
2224
init_config ph = <| pat_heuristic := ph |>

compiler/backend/gc/gc_combinedScript.sml

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ open data_to_wordTheory;
66

77
val _ = new_theory "gc_combined";
88

9-
val _ = Datatype `
10-
gen_state = GenState num (num list)`;
9+
Datatype:
10+
gen_state = GenState num (num list)
11+
End
1112

1213
Definition make_partial_conf_def:
1314
make_partial_conf (conf:'a gen_gc_conf) (GenState _ gen_starts) rs =

0 commit comments

Comments
 (0)