96 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
-1
votes
1
answer
65
views
Why a named function is still displayed as anonymous in utop?
(I am learning the OCaml and this may be a naive question.)
I use below code to define a named function a:
utop # let a = fun x -> x+1;;
val a : int -> int = <fun>
Note that the leading ...
1
vote
1
answer
135
views
Disable autocomplete suggestion bar in utop
How can I disable the autocomplete suggestion bar in the utop OCaml toplevel?
-1
votes
1
answer
343
views
Why does exiting Utop and reloading of modules not work?
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 ...
0
votes
2
answers
977
views
Base won't load in utop
So basically I am trying to follow these instructions https://dev.realworldocaml.org/install.html
I followed them literally. I have a working utop. I have a working VS Code environment. I can run code ...
0
votes
1
answer
234
views
How to display only the program output in utop on the VS Code terminal and not all the instructions one after the other
(*redefining the power function for integers*)
let rec ( ** ) v n = if n = 0 then 1 else v * (( ** ) v (n-1));;
let rec sommation n =
if n = 0 then 0 else -1**(n/3) * n**(2+ (-1)**n) + sommation (...
0
votes
1
answer
117
views
What is the namespace in utop for definitions in .ml file listed in dune's (executable ...) rule?
What is the namespace of the test0 definition in dune utop . environment, given the following ocaml code with dune build definition:
~/_ocaml_/n01$ cat bin/dune
(executable
(public_name n01)
(name ...
0
votes
1
answer
164
views
This expression has type int list but an expression was expected of type unit
I tried this in utop but since I am not familar with a dune project, it failed and report the error
This expression has type int list but an expression was expected of type unit.
This is for the ...
2
votes
3
answers
268
views
Receiving Stdlib.Scanf.Scan_failure : character '\\n'
I downloaded and executed utop as guided here, and I ran the following code:
Scanf.scanf "%d %d" (fun a b -> Printf.printf "%d\n" (a - b));;
On the first time I input 3 1, it ...
1
vote
1
answer
83
views
Why mark stag functions are not called here?
I am trying to understand the following behaviour of OCaml Format module and semantic tags.
My code:
let prepare_ppf ppf =
let original_stag_functions = Format.pp_get_formatter_stag_functions ppf () ...
-1
votes
1
answer
405
views
How can I produce multiline code in utop?
In Haskell we can enter multi-line code at the terminal, by enclosing it between " :{ " and " :} ". For example, typing
> :{ main = do
> print("Hello") :}
in ghci, ...
0
votes
0
answers
211
views
Searching for the type of an expression in OCaml
In Haskell we can search for the type of an expression, such as "+" by entering :t + at the terminal.
In utop, how can we determine the type of an expression such as "+"? I have ...
2
votes
1
answer
722
views
How to use ppx derive in utop?
How can I use ppx derive (https://github.com/ocaml-ppx/ppx_deriving) in my utop?
For example, I have to following code:
module A = struct
module T = struct
type t = int [@@deriving hash, sexp, ...
0
votes
1
answer
813
views
Finding the height of a multiway (general tree) using OCaml
As a newbie in functional programming (OCaml), I stuck with that problem.
I came up with a code shown below:
let rec height tr =
match tr with
| Node(d,[]) -> 1
| Node(d,[t1]) -> 1 + height ...
0
votes
1
answer
706
views
Base deprecates some useful functions
I am used to using the standard function print_int in OCaml, but when I open the library Base by Jane Street, as recommended in the book Real World OCaml, I obtain a deprecation warning:
utop # ...
1
vote
1
answer
515
views
Ocaml utop does not (but does) recognise Big_int
I have some code that uses the module Big_int, like in:
open Big_int;;
Big_int.gcd_big_int 5 6;;
However, when I compile this with utop dune utop --release (I use release to avoid some warnings), ...