Questions tagged [utop]

utop (Universal toplevel) is an improved toplevel (REPL) for OCaml. Not to be confused with [tag:ocaml-toplevel] which ships with the OCaml compiler.

utop is an improved toplevel for . It can run in a terminal or in . It supports line editing, history, real-time and context sensitive completion, colors, and more.

Useful resources

93 questions
25
votes
1 answer

how to reload OCaml modules in utop

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 to another terminal and run utop. From within utop,…
illabout
  • 3,517
  • 1
  • 18
  • 39
16
votes
2 answers

"Error: The function applied to this argument has type ..." when using named parameters

I'm currently working through "Real Word OCaml", and one of the basic examples with named / labeled parameters doesn't seem to work (using utop 4.01.0): let languages = ["OCaml"; "Perl"; "C"];; List.map ~f:String.length languages;; Produces: Error:…
Frank Schmitt
  • 30,195
  • 12
  • 73
  • 107
13
votes
3 answers

Merlin complains about a missing module in the same project

I am new to Ocaml and just setting up my dev environment with emacs, merlin and flycheck. Everything works more or less expected except one thing : merlin doesn't seem to be able recognise the dependencies between the modules in the same…
Roman Shestakov
  • 497
  • 5
  • 16
10
votes
3 answers

Is there a way to list all functions of a module in utop?

In utop, when opening a library (via ~require ...) or when opening a module (via open Module_name), is there a way to get the content of the library or module? utop offers this by completion tabs, but I would like to see all the functions at once.
Pierre G.
  • 4,346
  • 1
  • 12
  • 25
10
votes
4 answers

OCaml: Can't run utop after installing it

I'm trying to learn OCaml through the Real World OCaml book. They have a guide by which I am supposed to install the Core package and utop. However, while I seem to be successfully installing both of these using Opam, neither of them works when I…
akim330
  • 188
  • 1
  • 1
  • 7
8
votes
1 answer

Autocompletion in utop

I am sorry for the newb question, but I am just starting with OCaml and I could not find how to ues utop autocompletion. When I start typing something in utop, I see a list of choices at the bottom of the shell. If there is only one valid choice,…
Andrea
  • 20,253
  • 23
  • 114
  • 183
6
votes
1 answer

Export user input history from OCaml utop to file

When I'm using OCaml utop every line of the input and output is printed into the console: ───┬──────────────────────────────────────────────────────────────┬─── │ Welcome to utop version 2.10.0 (using OCaml version 4.14.0)! │ …
5
votes
1 answer

retrieving documentation from utop

Is there a way to retrieve the documentation, displayed in html here directly from utop. I can get the type by using utop # open Core;; ─( 10:41:50 )─< command 4 >─────────────────────────────────────────────────────────────────────────{ counter: 0…
nicolas
  • 9,549
  • 3
  • 39
  • 83
5
votes
0 answers

requiring "core" in utop gives error: Unix.Unix_error (Unix.ENOENT, "sysconf", "")

When I try to call #require "core" in utop, I get an error: utop # #require "core";; Exception: Unix.Unix_error (Unix.ENOENT, "sysconf", ""). Raised by primitive operation at unknown location Called from file "toplevel/topdirs.ml", line 144,…
illabout
  • 3,517
  • 1
  • 18
  • 39
5
votes
1 answer

Test if running in utop

I have added a few lines to my .ocamlinit to make the utop prompt less of an eyesore: #require "react";; #require "lambda-term";; UTop.prompt := fst (React.S.create LTerm_text.(eval [ S "\n"; B_bold true; B_fg (LTerm_style.cyan); S…
Tobia
  • 17,856
  • 6
  • 74
  • 93
5
votes
1 answer

show_module tediousness in utop

I am using OCaml utop, with Core.Std module. To see the help on a module, I have to follow the link of aliases like so: utop # #show_module Array;; module Array = Core_kernel.Std_kernel.Array …
MK.
  • 3,907
  • 5
  • 34
  • 46
4
votes
1 answer

How to load .ml file with its corresponding .mli file in utop?

Simply put, let us say I have an implementation file called moduleExample.ml and an interface file in the same directory called moduleExample.mli. How could I load them together in such a way that the functions not listed in the interface…
Gigi Bayte 2
  • 838
  • 1
  • 8
  • 20
4
votes
0 answers

List defined variables in utop

How can I print a list of variables I defined during a utop session? For example, in other interpreters there are really useful equivalents, eg. in R ls(), or octave/matlab who
Rorschach
  • 31,301
  • 5
  • 78
  • 129
4
votes
1 answer

utop require package warning : cannot read directory /usr/lib/ocaml/METAS: No such file or directory

When I type #require " in utop, I get this message every time I type an additional character after ". [WARNING] cannot read directory /usr/lib/ocaml/METAS: No such file or directory Package importing doesn't seem to be working. I tried…
Mei Zhang
  • 1,434
  • 13
  • 29
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…
1
2 3 4 5 6 7