I'm working through Real World OCaml and I'm getting a syntax error on the following bit of code:
`# module Logon = struct
type t =
{ session_id: string;
time: Time.t;
user: string;
credentials: string;
}
with fields
end;;
On running, Utop underlines the word "with" and throws a syntax error. I've tried similar, more simple examples on my own and get the same error. Any thoughts on what's going on?
EDIT: Omitted "}" added.
For ocaml 4.01.0 :
In utop : #require "fieldslib.syntax";; is solving the issue. (... do not forget to run opam install fieldslib).
For recent ocaml : (got some hints here ).
opam install ppx_jane fieldslib
#require "ppx_jane";;
#require "fieldslib";;
module Logon = struct
type t =
{ session_id: string;
time: Time.t;
user: string;
credentials: string;
}
[@@deriving fields]
end;;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With