From 242d99fd5ed1c958d7b44054447a275f989eb811 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Suzanne=20Dup=C3=A9ron?= Date: Wed, 17 Jun 2020 23:14:50 +0100 Subject: [PATCH 1/7] Improve error message --- src/passes/11-spilling/errors.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/passes/11-spilling/errors.ml b/src/passes/11-spilling/errors.ml index 93545afd3..eef709b4f 100644 --- a/src/passes/11-spilling/errors.ml +++ b/src/passes/11-spilling/errors.ml @@ -54,7 +54,7 @@ let rec error_ppformat : display_format:string display_format -> let s = Format.asprintf "%s\n corner case: %s\n%s" loc desc (corner_case_message ()) in Format.pp_print_string f s | `Spilling_no_type_variable tv -> - let s = Format.asprintf "type variables can't be transpiled : %a" Var.pp tv in + let s = Format.asprintf "unbound type variables can't be transpiled : %a" Var.pp tv in Format.pp_print_string f s | `Spilling_unsupported_pattern_matching loc -> let s = Format.asprintf "%a\n unsupported pattern-matching: tuple patterns aren't supported yet" Location.pp loc in From db051e7d3b891f91f114e2269c2e8697066855bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Suzanne=20Dup=C3=A9ron?= Date: Wed, 17 Jun 2020 22:37:39 +0100 Subject: [PATCH 2/7] Generic JSON pretty-printer for the typer's AST --- src/stages/5-ast_typed/PP_json.ml | 125 ++++++++++++++++++++++++++++ src/stages/5-ast_typed/ast_typed.ml | 1 + 2 files changed, 126 insertions(+) create mode 100644 src/stages/5-ast_typed/PP_json.ml diff --git a/src/stages/5-ast_typed/PP_json.ml b/src/stages/5-ast_typed/PP_json.ml new file mode 100644 index 000000000..191a30515 --- /dev/null +++ b/src/stages/5-ast_typed/PP_json.ml @@ -0,0 +1,125 @@ +open Types +open Fold +open Format +open PP_helpers + +module M = struct + type no_state = NoState + let needs_parens = { + generic = (fun NoState info -> + match info.node_instance.instance_kind with + | RecordInstance _ -> false + | VariantInstance _ -> true + | PolyInstance { poly =_; arguments=_; poly_continue } -> + (poly_continue NoState) + ); + generic_empty_ctor = (fun _ -> false) ; + type_variable = (fun _ _ _ -> true) ; + bool = (fun _ _ _ -> false) ; + int = (fun _ _ _ -> false) ; + z = (fun _ _ _ -> false) ; + string = (fun _ _ _ -> false) ; + ligo_string = (fun _ _ _ -> false) ; + bytes = (fun _ _ _ -> false) ; + unit = (fun _ _ _ -> false) ; + packed_internal_operation = (fun _ _ _ -> false) ; + expression_variable = (fun _ _ _ -> false) ; + constructor' = (fun _ _ _ -> false) ; + location = (fun _ _ _ -> false) ; + label = (fun _ _ _ -> false) ; + ast_core_type_expression = (fun _ _ _ -> true) ; + constructor_map = (fun _ _ _ _ -> false) ; + label_map = (fun _ _ _ _ -> false) ; + list = (fun _ _ _ _ -> false) ; + location_wrap = (fun _ _ _ _ -> false) ; + option = (fun _visitor _continue _state o -> + match o with None -> false | Some _ -> true) ; + poly_unionfind = (fun _ _ _ _ -> false) ; + poly_set = (fun _ _ _ _ -> false) ; + typeVariableMap = (fun _ _ _ _ -> false) ; + } + + let str ppf s = + fprintf ppf "\"%s\"" (Str.global_replace (Str.regexp_string "\"") "\\\"" s) + + let strpp pp ppf x = + fprintf ppf "\"%s\"" (asprintf "%a" pp x) + + let op ppf : (no_state, unit) fold_config = { + generic = (fun NoState info -> + match info.node_instance.instance_kind with + | RecordInstance { fields } -> + let aux ppf (fld : ('xi , 'xo) Adt_info.ctor_or_field_instance) = + fprintf ppf "%a: %a" str fld.cf.name (fun _ppf -> fld.cf_continue) NoState in + fprintf ppf "{ %a }" (list_sep aux (fun ppf () -> fprintf ppf " ;@ ")) fields + | VariantInstance { constructor ; _ } -> + if constructor.cf_new_fold needs_parens NoState + then fprintf ppf "[ %a , %a ]" str constructor.cf.name (fun _ppf -> constructor.cf_continue) NoState + else let spc = if String.equal constructor.cf.type_ "" then "" else " , " in + fprintf ppf "%a%s%a" str constructor.cf.name spc (fun _ppf -> constructor.cf_continue) NoState + | PolyInstance { poly=_; arguments=_; poly_continue } -> + (poly_continue NoState) + ); + generic_empty_ctor = (fun NoState -> ()) ; + int = (fun _visitor NoState i -> fprintf ppf "%i" i ); + type_variable = (fun _visitor NoState type_variable -> fprintf ppf "Var %a" (strpp Var.pp) type_variable) ; + bool = (fun _visitor NoState b -> fprintf ppf "%s" (if b then "true" else "false")) ; + z = (fun _visitor NoState i -> fprintf ppf "%a" Z.pp_print i) ; + string = (fun _visitor NoState str -> fprintf ppf "\"%s\"" str) ; + ligo_string = (fun _visitor NoState s -> fprintf ppf "%a" str (match s with Standard s -> s | Verbatim s -> s)) ; + bytes = (fun _visitor NoState _bytes -> fprintf ppf "\"bytes...\"") ; + unit = (fun _visitor NoState () -> fprintf ppf "\"unit\"") ; + packed_internal_operation = (fun _visitor NoState _op -> fprintf ppf "\"Operation(...bytes)\"") ; + expression_variable = (fun _visitor NoState ev -> fprintf ppf "%a" (strpp Var.pp) ev) ; + constructor' = (fun _visitor NoState (Constructor c) -> fprintf ppf "[ \"Constructor\" %a]" str c) ; + location = (fun _visitor NoState loc -> fprintf ppf "%a" (strpp Location.pp) loc) ; + label = (fun _visitor NoState (Label lbl) -> fprintf ppf "[ \"Label\" , %a ]" str lbl) ; + ast_core_type_expression = (fun _visitor NoState te -> fprintf ppf "%a" (strpp Ast_core.PP.type_expression) te) ; + constructor_map = (fun _visitor continue NoState cmap -> + let lst = List.sort (fun (Constructor a, _) (Constructor b, _) -> String.compare a b) (CMap.bindings cmap) in + let aux ppf (Constructor k, v) = + fprintf ppf "%a: %a" str k (fun _ppf -> continue NoState) v in + fprintf ppf "{ %a }" (list_sep aux (fun ppf () -> fprintf ppf " ; ")) lst); + label_map = (fun _visitor continue NoState lmap -> + let lst = List.sort (fun (Label a, _) (Label b, _) -> String.compare a b) (LMap.bindings lmap) in + let aux ppf (Label k, v) = + fprintf ppf "%a: %a" str k (fun _ppf -> continue NoState) v in + fprintf ppf "{ %a }" (list_sep aux (fun ppf () -> fprintf ppf " ; ")) lst); + list = (fun _visitor continue NoState lst -> + let aux ppf elt = + fprintf ppf "%a" (fun _ppf -> continue NoState) elt in + fprintf ppf "[ \"List\" %a ]" (list_sep aux (fun ppf () -> fprintf ppf " , ")) lst); + location_wrap = (fun _visitor continue NoState lwrap -> + let ({ wrap_content; location } : _ Location.wrap) = lwrap in + fprintf ppf "{ \"wrap_content\": %a ; \"location\" = %a }" (fun _ppf -> continue NoState) wrap_content (strpp Location.pp) location); + option = (fun _visitor continue NoState o -> + match o with + | None -> fprintf ppf "\"None\"" + | Some v -> fprintf ppf "[\"Some\" , %a]" (fun _ppf -> continue NoState) v) ; + poly_unionfind = (fun _visitor continue NoState p -> + let lst = (UnionFind.Poly2.partitions p) in + let aux1 l = fprintf ppf "[ %a ]" + (* (fun _ppf -> continue NoState) (UnionFind.Poly2.repr (List.hd l) p) *) + (list_sep (fun _ppf -> continue NoState) (fun ppf () -> fprintf ppf " , ")) l in + let aux2 = list_sep (fun _ppf -> aux1) (fun ppf () -> fprintf ppf " , ") in + fprintf ppf "[ \"UnionFind\" %a ]" aux2 lst); + poly_set = (fun _visitor continue NoState set -> + let lst = (RedBlackTrees.PolySet.elements set) in + fprintf ppf "[ \"Set\" %a ]" (list_sep (fun _ppf -> continue NoState) (fun ppf () -> fprintf ppf " , ")) lst); + typeVariableMap = (fun _visitor continue NoState tvmap -> + let lst = List.sort (fun (a, _) (b, _) -> Var.compare a b) (RedBlackTrees.PolyMap.bindings tvmap) in + let aux ppf (k, v) = + fprintf ppf "[ %a , %a ]" Var.pp k (fun _ppf -> continue NoState) v in + fprintf ppf "[ \"typeVariableMap\" %a ]" (list_sep aux (fun ppf () -> fprintf ppf " , ")) lst); + } + + let print : ((no_state, unit) fold_config -> no_state -> 'a -> unit) -> formatter -> 'a -> unit = fun fold ppf v -> + fold (op ppf) NoState v +end + +include Fold.Folds(struct + type in_state = M.no_state ;; + type out_state = unit ;; + type 'a t = formatter -> 'a -> unit ;; + let f = M.print ;; +end) diff --git a/src/stages/5-ast_typed/ast_typed.ml b/src/stages/5-ast_typed/ast_typed.ml index 09134e0fd..99f048844 100644 --- a/src/stages/5-ast_typed/ast_typed.ml +++ b/src/stages/5-ast_typed/ast_typed.ml @@ -4,6 +4,7 @@ module PP = PP module PP_generic = PP_generic module Compare_generic = Compare_generic module Formatter = Formatter +module PP_json = PP_json module Combinators = struct include Combinators end From b4bf0ae159589cd848d2a10ea096361f03dfdac6 Mon Sep 17 00:00:00 2001 From: Lesenechal Remi Date: Mon, 22 Jun 2020 19:10:31 +0200 Subject: [PATCH 3/7] using yojson to print typed AST program --- src/stages/5-ast_typed/PP_json.ml | 144 +++++++++++----------------- src/stages/5-ast_typed/formatter.ml | 4 +- 2 files changed, 57 insertions(+), 91 deletions(-) diff --git a/src/stages/5-ast_typed/PP_json.ml b/src/stages/5-ast_typed/PP_json.ml index 191a30515..c7ee73949 100644 --- a/src/stages/5-ast_typed/PP_json.ml +++ b/src/stages/5-ast_typed/PP_json.ml @@ -1,125 +1,93 @@ open Types open Fold open Format -open PP_helpers + +type json = Yojson.Basic.t module M = struct type no_state = NoState - let needs_parens = { - generic = (fun NoState info -> - match info.node_instance.instance_kind with - | RecordInstance _ -> false - | VariantInstance _ -> true - | PolyInstance { poly =_; arguments=_; poly_continue } -> - (poly_continue NoState) - ); - generic_empty_ctor = (fun _ -> false) ; - type_variable = (fun _ _ _ -> true) ; - bool = (fun _ _ _ -> false) ; - int = (fun _ _ _ -> false) ; - z = (fun _ _ _ -> false) ; - string = (fun _ _ _ -> false) ; - ligo_string = (fun _ _ _ -> false) ; - bytes = (fun _ _ _ -> false) ; - unit = (fun _ _ _ -> false) ; - packed_internal_operation = (fun _ _ _ -> false) ; - expression_variable = (fun _ _ _ -> false) ; - constructor' = (fun _ _ _ -> false) ; - location = (fun _ _ _ -> false) ; - label = (fun _ _ _ -> false) ; - ast_core_type_expression = (fun _ _ _ -> true) ; - constructor_map = (fun _ _ _ _ -> false) ; - label_map = (fun _ _ _ _ -> false) ; - list = (fun _ _ _ _ -> false) ; - location_wrap = (fun _ _ _ _ -> false) ; - option = (fun _visitor _continue _state o -> - match o with None -> false | Some _ -> true) ; - poly_unionfind = (fun _ _ _ _ -> false) ; - poly_set = (fun _ _ _ _ -> false) ; - typeVariableMap = (fun _ _ _ _ -> false) ; - } - let str ppf s = - fprintf ppf "\"%s\"" (Str.global_replace (Str.regexp_string "\"") "\\\"" s) - - let strpp pp ppf x = - fprintf ppf "\"%s\"" (asprintf "%a" pp x) - - let op ppf : (no_state, unit) fold_config = { + let to_json : (no_state, json) fold_config = { generic = (fun NoState info -> match info.node_instance.instance_kind with | RecordInstance { fields } -> - let aux ppf (fld : ('xi , 'xo) Adt_info.ctor_or_field_instance) = - fprintf ppf "%a: %a" str fld.cf.name (fun _ppf -> fld.cf_continue) NoState in - fprintf ppf "{ %a }" (list_sep aux (fun ppf () -> fprintf ppf " ;@ ")) fields + let fields' = List.fold_left + (fun acc (fld : ('xi, json) Adt_info.ctor_or_field_instance) -> (fld.cf.name, fld.cf_continue NoState)::acc) + [] fields + in + `Assoc fields' | VariantInstance { constructor ; _ } -> - if constructor.cf_new_fold needs_parens NoState - then fprintf ppf "[ %a , %a ]" str constructor.cf.name (fun _ppf -> constructor.cf_continue) NoState - else let spc = if String.equal constructor.cf.type_ "" then "" else " , " in - fprintf ppf "%a%s%a" str constructor.cf.name spc (fun _ppf -> constructor.cf_continue) NoState + `List [ `String constructor.cf.name ; constructor.cf_continue NoState ] | PolyInstance { poly=_; arguments=_; poly_continue } -> (poly_continue NoState) ); - generic_empty_ctor = (fun NoState -> ()) ; - int = (fun _visitor NoState i -> fprintf ppf "%i" i ); - type_variable = (fun _visitor NoState type_variable -> fprintf ppf "Var %a" (strpp Var.pp) type_variable) ; - bool = (fun _visitor NoState b -> fprintf ppf "%s" (if b then "true" else "false")) ; - z = (fun _visitor NoState i -> fprintf ppf "%a" Z.pp_print i) ; - string = (fun _visitor NoState str -> fprintf ppf "\"%s\"" str) ; - ligo_string = (fun _visitor NoState s -> fprintf ppf "%a" str (match s with Standard s -> s | Verbatim s -> s)) ; - bytes = (fun _visitor NoState _bytes -> fprintf ppf "\"bytes...\"") ; - unit = (fun _visitor NoState () -> fprintf ppf "\"unit\"") ; - packed_internal_operation = (fun _visitor NoState _op -> fprintf ppf "\"Operation(...bytes)\"") ; - expression_variable = (fun _visitor NoState ev -> fprintf ppf "%a" (strpp Var.pp) ev) ; - constructor' = (fun _visitor NoState (Constructor c) -> fprintf ppf "[ \"Constructor\" %a]" str c) ; - location = (fun _visitor NoState loc -> fprintf ppf "%a" (strpp Location.pp) loc) ; - label = (fun _visitor NoState (Label lbl) -> fprintf ppf "[ \"Label\" , %a ]" str lbl) ; - ast_core_type_expression = (fun _visitor NoState te -> fprintf ppf "%a" (strpp Ast_core.PP.type_expression) te) ; + generic_empty_ctor = (fun NoState -> `Null ) ; + int = (fun _visitor NoState i -> `Int i ) ; + type_variable = (fun _visitor NoState tv -> `Assoc ["type-var", `String (asprintf "%a" Var.pp tv)] ) ; + bool = (fun _visitor NoState b -> `Bool b ) ; + z = (fun _visitor NoState i -> `String (asprintf "%a" Z.pp_print i) ) ; + string = (fun _visitor NoState str -> `String str ) ; + ligo_string = (fun _visitor NoState s -> `String (asprintf "%s" (match s with Standard s -> s | Verbatim s -> s)) ) ; + bytes = (fun _visitor NoState bytes -> `String (Bytes.to_string bytes)) ; + unit = (fun _visitor NoState () -> `String "unit" ) ; + packed_internal_operation = (fun _visitor NoState _op -> `String "Operation(...bytes)") ; + expression_variable = (fun _visitor NoState ev -> `Assoc ["exp-var", `String (asprintf "%a" Var.pp ev)] ) ; + constructor' = (fun _visitor NoState (Constructor c) -> `Assoc ["constructor", `String c] ) ; + location = (fun _visitor NoState loc -> `String (asprintf "%a" Location.pp loc) ) ; (*TODO*) + label = (fun _visitor NoState (Label lbl) -> `Assoc ["label" , `String lbl] ) ; + ast_core_type_expression = (fun _visitor NoState te -> `String (asprintf "%a" (Ast_core.PP.type_expression) te) ) ; (*TODO*) constructor_map = (fun _visitor continue NoState cmap -> let lst = List.sort (fun (Constructor a, _) (Constructor b, _) -> String.compare a b) (CMap.bindings cmap) in - let aux ppf (Constructor k, v) = - fprintf ppf "%a: %a" str k (fun _ppf -> continue NoState) v in - fprintf ppf "{ %a }" (list_sep aux (fun ppf () -> fprintf ppf " ; ")) lst); + let lst' = List.fold_left + (fun acc (Constructor k, v) -> (k , continue NoState v)::acc) + [] lst + in + `Assoc lst' ); label_map = (fun _visitor continue NoState lmap -> let lst = List.sort (fun (Label a, _) (Label b, _) -> String.compare a b) (LMap.bindings lmap) in - let aux ppf (Label k, v) = - fprintf ppf "%a: %a" str k (fun _ppf -> continue NoState) v in - fprintf ppf "{ %a }" (list_sep aux (fun ppf () -> fprintf ppf " ; ")) lst); + let lst' = List.fold_left + (fun acc (Label k, v) -> (k , continue NoState v)::acc) + [] lst + in + `Assoc lst' ); list = (fun _visitor continue NoState lst -> - let aux ppf elt = - fprintf ppf "%a" (fun _ppf -> continue NoState) elt in - fprintf ppf "[ \"List\" %a ]" (list_sep aux (fun ppf () -> fprintf ppf " , ")) lst); + let aux elt = continue NoState elt in + `List (List.map aux lst) ); location_wrap = (fun _visitor continue NoState lwrap -> let ({ wrap_content; location } : _ Location.wrap) = lwrap in - fprintf ppf "{ \"wrap_content\": %a ; \"location\" = %a }" (fun _ppf -> continue NoState) wrap_content (strpp Location.pp) location); + `Assoc [("wrap_content", continue NoState wrap_content) ; ("location", `String (asprintf "%a" Location.pp location))] ); (*TODO*) option = (fun _visitor continue NoState o -> match o with - | None -> fprintf ppf "\"None\"" - | Some v -> fprintf ppf "[\"Some\" , %a]" (fun _ppf -> continue NoState) v) ; + | None -> `Null + | Some v -> continue NoState v ); poly_unionfind = (fun _visitor continue NoState p -> let lst = (UnionFind.Poly2.partitions p) in - let aux1 l = fprintf ppf "[ %a ]" - (* (fun _ppf -> continue NoState) (UnionFind.Poly2.repr (List.hd l) p) *) - (list_sep (fun _ppf -> continue NoState) (fun ppf () -> fprintf ppf " , ")) l in - let aux2 = list_sep (fun _ppf -> aux1) (fun ppf () -> fprintf ppf " , ") in - fprintf ppf "[ \"UnionFind\" %a ]" aux2 lst); + let lst' = List.map (fun l -> continue NoState (UnionFind.Poly2.repr (List.hd l) p )) lst in + `Assoc ["UnionFind", `List lst'] ); poly_set = (fun _visitor continue NoState set -> let lst = (RedBlackTrees.PolySet.elements set) in - fprintf ppf "[ \"Set\" %a ]" (list_sep (fun _ppf -> continue NoState) (fun ppf () -> fprintf ppf " , ")) lst); + let lst' = List.map (fun el -> continue NoState el) lst in + `Assoc ["Set", `List lst'] ); typeVariableMap = (fun _visitor continue NoState tvmap -> let lst = List.sort (fun (a, _) (b, _) -> Var.compare a b) (RedBlackTrees.PolyMap.bindings tvmap) in - let aux ppf (k, v) = - fprintf ppf "[ %a , %a ]" Var.pp k (fun _ppf -> continue NoState) v in - fprintf ppf "[ \"typeVariableMap\" %a ]" (list_sep aux (fun ppf () -> fprintf ppf " , ")) lst); + let aux (k, v) = + `Assoc [ ("key", `String (asprintf "%a" Var.pp k)) ; ("value", continue NoState v) ] in + let lst' = List.map aux lst in + `Assoc ["typeVariableMap", `List lst'] ); } - let print : ((no_state, unit) fold_config -> no_state -> 'a -> unit) -> formatter -> 'a -> unit = fun fold ppf v -> - fold (op ppf) NoState v + let print : ((no_state, json) fold_config -> no_state -> 'a -> json) -> 'a -> json = fun fold v -> + fold to_json NoState v end include Fold.Folds(struct type in_state = M.no_state ;; - type out_state = unit ;; - type 'a t = formatter -> 'a -> unit ;; + type out_state = json ;; + type 'a t = 'a -> json ;; let f = M.print ;; end) + + (* type in_state + type out_state + type 'a t + val f : ((in_state , out_state) fold_config -> in_state -> 'a -> out_state) -> 'a t *) \ No newline at end of file diff --git a/src/stages/5-ast_typed/formatter.ml b/src/stages/5-ast_typed/formatter.ml index 319342fff..f6c331722 100644 --- a/src/stages/5-ast_typed/formatter.ml +++ b/src/stages/5-ast_typed/formatter.ml @@ -4,9 +4,7 @@ let program_ppformat ~display_format f (typed,_) = match display_format with | Human_readable | Dev -> PP.program f typed -let program_jsonformat (typed,_) : json = - let core' = Format.asprintf "%a" PP.program typed in - `Assoc [("Typed(temp)" , `String core')] +let program_jsonformat (typed,_) : json = PP_json.program typed let program_format : 'a format = { pp = program_ppformat; From d743605aeed74f41d12aaa8a82c7b9acfddeda85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Lesenechal?= Date: Tue, 23 Jun 2020 11:27:09 +0000 Subject: [PATCH 4/7] Apply 1 suggestion(s) to 1 file(s) --- src/stages/5-ast_typed/PP_json.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stages/5-ast_typed/PP_json.ml b/src/stages/5-ast_typed/PP_json.ml index c7ee73949..55f39776f 100644 --- a/src/stages/5-ast_typed/PP_json.ml +++ b/src/stages/5-ast_typed/PP_json.ml @@ -59,7 +59,7 @@ module M = struct option = (fun _visitor continue NoState o -> match o with | None -> `Null - | Some v -> continue NoState v ); + | Some v -> `List [ `String "Some" ; continue NoState v ] ); poly_unionfind = (fun _visitor continue NoState p -> let lst = (UnionFind.Poly2.partitions p) in let lst' = List.map (fun l -> continue NoState (UnionFind.Poly2.repr (List.hd l) p )) lst in From 27d7856e52977d62edbe00da5602dede5c072445 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Lesenechal?= Date: Tue, 23 Jun 2020 11:27:29 +0000 Subject: [PATCH 5/7] Apply 1 suggestion(s) to 1 file(s) --- src/stages/5-ast_typed/PP_json.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stages/5-ast_typed/PP_json.ml b/src/stages/5-ast_typed/PP_json.ml index 55f39776f..2a17e0fc0 100644 --- a/src/stages/5-ast_typed/PP_json.ml +++ b/src/stages/5-ast_typed/PP_json.ml @@ -71,7 +71,7 @@ module M = struct typeVariableMap = (fun _visitor continue NoState tvmap -> let lst = List.sort (fun (a, _) (b, _) -> Var.compare a b) (RedBlackTrees.PolyMap.bindings tvmap) in let aux (k, v) = - `Assoc [ ("key", `String (asprintf "%a" Var.pp k)) ; ("value", continue NoState v) ] in + `Assoc [ asprintf "%a" Var.pp k ; continue NoState v ] in let lst' = List.map aux lst in `Assoc ["typeVariableMap", `List lst'] ); } From 362e33c7f913d2594f872acd34d6042ea86809d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Lesenechal?= Date: Tue, 23 Jun 2020 11:27:32 +0000 Subject: [PATCH 6/7] Apply 1 suggestion(s) to 1 file(s) --- src/stages/5-ast_typed/PP_json.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stages/5-ast_typed/PP_json.ml b/src/stages/5-ast_typed/PP_json.ml index 2a17e0fc0..1156d4038 100644 --- a/src/stages/5-ast_typed/PP_json.ml +++ b/src/stages/5-ast_typed/PP_json.ml @@ -58,7 +58,7 @@ module M = struct `Assoc [("wrap_content", continue NoState wrap_content) ; ("location", `String (asprintf "%a" Location.pp location))] ); (*TODO*) option = (fun _visitor continue NoState o -> match o with - | None -> `Null + | None -> `List [ `String "None" ; `Null ] | Some v -> `List [ `String "Some" ; continue NoState v ] ); poly_unionfind = (fun _visitor continue NoState p -> let lst = (UnionFind.Poly2.partitions p) in From 2351dda44e3ff9c2d9c4f094f851f1f03e164086 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Lesenechal?= Date: Tue, 23 Jun 2020 11:30:04 +0000 Subject: [PATCH 7/7] Apply 1 suggestion(s) to 1 file(s) --- src/stages/5-ast_typed/PP_json.ml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/stages/5-ast_typed/PP_json.ml b/src/stages/5-ast_typed/PP_json.ml index 1156d4038..745483ebc 100644 --- a/src/stages/5-ast_typed/PP_json.ml +++ b/src/stages/5-ast_typed/PP_json.ml @@ -71,7 +71,7 @@ module M = struct typeVariableMap = (fun _visitor continue NoState tvmap -> let lst = List.sort (fun (a, _) (b, _) -> Var.compare a b) (RedBlackTrees.PolyMap.bindings tvmap) in let aux (k, v) = - `Assoc [ asprintf "%a" Var.pp k ; continue NoState v ] in + `Assoc [ asprintf "%a" Var.pp k , continue NoState v ] in let lst' = List.map aux lst in `Assoc ["typeVariableMap", `List lst'] ); } @@ -86,8 +86,3 @@ include Fold.Folds(struct type 'a t = 'a -> json ;; let f = M.print ;; end) - - (* type in_state - type out_state - type 'a t - val f : ((in_state , out_state) fold_config -> in_state -> 'a -> out_state) -> 'a t *) \ No newline at end of file