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
57
votes
4 answers

What's really more performant? Haskell or OCaml

I spent the last 18 months getting the grip of functional programming, starting with learning OCaml and for some weeks now Haskell. Now I want to take the next step and implement some actual application: A simple realtime terrain editor. I've…
datenwolf
  • 159,371
  • 13
  • 185
  • 298
57
votes
1 answer

When should objects be used in OCaml?

Usually, an OCaml program can be written with or without objects. When is it most beneficial to use objects, and when should they be avoided?
Matthew Piziak
  • 3,430
  • 4
  • 35
  • 49
54
votes
2 answers

OCaml: Match expression inside another one?

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…
Sergio Morales
  • 2,600
  • 6
  • 32
  • 40
52
votes
6 answers

What's the closest thing to Haskell's typeclasses in OCaml?

What are some ways that I can accomplish what Haskell's typeclasses do in OCaml? Basically, I want to write a polymorphic function without writing too much code. The typical way to do polymorphism is to supply an additional argument telling the…
Jason Yeo
  • 3,602
  • 3
  • 30
  • 38
50
votes
3 answers

designing large projects in OCaml

What is a best practices to write large software projects in OCaml? How do you structure your projects? What features of OCaml should and should not be used to simplify code management? Exceptions? First-class modules? GADTs? Object types? Build…
John Rivers
  • 1,307
  • 10
  • 20
50
votes
1 answer

How to build an OCaml cross compiler

After finding a way to generate the fitting configuration files for the target machine, the cross compiler itself must still be built. The approach using the 1 1/2 build described here (and, with more details, here) does not seem to work if the host…
Percival Ulysses
  • 1,133
  • 11
  • 18
46
votes
1 answer

How are functors in Haskell and OCaml similar?

I've been toying around in a Haskell for the past year or so and I'm actually starting to 'get' it, up until Monads, Lenses, Type Families, ... the lot. I'm about to leave this comfort zone a little and I am moving to an OCaml project as a day…
Kasper
  • 1,205
  • 12
  • 22
45
votes
1 answer

Why does ocaml need both "let" and "let rec"?

Possible Duplicates: Why are functions in OCaml/F# not recursive by default? What's the reason of 'let rec' for impure functional language OCaml? OCaml uses let to define a new function, or let rec to define a function that is recursive. Why does…
Chris Taylor
  • 46,912
  • 15
  • 110
  • 154
45
votes
2 answers

Can F# units of measure be implemented in OCaml?

F# has a units of measure capability (there's more detail in this research paper). [] type unit-name [ = measure ] This allows units to be defined such as: type [] USD type [] EUR And code to be written as: let dollars =…
Darren
  • 2,888
  • 1
  • 23
  • 34
45
votes
1 answer

80-bit extended precision floating-point in OCaml

Is there an OCaml library to take advantage of the 80-bit extended precision floating-point type on the IA-32 and x86-64 architectures? I know about the MPFR bindings but my ideal library would be more lightweight. Taking advantage of the historical…
Pascal Cuoq
  • 79,187
  • 7
  • 161
  • 281
45
votes
2 answers

Haskell, Scala, Clojure, what to choose for high performance pattern matching and concurrency

I have started work on FP recently after reading a lot of blogs and posts about advantages of FP for concurrent execution and performance. My need for FP has been largely influenced by the application that I am developing, My application is a state…
2ndlife
  • 1,378
  • 3
  • 14
  • 20
44
votes
4 answers

What is the difference between the `fun` and `function` keywords?

Sometimes I see code like let (alt : recognizer -> recognizer -> recognizer) = fun a b p -> union (a p) (b p) Or like: let hd = function Cons(x,xf) -> x | Nil -> raise Empty What is the difference between fun and function?
Nick Heiner
  • 119,074
  • 188
  • 476
  • 699
43
votes
10 answers

Print a List in OCaml

I want to do something as simple as this: Print a list. let a = [1;2;3;4;5] How can I print this list to Standard Output?
Gitmo
  • 2,366
  • 5
  • 25
  • 31
43
votes
2 answers

OCaml explicit type signatures

In Haskell, it is considered good practice to explicitly declare the type signature of your functions, even though it can (usually) be inferred. It seems like this isn't even possible in OCaml, e.g. val add : int -> int -> int ;; gives me an…
Xodarap
  • 11,581
  • 11
  • 56
  • 94
43
votes
6 answers

What's the reason of 'let rec' for impure functional language OCaml?

In the book Real World OCaml, the authors put why OCaml uses let rec for defining recursive functions. OCaml distinguishes between nonrecursive definitions (using let) and recursive definitions (using let rec) largely for technical reasons: the…
prosseek
  • 182,215
  • 215
  • 566
  • 871