diff --git a/src/stages/ast_simplified/PP.ml b/src/stages/ast_simplified/PP.ml index 5f1998f95..ac7c4bafe 100644 --- a/src/stages/ast_simplified/PP.ml +++ b/src/stages/ast_simplified/PP.ml @@ -5,7 +5,10 @@ include Stage_common.PP let list_sep_d x ppf lst = match lst with | [] -> () - | _ -> fprintf ppf "@; @[%a@]@;" (list_sep x (tag "@;")) lst + | _ -> fprintf ppf " @[%a@] " (list_sep x (tag " ; ")) lst +let tuple_sep_d x ppf lst = match lst with + | [] -> () + | _ -> fprintf ppf " @[%a@] " (list_sep x (tag " , ")) lst let rec te' ppf (te : type_expression type_expression') : unit = type_expression' type_expression ppf te @@ -19,13 +22,13 @@ let rec expression ppf (e:expression) = match e.expression with | E_application (f, arg) -> fprintf ppf "(%a)@(%a)" expression f expression arg | E_constructor (c, ae) -> fprintf ppf "%a(%a)" constructor c expression ae | E_constant (b, lst) -> fprintf ppf "%a(%a)" constant b (list_sep_d expression) lst - | E_tuple lst -> fprintf ppf "tuple[%a]" (list_sep_d expression) lst + | E_tuple lst -> fprintf ppf "(%a)" (tuple_sep_d expression) lst | E_accessor (ae, p) -> fprintf ppf "%a.%a" expression ae access_path p - | E_record m -> fprintf ppf "record[%a]" (lmap_sep expression (const " , ")) m - | E_map m -> fprintf ppf "map[%a]" (list_sep_d assoc_expression) m + | E_record m -> fprintf ppf "{%a}" (lrecord_sep expression (const " , ")) m + | E_map m -> fprintf ppf "[%a]" (list_sep_d assoc_expression) m | E_big_map m -> fprintf ppf "big_map[%a]" (list_sep_d assoc_expression) m - | E_list lst -> fprintf ppf "list[%a]" (list_sep_d expression) lst - | E_set lst -> fprintf ppf "set[%a]" (list_sep_d expression) lst + | E_list lst -> fprintf ppf "[%a]" (list_sep_d expression) lst + | E_set lst -> fprintf ppf "{%a}" (list_sep_d expression) lst | E_look_up (ds, ind) -> fprintf ppf "(%a)[%a]" expression ds expression ind | E_lambda {binder;input_type;output_type;result} -> fprintf ppf "lambda (%a:%a) : %a return %a" diff --git a/src/stages/common/PP.ml b/src/stages/common/PP.ml index 7cc0fb122..e32e9dd52 100644 --- a/src/stages/common/PP.ml +++ b/src/stages/common/PP.ml @@ -128,6 +128,11 @@ let lmap_sep value sep ppf m = let new_pp ppf (k, v) = fprintf ppf "%a -> %a" label k value v in fprintf ppf "%a" (list_sep new_pp sep) lst +let lrecord_sep value sep ppf m = + let lst = Types.LMap.to_kv_list m in + let new_pp ppf (k, v) = fprintf ppf "%a = %a" label k value v in + fprintf ppf "%a" (list_sep new_pp sep) lst + let list_sep_d x = list_sep x (const " , ") let cmap_sep_d x = cmap_sep x (const " , ") let lmap_sep_d x = lmap_sep x (const " , ") diff --git a/src/stages/common/PP.mli b/src/stages/common/PP.mli index fa63bb418..b95fd3851 100644 --- a/src/stages/common/PP.mli +++ b/src/stages/common/PP.mli @@ -8,6 +8,7 @@ val label : formatter -> label -> unit val constant : formatter -> constant -> unit val cmap_sep : (formatter -> 'a -> unit) -> (formatter -> unit -> unit) -> formatter -> 'a CMap.t -> unit val lmap_sep : (formatter -> 'a -> unit) -> (formatter -> unit -> unit) -> formatter -> 'a LMap.t -> unit +val lrecord_sep : (formatter -> 'a -> unit) -> (formatter -> unit -> unit) -> formatter -> 'a LMap.t -> unit val type_expression' : (formatter -> 'a -> unit) -> formatter -> 'a type_expression' -> unit val type_operator : (formatter -> 'a -> unit) -> formatter -> 'a type_operator -> unit val type_constant : formatter -> type_constant -> unit