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
243
votes
19 answers

In Functional Programming, what is a functor?

I've come across the term 'Functor' a few times while reading various articles on functional programming, but the authors typically assume the reader already understands the term. Looking around on the web has provided either excessively technical…
Erik Forbes
  • 35,357
  • 27
  • 98
  • 122
172
votes
1 answer

Sneaking lenses and CPS past the value restriction

I'm encoding a form of van Laarhoven lenses in OCaml, but am having difficulty due to the value restriction. The relevant code is as follows: module Optic : sig type (-'s, +'t, +'a, -'b) t val lens : ('s -> 'a) -> ('s -> 'b -> 't) -> ('s, 't,…
J. Abrahamson
  • 72,246
  • 9
  • 135
  • 180
132
votes
4 answers

F# changes to OCaml

F# is derived from OCaml, but what major items are missing or added? Specifically I'm curious as to whether the resources available for learning OCaml are also useful to someone who wants to learn F#.
Erik Forbes
  • 35,357
  • 27
  • 98
  • 122
123
votes
5 answers

Why is an int in OCaml only 31 bits?

Haven't seen this "feature" anywhere else. I know that the 32nd bit is used for garbage collection. But why is it that way only for ints and not for the other basic types?
Daniel
  • 26,899
  • 12
  • 60
  • 88
116
votes
6 answers

Why are functions in OCaml/F# not recursive by default?

Why is it that functions in F# and OCaml (and possibly other languages) are not by default recursive? In other words, why did the language designers decide it was a good idea to explicitly make you type rec in a declaration like: let rec foo ... =…
nsantorello
  • 1,709
  • 3
  • 16
  • 18
106
votes
2 answers

What are the differences between SML and OCaml?

What sets the two ML dialects apart?
Nathan
  • 1,071
  • 2
  • 8
  • 5
92
votes
7 answers

Why is writing a compiler in a functional language easier?

I've been thinking of this question very long, but really couldn't find the answer on Google as well a similar question on Stackoverflow. If there is a duplicate, I'm sorry for that. A lot of people seem to say that writing compilers and other…
wvd
  • 1,189
  • 2
  • 12
  • 23
74
votes
9 answers

Explaining pattern matching vs switch

I have been trying to explain the difference between switch statements and pattern matching(F#) to a couple of people but I haven't really been able to explain it well..most of the time they just look at me and say "so why don't you just use…
Nathan W
  • 54,475
  • 27
  • 99
  • 146
70
votes
11 answers

Machine learning in OCaml or Haskell?

I'm hoping to use either Haskell or OCaml on a new project because R is too slow. I need to be able to use support vectory machines, ideally separating out each execution to run in parallel. I want to use a functional language and I have the…
griffin
  • 3,158
  • 8
  • 37
  • 34
67
votes
2 answers

F# vs OCaml: Stack overflow

I recently found a presentation about F# for Python programmers, and after watching it, I decided to implement a solution to the "ant puzzle" on my own. There is an ant that can walk around on a planar grid. The ant can move one space at a time…
ttsiodras
  • 10,602
  • 6
  • 55
  • 71
67
votes
5 answers

Does != have meaning in OCaml?

It seems to be an equivalency comparison for some types, but not strings. # 3 != 3;; - : bool = false # 3 != 2;; - : bool = true This is as expected. # "odp" = "odp";; - : bool = true # "odp" != "odp";; - : bool = true # "odp" <> "odp";; - : bool =…
Nick Heiner
  • 119,074
  • 188
  • 476
  • 699
64
votes
5 answers

What is the preferred way to structure and build OCaml projects?

It is unclear to newcomers to the ecosystem what is the canonically preferred way to structure and manage building small to medium sized OCaml projects. I understand the basics of ocamlc, &c.--they mirror conventional UNIX C compilers enough to seem…
jrk
  • 2,896
  • 1
  • 22
  • 35
62
votes
5 answers

What is the benefit of purely functional data structure?

There are large number of texts on data structures, and libraries of data structures code. I understand that purely functional data structure is easier to reason about. However I have trouble to understand the real world advantage of using purely…
62
votes
2 answers

OCaml and Opam: unbound module Core

I'm trying to get an OCaml environment set up, and I've followed the instructions from appendix A of the Real World OCaml beta. I set up opam, and installed a version of OCaml with the command $ opam switch 4.01.0dev+trunk which passed fine. I then…
bstamour
  • 7,746
  • 1
  • 26
  • 39
61
votes
3 answers

What are the primary theoretical difficulties with adding ML-style modules to Haskell?

It is well known that Haskell-style typeclasses and ML-style modules offer different mechanisms for specifying interfaces. They are (possibly) equivalent in power, but in practice each has their own benefits and drawbacks. Since I'm a bit of an…
Edward Z. Yang
  • 26,325
  • 16
  • 80
  • 110
1
2 3
99 100