Quantcast
Channel: OCaml - Topics tagged dune
Viewing all articles
Browse latest Browse all 521

How to use generated .ml files from `dune utop`?

$
0
0

@nekketsuuu wrote:

I sometimes insert #mod_use "foobar.ml" into .ocamlinit to debug my library on OCaml toplevel. When I use Dune, however, I noticed some auto-generated files (e.g. parser.ml generated by parser.mly by Menhir) are not recognized by dune utop. How to configure dune utop to be able to find these files? Should I build a custom toplevel using toplevel stanza?

How to reproduce

Files:

.
├── bin
│   ├── dune
│   └── main.ml
├── dune-project
├── foobar.opam
└── lib
    ├── .ocamlinit
    ├── dune
    ├── lexer.mll
    └── parser.mly

.ocamlinit:

#mod_use "parser.ml";;
#mod_use "lexer.ml";;

Commands:

$ cd lib
$ dune utop .
Entering directory '/path/to/foobar'
─┬─────────────────────────────────────────────────────────────┬─
 │ Welcome to utop version 2.4.1 (using OCaml version 4.08.1)! │
 └─────────────────────────────────────────────────────────────┘
Cannot find file parser.ml.
Cannot find file lexer.ml.

Type #utop_help for help about using utop.

─( 16:11:53 )─< command 0 >───────────────────────{ counter: 0 }─
utop # (* BTW Parser can be opened here *)
open Parser;;
─( 16:12:39 )─< command 1 >───────────────────────{ counter: 0 }─
utop #

Environment

  • Dune 1.11.3
  • utop 2.4.1
  • OCaml 4.08.1

Posts: 12

Participants: 4

Read full topic


Viewing all articles
Browse latest Browse all 521

Trending Articles