Questions tagged [ocaml]

OCaml is a strict statically-typed functional programming language, focusing on expressiveness, correctness, and efficiency.

#OCaml

OCaml is a strict statically-typed functional programming language, focusing on expressivity, correctness, and efficiency. These qualities make it the language of choice for complex software and timely go-to-market strategies.

For more information visit, the official OCaml site.

##Resources for OCaml Developers

##Resources for learning OCaml

Stack Overflow OCaml FAQ

  1. Documentation
  1. Editor
  1. The core language
  1. Loops/recursion
  1. Tools
  1. Good practices

#See also:#

7516 questions
29
votes
6 answers

Saving my running toplevel for later

When working in the ocaml or ghci toplevels I often build up a significant "context" for want of a better word, values bound, functions, modules loaded, and so on. Is there a way to save all of that and reload it later so I can continue exactly…
Gaius
  • 2,556
  • 1
  • 24
  • 43
29
votes
2 answers

Is it possible to get the infinite kind error in Haskell 98?

I am implementing a kind system for a new functional programming language and I am currently writing the function to unify two kinds. There are four cases two consider: +---------+---------+-------------------------------------------------------+ | …
Aadit M Shah
  • 72,912
  • 30
  • 168
  • 299
29
votes
1 answer

llvm OCaml bindings

I'm working on llvm OCaml bindings. I installed llvm package through opam (opam install llvm), when I use llvm in utop, I get the following error: #require "llvm";; Error: The external function 'llvm_global_succ' is not available. The opam llvm…
xysun
  • 1,995
  • 18
  • 18
28
votes
2 answers

OCaml: Why I can't use this operator infix?

I defined a custom equality operator (the definition is not really important so I will insert dummy stuff): let ( ~=~ ) a b = true If I try to use it infix: if a ~=~ b then 1 else 2 I get the following error:This expression is not a function; it…
Calin
  • 1,471
  • 1
  • 15
  • 22
28
votes
4 answers

Higher-order type constructors and functors in Ocaml

Can the following polymorphic functions let id x = x;; let compose f g x = f (g x);; let rec fix f = f (fix f);; (*laziness aside*) be written for types/type constructors or modules/functors? I tried type 'x id = Id of 'x;; type 'f 'g 'x…
sdcvvc
  • 25,343
  • 4
  • 66
  • 102
28
votes
9 answers

Why do hedge funds and financial services often use OCaml?

Speaking to a number of quants / hedgies, I came to the conclusion that a large number of them seem to be using either a homebrew language or OCaml for many tasks. What many of them couldn't answer was why. I can certainly understand why they…
oneAday
  • 1,261
  • 4
  • 15
  • 16
28
votes
7 answers

Which is the current setup to use OCaml in Vim?

I never used Vi or Vim, but it seems that it is the best option to edit OCaml files. Unfortunately I am lost with so many things to care about: ocaml-vi-addon, vi-scripts, otags etc. I broke my initial fear of Vim using cream, but I am in doubt if I…
user445107
28
votes
6 answers

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…
Chris Conway
  • 55,321
  • 43
  • 129
  • 155
26
votes
11 answers

How do I read in lines from a text file in OCaml?

This is what I have so far. Isn't this all that you need? I keep getting the error "Error: Unbound module Std" let r file = let chan = open_in file in Std.input_list (chan)
Travis
  • 663
  • 1
  • 10
  • 16
26
votes
4 answers

Functional Breadth First Search

Functional depth first search is lovely in directed acyclic graphs. In graphs with cycles however, how do we avoid infinite recursion? In a procedural language I would mark nodes as I hit them, but let's say I can't do that. A list of visited nodes…
N. McA.
  • 4,796
  • 4
  • 35
  • 60
26
votes
4 answers

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..
int3
  • 12,861
  • 8
  • 51
  • 80
26
votes
11 answers

Know of an OCaml IDE?

Know of an OCAML/CAML IDE? Especially one that runs on Linux?
DustinB
  • 11,037
  • 5
  • 46
  • 54
25
votes
1 answer

how to reload OCaml modules in utop

Is it possible reload modules in OCaml's utop? My development workflow goes something like this when playing around with OCaml code: First, open up a file example.ml in Vim and hack on it. Switch to another terminal and run utop. From within utop,…
illabout
  • 3,517
  • 1
  • 18
  • 39
25
votes
3 answers

OCaml |> operator

Could someone explain what the |> operator does? This code was taken from the reference here: let m = PairsMap.(empty |> add (0,1) "hello" |> add (1,0) "world") I can see what it does, but I wouldn't know how to apply the |> operator otherwise. For…
eatonphil
  • 13,115
  • 27
  • 76
  • 133
25
votes
3 answers

tail recursion vs. forward recursion

Can someone give me the difference between these two kinds recursions and example (specifically in OCaml)?
REALFREE
  • 4,378
  • 7
  • 40
  • 73