use Yojson.t isntead of Yojson.Basic.t

This commit is contained in:
Lesenechal Remi 2020-06-24 12:11:12 +02:00
parent bff67e3779
commit ca2ec3d795
17 changed files with 17 additions and 33 deletions

View File

@ -13,7 +13,7 @@ let toplevel : display_format:ex_display_format -> displayable -> (unit -> unit
match t with match t with
| Human_readable -> convert ~display_format:t disp ; | Human_readable -> convert ~display_format:t disp ;
| Dev -> convert ~display_format:t disp ; | Dev -> convert ~display_format:t disp ;
| Json -> Yojson.Basic.to_string @@ convert ~display_format:t disp in | Json -> Yojson.to_string @@ convert ~display_format:t disp in
Format.printf "%s\n" as_str ; Format.printf "%s\n" as_str ;
return () return ()

View File

@ -1,4 +1,3 @@
open Trace
open Display open Display
let error_suggest: string = "\n let error_suggest: string = "\n
@ -147,7 +146,7 @@ let error_ppformat : display_format:string display_format ->
(error_ppformat' ~display_format) a (error_ppformat' ~display_format) a
error_suggest error_suggest
let rec error_jsonformat : Types.all -> J.t = fun a -> let rec error_jsonformat : Types.all -> Yojson.t = fun a ->
let json_error ~stage ~content = let json_error ~stage ~content =
`Assoc [ `Assoc [
("status", `String "error") ; ("status", `String "error") ;

View File

@ -1,4 +1,3 @@
open Trace
open Simple_utils.Display open Simple_utils.Display
module CST = Cst.Cameligo module CST = Cst.Cameligo
@ -49,7 +48,7 @@ let error_ppformat : display_format:string display_format ->
Format.pp_print_string f s ; Format.pp_print_string f s ;
) )
let error_jsonformat : parser_error -> J.t = fun a -> let error_jsonformat : parser_error -> Yojson.t = fun a ->
let json_error ~stage ~content = let json_error ~stage ~content =
`Assoc [ `Assoc [
("status", `String "error") ; ("status", `String "error") ;

View File

@ -1,4 +1,3 @@
open Trace
open Simple_utils.Display open Simple_utils.Display
module Raw = Cst.Cameligo module Raw = Cst.Cameligo
@ -147,7 +146,7 @@ let rec error_ppformat : display_format:string display_format ->
) )
let rec error_jsonformat : abs_error -> J.t = fun a -> let rec error_jsonformat : abs_error -> Yojson.t = fun a ->
let json_error ~stage ~content = let json_error ~stage ~content =
`Assoc [ `Assoc [
("status", `String "error") ; ("status", `String "error") ;

View File

@ -1,4 +1,3 @@
open Trace
open Simple_utils.Display open Simple_utils.Display
module Raw = Cst.Pascaligo module Raw = Cst.Pascaligo
@ -126,7 +125,7 @@ let rec error_ppformat : display_format:string display_format ->
) )
let rec error_jsonformat : abs_error -> J.t = fun a -> let rec error_jsonformat : abs_error -> Yojson.t = fun a ->
let json_error ~stage ~content = let json_error ~stage ~content =
`Assoc [ `Assoc [
("status", `String "error") ; ("status", `String "error") ;

View File

@ -1,6 +1,5 @@
open Simple_utils.Display open Simple_utils.Display
open Ast_imperative open Ast_imperative
open Trace
let stage = "self_ast_imperative" let stage = "self_ast_imperative"
@ -67,7 +66,7 @@ let error_ppformat : display_format:string display_format ->
Location.pp e.location Location.pp e.location
) )
let error_jsonformat : self_ast_imperative_error -> J.t = fun a -> let error_jsonformat : self_ast_imperative_error -> Yojson.t = fun a ->
let json_error ~stage ~content = let json_error ~stage ~content =
`Assoc [ `Assoc [
("status", `String "error") ; ("status", `String "error") ;

View File

@ -1,4 +1,3 @@
open Trace
open Simple_utils.Display open Simple_utils.Display
let stage = "purification" let stage = "purification"
@ -21,7 +20,7 @@ let error_ppformat : display_format:string display_format ->
s s
) )
let error_jsonformat : purification_error -> J.t = fun a -> let error_jsonformat : purification_error -> Yojson.t = fun a ->
let json_error ~stage ~content = let json_error ~stage ~content =
`Assoc [ `Assoc [
("status", `String "error") ; ("status", `String "error") ;

View File

@ -1,4 +1,3 @@
open Trace
open Simple_utils.Display open Simple_utils.Display
@ -580,7 +579,7 @@ let rec error_ppformat : display_format:string display_format ->
error_ppformat ~display_format f err error_ppformat ~display_format f err
) )
let rec error_jsonformat : typer_error -> J.t = fun a -> let rec error_jsonformat : typer_error -> Yojson.t = fun a ->
let json_error ~stage ~content = let json_error ~stage ~content =
`Assoc [ `Assoc [
("status", `String "error") ; ("status", `String "error") ;

View File

@ -1,5 +1,4 @@
open Simple_utils.Display open Simple_utils.Display
open Trace
let stage = "self_ast_typed" let stage = "self_ast_typed"
@ -104,7 +103,7 @@ let error_ppformat : display_format:string display_format ->
Location.pp loc Location.pp loc
) )
let error_jsonformat : self_ast_typed_error -> J.t = fun a -> let error_jsonformat : self_ast_typed_error -> Yojson.t = fun a ->
let json_error ~stage ~content = let json_error ~stage ~content =
`Assoc [ `Assoc [
("status", `String "error") ; ("status", `String "error") ;

View File

@ -1,4 +1,3 @@
open Trace
open Simple_utils.Display open Simple_utils.Display
type spilling_error = [ type spilling_error = [
@ -77,7 +76,7 @@ let rec error_ppformat : display_format:string display_format ->
Format.pp_print_string f s Format.pp_print_string f s
) )
let rec error_jsonformat : spilling_error -> J.t = fun a -> let rec error_jsonformat : spilling_error -> Yojson.t = fun a ->
let json_error ~stage ~content = let json_error ~stage ~content =
`Assoc [ `Assoc [
("status", `String "error") ; ("status", `String "error") ;

View File

@ -1,5 +1,4 @@
open Simple_utils.Display open Simple_utils.Display
open Trace
let stage = "self_mini_c" let stage = "self_mini_c"
@ -27,7 +26,7 @@ let error_ppformat : display_format:string display_format ->
| `Self_mini_c_aggregation -> Format.fprintf f "could not aggregate" | `Self_mini_c_aggregation -> Format.fprintf f "could not aggregate"
) )
let error_jsonformat : self_mini_c_error -> J.t = fun a -> let error_jsonformat : self_mini_c_error -> Yojson.t = fun a ->
let json_error ~stage ~content = let json_error ~stage ~content =
`Assoc [ `Assoc [
("status", `String "error") ; ("status", `String "error") ;

View File

@ -1,4 +1,3 @@
open Trace
open Simple_utils.Display open Simple_utils.Display
open Stage_common.Types open Stage_common.Types
@ -92,7 +91,7 @@ let rec error_ppformat : display_format:string display_format ->
Mini_c.PP.constant c Mini_c.PP.constant c
) )
let rec error_jsonformat : stacking_error -> J.t = fun a -> let rec error_jsonformat : stacking_error -> Yojson.t = fun a ->
let json_error ~stage ~content = let json_error ~stage ~content =
`Assoc [ `Assoc [
("status", `String "error") ; ("status", `String "error") ;

View File

@ -2,7 +2,7 @@ open Types
open Fold open Fold
open Format open Format
type json = Yojson.Basic.t type json = Yojson.t
module M = struct module M = struct
type no_state = NoState type no_state = NoState

View File

@ -9,7 +9,7 @@ let (|>) v f = f v
(* TODO: how should we plug these into our test framework? *) (* TODO: how should we plug these into our test framework? *)
let test (x : (unit,_) result) : unit = match x with let test (x : (unit,_) result) : unit = match x with
| Ok (() , _annotation_thunk) -> () | Ok (() , _annotation_thunk) -> ()
(* | Error err -> failwith (Yojson.Basic.to_string @@ err ()) *) (* | Error err -> failwith (Yojson.to_string @@ err ()) *)
| Error _err -> failwith ("TODO") | Error _err -> failwith ("TODO")
let () = let () =

View File

@ -1,4 +1,4 @@
type json = Yojson.Basic.t type json = Yojson.t
type 'a display_format = type 'a display_format =
| Human_readable : string display_format | Human_readable : string display_format

View File

@ -1,4 +1,4 @@
type json = Yojson.Basic.t type json = Yojson.t
type 'a display_format = type 'a display_format =
| Human_readable : string display_format | Human_readable : string display_format

View File

@ -212,15 +212,12 @@ module Trace_tutorial = struct
end (* end Trace_tutorial. *) end (* end Trace_tutorial. *)
module J = Yojson.Basic
(* Annotations should be used in debug mode to aggregate information (* Annotations should be used in debug mode to aggregate information
about some value history. Where it was produced, when it was about some value history. Where it was produced, when it was
modified, etc. It is currently not being used. *) modified, etc. It is currently not being used. *)
type 'a thunk = unit -> 'a type 'a thunk = unit -> 'a
type annotation = J.t type annotation = Yojson.t
(* Even in debug mode, building annotations can be quite (* Even in debug mode, building annotations can be quite
resource-intensive. Instead, a thunk is passed, that is computed resource-intensive. Instead, a thunk is passed, that is computed
@ -554,5 +551,3 @@ module Assert = struct
assert_true err List.(length lsta = length lstb) assert_true err List.(length lsta = length lstb)
end end
let json_of_error = J.to_string