Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to use arrow keys in OCaml interpreter?

Tags:

Everytime I use these keys in the interpreter I keep getting symbols like this appearing:

[[D^[[C 

I'm using Linux Mint 12 in ZSH, however I'm getting the same result in Ubuntu with bash. Also, same thing in ssh.

like image 819
Pacane Avatar asked Nov 05 '12 02:11

Pacane


People also ask

What does Arrow do in OCaml?

The operator is usually called type arrow where T1 -> T2 represents functions from type T1 to type T2 . For instance, the type of + is int -> (int -> int) because it takes two integers and returns another one.


1 Answers

The stock OCaml toplevel doesn't have line editing built in. I use rlwrap:

$ cat bin/ocaml #!/bin/sh exec rlwrap /usr/local/bin/ocaml "$@" 

Using the toplevel without something like this is quite painful, in my opinion!

Other possibilities are to run the toplevel under emacs (a popular choice, I think), or to use utop. I haven't used utop, but it sounds cool.

like image 98
Jeffrey Scofield Avatar answered Oct 23 '22 04:10

Jeffrey Scofield