ocaml

Writing Emacs extensions in languages other than Lisp

I'd like to take an existing application (written in OCaml) and create an Emacs "interface" for it (like, for example, the Emacs GDB mode). I would prefer to do this without writing a ton of Lisp code. In MVC terms, I'd like for the View to be Emacs, but for the Model and Controller to remain (primarily) OCaml. Does anybody know of a wa...

Resolving reduce/reduce conflict in yacc/ocamlyacc

I'm trying to parse a grammar in ocamlyacc (pretty much the same as regular yacc) which supports function application with no operators (like in Ocaml or Haskell), and the normal assortment of binary and unary operators. I'm getting a reduce/reduce conflict with the '-' operator, which can be used both for subtraction and negation. Here ...

Learning OCaml (Fast)

Suppose I had to learn OCaml in a hurry. What would you suggest I read and/or do? I would happily spend real $$$ (or £££, or €€€) on a book or two, but by the time our favoured online book store delivers them I would hope to have turned my attention to something else. ...

Dealing with circular dependencies in OCaml

I'm writing an interpreter for an experimental language. Three of the main constructs of the language are definitions, statements, and expressions. Definitions can contain statements and expressions, statements can contain definitions and expressions, and one kind of expression can contain statements. I represent all of these using union...

GODI installation issue

I'm trying to install GODI on linux (Ubuntu). It's a library management tool for the ocaml language. I've actually installed this before --twice, but awhile ago-- with no issues --that I can remember-- but this time I just can't figure out what I'm missing. $ ./bootstrap --prefix /home/nlucaroni/godi $ ./bootstrap_stage2 .: 1: godi_conf...

Best way to represent a parameterized enum in C#?

Are there any good solutions to represent a parameterized enum in C# 3.0? I am looking for something like OCaml or haXe has. I can only think of class hierarchy with a simple enum field for easy switching for now, maybe there are better ideas? See Ocaml example below in one of the replies, a haXe code follows: enum Tree { Node(left:...

Know of an OCAML IDE?

Know of an OCAML/CAML IDE? Especially one that runs on Linux? ...

Is this a reasonable implementation of the quadratic Bézier function in OCaml?

A friend came across a quadratic Bézier curve function in his codebase that used a gigantic rats nest of a switch table to perform the computation. He challenged me to find a single, short expression that would allow him to replace the gigantic block of code. In attempting to satisfy two different curiosities, I thought I'd try impleme...

How do I get a stack trace in OCaml?

The Objective Caml language will only produce stack traces if you ask for them just right - what are the requirements for both bytecode and native code? ...

F# and OCaml

I hear that F# is derived from OCaml. How true is this statement? That is to say, are the resources available for learning OCaml useful to someone who wants to learn F#? What are the major differences between the two languages (aside from the fact that F# is .NET)? ...

Coming to Ocaml from Ruby, Lisp, Haskell, and Erlang

I've been reading about Ocaml's consistent speed, rapid prototyping ability, and excellent memory management, and decided to take it up. As I've already got Ruby, *lisp, Haskell, and Erlang under my belt, I'm interested specifically in what KISS-violating features I should look out for in Ocaml. If you've started Ocaml with a backgroun...

Explaining pattern matching vs switch.

I have been trying to explain the difference between switch statements and pattern matching(F#) to a couple of people but I haven't really been able to explain it well..most of the time they just look at me and say "so why don't you just use if..then..else". How would you explain it to them? EDIT! Thanks everyone for the great answers...

Can record field updates in OCaml be generalized?

I'm a very novice OCaml programmer so please forgive me if this is a stupid/obvious question. There's a lot to absorb and I may have missed this in the documentation. I have a base of code that's starting to look like this: let update_x p x = add_delta p; p.x <- x; refresh p let update_y p y = add_delta p; p.y <- y; refre...

GODI installation error

I'm running Fedora 9 x86_64 and am more or less a Linux newbie (not using it, but installing and such). The error occurs in the second stage of the bootstrap (i.e. "./bootstrap_stage2"). It does a whole lot fo stuff and then these errors start happening: Fatal error: exception Out_of_memory make[8]: *** [odoc_html.cmo] Error 2 make[8]: ...

Is my OCaml implementation of SHA256 sane?

I'm a novice OCaml programmer and thought I would throw myself into the deep end by attempting to implement a very tricky algorithm. I'm open to all criticisms great and small be they stylistic or security or performance related. One criticism that I'm already aware of is that the algorithm requires the entire message to fit in memor...

What is the OCaml idiom equivalent to Python's range function?

I want to create a list of integers from 1 to n. I can do this in Python using range(1, n+1), and in Haskell using: take n (iterate (1+) 1). What is the right OCaml idiom for this? ...

Ocaml: Match expression inside another one?

Hello, I'm currently working on a small project with Ocaml; a simple mathematical expression simplifier. I'm supposed to find certain patterns inside an expression, and simplify them so the number of parenthesis inside the expression decreases. So far I've been able to implement most rules except two, for which I've decided to create a r...

Does OCaml have general map()/reduce() functions?

In Python map() works on any data that follows the sequence protocol. It does The Right Thing^TM whether I feed it a string or a list or even a tuple. Can't I have my cake in OCaml too? Do I really have no other choice but to look at the collection type I'm using and find a corresponding List.map or an Array.map or a Buffer.map or a S...

A good ocaml parser?

Hi, I'm looking for a good ocaml parsing library that isn't a derivative of flex/bison. Ideally, I'd like a monadic combinator library along the lines of parsec, but I can't find anything. I would use haskell, but making llvm bindings for haskell is proving more tiresome than I originally thought. Cheers, Duane ...

running ocaml on Mac OS X gives bus error

I've just installed Ocaml on Mac OS X, and when I run the ocaml program I get a "Bus Error" with no other clues to what might be going on. Can anyone offer suggestions on where to go from here? EDIT: I installed via the package: http://caml.inria.fr/pub/distrib/ocaml-3.10/ocaml-3.10.2-ppc.dmg (I have an iBook G4, so PPC is approp...