New to both UTop and BER MetaOcaml N114, loading Trx

Hello, I want to give a try to MetaOcaml but utop ask me about the Trx module:

utop #
let rec spower n x =
if n = 0 then .<1>.
else if n mod 2 = 0 then .<square .~(spower (n/2) x)>.
else .<.~x * .~(spower (n-1) x)>. ;;
Line 1:
Error: Reference to undefined global `Trx’

$ find ~/.opam/MSP4141/lib/ | grep -i trx
/home/catseye/.opam/MSP4141/lib/ocaml/trx.cmi
/home/catseye/.opam/MSP4141/lib/ocaml/trx.cmx
/home/catseye/.opam/MSP4141/lib/ocaml/compiler-libs/trx.cmi
/home/catseye/.opam/MSP4141/lib/ocaml/compiler-libs/trx.cmx
/home/catseye/.opam/MSP4141/lib/ocaml/compiler-libs/trx.cmti
/home/catseye/.opam/MSP4141/lib/ocaml/compiler-libs/trx.mli
/home/catseye/.opam/MSP4141/lib/ocaml/compiler-libs/trx.cmt

How do I get either the Trx module loaded in utop or a utop linked against it? I’m using latest opam, opam install utop

Thanks!

I’ve tried reinstalling the BER switch and:

utop # #require “compiler-libs”;;

utop # open Trx;;

utop #
let rec spower n x =
if n = 0 then .<1>.
else if n mod 2 = 0 then .<square .~(spower (n/2) x)>.
else .<.~x * .~(spower (n-1) x)>. ;;
Line 1:
Error: Reference to undefined global `Trx’

still no luck!

The file listing you provided in your first message shows there is no trx.cmo. This means that you won’t be able to use MetaOCaml with bytecode. However, it should work fine in native-code, since trx.cmx is available.

May be a good idea to find out if the bytecode limitation is due to a technical issue or if it is just an oversight in the distribution package.

Cheers,
Nicolas

Speaking off the top of my head, but MetaOCaml provides both bytecode and native code backends. So it should be a limitation in the distribution package – not so much an oversight as it might need some packaging work to support both?

I’m not a utop user, so don’t know the details, but I think using utop-full rather than utop should work.

Thanks Jeremy, it is it, using utop-full solve the issue! You are a damn usefull utop non-user :slight_smile: