OCaml version in utop [closed]
OCaml » Stack Overflow
by roflmoqkz
4h ago
When I use utop, the version of OCaml used is 4.05.0. I need to use a newer version (4.07.0 or higher). I have already installed a newer version (4.07.0), and I have configured the path variable so that this is the default version when I use the command line, but utop still says that it uses version 4.05.0. I have also reinstalled utop, but the version still doesn't change, and even the utop version is still the previous one (1.19.3 instead of 2.2.0) How do I make utop use a newer version? Thank you ..read more
Visit website
How to read large files faster [closed]
OCaml » Stack Overflow
by Echo_Zero
2d ago
I am writing a parser in OCaml and first I need a function to read the object file. I wrote the following function to read the contents of the target file and convert it to string output: let read_all_lines filename : string = let contents = In_channel.with_open_bin filename In_channel.input_all in contents When I use this function to read large files, it takes a long time. For example, a file with more than 20,000 lines of code would take 20 seconds to read. Is there any way to optimize it ..read more
Visit website
Can't understand the syntax in ocaml code
OCaml » Stack Overflow
by georgehu
2d ago
I have the following code: module Make_Set (Elt : EQ) : SET with type elt = Elt.t = struct type elt = Elt.t type t = elt list let empty = [] let rec is_element i set = match set with [] -> false | x :: xs -> Elt.eq x i || is_element i xs let add i set = if is_element i set then set else i :: set end I can't understand the SET with type elt = Elt.t, nor I can find it in the official documentation ..read more
Visit website
Why does exiting Utop and reloading of modules not work?
OCaml » Stack Overflow
by user172501
6d ago
When I start my utop interpreter and then say #quit;; I get the answer Error: unbound value quit The command #Topfind.reset();; doesn't recompile the ml-files, that I have changed I always need to kill the whole terminal and start a new one, which makes work tedious. What do I do wrong ..read more
Visit website
Installing Dune with the help of Opam
OCaml » Stack Overflow
by user172501
6d ago
I have somehow managed to install Opam on MSYS2 on Windows. When I open the MSYS2 MING64 (the blue one) shell and enter opam --version it tells me that it is installed. When I run opam install dune , that command worked the first time and now it says [NOTE] Package dune is already installed (current version is 3.5.0). However if I then want to launch dune with dune init proj myfirstocamlproject it says bash : dune : command not found I followed also the tutorial https://opam.ocaml.org/doc/Usage.html and ran the command opam init It tells me in the end User configuration: C:/Soft ..read more
Visit website
OCaml equivalent of Python generators
OCaml » Stack Overflow
by Aristide
6d ago
The french Sécurité Sociale identification numbers end with a check code of two digits. I have verified that every possible common transcription error can be detected, and found some other kinds of errors (e.g., rolling three consecutive digits) that may stay undetected. def check_code(number): return 97 - int(number) % 97 def single_digit_generator(number): for i in range(len(number)): for wrong_digit in "0123456789": yield number[:i] + wrong_digit + number[i+1:] def roll_generator(number): for i in range(len(number) - 2): yield number[:i] + number[i ..read more
Visit website
Compiling multifile projects in Ocaml, leading to Unbound Module error
OCaml » Stack Overflow
by user2628206
1w ago
Context I am currently trying to learn the basics of OCaml (by doing the 2022 advent of code challenges). My aim is to get the basic down using only the OCaml standard library and writing my own make-files and not using package managers but instead directly running the commands like ocamlopt and ocamlc to compile and link a program together. I'm getting to the point where I have enough program-logic abstracted out that it makes sense for me to start writing modules and popping into their own .ml files to be included into the main .ml file for my compiled programs. However, I am having trouble ..read more
Visit website
Getting "Unbound record field mid_x"
OCaml » Stack Overflow
by geek123
1w ago
I am not understanding why I am getting this error: Unbound record field mid_x when running this code. What the function midpoint_segment is trying to do is find the midpoint of a given type segment and return a point type. type point = {x : float; y : float} type segment = {startp : point; endp : point} let midpoint_segment {startp; endp} = let mid_x = (startp.x +. endp.x) /. 2.0 in let mid_y = (startp.y +. endp.y) /. 2.0 in {mid_x; mid_y} What does this error mean? I am defining mid_x and mix_y with let ..read more
Visit website
OCaml and Opam: unbound module Core
OCaml » Stack Overflow
by bstamour
1w ago
I'm trying to get an OCaml environment set up, and I've followed the instructions from appendix A of the Real World OCaml beta. I set up opam, and installed a version of OCaml with the command $ opam switch 4.01.0dev+trunk which passed fine. I then did an $ eval `opam config env` to pull in the changes. I'm running the correct top level, as $ which ocaml outputs /home/bryan/.opam/4.01.0dev+trunk/bin/ocaml I installed the Core package from Jane street, with the command $ opam install core Both ocamlfind and opam search show that the package was installed correctly. However when I try ..read more
Visit website
How to set locale in ocaml?
OCaml » Stack Overflow
by nmd
2w ago
I'm interested in changing LC_ALL in an ocaml program. The equivalent C function would be setlocale(LC_ALL, "my_new_locale");. How would one do this in ocaml ..read more
Visit website

Follow OCaml » Stack Overflow on FeedSpot

Continue with Google
Continue with Apple
OR