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
25
votes
7 answers

Good projects to learn OCaml and F#

After learning the basic syntax, reading some non-trivial code is a fast way to learn a language. We can also learn how to design a library/software during reading others' code. I have following lists. A Chess program in OCaml by Tomek Czajka. Hal…
Yin Zhu
  • 16,980
  • 13
  • 75
  • 117
25
votes
2 answers

Is it possible to use arrow keys in OCaml interpreter?

Everytime I use these keys in the interpreter I keep getting symbols like this appearing: [[D^[[C I'm using Linux Mint 12 in ZSH, however I'm getting the same result in Ubuntu with bash. Also, same thing in ssh.
Pacane
  • 20,273
  • 18
  • 60
  • 97
25
votes
3 answers

how to repeat last command in OCaml interpreter shell

I've been trying out OCaml. Sometimes its quicker just to test out some code using the interpreter shell but, it doesn't bring up the last command when I press the 'up' key. Its a pain when I miss type something or wish to see what a little…
neildaemond
  • 656
  • 1
  • 8
  • 17
24
votes
8 answers

Should I learn Haskell or F# if I already know OCaml?

I am wondering if I should continue to learn OCaml or switch to F# or Haskell. Here are the criteria I am most interested in: Longevity Which language will last longer? I don't want to learn something that might be abandoned in a couple years by…
Unknown
  • 45,913
  • 27
  • 138
  • 182
24
votes
1 answer

comparing F# and OCaml

I know roughly how F# and OCaml differ in terms of "features" (e.g. functors, camlp4, units of measure...). I wonder about the following: Concerning code that doesn't contain said features, is there a difference in coding style (other than say…
D.F.F
  • 914
  • 1
  • 6
  • 17
24
votes
3 answers

Regular Expressions in OCaml

I want to use regexps in OCaml and it seems that Str module provides these functionalities. So I tried with a simple program: open Str let regx = regexp "." but it gives me the following error File "lol.ml", line 1, characters 0-1: Error: Error…
Jack
  • 131,802
  • 30
  • 241
  • 343
24
votes
1 answer

What, if anything, do you need to add to a dependent type system to get a module system?

Dependent type systems seem to support some of the uses of a ML module system. What do you get out of a module system that you do not get out of dependent records? module ~ record signature ~ record type functor ~ function on records module with an…
Jules
  • 6,318
  • 2
  • 29
  • 40
24
votes
1 answer

How can I load a ml file in toplevel of OCaml, just like `use mine.sml` in SML/NJ?

In SML's repl, you can just type use whatever.sml and load all things inside that .sml into repl. How can I do that in OCaml?
Jackson Tale
  • 25,428
  • 34
  • 149
  • 271
23
votes
1 answer

Hesitating between C/C++, OCaml, and F# for my compiler

I want to start working on a little compiler and to build it I am hesitating between several different languages. My requirements are simple, I want to be able to emit LLVM-IR code cause I have a LLVM backend I would like to reuse to target a…
Thibault Imbert
  • 433
  • 3
  • 7
23
votes
1 answer

Why does OCaml sometimes require eta expansion?

If I have the following OCaml function: let myFun = CCVector.map ((+) 1);; It works fine in Utop, and Merlin doesn't mark it as a compilation error. When I try to compile it, however, I get the following error: Error: The type of this expression, …
LogicChains
  • 4,332
  • 2
  • 18
  • 27
23
votes
2 answers

Unbound Graphics Module

Running open Graphics;; in OCaml returns an error, saying it is an unbound module. Running it in terminal (ocaml) returns the same thing. Does this mean my Graphics Module was somehow not installed with the OCaml package? If so, how can I install…
Secret
  • 3,291
  • 3
  • 32
  • 50
23
votes
3 answers

How to get type information in interactive Ocaml?

I am using Ocaml of version 4. When I define interactively some type, the interpreter prints out string representation of the type immediately after that: # type foo = Yes | No;; <-- This is what I entered type foo = Yes | No …
Alexey Alexandrov
  • 2,951
  • 1
  • 24
  • 24
23
votes
7 answers

string to list of char

I want to write a function that taking a string and return a list of char. Here is a function, but I think it is not do what I want ( I want to take a string and return a list of characters). let rec string_to_char_list s = match s with |…
Quyen
  • 1,363
  • 1
  • 11
  • 21
23
votes
3 answers

What are type quantifiers?

Many statically typed languages have parametric polymorphism. For example in C# one can define: T Foo(T x){ return x; } In a call site you can do: int y = Foo(3); These types are also sometimes written like this: Foo :: forall T. T -> T I…
Jules
  • 6,318
  • 2
  • 29
  • 40
22
votes
2 answers

Inconsistent assumptions over interface (Ocaml)

I suddenly started to get this error. I don't know how to diagnose or fix it. Am I supposed to grep through bar.ml and check every Big_int function against signature in Big_int.mli? File "foo.ml", line 1, characters 0-1: Error: The files…
pbp
  • 1,461
  • 17
  • 28