You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original bug ID: 4452 Reporter: eaubin Assigned to:@bobzhang Status: closed (set by @xavierleroy on 2015-12-11T18:21:12Z) Resolution: not a bug Priority: normal Severity: minor Version: 3.10.0 Target version: 4.01.0+dev Category: -for Camlp4 use https://github.com/ocaml/camlp4/issues
module rec b :
sig
type record =
{ key : int; f1 : f1.record; f2 : f2.record;
(((((((((((((((((((((((((((((((((((((((((((...
I'm probably doing something wrong creating the list of fields. How should this be done? Thanks
Additional information
open Camlp4.PreCast
let _loc = Loc.mk "?"
let base base fields ty =
let fields = List.fold_right (fun field acc ->
let c = <:ctyp< $lid:field$ : $uid:field$.record >> in
<:ctyp< $c$ ; $acc$ >>) fields <:ctyp< >>
in
<:module_binding< $uid:base$ :
sig type record = {
key : $ty$; $fields$
} end = struct
type record = {
key : $ty$; $fields$
} end
>>
let _ =
let b = base "b" ["f1"; "f2"] <:ctyp< int >> in
Camlp4.PreCast.Printers.OCaml.print_implem
<:str_item< module rec $b$ >>
The text was updated successfully, but these errors were encountered:
You should use CleanAst to remove useless nil nodes.
module CleanAst = Camlp4.Struct.CleanAst.Make(Ast)
let _ =
let b = base "b" ["f1"; "f2"] <:ctyp< int >> in
Camlp4.PreCast.Printers.OCaml.print_implem
((new CleanAst.clean_ast)#str_item
<:str_item< module rec $b$ >>)
However I don't know if clean ast should be called by print_implem. I've not done it since I don't want it to be called too often since it costs. For now it's called in the main of camlp4 before printing (camlp4/Camlp4Bin.ml).
Original bug ID: 4452
Reporter: eaubin
Assigned to: @bobzhang
Status: closed (set by @xavierleroy on 2015-12-11T18:21:12Z)
Resolution: not a bug
Priority: normal
Severity: minor
Version: 3.10.0
Target version: 4.01.0+dev
Category: -for Camlp4 use https://github.com/ocaml/camlp4/issues
Bug description
Camlp4.PreCast.Printers.OCaml.print_implem loops printing
module rec b :
sig
type record =
{ key : int; f1 : f1.record; f2 : f2.record;
(((((((((((((((((((((((((((((((((((((((((((...
I'm probably doing something wrong creating the list of fields. How should this be done? Thanks
Additional information
open Camlp4.PreCast
let _loc = Loc.mk "?"
let base base fields ty =$lid:field$ : $uid:field$ .record >> in$c$ ; $acc$ >>) fields <:ctyp< >>$uid:base$ :$ty$ ;
$fields$ $ty$ ;
$fields$
let fields = List.fold_right (fun field acc ->
let c = <:ctyp<
<:ctyp<
in
<:module_binding<
sig type record = {
key :
} end = struct
type record = {
key :
} end
>>
let _ =$b$ >>
let b = base "b" ["f1"; "f2"] <:ctyp< int >> in
Camlp4.PreCast.Printers.OCaml.print_implem
<:str_item< module rec
The text was updated successfully, but these errors were encountered: