Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Test if running in utop

Tags:

prompt

ocaml

utop

I have added a few lines to my .ocamlinit to make the utop prompt less of an eyesore:

#require "react";;
#require "lambda-term";;
UTop.prompt := fst (React.S.create LTerm_text.(eval [
    S "\n";
    B_bold true;
    B_fg (LTerm_style.cyan);
    S "# ";
]));;

(I don't understand everything that is going on there... I just found it posted online and tweaked it.)

But now if I use the regular ocaml toplevel I get:

Error: Unbound module UTop

Can I add a test to .ocamlinit to skip those lines unless I'm running utop? Can I put them in an additional file that is only loaded by utop?

like image 698
Tobia Avatar asked Nov 08 '22 20:11

Tobia


1 Answers

What if you add #require "utop";; ?

like image 52
Pierre G. Avatar answered Nov 15 '22 05:11

Pierre G.