realworldocaml / examples

All the examples in Real World OCaml
The Unlicense
376 stars 81 forks source link

`with` returns Syntax Error #43

Open gjaldon opened 7 years ago

gjaldon commented 7 years ago

I'm trying to run the below code but get a syntax error for with:

module Logon = struct
  type t =
    { session_id: string;
      time: Time.t;
      user: string;
      credentials: string;
    } with fields
end;;

I've already loaded core with open Core.Std;;. Is there some other step I'm missing or does fieldslib no longer work with Ocaml 4.03? I'm running the code above in utop (1.19.3), btw.

ackerleytng commented 7 years ago

Same issue here! OCaml 4.02.3 here.

This shows another syntax [@@deriving fields], which works.

Not sure what that means though.

yixing-liu commented 7 years ago

Same issue here! module type M = sig type t with sexp end;; The above is a textbook example, however, utop returns syntax error with "with" word underlined.

brooklynrob commented 7 years ago

Ran into same issue. See reply in Google Groups from @yminsky: https://groups.google.com/d/msg/ocaml-core/g9UfzyQ0hL8/HWqDU2UlBAAJ