Questions tagged [ocaml-toplevel]

ocaml-toplevel refers to the toplevel that ships with the OCaml compiler, and is invoked with the `ocaml` command. Not to be confused with [tag:utop], which is an improved toplevel that must be installed separately. This tag refers to the ocaml toplevel specifically, not the general concept of a toplevel as it relates to OCaml.

ocaml-toplevel is a toplevel (ie. a REPL) that ships with , and is invoked with the ocaml command.

Also see , the improved toplevel for OCaml.

Useful resources

24 questions
1
vote
1 answer

ocamlbuild with Toploop/TopLevel

I'm looking to implement an eval function like in this answer here: https://stackoverflow.com/a/33293116/ However, when I go to compile my code sample: let eval code = let as_buf = Lexing.from_string code in let parsed =…
NiallMitch14
  • 1,198
  • 1
  • 12
  • 28
1
vote
1 answer

Load ml files dynamically in OCaml toplevel?

As all we know, in we can use #use directive in OCaml toplevel to load ml files then execute. And we can also use ocaml.exe to load and execute ml files. Here my requirement has some changes to these two situations: I have a main process, who…
Enzojz
  • 863
  • 2
  • 9
  • 15
1
vote
0 answers

Typetexp.Error in OCaml Toplevel (Eclipse)

I have recently installed Eclipse with OCaml plug-in and cygwin (for binaries Eclipse asked for) on Windows 10. I really need to work with OCaml Toplevel, but all it does is OCaml version 4.02.3 Fatal error: exception Typetexp.Error(_, _, _) Process…
krecik
  • 11
  • 3
1
vote
1 answer

How to run program in OCaml toplevel with input from file?

I know that in order to load a program in OCaml one has to type #use "source_code_file.ml" in toplevel where source_code_file.ml is the file we want to use. My program reads input from stdin. In the command line i have a txt file that with…
power_output
  • 411
  • 10
  • 26
0
votes
0 answers

How do i run Ocaml function from the command line in Windows

I have a question, am new to Ocaml THE functional programming. I have simple function of Ocaml which calculates a total of two numbers. Am using visual studio code. here is a sample of my function : let cubic a b = a + b ;; so, how do i run my…
Chung Lee
  • 13
  • 6
0
votes
1 answer

Ocaml: unknown directive `require'

When loading OCaml, I receive this message when loading ocaml at the terminal: ocaml OCaml version 4.07.1 Unknown directive `require'. What is the problem exactly? I had previously modified my ocamlinit file, because I had some…
user65526
  • 685
  • 6
  • 19
0
votes
1 answer

How to build a custom utop-based toplevel with ocamlbuild?

I want to create a utop-based toplevel for my project, which is built by ocamlbuild. However, ocamlbuild supports only mktoplevel, built from *.mltop. It doesn't mention utop anywhere in the docs. Also, the utop manual explains just toplevel…
vog
  • 23,517
  • 11
  • 59
  • 75
0
votes
1 answer

OCaml: Unbound module from parent directory in toplevel

I'm trying to load a module from a parent directory into the top level interpretor. #load "../Syntax.cmo";; open Syntax let foo = bar Where bar is in Syntax. I have module Syntax in the parent directory. Loading module Syntax does not cause any…
laifs
  • 197
  • 1
  • 2
  • 11
0
votes
1 answer

How are command line argument are treated in toplevel?

I have a program which takes command line argument. The same of source file is encode.ml. I want to load this file in the toplevel. Is there way to load the source file in the toplevel where we can pass it a command line arguments? Thanks.
UnSat
  • 1,347
  • 2
  • 14
  • 28
1
2