1
votes

I am currently working on an OCaml project. From time to time, I would like to debug the data I am currently working with, and see the output in the terminal from .ml file I am building. I was just wondering what the equivalent in OCaml would be?

Let's assume that user is creating an executable file, being built by dune: dune build example.bc -w

Thank you, your time is very much so appreciated.

1

1 Answers

3
votes

If you mean a logger function that works 'universally', i.e. it can print out some representation of any type, then try https://reason-native.com/docs/console/ . It's meant to be similar to JavaScript's console.log. Examples on the page are in ReasonML syntax but will work in OCaml too.

Console is not published to opam though, and unfortunately does not currently support opam. However, since it is a dune project ( https://github.com/facebookexperimental/reason-native/tree/master/src/console ), you could keep it in-source as part of your own project.