ocaml

Ocaml Syntax Error

What's wrong with this code? I can't figure it out: let parent (rules : grammar) (symbol1 : string) (symbol2 : string) : (SymbolSet.t) = try SymbolSet.singleton (getParent [symbol1; symbol2] rules) with Not_found -> SymbolSet.singleton "";; let fundementalRule (set1 : SymbolSet) (set2 : SymbolSet) (rules : grammar) : (S...

OCaml modules and performance

Some functions are really easy to implement in OCaml (for example, map from a list) but you may use the map of the OCaml library: List.map However, we can wonder which code will be more efficient. Calling a module of a separate compilation unit (a library) may void some possible optimizations. I read in the news group fa.caml that when ...

Linked List Ocaml

How would i create a linked list to hold my data in Ocaml? Im trying to make a singly linked list, however im having trouble with the syntax. I just want to make a module to simply get the 'a from the linked list, insert 'a or delete 'a. Anyone have any idea? Thanks, Faisal Abid ...

Extending an existing type in OCaml

I've been doing some OCaml programming lately to learn the language and to get more acquainted with functional programming. Recently, I've started to think that I'd like to be able to extend an existing type (either built in-or one of my own), for example: type bexp = And of bexp * bexp | Or of bexp * bexp | Xor of bexp * bexp | Not ...

When choosing a functional programming language for use with LLVM, what are the trade-offs?

Let's assume for the moment that C++ is not a functional programming language. If you want to write a compiler using LLVM for the back-end, and you want to use a functional programming language and its bindings to LLVM to do your work, you have two choices as far as I know: Objective Caml and Haskell. If there are others, then I'd like...

Hashtable indexed on several fields

Hello SO, I'm currently programming an OCaml module defining a type corresponding to a CPU register. The interface of this module is the following : (* * Defines a type which represents a R3000 register. *) type t = | R0 (* Always 0 *) | AT (* Assembler te...

Ideas for Natural Language Processing project?

I have to do a final project for my computational linguistics class. We've been using OCaml the entire time, but I also have familiarity with Java. We've studied morphology, FSMs, collecting parse trees, CYK parsing, tries, pushdown automata, regular expressions, formal language theory, some semantics, etc. Here are some ideas I've come...

How do I make a type that uses Batteries' Dyn_array in OCaml?

For instance, suppose I want to make a type like this (using Dyn_array): type some_type = SomeConstructor of <Dyn_array of integers> I'm a little bit lost on how to do this though. Could someone give me an example so I can wrap my head around this? ...

How can I create a type with multiple parameters in OCaml?

I'm trying to create a type that has multiple type parameters. I know how to make a type with one parameter: type 'a foo = 'a * int But I need to have two parameters, so that I can parameterize the 'int' part. How can I do this? ...

How can I simplify this ocaml pattern-matching code?

I'm writing a simple little ocaml program that reads an algebraic statement in from a file, parses it into an AST using ocamllex/ocamlyacc, reduces it, and then prints it. The part where I'm reducing the expression seems a bit... ugly. Is there any way I can simplify it? (* ocaml doesn't seem to be able to take arithmetic operators a...

How can I avoid warnings when I apply function to a known list of arguments in OCaml?

How can I transform several values a,b,c etc. to a',b',c' etc, such that x'=f(x)? The values are bound to specific names and their quantity is known at compile-time. I tried to apply a function to a list in the following way: let [a';b'] = List.map f [a;b] in ... But it yields warning: Warning P: this pattern-matching is not exhaus...

ocamlc, module compilation

Hi. I wrote app in ocaml. It consist of several modules: Util (util.ml) Work1 (work1.ml) -- open Util Work2 (work2.ml) -- open Util, too Main (main.ml) -- open all of them. When i compile its, using ocamlc, compilation failed on module Work2, and i get error message about unbound value from Util. Separate compilation doesn't wo...

Is there an enhanced interpreter toploop for OCaml?

Python has IPython.. does OCaml have anything similar? I'd very much like to have command history, although other features would be nice too. I've read that I could get command history by running it in Emacs, but I don't use Emacs.. ...

Ocaml Implementation

I am having problems for converting following algo in ocaml To implement this algorithm i used Set.Make(String) functor actualy in and out are 2 functions Can any one give me percise code help in ocaml for following This is actually Algo for Live Variables[PDF] ..Help would be appreciated greatly for all n, in[n] = out[n] = Ø w = { s...

What does % mean in an OCaml external declaration?

Many external declarations in the OCaml standard library have a % at the beginning of the function name, such as the definition of int_of_float: external int_of_float : float -> int = "%intoffloat" What does the '%' mean? ...

hedge funds / financial services: caml. why?

speaking to a number of quants / hedgies, i came to the conclusion that a large number of them seem to be using their a homebrew or caml (for the most part). what many of them couldnt answer was why. i can certainly understand why they wouldnt want to use c++ for the most part, but why is caml superior for these uses compared to other s...

How to indent existing OCaml code

I have ~30.000 lines of badly indented OCaml code (including mly and mll files) and would like to indent them. I tried googling for variations of 'ocaml indent' the closest I can get is to use Omlet.vim and indent the code one line at a time (via C-f in insert mode). Is there a way to do the indentation for all the 30000 lines? ...

ocamlyacc parse error: what token?

I'm using ocamlyacc and ocamllex. I have an error production in my grammar that signals a custom exception. So far, I can get it to report the error position: | error { raise (Parse_failure (string_of_position (symbol_start_pos ()))) } But, I also want to know which token was read. There must be a way---anyone know? Thanks. ...

What does the ocaml type 'a. 'a -> 'a mean?

In the ocaml language specification, there's a short section: poly-typexpr ::= typexpr | { ' ident }+ . typexpr There's no explanation in the text, and the only instance of poly-typexpr is in defining a method type: method-type ::= method-name : poly-typexpr What does this allow me to do? ...

F# graph library (ocamlgraph like)

Hi, I'm writing a program in ocaml using ocamlgraph and wondering if I am to port it to F# what are my options ? Thanks. ...