Skip to content

Commit df8c071

Browse files
tahina-promtzguido
authored andcommitted
Tactics.Prettify: allow the user to define the full name of a new type
1 parent 40c7690 commit df8c071

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

tests/tactics/Prettify.fst

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ type myty =
1313
myty_pretty_right;
1414
Mkmyty_pretty0;
1515
Mkmyty_pretty1
16-
] (entry "_pretty" (`%myty))
16+
] (entry "myty_pretty" (`%myty))
1717

1818
(* Sanity check *)
1919
let right (x : myty) : r:myty_pretty{myty_pretty_right x == r} =
@@ -37,7 +37,7 @@ type named_ty =
3737
Mknamed_ty_pretty_Case1;
3838
Mknamed_ty_pretty_Case2;
3939
// named_ty_pretty_bij; // bijection record disabled for now
40-
] (entry "_pretty" (`%named_ty))
40+
] (entry "named_ty_pretty" (`%named_ty))
4141

4242
// test bijection
4343

@@ -75,7 +75,7 @@ type named_ty2 =
7575
named_ty2_pretty;
7676
Mknamed_ty2_pretty_Case1;
7777
Mknamed_ty2_pretty_Case2;
78-
] (entry "_pretty" (`%named_ty2))
78+
] (entry "named_ty2_pretty" (`%named_ty2))
7979

8080
let test_named_ty2 (i : named_ty2_pretty) =
8181
match i with
@@ -84,13 +84,13 @@ let test_named_ty2 (i : named_ty2_pretty) =
8484
()
8585

8686
type t2 = tuple2 int int
87-
%splice[t2_pretty] (entry "_pretty" (`%t2))
87+
%splice[t2_pretty] (entry "t2_pretty" (`%t2))
8888

8989
type t3 = tuple2 int (either bool string)
90-
%splice[t3_pretty] (entry "_pretty" (`%t3))
90+
%splice[t3_pretty] (entry "t3_pretty" (`%t3))
9191

9292
type t4 = either t3 (tuple2 int (either bool string))
93-
%splice[t4_pretty; t4_pretty_left_right] (entry "_pretty" (`%t4))
93+
%splice[t4_pretty; t4_pretty_left_right] (entry "t4_pretty" (`%t4))
9494

9595
let inv (x:t4) = t4_pretty_left_right x
9696

@@ -103,7 +103,7 @@ type t5 =
103103
noextract
104104
noeq (* will only go to the generated type. *)
105105
unfold
106-
%splice[t5_quals; t5_quals_left_right] (entry "_quals" (`%t5))
106+
%splice[t5_quals; t5_quals_left_right] (entry "t5_quals" (`%t5))
107107

108108
type big =
109109
either int <|
@@ -150,4 +150,6 @@ type bigger =
150150
) bool
151151

152152
[@@no_auto_projectors] // makes it a bit faster
153-
%splice[] (entry "_pretty" (`%bigger))
153+
%splice[huger] (entry "huger" (`%bigger))
154+
155+
let _ = huger

ulib/FStar.Tactics.PrettifyType.fst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ let mk_bij cfg : Tac decls =
453453
[pack_sigelt sv]
454454

455455
[@@plugin]
456-
let entry (suf nm : string) : Tac decls =
456+
let entry (pretty_tynm nm : string) : Tac decls =
457457
// print ("ENTRY, n quals = " ^ string_of_int (List.length (splice_quals ())));
458458
// print ("ENTRY, n attrs = " ^ string_of_int (List.length (splice_attrs ())));
459459
let quals = splice_quals () in
@@ -464,7 +464,9 @@ let entry (suf nm : string) : Tac decls =
464464
// print ("def: " ^ term_to_string def);
465465
let at = parse_type def in
466466
// print ("at: " ^ parsed_type_to_string at);
467-
let pretty_tynm = add_suffix suf nm in
467+
assume (List.length nm > 0);
468+
let qns, _ = unsnoc nm in
469+
let pretty_tynm = qns @ [pretty_tynm] in
468470
let _, fat = flatten_type pretty_tynm 0 at in
469471
// print ("fat: " ^ flat_type_to_string fat);
470472

0 commit comments

Comments
 (0)