ocaml Questions
2
Solved
Does OCaml have an equivalent to Haskell's Do Notation?
Another way to put it - is there an easy way to handle nesting monadic operations more easily... cause this is annoying:
open Batteries
open ...
Affectation asked 26/5, 2021 at 6:20
5
Solved
What is the OCaml counterpart to Python's "with"-statement?
with open('test.txt', 'r') as f:
# Do stuff with f
# At this point, f will always be closed, even in case of exceptions
That is: What...
Nostrum asked 11/6, 2018 at 9:3
4
Solved
I am a complete beginner with Ocaml programming and I am having trouble linking a module into my program. Actually I am doing some regular expression checking and I have written a function that bas...
7
Solved
When I have two lists in OCaml, for example
e1 = [3; 4; 5; 6; 7]
and
e2 = [1; 3; 5; 7; 9]
Is there an efficient way to get the intersection of those two lists?
I.e.:
[3; 5; 7]
Because I do...
Merline asked 4/3, 2010 at 11:44
1
Solved
I have an OCaml project using dune
Following advice in basic tutorials I have a dir structure like:
bin/
cli.ml
dune
lib/
dune
...
<various>.ml
The number of files in my lib dir is grow...
Taurine asked 9/5, 2021 at 21:1
7
Solved
OCaml's try .. with does not offer a finally clause like Java. It would be useful, though, especially when dealing with side effects. For example, I like to open a file, pass the open file to a fun...
6
Solved
I am coding OCaml under Emacs, I have one makefile in the working folder, and several sub-folders containing .ml files. If I launch M-x compile and make works fine on a buffer of makefile, but does...
Hotbox asked 27/1, 2012 at 17:58
2
Solved
For instance, consider the following code:
type foo = Foo of int
let apply z f = f z
(* This is not allowed *)
let create_foo = Foo
(* This is allowed *)
let create_foo i = Foo i
(* This is not...
1
Brodal et al. demonstrated in their ESA '06 paper the existence of a purely functional structure with logarithmic-time search, update and insertion, and constant-time merge. (Note I'm not talking a...
Typo asked 27/12, 2018 at 12:52
1
Solved
Dependent type systems seem to support some of the uses of a ML module system. What do you get out of a module system that you do not get out of dependent records?
module ~ record
signature ~ rec...
2
I am new to OCaml which I installed via opam. My compiler is dune. Each time I build my project and run it, it crashes but I get no information from where it crashes in the code.
A friend of mine w...
Li asked 24/1, 2021 at 9:7
1
Is it possible reload modules in OCaml's utop?
My development workflow goes something like this when playing around with OCaml code:
First, open up a file example.ml in Vim and hack on it. Switch...
3
Solved
I've been trying out OCaml. Sometimes its quicker just to test out some code using the interpreter shell but, it doesn't bring up the last command when I press the 'up' key.
Its a pain when I miss...
Assistance asked 1/8, 2012 at 10:24
5
Using the traditional, sequential reduction approach, the following graph is reduced as:
(+ (+ 1 2) (+ 3 4)) ->
(+ 3 (+ 3 4)) ->
(+ 3 7) ->
10
Graph reductions are, though, inherently p...
Toucan asked 5/2, 2014 at 16:55
5
Solved
For example in Ruby you could do something like:
list = ["foo", "bar", "baz", "qux", "quux", "corge"]
result = list[2..4]
And result would contain ["baz", "qux", "quux"].
How would you do this ...
4
I have a char list ['a';'b';'c']
How do I convert this to the string "abc"?
thanks x
3
Solved
Haskell has a really swell undefined value, which lazily raises an exception (upon evaluation). Ocaml is of course strict, so as far as I can tell there is no equivalent of Haskell's undefined. Thi...
Heave asked 16/1, 2018 at 11:27
7
Solved
I never used Vi or Vim, but it seems that it is the best option to edit OCaml files.
Unfortunately I am lost with so many things to care about: ocaml-vi-addon, vi-scripts, otags etc.
I broke...
11
Solved
I'm hoping to use either Haskell or OCaml on a new project because R is too slow. I need to be able to use support vectory machines, ideally separating out each execution to run in parallel. I want...
Tucci asked 15/2, 2010 at 21:4
2
Solved
Why does Ocaml have mutable arrays? As far as i understood functional programming, it is to minimize side effects. Are mutable (edit:) Arrays not contrary to that thought?
Even strings are mutable ...
Kex asked 25/8, 2020 at 20:58
2
Solved
Here's a simple example of using the library Cohttp:
open Lwt
open Cohttp
open Cohttp_lwt_unix
let body =
Client.get (Uri.of_string "http://www.reddit.com/") >>= fun (resp, body) ->
le...
Pforzheim asked 2/1, 2018 at 10:10
2
Solved
I'm looking at an OCaml source file that begins with the following instruction:
open! MiscParser
I understand that open MiscParser means "open the MiscParser module", but I don't know what the e...
2
I would do something like this (pseudo code):
1. load sensitive encrypted data from file
2. decrypt the data
3. do something with the unencrypted data
4. override the data safely / securely (for e...
Significs asked 2/6, 2020 at 9:17
2
Solved
I'm a novice to Linux and OCAML. I gather that getting OCaml working on Windows is not straight forward. I found this link:
https://www.cs.umd.edu/class/spring2018/cmsc330/ocamlInstallationGuide.p...
Airt asked 4/3, 2019 at 16:8
2
Solved
I have an OCaml project that uses the Str module, but when compiling, I get this error:
$ make
ocaml setup.ml -build
Finished, 0 targets (0 cached) in 00:00:00.
+ /home/phase/.opam/system/bin/oc...
© 2022 - 2024 — McMap. All rights reserved.