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
15
votes
6 answers

What is the "let" keyword in functional languages like F# and OCaml for?

When looking at F#, Ocaml and other functional language code examples I notice that the let keyword is used very often. Why do you need it? Why were the languages designed to have it? Why can't you just leave it out? e.g: let x=4 becomes x=4
Trix
  • 221
  • 3
  • 5
15
votes
5 answers

Stack overflow in OCaml and F# but not in Haskell

I've been comparing for fun different languages for speed in execution of the following program: for i from 1 to 1000000 sum the product i*(sqrt i) One of my implementations (not the only one) is constructing a list [1..1000000] and then folding…
FDP
  • 173
  • 6
15
votes
3 answers

The value restriction

In OCaml you can't generalize a partially-applied curried function (the "value restriction"). What is the purpose of the value restriction? What unpleasant would happen if it did not exist?
ThePiercingPrince
  • 1,873
  • 13
  • 21
15
votes
3 answers

How to load file.ml

How to load a file myfile.ml that I can use it my file? And where should I put this file for the compiler to find it?
user3077133
  • 209
  • 1
  • 3
  • 6
15
votes
1 answer

Why SML and OCaml are considered as dialects of ML? What is the definition of ML?

There are many dialects of ML, and SML and OCaml are most popular ones. There're many differences between SML and OCaml, but they are both considered as dialects of ML. So, Why SML and OCaml are considered as dialects of ML? How can a language be…
InsaneRabbit
  • 316
  • 1
  • 9
15
votes
2 answers

Module and Class in OCaml

What are the differences between Module and Class in OCaml. From my searching, I found this: Both provide mechanisms for abstraction and encapsulation, for subtyping (by omitting methods in objects, and omitting fields in modules), and for…
yjasrc
  • 503
  • 1
  • 4
  • 15
15
votes
2 answers

How to get a formatted string in OCaml?

In OCaml, I can use Printf.printf to output formatted string, like Printf.printf "Hello %s %d\n" world 123 However, printf is a kind of output. What I wish for is not for output, but for a string. For example, I want let s = something "Hello %s…
Jackson Tale
  • 25,428
  • 34
  • 149
  • 271
15
votes
2 answers

Why OCaml's threading is considered as `not enough`?

It seems many people are saying OCaml does not have a good capacity for concurrency and it is also not good for web server applications. I am currently learning ocaml's manual. It seems that OCaml provide concurrency now. Can I know why OCaml's…
Jackson Tale
  • 25,428
  • 34
  • 149
  • 271
15
votes
2 answers

Why doesn't OCaml support record subtyping?

Reading "Types and programming languages", I got impressed by the object implementation using closures and record subtyping (chapter 18). Is there any particular reason OCaml doesn't support record subtyping (I know objects do, though)? In fact, I…
Olle Härstedt
  • 3,799
  • 1
  • 24
  • 57
15
votes
4 answers

How to implement a dictionary as a function in OCaml?

I am learning Jason Hickey's Introduction to Objective Caml. Here is an exercise I don't have any clue First of all, what does it mean to implement a dictionary as a function? How can I image that? Do we need any array or something like that?…
Jackson Tale
  • 25,428
  • 34
  • 149
  • 271
15
votes
1 answer

ocaml pretty printer (code formatter)

I am looking for a code formatter or pretty printer for ocaml. Something like gofmt for the go programming language. It should preferably preserve comments. I am correcting hand-ins and some of the code is formatted in a way that makes it very hard…
ReyCharles
  • 1,772
  • 10
  • 30
14
votes
2 answers

is begin..end in OCaml syntactic sugar?

Looking at an unofficial OCaml grammar in this site the only production where begin appears is: Expression ::= begin Expression end and a little further down one sees: Expression ::= ( Expression [:Type] ) That, together with some offhand…
Marcus Junius Brutus
  • 26,087
  • 41
  • 189
  • 331
14
votes
3 answers

OCaml + Menhir Compiling/Writing

I'm a complete newbie when it comes to OCaml. I've only recently started using the language (about 2 weeks ago), but unfortunately, I've been tasked with making a syntax analyzer (parser + lexer, whose function is to either accept or not a sentence)…
Lopson
  • 1,202
  • 1
  • 8
  • 20
14
votes
7 answers

Is there a name for a function that takes a piece of data and a list of functions and applies each function to the result of the last one?

Clojure has a macro, ->, which takes a piece of data and a bunch of functions, applies the data to the first function, and then applies the result of that to the next one, the result of that to the third one, and so on, finally giving you back the…
14
votes
2 answers

How to visualize/draw automata in ocaml?

I am doing composition of automata. So at the end of that, I want to draw the composed automata also. So are there any libraries for that in ocaml? or are there ocaml wrappers written for any graph visualization tool? I have googled for it but…
priyanka
  • 923
  • 1
  • 9
  • 20