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
4
votes
2 answers

Why product use more memory than record?

According to this presentation (http://oud.ocaml.org/2012/slides/oud2012-paper13-slides.pdf, PDF page 4), the following two data structures use different amount of memory type t1 = { f1: float; f2:float};; type t2 = (float * float);; And t1 use…
Bob Fang
  • 6,963
  • 10
  • 39
  • 72
4
votes
4 answers

OCaml: How to handle sum type properly?

suppose I have the following code: type s = A of a | B of b let foo (a:?) = let bar (input:s) = match input with | A a -> foo input | B b -> ... My question is what should I fill in the question mark in the signature of foo so I won't need a…
Bob Fang
  • 6,963
  • 10
  • 39
  • 72
4
votes
1 answer

Pattern match against a Set

Is it possible to pattern match against a Set like as against a List? For example consider the following code: module MySet = Set.Make (struct ... end) match MySet.empty with | MySet () -> "Empty Set" | MySet (x) -> "Set with exactly one element" |…
Max Maier
  • 985
  • 6
  • 16
4
votes
2 answers

What are the equivalent F# bitwise operators to OCaml's 'lsr' and 'asr'?

I have been looking at an OCaml implementation of Hash Array Mapped Tries and noticed that three distinct bit-level operators are used: lsl: left shift lsr: right shift asr: unsigned right shift I would like to port this to F# but am unsure of the…
Michael Thomas
  • 1,354
  • 7
  • 18
4
votes
2 answers

OCaml recursive types crossing a "module type ="

I've got a complicated set of constraints (mostly pedagogical) that result in me wanting to do something like this: type alpha = ... ENV.env ... and module type ENV = sig type env val foo : ...alpha... end But that's not legal OCaml. For…
dubiousjim
  • 4,722
  • 1
  • 36
  • 34
4
votes
0 answers

How to compile ocaml with android ndk

I am new to ocaml, and I am trying to use ocaml with android ndk but I can't figure out how the linking works. I already got c to work by itself and even haskell (using ghc-android) Here is my c file that will call ocaml code. Right now I am just…
whitehead1415
  • 435
  • 4
  • 14
4
votes
1 answer

How to exit a program?

If the input argument are not as expected I want to exit the program. How should I achieve that? Below is my attempt. let () = if ((Array.length Sys.argv) - 1) <> 2 then …
UnSat
  • 1,347
  • 2
  • 14
  • 28
4
votes
3 answers

OCaml Explicit polymorphic type annotations

I would enjoy to receive some helpful comments concerning an example given on: http://caml.inria.fr/pub/docs/manual-ocaml-400/manual021.html#toc79 7.12 Explicit polymorphic type annotations type 'a t = Leaf of 'a | Node of ('a * 'a) t let rec…
4
votes
3 answers

How to configure _oasis for OCaml to set 'Profile' flag

I have an existing project in OCaml and one _oasis file. I don't know where to enable the profiling flag for ocamlbuild. I looked up Oasis manual and the code, and found there was a variable profile available in setup.data. I assume this was what…
Txin
  • 43
  • 4
4
votes
2 answers

How to traverse typed abstract syntax tree in OCaml compiler

I'm trying to dump type information of all identifiers in an OCaml project, basically it's the same as traversing the typed abstract syntax tree(https://github.com/ocaml/ocaml/blob/trunk/typing/typedtree.mli). Since I'm new to OCaml compiler's…
4
votes
2 answers

Oasis build configuration with subdirectories

I am using oasis to build my ocaml project, with the source code present in a directory called src. The oasis build file looks like that: OASISFormat: 0.4 Name: Test Version: 0.1 Synopsis: no Authors: Me License: …
lambda.xy.x
  • 4,918
  • 24
  • 35
4
votes
3 answers

Compiling C lib and OCaml exe using it, all using ocamlfind

I'm trying to work out how to use ocamlfind to compile a C library and an OCaml executable using that C library. I put together a set of rather silly example files. % cat sillystubs.c #include #include #include…
Magnus
  • 4,644
  • 1
  • 33
  • 49
4
votes
3 answers

Can we define a function with 0 argument in ocaml?

In other languages, we can have a function which takes no arguments. Can we have 0 argument function in ocaml?
UnSat
  • 1,347
  • 2
  • 14
  • 28
4
votes
4 answers

What do I need to know to create a source code editor?

Say I want to create a source code editor for ocaml programming language, where do I start? I am looking to create an editor for the Windows platform as a hobby project. My primary skill is in web development. I have developed windows apps long time…
Animesh
  • 4,926
  • 14
  • 68
  • 110
4
votes
3 answers

How should I do clear screen on ocaml toplevel?

I am using ocaml toplevel with ledit (ledit -l 100 ocaml) on Ubuntu 14.04. Since there is no way to do clear screen, all the time, I keep dwelling at the bottom of the screen. I would like to know if there is a way to do clear screen at…
UnSat
  • 1,347
  • 2
  • 14
  • 28