2

I'm running this code in utop:

# type u = { a: int; b: float } [@@deriving sexp];;

But the expected declarations of s-expression converters are not generated.

I have Core 0.11.0 and utop version 2.1.0 installed.

the version of Ocaml is 4.06.1.

Thanks.

javier
  • 1,705
  • 2
  • 18
  • 24

1 Answers1

7

You need to pass -require so that the ppx is loaded. In addition (that's specific to this driver), you need to pass its runtime in scope using -require sexplib and a manual open Sexplib.Std:

% utop -require ppx_sexp_conv -require sexplib                  
utop # open Sexplib.Std;;
utop # type u = { a: int; b: float } [@@deriving sexp];;
type u = { a : int; b : float; }
val u_of_sexp : Sexplib0.Sexp.t -> u = <fun>
val sexp_of_u : u -> Sexplib0.Sexp.t = <fun>
Étienne Millon
  • 3,018
  • 11
  • 27
  • Thank you, your answer worked, the only thing is that It requires to install the package ppx_deriving as explained here: https://github.com/janestreet/ppx_sexp_conv/issues/21 – javier Jul 11 '18 at 21:37
  • Also, it worked only with `utop -require ppx_sexp_conv` and instead of `open Sexplib.Std`, I can `open Core` or `open Base`. – javier Jul 11 '18 at 21:42
  • Ah, right. Thanks for the extra info. There are several ways to use this deriver indeed. – Étienne Millon Jul 12 '18 at 08:51