Fieldslib syntax extension usage | Real World OCaml

261 views
Skip to first unread message

synco...@gmail.com

unread,
Apr 13, 2016, 12:00:08 PM4/13/16
to ocaml-core
Hi, I was reading Real World OCaml, and I am stuck at First-Class Fields [1]. The "with fields" syntax is no longer working as it appears in the book. As far as I can tell, the fieldslib was originally inside core, but is now a separate package. 

I tried reading the .mli file at https://github.com/janestreet/fieldslib/blob/master/src/field.mli, but I can't seem to figure out what the code means or how to use the fieldslib package. 


[1]

Yaron Minsky

unread,
Apr 13, 2016, 12:18:58 PM4/13/16
to ocaml...@googlegroups.com
RWO really needs a refresh (for which I have plans brewing...)

With the arrival of PPX, Core and friends no longer use the old
camlp4-based syntax extensions. If you install the new PPX versions
(which are installed by opam when you install Core), you can use the
now-standardized "deriving syntax", e.g.:

type r = { foo:int; bar: float} [@@deriving fields]

to get the same effect you would have gotten with:

type r = { foo:int; bar: float} with fields

in the old world.

y
> --
> You received this message because you are subscribed to the Google Groups
> "ocaml-core" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ocaml-core+...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

syn copy

unread,
Apr 13, 2016, 2:03:35 PM4/13/16
to ocaml...@googlegroups.com
I see. Thanks for the quick reply!
Reply all
Reply to author
Forward
0 new messages