ocaml-community / utop Goto Github PK
View Code? Open in Web Editor NEWUniversal toplevel for OCaml
License: Other
Universal toplevel for OCaml
License: Other
Hi,
Is it possible to remove all colouration of the utop topelevel. I find them very distracting, even using the dark profile.
Cheers
PS.
Just imported utop-1.5 into OpenBSD ports. Thanks for utop.
Hi,
I am building a package of utop for OpenBSD. Looking at the oasis documentation, it seems that I should be able to prefix all installed files with a path. E.g.:
$ ./setup.exe -configure --destdir /tmp
The configure report shows the following:
Prepend a path when installing package: .............. /tmp
Then we build as usual. When it comes to installing, destdir is ignored:
$ ./setup.exe -install
ocamlfind: Cannot mkdir /usr/local/lib/ocaml/utop: Permission denied
I have also tried:
./setup.exe -install --destdir /tmp
ocamlfind: Cannot mkdir /usr/local/lib/ocaml/utop: Permission denied
Is this a bug? Perhaps I am doing it wrong?
Hi there,
I installed utop through opam on Mac OS 10.6.8, and I am unable to use the completion keybindings in ~/.lambda-term-inputrc
. By default, they were
[read-line]
M-left: complete-bar-prev
M-right: complete-bar-next
M-down: complete-bar
I intercept M-left and M-right in my terminal to navigate between words, so I changed them to
[read-line]
M-S-left: complete-bar-prev
M-S-right: complete-bar-next
M-S-down: complete-bar
However, these bindings still don't work. Moreover, when I try to view the manpage using man 5 lambda-term-inputrc
as suggested in the Readme, nothing shows up. Is it possible that opam did not install the manpages for lambda-term and utop? Would that issue be linked to my inability to use the completion keybindings?
I am using the most recent versions of opam (1.1.0) and utop (1.8).
FYI, this problem occurs both in the standard Terminal and in iTerm2.
If I load "optcomp" into utop then I can't issue any more toplevel directives:
utop # #require "optcomp";;
/usr/lib64/ocaml/threads: added to search path /usr/lib64/ocaml/findlib: added to search path /usr/lib64/ocaml/lwt: added to search path
/usr/lib64/ocaml/react: added to search path
/usr/lib64/ocaml/camomile: added to search path
/usr/lib64/ocaml/zed: added to search path
/usr/lib64/ocaml/lambda-term: added to search path
/usr/lib64/ocaml/utop: added to search path
/usr/lib64/ocaml/dynlink.cma: loaded
/usr/lib64/ocaml/camlp4: added to search path
/usr/lib64/ocaml/camlp4/camlp4o.cma: loaded
/usr/lib64/ocaml/utop/utop-camlp4.cma: loaded
Camlp4 Parsing version 4.00.1
/usr/lib64/ocaml/optcomp: added to search path
/usr/lib64/ocaml/optcomp/optcomp.cma: loaded
utop # #require "unix";;
Error: Parse error: unknown directive ``require''
If I use the regular toplevel it works fine:
[root@st30 ~]# ocaml OCaml version 4.00.1
# #use "topfind";;
- : unit = ()
Findlib has been successfully loaded. Additional directives:
#require "package";; to load a package
#list;; to list the available packages
#camlp4o;; to load camlp4 (standard syntax)
#camlp4r;; to load camlp4 (revised syntax)
#predicates "p,q,...";; to set these predicates
Topfind.reset();; to force that packages will be reloaded
#thread;; to enable threads
- : unit = ()
# #require "optcomp";;
/usr/lib64/ocaml/dynlink.cma: loaded
/usr/lib64/ocaml/camlp4: added to search path
/usr/lib64/ocaml/optcomp: added to search path
# #require "unix";;
/usr/lib64/ocaml/unix.cma: loaded
in the terminal, it would be great to support such key bindings
Ctrl-b - backward
Ctrl-f - forward
Ctrl-h - backspace
Alt-p previous phrase
Alt-n next phrase
with the standard toplevel:
# #warnings "+a";;
# type t = { x : int; y : int };;
type t = { x : int; y : int; }
# let f { x } = x;;
Warning 9: the following labels are not bound in this record pattern:
y
Either bind these labels explicitly or add '; _' to the pattern.
val f : t -> int = <fun>
# #warn_error "+a";;
# let f { x } = x;;
Warning 9: the following labels are not bound in this record pattern:
y
Either bind these labels explicitly or add '; _' to the pattern.
Error: Error-enabled warnings (1 occurrences)
With utop:
# #warnings "+a";;
# type t = { x : int; y : int };;
type t = { x : int; y : int; }
# let f { x } = x;;
File "", line 1, characters 6-11:
Warning 9: the following labels are not bound in this record pattern:
y
Either bind these labels explicitly or add '; _' to the pattern.
val f : t -> int = <fun>
# #warn_error "+a";;
# let f { x } = x;;
Error: Error-enabled warnings (1 occurrences)
The warning is not displayed. Also it prints the location instead of highlighting it.
utop # (fun a => true)
;;
Error: Unknown parsing error (please report it to the utop project): Syntaxerr.Error(_)
Following instructions and reporting the error :)
Installed utop from opam today
The README refers to key combinations such as Alt+Right
, but this should be written M-right
. I got confused at first trying the Alt
key, when in fact M
is ESC
on systems I use.
And might as well use the standard -
notation to indicate key combinations, instead of +
.
In recent Core suite (109.58.00), Async_core
library was renamed as Async_kernel
.
So, I think there is need to update rewriting rule in:
https://github.com/diml/utop/blob/master/src/lib/uTop_main.ml#L376
Hashtbl.add rewrite_rules (Longident.parse "Async_core.Ivar.Deferred.t") { ...
.
It would be useful for lambda-term-actions
to list the current key bindings to each action. An extra column in the output could show this by default.
Supposedly Alt+Right
and Alt+Left
allow to navigate the completion bar. However, they don't work for me. I wanted to try other key bindings to investigate the issue, but I can't figure out how to change the key binding to the complete-bar-next
action. I tried this:
$ cat ~/.lambda-term-inputrc
M-right: complete-bar-next
$ utop
Fatal error: exception LTerm_inputrc.Parse_error("/Users/ashish/.lambda-term-inputrc", 1, "invalid edit action \"complete-bar-next\"")
Raised at file "src/core/lwt.ml", line 782, characters 22-23
Called from file "src/unix/lwt_main.ml", line 34, characters 8-18
Called from file "src/lib/uTop_main.ml", line 1084, characters 6-64
Called from file "src/lib/uTop_main.ml", line 1109, characters 4-15
Is it possible to provide an action to send the current buffer into the server regardless of whether it is syntax correct or not?
For example, currently in the utop
3;; Enter
the phrase will be sent to the toplevel,
3 Enter
will result in a new line
Is it possible to send a phrase only "3" ?
I tried the [accept] action, but it seems not to work, thanks!
I run the following script in
The universal toplevel for OCaml, version 1.7, compiled for OCaml version 4.01.0
The file test.txt
exists, and the file dummy.txt
does not.
I believe this async exception should not crash the top-level. Am i wrong?
utop # #require "async";;
utop # open Async.Std;;
utop # Out_channel.write_all "test.txt" ~data:"Oh no! Oh my! It's a Gruffalo!";;
- : unit = ()
utop # In_channel.read_all "test.txt";;
- : string = "Oh no! Oh my! It's a Gruffalo!"
utop # let contents = Reader.file_contents "test.txt";;
val contents : string Deferred.t = <abstr>
utop # let dummy = Reader.file_contents "dummy.txt";;
val dummy : string Deferred.t = <abstr>
utop # Deferred.peek contents;;
- : string option = None
utop # Deferred.peek dummy;;
- : string option = None
utop # contents;;
("unhandled exception" ((lib/monitor.ml.Error_ ((exn
(Unix.Unix_error "No such file or directory" open
"((filename dummy.txt) (mode (O_RDONLY)) (perm 0o0))"))
(backtrace (""))
(monitor
(((name main) (here ()) (id 1) (has_seen_error true)
(someone_is_listening false) (kill_index 0))))))
(Pid 13052)))
utop crashes and i am back to command line here.
[vb@haramix ~/code/utop]% make
./setup-dev.exe -build
W: Field XMETAType is set but matching plugin is not enabled.
W: Field XMETAType is set but matching plugin is not enabled.
Finished, 1 target (0 cached) in 00:00:00.
+ ocamlfind ocamlc -c -g -package threads -package lwt.syntax -package lambda-term -package findlib -thread -I /usr/lib/ocaml/comp
iler-libs -I src/lib -o src/lib/uTop.cmi src/lib/uTop.mli
findlib: [WARNING] Interface topdirs.cmi occurs in several directories: /usr/lib/ocaml/compiler-libs, /usr/lib/ocaml
+ ocamlfind ocamlc -c -g -package threads -package lwt.syntax -package lambda-term -package findlib -thread -I /usr/lib/ocaml/comp
iler-libs -I src/lib -o src/lib/errors.cmi src/lib/errors.mli
findlib: [WARNING] Interface topdirs.cmi occurs in several directories: /usr/lib/ocaml/compiler-libs, /usr/lib/ocaml
+ ocamlfind ocamlc -c -g -package threads -package lwt.syntax -package lambda-term -package findlib -syntax camlp4o -thread -ppopt
syntax/pa_optcomp.cmo -ppopt -let -ppopt 'findlib_version=(1, 3)' -I /usr/lib/ocaml/compiler-libs -I src/lib -o src/lib/uTop_priv
ate.cmo src/lib/uTop_private.ml
findlib: [WARNING] Interface errors.cmi occurs in several directories: src/lib, /usr/lib/ocaml/compiler-libs
findlib: [WARNING] Interface topdirs.cmi occurs in several directories: /usr/lib/ocaml/compiler-libs, /usr/lib/ocaml
+ ocamlfind ocamlc -c -g -package threads -package lwt.syntax -package lambda-term -package findlib -syntax camlp4o -thread -ppopt
syntax/pa_optcomp.cmo -ppopt -let -ppopt 'findlib_version=(1, 3)' -I /usr/lib/ocaml/compiler-libs -I src/lib -o src/lib/uTop_vers
ion.cmo src/lib/uTop_version.ml
findlib: [WARNING] Interface errors.cmi occurs in several directories: src/lib, /usr/lib/ocaml/compiler-libs
findlib: [WARNING] Interface topdirs.cmi occurs in several directories: /usr/lib/ocaml/compiler-libs, /usr/lib/ocaml
+ ocamlfind ocamlc -c -g -package threads -package lwt.syntax -package lambda-term -package findlib -thread -I /usr/lib/ocaml/comp
iler-libs -I src/lib -o src/lib/uTop_main.cmi src/lib/uTop_main.mli
findlib: [WARNING] Interface errors.cmi occurs in several directories: src/lib, /usr/lib/ocaml/compiler-libs
findlib: [WARNING] Interface topdirs.cmi occurs in several directories: /usr/lib/ocaml/compiler-libs, /usr/lib/ocaml
+ ocamlfind ocamlc -c -g -package threads -package lwt.syntax -package lambda-term -package findlib -syntax camlp4o -thread -ppopt
syntax/pa_optcomp.cmo -ppopt -let -ppopt 'findlib_version=(1, 3)' -I /usr/lib/ocaml/compiler-libs -I src/lib -o src/lib/uTop_toke
n.cmo src/lib/uTop_token.ml
findlib: [WARNING] Interface errors.cmi occurs in several directories: src/lib, /usr/lib/ocaml/compiler-libs
findlib: [WARNING] Interface topdirs.cmi occurs in several directories: /usr/lib/ocaml/compiler-libs, /usr/lib/ocaml
+ ocamlfind ocamlc -c -g -package threads -package lwt.syntax -package lambda-term -package findlib -thread -I /usr/lib/ocaml/comp
iler-libs -I src/lib -o src/lib/uTop_complete.cmi src/lib/uTop_complete.mli
findlib: [WARNING] Interface errors.cmi occurs in several directories: src/lib, /usr/lib/ocaml/compiler-libs
findlib: [WARNING] Interface topdirs.cmi occurs in several directories: /usr/lib/ocaml/compiler-libs, /usr/lib/ocaml
+ ocamlfind ocamlc -c -g -package threads -package lwt.syntax -package lambda-term -package findlib -thread -I /usr/lib/ocaml/comp
iler-libs -I src/lib -o src/lib/uTop_lexer.cmi src/lib/uTop_lexer.mli
findlib: [WARNING] Interface errors.cmi occurs in several directories: src/lib, /usr/lib/ocaml/compiler-libs
findlib: [WARNING] Interface topdirs.cmi occurs in several directories: /usr/lib/ocaml/compiler-libs, /usr/lib/ocaml
+ ocamlfind ocamlc -c -g -package threads -package lwt.syntax -package lambda-term -package findlib -thread -I /usr/lib/ocaml/comp
iler-libs -I src/lib -o src/lib/uTop_styles.cmi src/lib/uTop_styles.mli
findlib: [WARNING] Interface errors.cmi occurs in several directories: src/lib, /usr/lib/ocaml/compiler-libs
findlib: [WARNING] Interface topdirs.cmi occurs in several directories: /usr/lib/ocaml/compiler-libs, /usr/lib/ocaml
+ ocamlfind ocamlc -c -g -package threads -package lwt.syntax -package lambda-term -package findlib -syntax camlp4o -thread -ppopt
syntax/pa_optcomp.cmo -ppopt -let -ppopt 'findlib_version=(1, 3)' -I /usr/lib/ocaml/compiler-libs -I src/lib -o src/lib/uTop.cmo
src/lib/uTop.ml
findlib: [WARNING] Interface errors.cmi occurs in several directories: src/lib, /usr/lib/ocaml/compiler-libs
findlib: [WARNING] Interface topdirs.cmi occurs in several directories: /usr/lib/ocaml/compiler-libs, /usr/lib/ocaml
+ ocamlfind ocamlc -c -g -package threads -package lwt.syntax -package lambda-term -package findlib -syntax camlp4o -thread -ppopt
syntax/pa_optcomp.cmo -ppopt -let -ppopt 'findlib_version=(1, 3)' -I /usr/lib/ocaml/compiler-libs -I src/lib -o src/lib/uTop_main
.cmo src/lib/uTop_main.ml
findlib: [WARNING] Interface errors.cmi occurs in several directories: src/lib, /usr/lib/ocaml/compiler-libs
findlib: [WARNING] Interface topdirs.cmi occurs in several directories: /usr/lib/ocaml/compiler-libs, /usr/lib/ocaml
File "src/lib/uTop_main.ml", line 748, characters 6-30:
Error: Unbound value Env.reset_cache_toplevel
Command exited with code 2.
Compilation unsuccessful after building 29 targets (0 cached) in 00:00:04.
E: Failure("Command ''/usr/bin/ocamlbuild' syntax/optcomp.cma src/lib/utop.cma src/lib/utop.cmxa src/lib/utop.a src/lib/utop.cmxs
src/camlp4/utop-camlp4.cma src/camlp4/utop-camlp4.cmxa src/camlp4/utop-camlp4.a src/camlp4/utop-camlp4.cmxs src/top/uTop_top.byte
src/top/uTop_top_full.byte -tag debug' terminated with error code 10")
make: *** [build] Erreur 1
zsh: exit 2 make
When I am pasting a fragment with a default type flag utop gets confused about new lines and syntax extension fails with ."several default expressions are given". Default toplevel is unaffected.
Code in question:
open Core.Std;;
type http_server_config = {
port: int with default(80);
web_root: string;
addr: string with default("localhost")
} with sexp ;;
utop version 1.8 (using OCaml version 4.01.0)
on Debian GNU/Linux testing (jessie/sid)
Both 1.7 and 1.8 are affected.
Example:
─( 03:00:00 )─< command 0 >─────────────────────────────{ counter: 0 }─
utop # type http_server_config = {
port: int with default(80);
web_root: string;
Error: Failure: "several default expressions are given"
─( 23:17:08 )─< command 1 >─────────────────────────────{ counter: 0 }─
utop # addr: string with default("localhost")
Error: Parse error: [str_item] or ";;" expected (in [top_phrase])
─( 23:21:22 )─< command 2 >─────────────────────────────{ counter: 0 }─
utop # } with sexp ;;
Error: Parse error: illegal begin of top_phrase
─( 23:21:22 )─< command 3 >─────────────────────────────{ counter: 0 }─
utop #
Meanwhile #use loads ok:
─( 23:21:22 )─< command 3 >────────────────────────────{ counter: 0 }─
utop # #use "a.ml";;
type http_server_config = { port : int; web_root : string; addr : string; }
val http_server_config_of_sexp : Sexp.t -> http_server_config = val sexp_of_http_server_config : http_server_config -> Sexp.t =
─( 23:21:27 )─< command 4 >────────────────────────────{ counter: 0 }─
Default toplevel is fine:
...
/home/ig/.opam/4.01.0/lib/core_bench/core_bench.cma: loaded
# open Core.Std;;
type http_server_config = {
port: int with default(80);
web_root: string;
addr: string with default("localhost")
} with sexp ;;
# type http_server_config = { port : int; web_root : string; addr : string; }
val __http_server_config_of_sexp__ : Sexplib.Sexp.t -> http_server_config =
<fun>
val http_server_config_of_sexp : Sexplib.Sexp.t -> http_server_config = <fun>
val sexp_of_http_server_config : http_server_config -> Sexplib.Sexp.t = <fun>
#
under this terminal, once utop is ran the screen becomes full of grabage
When attempting to evaluate the current line of an .ml file or buffer in tuareg-mode emacs 22.1, the prompt "utop command line:" comes up at the bottom of the buffer. Pretty much no matter what is entered the following error appears: "Symbol's function definition is void: split-string-and-unquote". I'm guessing since it's an older version of emacs, it's missing this function? Upon update to emacs 24.3, problem went away.
I was surprised to get this:
utop # Lines.Lwt.of_channel;;
- : Lwt_io.input_channel -> Lines.item Lwt_stream.t = <fun>
utop # Lines.Lwt.of_channel;;
- : Lwt_io.input_channel -> Biocaml_lines.item Lwt_stream.t = <fun>
The exact same type displayed immediately twice prints differently. (Note I have a dev version of Biocaml open, and have not tried to reproduce this in other cases.)
The error message is the following :
Fatal error: unknown C primitive `caml_ba_dim_1'
Probable the same as ocaml-batteries-team/batteries-included#434
(Some string_of_int ((int_of_string "1") + 1));;
Error: Unknown parsing error (please report it to the utop project): Syntaxerr.Error(_)
A reminder, as per email thread :)
There is no such documentation for utop at the moment. Most parts of
chapter 9 from the OCaml manual still apply to utop so it should be
easy to copy&paste and adapt it to utop.
https://sympa.inria.fr/sympa/arc/caml-list/2013-07/msg00050.html
This is very confusing to me, it's as if Async scheduler is sometimes working (deferred binding contents
works), but sometimes (as in the case of printf
) does not? I remember RWO book said that utop is supposed to run the scheduler when required. Am i missing something obvious? Help! :)
OCaml 4.01.0, Async 109.42.00, utop 1.7 on OS X Mavericks.
utop # #require "async";;
utop # open Async.Std;;
utop # let contents = Reader.file_contents "test.txt";; (* file exists *)
val contents : string Deferred.t = <abstr>
utop # contents;;
- : string = "OH NO! OH MY! IT'S A GRUFFALO!"
utop # printf "Gruffalo";;
- : unit = ()
utop # Scheduler.go ();;
Gruffalo
(* and Scheduler.go never returns; as expected *)
This is a feature request, thanks!
-dsource (undocumented)
-dparsetree (undocumented)
-dtypedtree (undocumented)
-drawlambda (undocumented)
-dlambda (undocumented)
-dinstr (undocumented)
Hi,
I installed utop by running opam install utop
and it runs correctly. But I did not find a file named .lambda-term-inputrc
in my home directory so I manually created such a file and wrote:
[read-line]
M-left: complete-bar-prev
M-right: complete-bar-next
M-down: complete-bar
Then I restarted utop but found them not working at all (the cursor of completion bar dis not move).
I tried running ocaml print_sequences.ml
within lambda-term, and ensured these 3 key combinations available:
press 'q' to quit
\027b
\027f
\027[B
What could the problem be?
Here is an example :
Objective Caml version 3.12.1
# #use "topfind" ;;
- : unit = ()
Findlib has been successfully loaded. Additional directives:
#require "package";; to load a package
#list;; to list the available packages
#camlp4o;; to load camlp4 (standard syntax)
#camlp4r;; to load camlp4 (revised syntax)
#predicates "p,q,...";; to set these predicates
Topfind.reset();; to force that packages will be reloaded
#thread;; to enable threads
- : unit = ()
# #require "lacaml" ;;
/usr/lib/ocaml/unix.cma: loaded
/usr/lib/ocaml/bigarray.cma: loaded
/usr/local/lib/ocaml/3.12.1/lacaml: added to search path
/usr/local/lib/ocaml/3.12.1/lacaml/lacaml.cma: loaded
/usr/local/lib/ocaml/3.12.1/lacaml/lacaml_top.cma: loaded
Whereas :
───────────┬───────────────────────────────────────────────────────────┬────────────
│ Welcome to utop version 1.5 (using OCaml version 3.12.1)! │
└───────────────────────────────────────────────────────────┘
Type #utop_help for help about using utop.
─( 01:00:00 )─< command 0 >──────────────────────────────────────────{ counter: 0 }─
utop # #use "topfind";;
- : unit = ()
Findlib has been successfully loaded. Additional directives:
#require "package";; to load a package
#list;; to list the available packages
#camlp4o;; to load camlp4 (standard syntax)
#camlp4r;; to load camlp4 (revised syntax)
#predicates "p,q,...";; to set these predicates
Topfind.reset();; to force that packages will be reloaded
#thread;; to enable threads
- : unit = ()
─( 01:58:46 )─< command 1 >──────────────────────────────────────────{ counter: 0 }─
utop # #require "lacaml";;
No such package: lacaml""
Please tell me what additionnal information I can give.
Bug obtained with the latest version of utop and ctypes from opam. To reproduce the bug, install ctypes, launch utop, type #use "topfind";;
and #require "ctypes"
.
On my computer I get the following output :
/usr/local/lib/ocaml/threads: added to search path
~/.opam/system/lib/ctypes: added to search path
~/.opam/system/lib/ctypes/ctypes.cma: loaded
zsh: segmentation fault utop
The same operations works successfully in the ocaml toplevel.
% utop
Fatal error: exception UChar.Out_of_range
Exit 2
% utop -version
The universal toplevel for OCaml, version 1.5, compiled for OCaml version 4.01.0+dev16-2013-06-03
It crashes with 4.00.1 as well. Let me know if I can do some extra debugging.
Thanks.
Thank you for providing Emacs support! But I'm not sure I understand the instructions...what do you mean by executing "utop" in emacs? Do you mean M-x utop
? If so that doesn't seem to work for me.
I installed utop via opam like this:
$ opam init
$ opam switch 4.00.1+short-types
$ opam install utop core_extended $ eval `opam config -env`
I have an .omalinit that looks like this:
# use "topfind"
# camlp4o
# thread
# require "core.top"
When I run M-x utop
I get
Cannot open load file: utop
Thanks for your help,
C
Hi,
I just wrote some buggy code mixing type a quantification and 'a (which is wrong of course) but the error I received seems a little off :
utop # let f : type a . a -> 'a = fun x -> Obj.magic x;;
Error: Unknown parsing error (please report it to the utop project): Syntaxerr.Error(_)
M-right
lets you move to the next item in the autocompletion bar, but moving multiple times requires releasing M
and pressing the entire combination again. This is significantly inconvenient and, I think, not the usual semantics of key combinations. I think it should be possible to keep M
pressed down, while right
is repeatedly pressed.
This is how other key combinations work. For example, C-b
lets me move the cursor back repeatedly by keeping C
pressed down and repeatedly pressing b
.
M-b and M-f for example don't work in my terminal.
I tried in xterm and GNOME Terminal.
The _oasis Homepage needs to be updated to http://forge.ocamlcore.org/projects/utop/
See https://github.com/OCamlPro/opam-repository/pull/629
Hi,
The alt+tab binding fails to work on OpenBSD. Instead is inserts a space.
I have tried in a different window manager too. The result is the same.
If I put the following in my ~/.lambda-term-rc, then completion works as expected albeit for the different key combo:
[read-line]
M-down: complete-bar
I am using lambda-term-1.4.
The utop project has bug tracking enabled on both github and ocamlforge. I think this causes confusion, and I recommend disabling one or the other. My strong preference is to keep the github one.
The ocamlforge one can be disabled as follows:
Utop is now sensitive to the use of double semicolons to end a statement, while the normal ocaml toplevel is not. It is okay if intended, but I'm guessing this is an unintended change.
With semicolons, both utop
and ocaml
work the same:
$ cat .ocamlinit
#use "topfind";;
#require "csv"
$ ocaml
(* no errors *)
$ utop
(* no errors *)
Without the semicolons, utop
gives an error but ocaml
works fine:
$ cat .ocamlinit
#use "topfind"
#require "csv"
$ ocaml
(* no errors *)
$ utop
...
Camlp4 Parsing version 4.01.0
Invalid argument: "ident_of_expr: this expression is not an identifier"
Type #utop_help for help about using utop.
The following example from the book "Real World OCaml" doesn't work as expected for me. Pressing C-c C-c
after Pipe.write w "Hello World!";;
, which blocks, crashes utop:
utop[0]> open Core.Std;;
utop[1]> open Async.Std;;
utop[2]> let (r, w) = Pipe.create ();;
val r : '_a Pipe.Reader.t = <abstr>
val w : '_a Pipe.Writer.t = <abstr>
utop[3]> Pipe.write w "Hello World!";;
("bug in async scheduler"
(("File_descr_watcher.post_check bug"
(("select raised unexpected exn" Sys.Break)
((pre ((read (8)) (write ()))) (select_result (Error Sys.Break)))
((read ((num_keys 1024) (alist ((8 ())))))
(write ((num_keys 1024) (alist ()))))))
((mutex ((id_of_thread_holding_lock 3) (num_using_blocker 0) (blocker ())))
(is_running true) (have_called_go false)
(fds_whose_watching_has_changed ())
(file_descr_watcher
(Select
((read ((num_keys 1024) (alist ((8 ())))))
(write ((num_keys 1024) (alist ()))))))
(fd_by_descr
((num_keys 1024)
(alist
((39
((file_descr 39) (info interruptor_pipe_write) (kind Fifo)
(supports_nonblock true) (have_set_nonblock true) (state Open)
(watching ((read Not_watching) (write Not_watching)))
(watching_has_changed false) (num_active_syscalls 0)
(close_finished Empty)))
(8
((file_descr 8) (info interruptor_pipe_read) (kind Fifo)
(supports_nonblock true) (have_set_nonblock true) (state Open)
(watching ((read (Watching Empty)) (write Not_watching)))
(watching_has_changed false) (num_active_syscalls 1)
(close_finished Empty)))))))
(timerfd ()) (scheduler_thread_id 3)
(interruptor
((pipe
((read
((file_descr 8) (info interruptor_pipe_read) (kind Fifo)
(supports_nonblock true) (have_set_nonblock true) (state Open)
(watching ((read (Watching Empty)) (write Not_watching)))
(watching_has_changed false) (num_active_syscalls 1)
(close_finished Empty)))
(write
((file_descr 39) (info interruptor_pipe_write) (kind Fifo)
(supports_nonblock true) (have_set_nonblock true) (state Open)
(watching ((read Not_watching) (write Not_watching)))
(watching_has_changed false) (num_active_syscalls 0)
(close_finished Empty)))))
(already_interrupted false) (clearbuffer <opaque>)))
(signal_manager
((handlers_by_signal ((-8 ((bag ()))))) (delivered <opaque>)
(thread_safe_notify_signal_delivered <fun>)))
(thread_pool
((id 0) (state In_use)
(mutex
((id_of_thread_holding_lock -1) (num_using_blocker 0) (blocker ())))
(default_priority 0) (max_num_threads 50) (num_threads 7)
(threads
(((name read) (thread_id (10)) (priority 0) (state Available)
(unfinished_work 0)
(work_queue
((ev_q ()) (maxsize 1) (mutex <opaque>) (not_empty <opaque>)
(not_full <opaque>) (finally <fun>))))
((name "thread-pool thread") (thread_id (9)) (priority 0)
(state Available) (unfinished_work 0)
(work_queue
((ev_q ()) (maxsize 1) (mutex <opaque>) (not_empty <opaque>)
(not_full <opaque>) (finally <fun>))))
((name fchmod) (thread_id (8)) (priority 0) (state Available)
(unfinished_work 0)
(work_queue
((ev_q ()) (maxsize 1) (mutex <opaque>) (not_empty <opaque>)
(not_full <opaque>) (finally <fun>))))
((name writev) (thread_id (7)) (priority 0) (state Available)
(unfinished_work 0)
(work_queue
((ev_q ()) (maxsize 1) (mutex <opaque>) (not_empty <opaque>)
(not_full <opaque>) (finally <fun>))))
((name close) (thread_id (6)) (priority 0) (state Available)
(unfinished_work 0)
(work_queue
((ev_q ()) (maxsize 1) (mutex <opaque>) (not_empty <opaque>)
(not_full <opaque>) (finally <fun>))))
((name stat) (thread_id (5)) (priority 0) (state Available)
(unfinished_work 0)
(work_queue
((ev_q ()) (maxsize 1) (mutex <opaque>) (not_empty <opaque>)
(not_full <opaque>) (finally <fun>))))
((name fcntl_getfl) (thread_id (4)) (priority 0) (state Available)
(unfinished_work 0)
(work_queue
((ev_q ()) (maxsize 1) (mutex <opaque>) (not_empty <opaque>)
(not_full <opaque>) (finally <fun>))))))
(available_threads
(((name close) (thread_id (6)) (priority 0) (state Available)
(unfinished_work 0)
(work_queue
((ev_q ()) (maxsize 1) (mutex <opaque>) (not_empty <opaque>)
(not_full <opaque>) (finally <fun>))))
((name read) (thread_id (10)) (priority 0) (state Available)
(unfinished_work 0)
(work_queue
((ev_q ()) (maxsize 1) (mutex <opaque>) (not_empty <opaque>)
(not_full <opaque>) (finally <fun>))))
((name writev) (thread_id (7)) (priority 0) (state Available)
(unfinished_work 0)
(work_queue
((ev_q ()) (maxsize 1) (mutex <opaque>) (not_empty <opaque>)
(not_full <opaque>) (finally <fun>))))
((name fcntl_getfl) (thread_id (4)) (priority 0) (state Available)
(unfinished_work 0)
(work_queue
((ev_q ()) (maxsize 1) (mutex <opaque>) (not_empty <opaque>)
(not_full <opaque>) (finally <fun>))))
((name fchmod) (thread_id (8)) (priority 0) (state Available)
(unfinished_work 0)
(work_queue
((ev_q ()) (maxsize 1) (mutex <opaque>) (not_empty <opaque>)
(not_full <opaque>) (finally <fun>))))
((name stat) (thread_id (5)) (priority 0) (state Available)
(unfinished_work 0)
(work_queue
((ev_q ()) (maxsize 1) (mutex <opaque>) (not_empty <opaque>)
(not_full <opaque>) (finally <fun>))))
((name "thread-pool thread") (thread_id (9)) (priority 0)
(state Available) (unfinished_work 0)
(work_queue
((ev_q ()) (maxsize 1) (mutex <opaque>) (not_empty <opaque>)
(not_full <opaque>) (finally <fun>))))))
(work_queue ()) (unfinished_work 0) (num_work_completed 60)))
(handle_thread_pool_stuck <fun>)
(busy_pollers
((core_scheduler
((check_access ())
(jobs
((normal ((jobs ()) (jobs_left_this_cycle 500)))
(low ((jobs ()) (jobs_left_this_cycle 500)))))
(main_execution_context
((monitor
(((name main) (here ()) (id 1) (has_seen_error false)
(someone_is_listening false) (kill_index 0))))
(priority Normal) (backtrace_history ()) (kill_index 0)))
(current_execution_context
((monitor
(((name main) (here ()) (id 1) (has_seen_error false)
(someone_is_listening false) (kill_index 0))))
(priority Normal) (backtrace_history ()) (kill_index 0)))
(max_num_jobs_per_priority_per_cycle 500) (uncaught_exn ())
(global_kill_index 0) (num_jobs_run 891) (cycle_count 125)
(cycle_start (2013-08-03 19:05:04.151723+03:00))
(run_every_cycle_start ()) (last_cycle_time 0.0221729ms)
(last_cycle_num_jobs 0)
(events
((start (2013-08-03 17:42:45.332700+03:00))
(now (2013-08-03 19:05:04.151723+03:00)) (alarm_precision 1ms)
(alarms
(((at (2013-08-03 19:05:05.000935+03:00))
(value
((monitor
(((name main) (here ()) (id 1) (has_seen_error false)
(someone_is_listening false) (kill_index 0))))
(priority Normal) (backtrace_history ()) (kill_index 0))))))))
(finalizer_jobs <opaque>) (thread_safe_finalizer_hook <fun>)))
(pollers ())))
(busy_poll_thread_is_running false)
(core_scheduler
((check_access ())
(jobs
((normal ((jobs ()) (jobs_left_this_cycle 500)))
(low ((jobs ()) (jobs_left_this_cycle 500)))))
(main_execution_context
((monitor
(((name main) (here ()) (id 1) (has_seen_error false)
(someone_is_listening false) (kill_index 0))))
(priority Normal) (backtrace_history ()) (kill_index 0)))
(current_execution_context
((monitor
(((name main) (here ()) (id 1) (has_seen_error false)
(someone_is_listening false) (kill_index 0))))
(priority Normal) (backtrace_history ()) (kill_index 0)))
(max_num_jobs_per_priority_per_cycle 500) (uncaught_exn ())
(global_kill_index 0) (num_jobs_run 891) (cycle_count 125)
(cycle_start (2013-08-03 19:05:04.151723+03:00))
(run_every_cycle_start ()) (last_cycle_time 0.0221729ms)
(last_cycle_num_jobs 0)
(events
((start (2013-08-03 17:42:45.332700+03:00))
(now (2013-08-03 19:05:04.151723+03:00)) (alarm_precision 1ms)
(alarms
(((at (2013-08-03 19:05:05.000935+03:00))
(value
((monitor
(((name main) (here ()) (id 1) (has_seen_error false)
(someone_is_listening false) (kill_index 0))))
(priority Normal) (backtrace_history ()) (kill_index 0))))))))
(finalizer_jobs <opaque>) (thread_safe_finalizer_hook <fun>))))))
Please let me know if I can provide any information that would help to debug this issue (e.g., in case it's particular to my setup). utop -version
prints
The universal toplevel for OCaml, version 1.5, compiled for OCaml version 4.01.0+dev18-2013-06-13
#use topfind
and #require ocamlgraph
in .ocamlinitmodule X = Graph;;
This is being tested on an x86_64 machine with the latest github version, but I also can produce the problem on v1.2.1.
utop crashes on attempt to print value of '|>'-operator, if "core.syntax" was required:
ramntry@ramntry-R418:~$ utop Type #utop_help for help about using utop. ─( 03:00:00 )─< command 0 >───{ counter: 0 }─ utop # #require "core.syntax";; Camlp4 Parsing version 4.01.1+dev0-2013-09-11 ─( 15:32:55 )─< command 1 >───{ counter: 0 }─ utop # ( |> );; Fatal error: exception Loc.Exc_located(_, _) ramntry@ramntry-R418:~$
(yes, time "03:00:00" is incorrect)
ramntry@ramntry-R418:~$ utop -version The universal toplevel for OCaml, version 1.7, compiled for OCaml version 4.01.1+dev0-2013-09-11
ramntry@ramntry-R418:~$ uname -a Linux ramntry-R418 3.2.0-27-generic #43-Ubuntu SMP Fri Jul 6 14:25:57 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
ramntry@ramntry-R418:~$ cat /home/ramntry/.ocamlinit (* Added by OPAM. *) let () = try Topdirs.dir_directory (Sys.getenv "OCAML_TOPLEVEL_PATH") with Not_found -> () ;; ramntry@ramntry-R418:~$
ramntry@ramntry-R418:~$ opam info core package: core version: 109.42.00 homepage: https://github.com/janestreet/core authors: Jane Street Capital LLC license: Apache-2.0 depends: ocamlfind >= 1.3.2 & bin_prot = 109.42.00 & comparelib = 109.27.00 & core_kernel = 109.42.00 & custom_printf = 109.27.00 & fieldslib = 109.20.00 & herelib = 109.35.00 & pa_ounit = 109.36.00 & pipebang = 109.28.00 & res & sexplib = 109.41.00 & variantslib = 109.15.00 installed-version: core.109.42.00 [4.02.0dev+trunk 4.01.0dev+trunk] available-versions: 108.00.02, 108.07.00, 108.07.01, 108.08.00, 109.07.00, 109.08.00, 109.09.00, 109.10.00, 109.11.00, 109.12.00, 109.13.00, 109.14.00, 109.14.01, 109.15.00, 109.15.01, 109.17.00, 109.18.00, 109.19.00, 109.20.00, 109.21.00, 109.22.00, 109.23.00, 109.24.00, 109.27.00, 109.28.00, 109.30.00, 109.31.00, 109.32.00, 109.34.00, 109.35.00, 109.36.00, 109.37.00, 109.38.00, 109.40.00, 109.41.00 description: Industrial strength alternative to OCaml's standard library The Core suite of libraries is an industrial strength alternative to OCaml's standard library that was developed by Jane Street, the largest industrial user of OCaml. ramntry@ramntry-R418:~$
The Emacs commands utop-eval-{region,buffer}
are quite limited in usefulness, as utop reads only one phrase at a time and stops after executing it. For instance, executing utop-eval-buffer
in a buffer containing
let n = 3;;
let k = 4;;
let m = n + "a";;
defines n
to be 3
, but does not define k
, and does not raise a type error.
It would be nice if utop executed all phrases sent to it in one go.
(I've actually managed to hack around the problem on the Emacs side, but it's an ugly workaround that is almost guaranteed to break whenever ;;
occurs somewhere within an expression (e.g. in a string literal).)
To reproduce: start utop in a dumb terminal (e.g. emacs inferior shell), exit with ^D.
$ echo $TERM
dumb
$ utop -version
The universal toplevel for OCaml, version 1.4, compiled for OCaml version 4.01.0+dev10-2012-10-16
$ utop
Type #utop_help for help about using utop.
Segmentation fault (core dumped)
$
c>opam install utop
Package utop is already installed (current version is 1.4.0)
c>utop
Fatal error: exception UChar.Out_of_range
Called from unknown location
Called from file "src/lTerm.ml", line 843, characters 11-24
Called from file "src/lTerm.ml", line 879, characters 25-47
Called from file "src/lib/uTop_main.ml", line 594, characters 11-38
Called from file "src/lib/uTop_main.ml", line 1024, characters 20-32
Called from file "src/lib/uTop_main.ml", line 1047, characters 4-15
I'd like a way to page through the possible completions. It seems like the most natural way would be for subsequent presses of tab to advance to the next page.
My os is MAC 10.7.5 and emacs version is 24.3.
I add follow line to my emacs config(.emacs):
(load-file "~/.opam/system/share/emacs/site-lisp/utop.el")
(autoload 'utop "utop" "Toplevel for OCaml" t)
(autoload 'utop-setup-ocaml-buffer "utop" "Toplevel for OCaml" t)
(add-hook 'tuareg-mode-hook 'utop-setup-ocaml-buffer)
(add-hook 'typerex-mode-hook 'utop-setup-ocaml-buffer)
and run utop in emacs , and then output
Process utop exited with code 2
but i run utop in my terminal , everything is ok.
Thanks.
utop $ cu.cu_imports;;
Fatal error: exception Invalid_argument("Zed_utf8.singleton") (Program not linked with -g, cannot print stack backtrace)
------ in the normal toplevel the output is
[("Int32", "&Y(y\140\011\138c?H?\154?\002??");
("Config", "\128\130?"??j{\027Y??S$ܮ");
("Location", "?\139\rIk\147?\152/\014??\153??\011");
("Primitive", "?]?C4??xw?o\019????");
("Cmi_format", "???\144%x\027?̣?$");
("Printf", "\016?L\145,\147B?=a\025\132?.4");
("Lambda", "?s+\000?\n?E???\024\145\014?");
("Subst", "DU?\024\021?6c??\133=\015\020\156/");
("Filename", "?\025?????\015LT?\028jC>");
("Arg", "\t\018?7?}-}\024\137?\007+\127\005");
("Array", "M^?\030?\n?{\024OԲwp\140");
("Debuginfo", "-~\031"Z9?#:U>m]??7");
("Obj", "?\151{B+??,??;\157\004?\029?");
("Hashtbl", "q\140??\139?\131q?"H>6/x?");
("Env", "V?\157[z??\015?\018\128ޱ7??"); ("Sys", "E?u%?B&\020??\132???y&");
("Set", "????V\t?$.Q?C??");
("Consistbl", "\151?\158\151?\146?6\158n?\025S\148s?");
("Format", "nk{u?D?L?s?c??\005?"); ("Objinfo", "?0c?9V?+\155\152???:\005");
("Misc", "T??U2\148??O??T??\143");
("Asttypes", "\155\025W_N?w;?\014'#\003?&?");
("Digest", "?\029??r\156\006?U\028ATy[;l");
("Warnings", ""?\132??O]-(Jg\139\x,?");
("Cmo_format", "?\002\018?W-\030/.\026\146#??p?");
("Bytesections", "\158??T?\027e'?Wu\004???");
("String", "T?&\133??\021GSq\142\156\139?\139");
("Longident", "BLl\023=?\004?1?\006}A?}f");
("Buffer", "?l\153G!W<\159\139T\017?\130BI?");
("Ident", "?\147?s?ڠO\016??V??i"); ("Lexing", "~0f\003??\155[LPѪ???*");
("Annot", "?\131?[?3????\007?W?[");
("Types", "?Ϊ?E\155\r-\020Ӡ?\019?a\012");
("Clambda", "\024e?)?<??\148{:x?Mz\005");
("Pervasives", "H6?T????/?g??%??"); ("Map", "\027?t\132? \000WWv?\141B?/");
("List", "?|f,\t?P0jb?/?^??"); ("Cmx_format", "\141?X_???dA?gZ?=?");
("Path", "M\024W=\145??\014?\014?\152\143?z\156");
("Scanf", "k??\145\134?=?_?:\158\127??")]
$ pwd
/Users/ashish/code/biocaml
$ cat .ocamlinit
#use "topfind"
#thread
#require "core"
#require "zip"
#require "xmlm"
#require "pcre"
#directory "_build/src/lib"
#load "biocaml.cma"
Running the normal ocaml toplevel gives no errors:
$ ocaml
# Sys.chdir "/";;
- : unit = ()
Doing the same thing with utop gives an error:
$ utop
utop # Sys.chdir "/";;
- : unit = ()
Fatal error: exception (Sys_error "_build/src/lib: No such file or directory")
Raised at file "format.ml", line 197, characters 41-52
Called from file "format.ml", line 425, characters 8-33
Called from file "format.ml", line 440, characters 6-24
It seems calling Sys.chdir causes the #directory directive to be re-executed. The relative directory being referred to no longer exists, and hence the error.
When I M-x utop
in emacs on Mac 10.6.8, the only output is:
Process utop exited with code 2
When I try to run utop with M-!
, I get this message:
Fatal error: cannot load shared library dlllwt-unix_stubs
Reason: dlopen(dlllwt-unix_stubs.so, 138): image not found
The following sequence will crash utop:
#require "graphics";;
Graphics.open_graph "";;
Will crash with the message:
utop: select: Resource temporarily unavailable
Not sure why, but it seems that while #load commands have auto-completion, #load_rec commands don't. It's a minor annoyance to have to first run #load to get the filename, then go back and change it to #load_rec.
In the utop available via opam, the followings seem to not work:
M-b # back by one word
M-f # forward by one word
M-backspace # delete previous word
Thanks a lot,
F.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.