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

Drop first n items in a list

I'm trying to make a function which drops the first n items of a list: let rec drop n h = if n == 0 then h else (drop n-1 (match h with a::b -> b));; This is giving: Characters 43-49: if n == 0 then h else (drop n-1 (match h with a::b ->…
lalli
  • 6,083
  • 7
  • 42
  • 55
4
votes
1 answer

`brew install infer` error while updating infer

I recently updated facebook infer on my work laptop, and am trying to update infer on my personal laptop. It installed without an issue on my work laptop, but I am getting an error (see below) on my personal laptop. Both have opam 1.2.2 and ocaml…
lgdroid57
  • 699
  • 14
  • 29
4
votes
3 answers

OCaml: Combination of elements in Lists, functional reasoning

I am back to coding in OCaml and I missed it so much. I missed it so much I completely lost my reasoning in this language and I hit a wall today. What I want to do is the combination of elements between a set of n lists. I decomposed the problem by…
João Bastos
  • 193
  • 1
  • 10
4
votes
1 answer

OCaml refer to module in ml file inside mli

Here I have a file set.ml with a module called IntSet. How do I refer to the module IntSet inside the corresponding interface file set.mli? module IntSet = struct type t = int list;; let empty = [];; let rec is_member key = function | []…
Greg Nisbet
  • 6,710
  • 3
  • 25
  • 65
4
votes
3 answers

Difference between OCaml Type casting

What is the differences between Ocaml type casting / conversion methods below? let a = (float) b ;; And let a = float_of_int b ;; (Consider a is a float and b is an integer.) Is there any advantage one over another? or are they same?
Darshana
  • 130
  • 1
  • 8
4
votes
3 answers

Call graph generator for OCaml or Reason

I want to analyze a OCaml/Reason code repository and understand calls between various functions. Is there a tool that provides such functionality?
xennygrimmato
  • 2,646
  • 7
  • 25
  • 47
4
votes
3 answers

Unable to install core and utop for OCaml on Ubuntu 14.04 with OPAM

I have been trying to set up OCaml, OPAM, related libraries and UTOP on Ubuntu 14.04 based on instructions from Real World OCaml. I have currently managed to install OCaml compilers and OPAM. However, when trying to install core and UTOP, I get the…
4
votes
1 answer

How to find documentation in Core.Std?

Where is the documentation for functions, symbols under Core.Std ? Or, is there any conventional way to look up ocaml documentation rather than guessing in utop REPL ? E.g. I know if open Core.Std, then the function String.split will be imported.…
CodeFarmer
  • 2,644
  • 1
  • 23
  • 32
4
votes
1 answer

Physical equality test for functions in Caml

In Caml, the operator == tests the physical equality between two values of a same type. It can be used in particular to compare functions in this way. One has for instance # print_string == print_string;; - : bool = true but, surprisingly, # (==)…
Samuele Giraudo
  • 409
  • 2
  • 14
4
votes
2 answers

OCaml Test if a string is almost empty or contains keywords

I've got a problem in OCaml, I'm currently learning it but I'm quite a newbie still. I would like to make a function which is returning true if the string is empty or contains only whitespace and in the same time remove any occurence of begin and…
Valentin Montmirail
  • 2,594
  • 1
  • 25
  • 53
4
votes
1 answer

How does include work?

I have module type T = sig type t end and module Make (TypeProvider : T) = struct include TypeProvider type d = Wrapped of t end and module Test = struct include Make (struct type t = ForWrap end) let f = function | Wrapped…
Valentyn Zakharenko
  • 2,710
  • 1
  • 21
  • 47
4
votes
0 answers

Integrating GTK and Lwt

I am working on a program in which I would like to use lablgtk and lwt. I have functions fetching data on lwt threads, then I would like to display the data in a GUI using lablgtk. I am struggling with the integration of lablgtk in the lwt…
Thomas
  • 347
  • 3
  • 19
4
votes
1 answer

Make compatible ocaml, camlp4, ppx, node, js_of_ocaml, ocamlbuild

After installing npm and node, compiling OCaml files with js_of_ocaml gave errors, thus I did opam switch reinstall system: :testweb $ opam switch reinstall system Your system compiler has been changed. Do you want to upgrade your OPAM installation…
SoftTimur
  • 5,630
  • 38
  • 140
  • 292
4
votes
2 answers

OCaml attributes

I was looking at the manual and found that there are attributes in OCaml for declaring things as deprecated (see http://caml.inria.fr/pub/docs/manual-ocaml/extn.html), but I can not figure out how to get them to be recognized by the compiler. Here's…
Gregory
  • 1,205
  • 10
  • 17
4
votes
1 answer

OCaml Syntax: what does >>= mean?

in this piece of code: let rec write_from_exactly out s offs len = Lwt_unix.write out s offs len >>= fun n -> if n = len then Lwt.return () else write_from_exactly out s (offs + n) (len - n) in ... Although I can more or less…
user1252446