ocaml Questions

1

Solved

The ocaml manual chapter 8 "language extensions" describes "inline records" (8.17): The arguments of sum-type constructors can now be defined using the same syntax as records. Mutable and polymo...
Megalocardia asked 29/4, 2020 at 13:49

3

Solved

Is there any way to pass a constructor as a function? type foo = | Foo of int | Bar of int let foo x = Foo x let bar = fun x -> Bar x Is there any shorthand for the functions foo and bar? ...
Sendai asked 17/4, 2014 at 7:43

4

Solved

For a list, you can do pattern matching and iterate until the nth element, but for a tuple, how would you grab the nth element?
Streetwalker asked 23/9, 2014 at 22:15

5

Solved

It is unclear to newcomers to the ecosystem what is the canonically preferred way to structure and manage building small to medium sized OCaml projects. I understand the basics of ocamlc, &c.--...
Tanning asked 10/5, 2011 at 20:50

1

Solved

When seeing documentation of modules in Ocamel there is something like this for example in Graphics Module val close_graph : unit -> unit Or when writing a function in an interactive mode: #...
Modeling asked 3/3, 2020 at 19:26

2

Solved

I am trying to create a library that I can use in other OCaml projects, and I'm totally lost. I'm currently using ocamlbuild which is great for spitting out executables, but I don't know how to ge...
Dualism asked 26/5, 2014 at 1:25

1

I would like to expose a function from a Haskell source library using FFI and use it in OCaml code. I saw various examples using the foreign export ccallsyntax in Haskell which I believe exports th...
Unideaed asked 25/11, 2016 at 15:3

1

Solved

Suppose I have a type consisting of multiple polymorphic variants (covariantly) such as the following: [> `Ok of int | `Error of string] Let's further suppose that I want to factor this defin...

2

Solved

In F#, I'd simply do: > let x = Set.empty;; val x : Set<'a> when 'a : comparison > Set.add (2,3) x;; val it : Set<int * int> = set [(2, 3)] I understand that in OCaml, when u...
Driest asked 10/12, 2019 at 11:1

3

Solved

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 counterpa...
Deitz asked 18/5, 2013 at 18:13

3

Solved

I installed Coq with opam and want to make a Coq plugin. I managed to compile some plugin examples using coq_makefile, but it would be great if I could use merlin in vim for type information and co...
Lazulite asked 14/4, 2015 at 1:30

2

Solved

I'm a big fan of creating data structures that make representing invalid states impossible, so I wanted to ask how I could represent a non empty list in reasonml? Since it's possible to pattern ma...
Tunic asked 15/11, 2019 at 0:17

4

Solved

Sometimes I see code like let (alt : recognizer -> recognizer -> recognizer) = fun a b p -> union (a p) (b p) Or like: let hd = function Cons(x,xf) -> x | Nil -> raise Empty ...
Grievance asked 21/10, 2009 at 23:46

3

Solved

Let's say I have a user defined type like type foo = string * string list, if I want to insert print debug statements in my code to see what values it holds, what would be the fastest way to do it?...
Bindery asked 21/1, 2016 at 23:49

1

Solved

I was quite surprised to see that even a simple program like: print_string "Hello world !\n"; when statically compiled to native code through ocamlopt with some quite aggressive options (using m...
Coroner asked 20/9, 2019 at 12:55

1

Solved

My problem is similar to this, however, in my case .ocamlinit is set. Here is my ocaml version. mymac:Desktop myusr$ ocaml --version The OCaml toplevel, version 4.08.1 Here is my opam version. ...
Fibro asked 17/9, 2019 at 2:51

2

Solved

Based on my readings (notably the wiki and this blog post), I have come up with the following default.nix that I load with nix-shell: with import <nixpkgs> {}; let emacs = emacsWithPackage...
Chevalier asked 7/9, 2016 at 14:8

3

Solved

My question is if there is any difference between Standard ML's module system and OCaml module system? Has OCaml all the support of functors , ascriptions etc... that SML has?
Babettebabeuf asked 23/3, 2013 at 8:30

3

How can I install OCaml with OPam on windows?
Beeck asked 18/9, 2016 at 16:51

1

Solved

As per https://github.com/ocaml/ocaml/pull/1110, OCaml 4.08 and later raises a warning for unused module opens, even when they are opened with open!. This creates friction with the common practice ...
Mellissamellitz asked 20/7, 2019 at 0:39

2

Solved

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 contro...
Scotopia asked 11/7, 2019 at 4:48

1

Solved

This chapter in Real World OCaml describes the runtime memory layout of different data types. However, there is no discussion on lazy values. How is lazy_t implemented, i.e., what does its runtim...
Standoff asked 25/6, 2019 at 3:16

4

I often read some programming languages have "First Class" support for modules (OCaml, Scala, TypeScript[?]) and recently stumbled upon an answer on SO citing modules as first class citizens among ...
Stomatic asked 13/6, 2019 at 7:15

2

Solved

Trying to compile module F (M : sig type t = [> `Foo ] end) = struct type t = [ M.t | `Bar ] end gets me Error: A type variable is unbound in this type declaration. In type [> `Foo ] as...
Oratorian asked 18/10, 2014 at 7:46

4

Solved

I am using this to split strings: let split = Str.split (Str.regexp_string " ") in let tokens = split instr in .... But the problem is that for example here is a sentence I want to parse: po...
Audrey asked 21/4, 2014 at 19:57

© 2022 - 2024 — McMap. All rights reserved.