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
17
votes
1 answer

How practical is it to embed the core of a language with an effectful function space (like ML) into Haskell?

As Moggi proposed 20 years ago, the effectful function space -> of languages like ML can be decomposed into the standard total function space => plus a strong monad T to capture effects. A -> B decomposes to A => (T B) Now, Haskell supports…
RD1
  • 3,305
  • 19
  • 28
17
votes
2 answers

How stable and widespread is "OCaml Batteries Included" and is it recommended?

I'm just getting back into OCaml for a new small research project after many years of SML, Haskell and F#. I quickly found myself missing some things when using the OCaml libraries, and I also missed having a syntax for monadic comprehensions. OCaml…
RD1
  • 3,305
  • 19
  • 28
17
votes
6 answers

Learning .NET from F# without C#

I'm a Java/C++ developer that never spent time in learning C# and the relative .NET foundation. Then I learned OCaml because I had to use it for my master thesis so I heard about F# and wondered: will F# allow me to easily use the .NET API to build…
Jack
  • 131,802
  • 30
  • 241
  • 343
17
votes
2 answers

First class modules in OCaml 3.12: What kinds of things will they make easier (or possible)?

I've heard that "first class modules" are coming in OCaml 3.12. What advantages will they offer? What kids of things will be easier? What problem are they trying to solve? A simple example would suffice.
aneccodeal
  • 8,531
  • 7
  • 45
  • 74
17
votes
9 answers

Ideas for Natural Language Processing project?

I have to do a final project for my computational linguistics class. We've been using OCaml the entire time, but I also have familiarity with Java. We've studied morphology, FSMs, collecting parse trees, CYK parsing, tries, pushdown automata,…
Nick Heiner
  • 119,074
  • 188
  • 476
  • 699
17
votes
1 answer

Record type pattern matching in Ocaml

I'm trying to use pattern matching to write a calculator application. Two major types defined as below: type key = Plus | Minus | Multi | Div | Equals | Digit of int;; type state = { lcd: int; (* last computation done *) lka: key; (* last…
yjasrc
  • 503
  • 1
  • 4
  • 15
17
votes
3 answers

Integer exponentiation in OCaml

Is there a function for integer exponentiation in OCaml? ** is only for floats. Although it seems to be mostly accurate, isn't there a possibility of precision errors, something like 2. ** 3. = 8. returning false sometimes? Is there a library…
user2258552
  • 824
  • 1
  • 11
  • 25
17
votes
3 answers

Optional argument cannot be erased?

I wanted to have a tail-recursive version of List.map, so I wrote my own. Here it is: let rec list_map f l ?(accum=[])= match l with head :: tail -> list_map f tail ~accum:(head :: accum) | [] -> accum;; Whenever I compile this…
Jason Baker
  • 192,085
  • 135
  • 376
  • 510
17
votes
2 answers

Does `string` in OCaml support UTF-8?

Does the type string in OCaml support utf8? Or what library I should use for utf8 string?
Jackson Tale
  • 25,428
  • 34
  • 149
  • 271
17
votes
2 answers

Why there is a plus sign before this type?

I was browsing ocaml's standard library, and came across this code in the map.ml file. module type S = sig type key type +'a t val empty: 'a t' I'm wondering why there is type +'a t, and why the author use it instead of simply 'a…
octref
  • 6,521
  • 7
  • 28
  • 44
17
votes
4 answers

What's the difference between functors and "generics"

I'm looking at OCaml's functors. It looks to me pretty identical to the so called generic objects in C++/C#/Java. If you ignore Java's type erasion for now, and ignore the implementation details for C++ templates (I'm interested with the language…
Elazar Leibovich
  • 32,750
  • 33
  • 122
  • 169
17
votes
2 answers

How can I get syntastic error checking to work with OCaml?

Syntastic works for me in general (say, if I edit C/C++ files then I get syntax error notifications), but I can't get it to show syntax errors for OCaml. My OCaml install seems fine otherwise, and the binaries that are mentioned in the header of…
Nicholas Meyer
  • 253
  • 2
  • 7
16
votes
4 answers

How to represent a simple finite state machine in Ocaml?

I have written some state machine in C++ and Java but never in a functional language like Ocaml Problem is I don't know if I can just adapt code from the object languages versions, since in Ocaml records and variants are more powerful than class;…
codablank1
  • 6,055
  • 5
  • 19
  • 29
16
votes
3 answers

Tools for profiling OCaml code

Is anybody aware of programs for profiling OCaml code apart from using the -p option while compilation and then using gprof? I am asking this question in order to check if the sampling time of 0.01 second can be lowered further?
maths-help-seeker
  • 946
  • 1
  • 10
  • 30
16
votes
5 answers

List of Functional code snippets for Procedural Programmers?

Sometimes I still get stuck trying to translate procedural code into functional code. Is there a list of functional idioms/snippets that are mapped to procedural idioms/snippets? Edit Since there doesn't seem to be a centralized website of these…
Unknown
  • 45,913
  • 27
  • 138
  • 182