Browse thread
Upgrading sexplib-2.7.0 to camlp4 3.10
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2007-05-03 (05:59) |
From: | Dmitry Bely <dmitry.bely@g...> |
Subject: | Re: [Caml-list] camlp4 3.10: Matching variant types |
Probably the following is related to Joel's questions on variant type matching. I am trying to convert IoXML syntax extension to the new camlp4. Currently I am stuck here: ... value gen_output_cons (loc, c, tl) = let p = let p = <:patt< $uid:c$ >> in let (p, _) = List.fold_left (fun (p, cnt) _ -> let p = <:patt< $p$ $lid:pname cnt$ >> in (p, cnt + 1)) (p, 1) tl in p in let e = gen_xprint_cons loc c tl in (p, None, e) ; ... value gen_output_sum loc cdl = let mc = List.fold_right (fun cd mc -> let (p, _, e) = gen_output_cons cd in <:match_case< $p$ -> $e$ | $mc$ >>) cdl <:match_case<>> in <:expr< fun ppf -> fun [ $mc$ ] >> ; ... value gen_output_funs loc tdl sil = let pel = List.fold_right (fun ((loc, n), tpl, tk, cl) pel -> let body = loop tk where rec loop = fun [ <:ctyp< [ $cdl$ ] >> -> gen_output_sum loc cdl File "pa_ioXML.ml", line 257, characters 58-61: This expression has type Camlp4.PreCast.Ast.ctyp but is here used with type (Camlp4.PreCast.Ast.Loc.t * string * Camlp4.PreCast.Ast.ctyp list) list As usual: (cdl) was a list before, now it is not. Is were a simple way to get a list and make (gen_output_sum) happy? Or this should be complete rewritten - how? - Dmitry Bely