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
18
votes
3 answers

code compatibility between OCaml and F#

Good day all, I am developing a small hobby project in OCaml. I was wondering how easy it would be to migrate it to F#. I know that F# has some features that OCaml doesn't, but I was hoping that my OCaml code would require little effort to port. I…
user515232
  • 211
  • 1
  • 5
18
votes
1 answer

Unbound modules in OCaml

My problem is that ocamlc and ocamlopt apear to be refusing to find third party libraries installed through apt-get. I first started having this problem when I tried to incorporate third-party modules into my own OCaml programs, and quickly wrote it…
Eli
  • 2,041
  • 4
  • 18
  • 20
18
votes
7 answers

Functional programming languages introspection

I'm sketching a design of something (machine learning of functions) that will preferably want a functional programming language, and also introspection, specifically the ability to examine the program's own code in some nicely tractable format, and…
rwallace
  • 31,405
  • 40
  • 123
  • 242
18
votes
4 answers

What is the use of monads in OCaml?

This might be a stupid question, but since OCaml is not pure and has side effects built-in, what is the use of monads in OCaml?
Bob Fang
  • 6,963
  • 10
  • 39
  • 72
18
votes
5 answers

Handling incremental Data Modeling Changes in Functional Programming

Most of the problems I have to solve in my job as a developer have to do with data modeling. For example in a OOP Web Application world I often have to change the data properties that are in a object to meet new requirements. If I'm lucky I don't…
Adam Gent
  • 47,843
  • 23
  • 153
  • 203
18
votes
3 answers

Would you please explain OCaml functors to me?

Possible Duplicate: In Functional Programming, what is a functor? I don't know much about OCaml, I've studied F# for some time and quite understand it. They say that F# misses functor model, which is present in OCaml. I've tried to figure out…
Bubba88
  • 1,910
  • 20
  • 44
18
votes
4 answers

OCaml for JVM. Is there any?

I took a look at some new languages for JVM. Two of them are gathering much interest these days: Clojure and Scala. But in my humble opinion, both of them are not ideal. (Let's keep it a speculation, cause I don't want to damage myself…
Bubba88
  • 1,910
  • 20
  • 44
18
votes
2 answers

In OCaml, how can I create an out_channel which writes to a string/buffer instead of a file on disk

I have a function of type in_channel -> out_channel -> unit which will output something to an out_channel. Now I'd like to get its output as a string. Creating temporary files to write and read it back seems ugly, so how can I do that? Is there any…
Tianyi Cui
  • 3,933
  • 3
  • 21
  • 18
17
votes
8 answers

Splitting a list of items into two lists of odd and even indexed items

I would like to make a function that accepts a list and returns two lists: the first contains every odd item, and the second contains every even item. For example, given [1;2;4;6;7;9], I would like to return [ [1;4;7] ; [2;6;9] ]. I have written…
Nathron
  • 1,639
  • 3
  • 18
  • 25
17
votes
3 answers

What is the difference between `'a.` and `type a.` and when to use each?

OCaml has several different syntaxes for a polymorphic type annotation : let f : 'a -> 'a = … (* Isn’t this one already polymorphic? (answer: NO) *) let f : 'a. 'a -> 'a = … let f : type a. a -> a = … We often see them when using…
Maëlan
  • 3,586
  • 1
  • 15
  • 35
17
votes
4 answers

Recognizing arrow keys with stdin

is it possible to have a cross-platform way to handle backspace and arrows keys within a C or OCaml program? Actually an OCaml solution would be appreciated but many standard unix functions are wrapped directly to corresponding API calls so there's…
Jack
  • 131,802
  • 30
  • 241
  • 343
17
votes
1 answer

What does the `and` keyword mean in OCaml?

I'm mystified by the and keyword in OCaml. Looking through this code, I see type env = { (* fields for a local environment described here *) } and genv { (* fields for a global environment here *) } then later, let rec debug stack env (r,…
Jeff Hemphill
  • 406
  • 1
  • 3
  • 14
17
votes
3 answers

Dealing with circular dependencies in OCaml

I'm writing an interpreter for an experimental language. Three of the main constructs of the language are definitions, statements, and expressions. Definitions can contain statements and expressions, statements can contain definitions and…
Jay Conrod
  • 28,943
  • 19
  • 98
  • 110
17
votes
4 answers

How do I make a simple GET request in OCaml?

I'm trying to do something that should be simple: make a GET request to a url. However, when I search for examples of how to do this I often wind up with near-gibberish like this. Does anyone know how to make a simple HTTP request using OCaml? I'm…
dopatraman
  • 13,416
  • 29
  • 90
  • 154
17
votes
3 answers

Why do some OCaml functions take () as a parameter?

Example in Unix module: val environment : unit -> string array Why not just: val environment : string array ?
qrest
  • 3,083
  • 3
  • 25
  • 26