Upgrading the opam on Ubuntu 14.04

I'm trying to upgrade my opam to the latest version of Ubuntu 14.04 [email protected]:~$ sudo opam update default Downloading https://opam.ocaml.org/1.1/urls.txt Updating ~/.opam/repo/compiler-index ... Updating ~/.opam/compilers/ ...

Nativeint Bigarray seems to be unsigned

I want to return int-arrays from a C-library to a OCaml program. In order to do so, I thought I'd just wrap them in a Bigarray.Array1.t. Below is a small demo of the C-stubs: /* nativeintarray.c */ #include <stdio.h> #include <assert.h> #inclu

OCaml: Filter the map and place the values ​​in a list

I can filter my map by key : module PairKeys = struct type t = string * string let compare (x0,y0) (x1,y1) = match String.compare x0 x1 with | 0 -> String.compare y0 y1 | c -> c end module StringMap = Map.Make(PairKeys);; .... let put_key_values_int

Using the map function in 2d lists?

let lst = [[1;2;3];[4;5;6]];; How do I use a map function in a 2D array in OCaml(Lists are immutable) such that I can square every element and get : - lst = [[1;4;9];[16;25;36]];; You could write a mapmap : ('a -> 'b) -> 'a list list -> 'b list l

OCaml: JSON analysis in cyclic mode

This question is related to another question I asked before. I am reading data from a JSON file and try to parse them into a datatype i made. { "rooms": [ { "id": "room1", "description": "This is Room 1. There

Equivalent to OCaml variants in Ruby

Is there a way to create in Ruby something like the OCaml variants? I'm trying to do something like this: type status = | sent of DateTime * Location | paid of DateTime | new But I can't figure how to do this in a a clean, safe and concise way. I hav

Include the OCaml module in interpreted and compiled modes

Say I have some OCaml code where I need to use the Str module. If I run the code with the interpreter, then I have to put #load Str.cma to be able to use the Str module. But if I want to native-compile the code, then the load directive causes an erro

OCaml how to handle tuples?

Let's say I have a tuple: let x = (1,3) I want to add 1 to only the first value of the tuple. How would I do that?You use pattern matching to deconstruct the tuple and then construct the updated one: let (x1, x2) = x in (x1 + 1, x2)

OCaml: module, class & amp; type

I have the following code in OCaml that produces the error " Unbound type constructor variable" : module OrderedVar = struct type t = variable let compare v1 v2 = v1#get_name - v2#get_name end module VarSet = Set.Make(OrderedVar) class variable

ocamlfind can not see the installed package

I wanted to compile my project using command: ocamlfind ocamlopt -package ocamlnet -package batteries -package unix -linkpkg oauth.ml but I'm getting following error: ocamlfind: Package `ocamlnet' not found make: *** [oauth.cmi] Error 2 After some re

Global variables in Ocaml

I am looking for a way to define global variables in ocaml so that i can change their value inside the program. The global variable that I want to user is: type state = {connected : bool ; currentUser : string};; let currentstate = {connected = false

Chart with summits

I have a tiny grammar represented as a variant type term with strings that are tokens/part of tokens (type term). Given expressions from the grammar, I am collecting all strings from expressions and pack them into sets (function vars). Finally, I wan

ocaml function calling List.fold_left

Fill in the skeleton given for pipe which uses List.fold_left to get an OCaml function val pipe : ('a -> 'a) list -> ('a -> 'a) such that pipe [f1;...;fn] (where f1,...,fn are functions!) returns a function f such that for any x, we have f x retu

Can the reference type manufacturers be ocamldoc?

I'm trying to refer to a type constructor in ocamldoc. For example: type x = Awesome | Boring And later we want to refer to one of the constructors in some documentation: (** {!Awesome} is a really great constructor for {!x}. You should definitely us

Convert a list into a set?

Is it really true that OCaml doesn't have a function which converts from a list to a set? If that is the case, is it possible to make a generic function list_to_set? I've tried to make a polymorphic set without luck. Best regards, Lasse EspeholtFunda

Type of addition (+) in F #

I just learned that OCAML have to have a . postfix for doing float arithmetic. An example would be 3. +. 4. which equals 7. (float). However, F# handles float and integer arithmetic in the same way, so both 3 + 4 (int) and 3. + 4. (float) works. F# h

When can I free the GPL software from the LGPL libraries?

I am writing a system in OCaml which I'd like to release open source with a GPL license. However, I'm calling Batteries, which is LGPL, from within my code. Does this contaminate my code with the LGPL license? At first, I'd say NO, but I'm having a h

Ocamlyacc analysis error: which token?

I'm using ocamlyacc and ocamllex. I have an error production in my grammar that signals a custom exception. So far, I can get it to report the error position: | error { raise (Parse_failure (string_of_position (symbol_start_pos ()))) } But, I also wa

How do I create a type with multiple parameters in OCaml?

I'm trying to create a type that has multiple type parameters. I know how to make a type with one parameter: type 'a foo = 'a * int But I need to have two parameters, so that I can parameterize the 'int' part. How can I do this?The way to do this is:

Hashtable indexed on multiple fields

I'm currently programming an OCaml module defining a type corresponding to a CPU register. The interface of this module is the following : (* * Defines a type which represents a R3000 register. *) type t = | R0 (* Always 0 *) | AT (* Assembler tempor

What are OCaml's other high-level programs? (View)

I'm using OCamlWinPlus v1.9RC4. It sucks pretty hardcore. It's constantly crashing, and lacks basic features. What other toplevel OCaml programs can be recommended for Windows Vista?You can use a Windows version of Emacs and use the customization fil

F # passes to OCaml

F# is derived from OCaml, but what major items are missing or added? Specifically I'm curious as to whether the resources available for learning OCaml are also useful to someone who wants to learn F#.The main differences are that F# does not support:

How do I get a stack trace in OCaml?

The Objective Caml language will only produce stack traces if you ask for them just right - what are the requirements for both bytecode and native code?Compile with -g and set environment variable OCAMLRUNPARAM=b