From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.1.3 Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 7F982BC69 for ; Tue, 20 Feb 2007 10:45:37 +0100 (CET) Received: from triton.rz.uni-saarland.de (triton.rz.uni-saarland.de [134.96.7.25]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l1K9ja6u002633 for ; Tue, 20 Feb 2007 10:45:37 +0100 Received: from uni-sb.de (uni-sb.de [134.96.7.230]) by triton.rz.uni-saarland.de (8.12.11.20060614/8.12.10) with ESMTP id l1K9jaho1760305 for ; Tue, 20 Feb 2007 10:45:36 +0100 (CET) Received: from mail.cs.uni-sb.de (mail.cs.uni-sb.de [134.96.254.200]) by uni-sb.de (8.14.0/2007012900) with ESMTP id l1K9jaor016310 for ; Tue, 20 Feb 2007 10:45:36 +0100 (CET) Received: from mail.st.cs.uni-sb.de (goscinny.cs.uni-sb.de [134.96.235.32]) by mail.cs.uni-sb.de (8.14.0/2007012900) with ESMTP id l1K9jZNd011348 for ; Tue, 20 Feb 2007 10:45:35 +0100 (CET) Received: from [134.96.235.120] (qwerty.cs.uni-sb.de [134.96.235.120]) by mail.st.cs.uni-sb.de (Postfix) with ESMTP id 77DE16B671 for ; Tue, 20 Feb 2007 10:45:35 +0100 (CET) Mime-Version: 1.0 (Apple Message framework v752.3) To: Caml List Message-Id: <0FF9569C-EDF8-4D11-AC9C-B50CAEFE1D7E@cs.uni-sb.de> Content-Type: multipart/mixed; boundary=Apple-Mail-5-383890904 References: From: Christian Lindig Subject: inspecting abstract values in the debugger Date: Tue, 20 Feb 2007 10:43:39 +0100 X-Mailer: Apple Mail (2.752.3) X-AntiVirus: checked by AntiVir Milter (version: 1.1.3-1; AVE: 7.3.1.37; VDF: 6.37.1.118; host: AntiVir1) X-Miltered: at concorde with ID 45DAC341.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; lindig:01 lindig:01 debugger:01 debugger:01 debugging:01 cmi:01 mli:01 cmi:01 mli:01 debugging:01 makefiles:01 compiler:01 implicitly:01 compiler:01 ocamlc:01 X-Attachments: type="application/octet-stream" name="ocaml-3.09.3.patch" name="ocaml-3.09.3.patch" --Apple-Mail-5-383890904 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed In the debugger, abstract values cannot be inspected. This can be annoying since it gets in the way of understanding why something doesn't work. At least for debugging we would like all types to be fully declared such that we can inspect their values in the debugger. A quick fix is to remove all .cmi and .mli files and to compile a project again. Then at least all top-level types would be manifest and the debugger could print them. It would still not work for sub structures since they could be still constraint by interfaces. Another problem is that removing .cmi and .mli files temporarily for debugging does not work too well with Makefiles. Therefore I'd like to discuss a feature wish: a compiler flag that makes all type declarations manifest. When compiling a signature ascription - whether per explicit ":" operator or implicitly per .mli file - the compiler would automatically refine the signature to make all types manifest. In the case of .mli's this might require replacing an existing .cmi file. As a crude first approximation I am supplying a patch below that introduces such a flag. The -ignore-cmi flag makes the ocamlc compiler behave as if no .cmi/.mli file exists, hence it creates a new one that hides nothing. As explained above, this only works on the outermost level and therefore is not ideal. I'd expect that the correct solution is not too hard to implement for somebody who understands the type checker. Beware: sometimes the type annotations provided by an .mli file are necessary and compiling with -ignore-cmi might not work. In this case either compile the one file without -ignore-cmi, or supply the type annotation in the .ml file. -- Christian --Apple-Mail-5-383890904 Content-Transfer-Encoding: 7bit Content-Type: application/octet-stream; x-unix-mode=0664; name=ocaml-3.09.3.patch Content-Disposition: attachment; filename=ocaml-3.09.3.patch diff -c -r -x '*.cmo' -x '*.cmi' -x '*.[oa]' ocaml-3.09.3/driver/main.ml ocaml-3.09.3-patched/driver/main.ml *** ocaml-3.09.3/driver/main.ml Mon May 9 15:39:17 2005 --- ocaml-3.09.3-patched/driver/main.ml Sat Feb 17 22:15:03 2007 *************** *** 134,139 **** --- 134,140 ---- let _drawlambda = set dump_rawlambda let _dlambda = set dump_lambda let _dinstr = set dump_instr + let _ignore_cmi = set ignore_cmi let anonymous = anonymous end) diff -c -r -x '*.cmo' -x '*.cmi' -x '*.[oa]' ocaml-3.09.3/driver/main_args.ml ocaml-3.09.3-patched/driver/main_args.ml *** ocaml-3.09.3/driver/main_args.ml Wed Dec 28 18:27:03 2005 --- ocaml-3.09.3-patched/driver/main_args.ml Sat Feb 17 22:18:10 2007 *************** *** 60,65 **** --- 60,66 ---- val _drawlambda : unit -> unit val _dlambda : unit -> unit val _dinstr : unit -> unit + val _ignore_cmi : unit -> unit val anonymous : string -> unit end) = struct *************** *** 158,164 **** "-dlambda", Arg.Unit F._dlambda, " (undocumented)"; "-dinstr", Arg.Unit F._dinstr, " (undocumented)"; "-use-prims", Arg.String F._use_prims, " (undocumented)"; ! "-", Arg.String F.anonymous, " Treat as a file name (even if it starts with `-')"; ] --- 159,165 ---- "-dlambda", Arg.Unit F._dlambda, " (undocumented)"; "-dinstr", Arg.Unit F._dinstr, " (undocumented)"; "-use-prims", Arg.String F._use_prims, " (undocumented)"; ! "-ignore-cmi", Arg.Unit F._ignore_cmi, " ignore own cmi/mli file"; "-", Arg.String F.anonymous, " Treat as a file name (even if it starts with `-')"; ] diff -c -r -x '*.cmo' -x '*.cmi' -x '*.[oa]' ocaml-3.09.3/driver/main_args.mli ocaml-3.09.3-patched/driver/main_args.mli *** ocaml-3.09.3/driver/main_args.mli Mon May 9 15:39:17 2005 --- ocaml-3.09.3-patched/driver/main_args.mli Sat Feb 17 22:13:39 2007 *************** *** 60,65 **** --- 60,66 ---- val _drawlambda : unit -> unit val _dlambda : unit -> unit val _dinstr : unit -> unit + val _ignore_cmi: unit -> unit val anonymous : string -> unit end) : sig diff -c -r -x '*.cmo' -x '*.cmi' -x '*.[oa]' ocaml-3.09.3/tools/ocamlcp.ml ocaml-3.09.3-patched/tools/ocamlcp.ml *** ocaml-3.09.3/tools/ocamlcp.ml Mon May 9 15:39:17 2005 --- ocaml-3.09.3-patched/tools/ocamlcp.ml Sat Feb 17 22:20:10 2007 *************** *** 87,92 **** --- 87,93 ---- let _drawlambda = option "-drawlambda" let _dlambda = option "-dlambda" let _dinstr = option "-dinstr" + let _ignore_cmi = option "-ignore_cmi" let anonymous = process_file end);; diff -c -r -x '*.cmo' -x '*.cmi' -x '*.[oa]' ocaml-3.09.3/typing/typemod.ml ocaml-3.09.3-patched/typing/typemod.ml *** ocaml-3.09.3/typing/typemod.ml Fri Apr 21 08:18:51 2006 --- ocaml-3.09.3-patched/typing/typemod.ml Sun Feb 18 08:00:53 2007 *************** *** 793,799 **** let coercion = let sourceintf = Misc.chop_extension_if_any sourcefile ^ !Config.interface_suffix in ! if Sys.file_exists sourceintf then begin let intf_file = try find_in_path_uncap !Config.load_path (modulename ^ ".cmi") --- 793,799 ---- let coercion = let sourceintf = Misc.chop_extension_if_any sourcefile ^ !Config.interface_suffix in ! if Sys.file_exists sourceintf && not !Clflags.ignore_cmi then begin let intf_file = try find_in_path_uncap !Config.load_path (modulename ^ ".cmi") diff -c -r -x '*.cmo' -x '*.cmi' -x '*.[oa]' ocaml-3.09.3/utils/clflags.ml ocaml-3.09.3-patched/utils/clflags.ml *** ocaml-3.09.3/utils/clflags.ml Mon Aug 1 17:51:09 2005 --- ocaml-3.09.3-patched/utils/clflags.ml Sat Feb 17 22:16:22 2007 *************** *** 77,82 **** --- 77,83 ---- let native_code = ref false (* set to true under ocamlopt *) let inline_threshold = ref 10 + let ignore_cmi = ref false (* -ignore_cmi *) let dont_write_files = ref false (* set to true under ocamldoc *) diff -c -r -x '*.cmo' -x '*.cmi' -x '*.[oa]' ocaml-3.09.3/utils/clflags.mli ocaml-3.09.3-patched/utils/clflags.mli *** ocaml-3.09.3/utils/clflags.mli Wed Oct 26 15:23:27 2005 --- ocaml-3.09.3-patched/utils/clflags.mli Sat Feb 17 22:15:48 2007 *************** *** 73,75 **** --- 73,76 ---- val dont_write_files : bool ref val std_include_flag : string -> string val std_include_dir : unit -> string list + val ignore_cmi : bool ref --Apple-Mail-5-383890904 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed --Apple-Mail-5-383890904--