ocaml

Why does ocamldoc fail on unbound modules?

折月煮酒 提交于 2019-12-10 14:32:37
问题 Here is an example interface test.mli , commented with ocamldoc-style comments: (** ocamldoc module comment *) open MissingModule;; (** ocamldoc function comment *) val test : unit;; If I run the command ocamldoc test.mli , I get the following error: File "test.mli", line 2, characters 0-9: Error: Unbound module MissingModule 1 error(s) encountered Why should a documentation generator care about unbound modules? 回答1: That's because ocamldoc fully qualifies type names. The file: open

ocaml command line cannot not find “topfind”

穿精又带淫゛_ 提交于 2019-12-10 14:22:18
问题 I have top-level installed, and have $OCAML_TOPLEVEL_PATH setup. export OCAML_TOPLEVEL_PATH=/Users/smcho/.opam/system/lib/toplevel I checked that the directory exists, and has one file topfind . This is my ~/.ocamlinit file content. #use "topfind" #camlp4o #thread #require "core.top" #require "core.syntax" The issue is that I have the error message saying it can't find topfind. > ocaml OCaml version 4.02.1 Cannot find file topfind. Unknown directive `camlp4o'. # With "ustop", I have no error

Converting OCaml to F#: Is there a simple way to simulate OCaml top-level #trace in F#

泪湿孤枕 提交于 2019-12-10 14:20:09
问题 I am converting several modules based on OCaml to F#. I have the code converted and running in F#, however the result of the final function in F# is not the same as the result of the final function in OCaml. So obviously I have to follow the function calls to figure out which function is returning the wrong result. OCaml has a nice top-level directive for tracing the input and output of a function, i.e. #trace . I have searched F#'s debug and trace methods and the closest I get is to

multiple error reporting with menhir: which token?

ぃ、小莉子 提交于 2019-12-10 14:05:21
问题 I am writing a small parser with Menhir + Ocamllex and I have two requirements I cannot seem to meet at the same time I would like to keep parsing after an error (to report more errors). I would like to print the token at which the error ocurred. I can do only 1) easily, by using the error token. I can also do only 2) easily, using the approach suggested for this question. However, I don't know of an easy way to achieve both. The way I handle errors right now goes something like this: pair: |

OCaml constructor unpacking

最后都变了- 提交于 2019-12-10 13:53:20
问题 Is it possible to unpack a type by binding its data to a single value instead of a tuple? # type foo = Foo of int * string;; type foo = Foo of int * string # Foo (3; "bar");; Foo (3; "bar");; Error: The constructor Foo expects 2 argument(s), but is applied here to 1 argument(s) # Foo (3, "bar");; - : foo = Foo (3, "bar") # (* Can this possibly work? *) # let Foo data = Foo (3, "bar");; let Foo data = Foo (3, "bar");; Error: The constructor Foo expects 2 argument(s), but is applied here to 1

Basic Oasis or Opam file for a simple OCaml project

一笑奈何 提交于 2019-12-10 13:08:46
问题 I am a new OCaml user. I have asked a question to learn how to set up a basic OCaml project, but I still have issues. Jump to the end for a TL;DR For instance, I am trying to learn Irmin. On the home page of Irmin I see I have to do opam install irmin git cohttp Doing so, I end up with Irmin version 0.8.3. Unfortunately, I cannot follow their examples, because apparently Irmin is at version 0.9.4, and it looks like the API has changed. So, I would like to start a clean project having as

ocaml %identity function

拥有回忆 提交于 2019-12-10 12:43:45
问题 I'm wondering why do we need function like "%identity", which is the same as let a = a. Is it going to improve performance by using it ? I'm introducing phantom typing in my program, calling identity functions a ton times to convert types, curious if "%identity" can reduce a bit of overhead. 回答1: The %identity function is part of the implementation, not part of the OCaml language. It tells the compiler (in essence) that there's nothing to do to change the function's parameter to its return

Suppress exhaustive matching warning in OCaml

廉价感情. 提交于 2019-12-10 12:39:53
问题 I'm having a problem in fixing a warning that OCaml compiler gives to me. Basically I'm parsing an expression that can be composed by Bool , Int and Float . I have a symbol table that tracks all the symbols declared with their type: type ast_type = Bool | Int | Float and variables = (string, int*ast_type) Hashtbl.t; where int is the index used later in the array of all variables. I have then a concrete type representing the value in a variable: type value = | BOOL of bool | INT of int | FLOAT

CLR vs OCaml exception overhead

最后都变了- 提交于 2019-12-10 12:33:05
问题 Reading Beginning F# - Robert Pickering I focused on the following paragraph: Programmers coming from an OCaml background should be careful when using exceptions in F#. Because of the architecture of the CLR, throwing an exception is pretty expensive—quite a bit more expensive than in OCaml. If you throw a lot of exceptions, profile your code carefully to decide whether the performance costs are worth it. If the costs are too high, revise the code appropriately. Why, because of CLR, throwing

Is there a good OCaml lib for creating a web service like pyramid in python?

折月煮酒 提交于 2019-12-10 12:24:53
问题 The question title says itself. I find pyramid in python is quite easy to use. In OCaml, I know Eliom , but guess it too heavy. And also in client side, I will use angular js and don't need to write browser page in OCaml. Any suggestions? 回答1: OWebl is a new project that I personally find very promising, and it looks like that it can suite your needs quite well. Other option, is to use cohttp directly or with opium 回答2: Eliom doesn't have to be "heavy"; but I think their docs have a slight PR