ocaml

Command line arguments to ocamldebug

一笑奈何 提交于 2019-12-25 04:26:08
问题 How can I pass command line arguments to ocaml debugger? I am looking for something similar to gdbs --args , or r ... , or params ... < . For example, after compiling open Printf;; let () = for i = 0 to Array.length Sys.argv - 1 do printf "[%i] %s\n" i Sys.argv.(i) done;; is there a way to step through the executable? 回答1: I found it, after starting the debugger, you have to set the arguments, eg (ocd) set arguments "a" "b" "C" (ocd) r 来源: https://stackoverflow.com/questions/41128840/command

Where should I insert “etags -R .” in makefile?

十年热恋 提交于 2019-12-25 02:44:10
问题 I am writing a compiler in Ocaml... I am just wondering at which stage it is most convenient to generate the tags ... I guess it should not be after the compilation of all files, because it is possible that the compilation fails, and it still makes sense to get tags . Where do you usually put etags in makefile? 回答1: I put tag generation on a separate target. When I want to generate an executable, I don't care about tags. When I'm working on the source code, I might want to regenerate the tags

Building LablGtk fails

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-25 02:14:35
问题 I'm trying to build LablGtk to enable building CoqIDE from source. I used lablgtk-2.18.7.tar.gz from here. When I tried to configure-make it I got this error (and similar other errors): File "gdk.ml", line 346, characters 2-55: 346 | external create : len:int -> t = "ml_point_array_new" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Error (warning 61): This primitive declaration uses type t, which is unannotated and unboxable. The representation of such types may change in future

Boxes and XML in Format module

只愿长相守 提交于 2019-12-25 01:15:44
问题 I would like to print an output using boxes and XML in Format module. An idea format is as follows: <Events> <Event> <name> haha </name> <name> haha </name> </Event> <Event> <name> lili </name> <name> lili </name> </Event> <Event> <name> lolo </name> <name> lolo </name> </Event> </Events> At the moment my code is as follows, it does not print exactly what I expect (I omit to put the incorrect result here). (* in event.ml *) let print_name (fmt: formatter) (x: t) : unit = Format.open_tag "Name

OCaml pair int with char list

放肆的年华 提交于 2019-12-24 19:05:19
问题 I'm working with a function with the prototype remaining thelist that needs to take on the signature val remaining : char list -> int * char list = <fun> . I'm new to Ocaml and I do not understand how to make an Ocaml function take in only a list and output both an int and a list. This is the code I'm currently working with. let rec remaining thelist= match thelist with | [] -> [] | [x] -> [x] | x::y::t1 -> if x='a' then remaining (y::t1) else thelist;; match thelist with | [] -> 0 | x::t1 ->

How do I use the results of WP in another plug-in?

岁酱吖の 提交于 2019-12-24 16:39:51
问题 I am working on writing a Frama-C plug-in and I would like to know if it is possible to get the weakest precondition of something using WP from within my plug-in, and if so, how exactly? In the past I've used Db.Value, for example, to use the results of the EVA plug-in in my own plug-in. Is there something similar to Db.Value for WP? 回答1: The WP plugin exposes its API in the WP.mli file, that is generated by collecting the interfaces of the higher-level modules composing Wp . you can find it

Ocaml's Graphics.open_graph does not work

允我心安 提交于 2019-12-24 13:39:18
问题 I am trying to follow the ocaml manual to draw something. But here is a strange response from Ocaml's toplevel. Anyone sees why? Thanks. # #load "graphics.cma";; # Graphics.open_graph "foo:0";; _X11TransSocketINETConnect() can't get address for foo:6000: nodename nor servname provided, or not known Exception: Graphics.Graphic_failure "Cannot open display foo:0". 回答1: I use Graphics.open_graph " 600x400" , and it works. Note the space before the resolution specification. As to why foo:0 would

Error when convert to Boolean matrix

跟風遠走 提交于 2019-12-24 13:15:10
问题 I have this problem still bother me a lots. I have a (string * string list) list and I want to convert it to Boolean matrix. I have a special condition when transform it. For example I have this list: let entries = [("name", ["string"; "label"]); ("label", ["int"; "name"]); ("symbol", ["string"])] where " string " and " int " are undefined type, undefined type because in my real data, I don't have a definition describe this type. So I built a list of undefined type. let undefined = ["string";

Is it possible to use the font of tuareg in caml-mode under Emacs?

别等时光非礼了梦想. 提交于 2019-12-24 12:06:05
问题 For Indentation of “if”, i have to use caml-mode under Emacs. But I find the font of tuareg is more colorful than caml-font , so my question is whether it is possible to use the font of tuareg in caml-mode . Also, with the current .emacs which requires caml-font , when I open a .ml file, some lines (especially in the beginning of the file) are not highlighted. If I go to those lines, modify them, they will change their color. Could anyone tell me how to fix that problem? Also, do you have

How to convince ocaml that two functor instantiations are equal

情到浓时终转凉″ 提交于 2019-12-24 10:53:49
问题 Suppose I have a number of modules that are all parameterized with one module type, and also have dependencies between each other: module type AT = sig end module B(A: AT) = struct module Hash = struct type t = int let equal b1 b2 = b1 = b2 let hash b = b end end module C(A: AT) = struct module B = B(A) module Hashtbl = Hashtbl.Make(B.Hash) let make () = Hashtbl.create 16 end module D(A: AT) = struct module B = B(A) module Hashtbl = Hashtbl.Make(B.Hash) let use ht = Hashtbl.clear ht end