ocaml

OCaml: Type Checking Objects

If I have an object, how can I determine its type? (Is there an OCaml equivalent to Java's instanceof operator?) ...

Parser/Lexer ignoring incomplete grammar rules

I have a parser and lexer written in ocamlyacc and ocamllex. If the file to parse ends prematurely, as in I forget a semicolon at the end of a line, the application doesn't raise a syntax error. I realize it's because I'm raising and catching EOF and that is making the lexer ignore the unfinished rule, but how should I be doing this to r...

OCaml: bound expressions v. functions

Here we have a function definition: let f x = x + 3;; Here is an expression: let g = 4;; Could g just be thought of as constant function that takes no arguments? Is there any difference? ...

How to download and install Emacs for OCaml?

I feel retarded asking this question, but I've been banging my head against the wall for a while now... This directory is linked to by the website for obtaining emacs: http://ftp.gnu.org/pub/gnu/emacs/. Which file do I want? I downloaded emacs-23.1.tar.gz and unpacked it, but I don't know what to do now. I can't find any files to execut...

OCaml: Set modules

I want to use OCaml to generates sets of data and make comparisons between them. I have seen the documentation for Module types like Set.OrderType, Set.Make, etc, but I can't figure out how to initialize a set or otherwise use them. ...

"The cma file is not a bytecode object file" => What does that mean ?

Hi, I'm trying to install the ocaml-sqlite3 bindings, to access a sqlite database from an o'caml program. The configure and make go smoothly, but the installation fails. Because the file sqlite3.cma is not a bytecode object file (see below). ~/Software/ocaml-sqlite3-release-1.5.6> sudo make install [ -f *.so ] && SO_FILES=*.so; ...

Database binding for ocaml ?

Hi, I'm trying to find a lib to access a DB from an Ocaml program. After trying ocaml-sqlite, I'm not satisfied since it's somewhat slow. I've seen a mysql module but it doesn't seem to be maintained. thanks. ...

What language could I use for fast execution of this database summarization task?

So I wrote a Python program to handle a little data processing task. Here's a very brief specification in a made-up language of the computation I want: parse "%s %lf %s" aa bb cc | group_by aa | quickselect --key=bb 0:5 | \ flatten | format "%s %lf %s" aa bb cc That is, for each line, parse out a word, a floating-point number, an...

Ocaml: Set current working directory?

How do I set the current working directory on a windows system? ...

Ocaml: Tree functions

Are there any modules or functions for dealing with trees? I have a type that looks like this: type t = Leaf of string (* todo: replace with 'a *) | Node of string * t list and I'm struggling to do insertion, removal of subtrees, etc. I've used the googles but can't find anything. ...

What's the difference between functors and "generics"

I'm looking at OCaml's functors. It looks to me pretty identical to the so called generic objects in C++/C#/Java. If you ignore Java's type erasion for now, and ignore the implementation details for C++ templates (I'm interested with the language feature), functors are quite indentical to generics. If I understand it correctly, functor g...

Python type inference for autocompletion

Is it possible to use Ocaml/Haskell algorithm of type inference to suggest better autocompletions for Python? The idea is to propose autocompletion for example in the following cases: class A: def m1(self): pass def m2(self): pass a = A() a. <--- suggest here 'm1' and 'm2' fun1(a) def fun1(b): b. <--- suggest here...

Does "match ... true -> foo | false -> bar" have special meaning in Ocaml?

I encountered the following construct in various places throughout Ocaml project I'm reading the code of. match something with true -> foo | false -> bar At first glance, it works like usual if statement. At second glance, it.. works like usual if statement! At third glance, I decided to ask at SO. Does this construct have spec...

What's a stupidly simple way to compile an OCaml project?

I'm toying around with OCaml. The first thing I want to know how to do is build an OCaml project. Right now, I just want something stupidly simple since I'm just learning. Could anyone point me towards a build system along with a "hello world" type example for using that build system? ...

Ocaml: Error - this expression has type x but is used with type x

This is my error: Error: This expression has type nfa but is here used with type nfa What could possibly be happening to cause this? I'm using emacs tuareg, and loading evaluating files one by one. Sometimes this happens, and other times it doesn't. ...

OCaml: Permutation of every value in two sets? (how to translate this from Java)

I have two sets, returned by Set.Make(t). I would like to generate every possible combination of the values in the two. How can I do this? This works to generate some pairs, but not all: List.combine (IntSet.elements odp) (IntSet.elements ftw) This would do it in Java: for (int i : ktr) { for (int m : mnx) { System.out.p...

OCaml Emacs Tuareg: Evaluate phrase keyboard shortcut, and how to display actual greek symbols?

Two questions about Emacs Tuareg for OCaml: I have seen some configurations where it displays an alpha symbol instead of a'. How can I turn this on? What is the keyboard shortcut for "evaluate phrase" or "evaluate buffer"? ...

OCaml for JVM. Is there any?

I took a look at some new languages for JVM. Two of them are gathering much interest these days: Clojure and Scala. But in my humble opinion, both of them are not ideal. (Let's keep it a speculation, cause I don't want to damage myself discussing..) What I actually see as a tricky move is MS's invention - F#. Simply moving the OCaml lan...

Frameworks that support complex nested forms ala Rails' accepts_nested_attributes_for?

I'm working on a small side project for a friend and I need to build complex forms dynamically from a set of predefined types which in-turn are persisted via the underlying object model. So far I'm using Rails 2.3.4, accepts_nested_attributes_for, and a bit of Javascript. There's nothing wrong with this, I've just about got it modified...

Appending an integer to a List in Ocaml

How can i implement this function? let rec append l i = (* For example, if l is a list [1;2] and i is an integer 3 append [1;2] 3 = [1;2;3]*) ;; ...