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

OCaml toplevel with syntax extensions

I don't know how to accomplish this in general, but I'll ask about one instance in particular for clarity: Sexplib looks interesting to me. I want to play around with it. I've downloaded it, installed it just fine (I'm pretty sure, anyway), etc. I…
koschei
  • 819
  • 6
  • 13
14
votes
2 answers

OCaml interface vs. signature?

I'm a bit confused about interfaces vs. signatures in OCaml. From what I've read, interfaces (the .mli files) are what govern what values can be used/called by the other programs. Signature files look like they're exactly the same, except that they…
14
votes
1 answer

automata in OCaml

I am a bit new to OCaml. I want to implement product construction algorithm for automata in OCaml. I am confused how to represent automata in OCaml. Can someone help me?
priyanka
  • 923
  • 1
  • 9
  • 20
14
votes
2 answers

Why does OCaml use exceptions instead of representing errors with Sum Types?

I've read https://stackoverflow.com/a/12161946/ which somewhat addresses OCaml exceptions in the context of performance and mentions that one might use exceptions to intentionally manipulate control flow. However, I'd like to know the rationale…
Julian Ceipek
  • 525
  • 3
  • 13
14
votes
1 answer

When should extensible variant types be used in OCaml?

I took a course on OCaml before extensible variant types were introduced, and I don't know much about them. I have several questions: (This question was deleted because it attracted a "not answerable objectively" close vote.) What are the…
Pteromys
  • 1,441
  • 2
  • 12
  • 29
14
votes
2 answers

Open and closed union types in Ocaml

I'm looking into OCaml for the first time, having a bit of background with F# and Haskell. As such, a lot is familiar-looking, but one thing that isn't is the concept of "open" and "closed" unions (with the backtick and [< syntax). What are these…
J Cooper
  • 16,891
  • 12
  • 65
  • 110
14
votes
2 answers

How do I declare a map type in Reason ML?

One advantage of Reason ML over JavaScript is that it provides a Map type that uses structural equality rather than reference equality. However, I cannot find usage examples of this. For example, how would I declare a type scores that is a map of…
sdgfsdh
  • 33,689
  • 26
  • 132
  • 245
14
votes
4 answers

Mixing OCaml and C: is it worth the pain?

I am faced with the task of building a new component to be integrated into a large existing C codebase. The component is essentially a kind of compiler, and will be complicated enough that I would like to write it in OCaml (for reasons along the…
tjgreen
  • 469
  • 2
  • 10
14
votes
2 answers

Why does Scala allow nested data structures like List or Array

Why does a language like Scala, with a very strong static type system, allow the following constructions: scala> List(1, List(1,2)) res0: List[Any] = List(1, List(1, 2)) The same thing works if you replace List with Array. I learned functional…
alifirat
  • 2,899
  • 1
  • 17
  • 33
14
votes
2 answers

A good ocaml parser?

I'm looking for a good ocaml parsing library that isn't a derivative of flex/bison. Ideally, I'd like a monadic combinator library along the lines of parsec, but I can't find anything. I would use haskell, but making llvm bindings for haskell is…
gnkdl_gansklgna
  • 2,227
  • 1
  • 16
  • 17
14
votes
1 answer

how to to do the "noop but return unit" in OCaml

I want to print a list of strings after going through a pattern matching just to get into this powerful functionality. How can I express the "do-nothing-but-return-unit" operation ? What I mean is: let print_nodes nodes = match nodes with …
Jack
  • 131,802
  • 30
  • 241
  • 343
14
votes
2 answers

List Comprehension in Ocaml?

It seems that Ocaml batteries have comprehension syntax: http://en.wikipedia.org/wiki/List_comprehension#OCaml However, what module should I include to use this syntax? I already open Batteries, but it doesn't work. Or is there a more idiomatic way…
user69818
  • 403
  • 6
  • 13
14
votes
2 answers

Ocaml utop library paths, Core module

I am attempting to use the Core module in utop, as originated by Jane Street and installed using opam. Here's the problem utop # open Core.Std;; Error: Unbound module Core utop does not seem to have the path to the Core module. How do you specify…
user3161399
  • 253
  • 2
  • 6
14
votes
2 answers

What does % mean in an OCaml external declaration?

Many external declarations in the OCaml standard library have a % at the beginning of the function name, such as the definition of int_of_float: external int_of_float : float -> int = "%intoffloat" What does the '%' mean?
Michael Ekstrand
  • 28,379
  • 9
  • 61
  • 93
14
votes
3 answers

Is there a `flip` function in the OCaml standard library?

In Haskell, we have a flip function: flip f x y = f y x, which essentially takes a function and returns the same function except that the two arguments are swapped. I wonder if there is a counterpart in OCaml, since I could not find one and don't…
tfboy
  • 947
  • 1
  • 10
  • 14