What to learn? Lisp or OCaml or…? [closed]

Neither Lisp nor OCaml is super far afield from what you already know. Here are four suggestions chosen partly for intrinsic interest and partly to stretch your horizons. A logic programming language, probably Prolog. I haven’t found good materials online, but the book The Art of Prolog by Sterling and Shapiro is excellent. The more … Read more

Or-patterns in Haskell

I don’t think this is possible in haskell. There are however, a few alternatives: Factor out the common code with a where binding This doesn’t make much sense in your example, but is useful if you have more code in the body of the case expression: combine o1 o2 = case (o1,o2) of (Valid, Invalid) … Read more

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

Either OCaml or Haskell would be a good choice. Why not check out the LLVM tutorials for each language? The LLVM tutorial for OCaml is here: http://llvm.org/docs/tutorial/OCamlLangImpl1.html Haskell has more momentum these days, but there are plenty of good parsing libraries for OCaml as well including the PEG parser generator Aurochs, Menhir, and the GLR … Read more

{X with value} in ocaml

This is sometimes called a “record update” or “functional update” or something like that. It evaluates to a new record of the same type as X, and whose fields are initialized to the same as those in X, except the ones which are listed after the “with”, which are initialized to those given values. It … Read more

IDE for OCaml language

Edit: a decade later (2022), VS Code OCaml Platform is probably the best option. Editors • Emacs ◦ ocaml-mode from the standard distribution ◦ alternative tuareg-mode https://forge.ocamlcore.org/projects/tuareg/ − cheat-sheet: http://www.ocamlpro.com/files/tuareg-mode.pdf ◦ camldebug intergration with debugger ◦ type feedback with C-c C-t key shortcut, needs .annot files • Vim ◦ OMLet plugin http://www.lix.polytechnique.fr/~dbaelde/productions/omlet.html ◦ For type … Read more

What’s the easiest way to build an F# compiler that runs on the JVM and generates Java bytecode?

Another option that should probably be considered is to convert the .NET CLR byte code into JVM byte-code like http://www.ikvm.net does with JVM > CLR byte codes. Although this approach has been considered and dismissed by the fjord owner. Getting buy-in from the top with option 1) and have the F# compiler team have pluggable … Read more

Tail recursive function to find depth of a tree in Ocaml

You can trivially do this by turning the function into CPS (Continuation Passing Style). The idea is that instead of calling depth left, and then computing things based on this result, you call depth left (fun dleft -> …), where the second argument is “what to compute once the result (dleft) is available”. let depth … Read more

What’s the difference between “equal (=)” and “identical (==)” in ocaml?

I don’t know exactly how x.equals(y) works in Java. If it does a “deep” comparison, then the analogy is pretty close. One thing to be careful of is that physical equality is a slippery concept in OCaml (and functional languages in general). The compiler and runtime system are going to move values around, and may … Read more