Reputation: 704
I've tried to compile the following example
open Core.Std
module Foo_and_bar : sig
type t = S of string | I of int
include Hashable.S with type t := t
end = struct
module T = struct
type t = S of string | I of int with sexp, compare
let hash t1 t2 = (hashData t1)
end
include T
include Comparable.Make(T)
end;;
with camlopt -o exec core.cmxa algebra.ml
that could be found on this book but as a result, I obtain an error with sexp declaration. Where am I going wrong?
Upvotes: 0
Views: 105
Reputation: 35260
Core library comes with a tool that simplifies your life. It is named corebuild
. With it you can compile just with:
corebuild algebra.native
And it will produce executable named algrebra.native
What concerning your try, then you are referring to core.cmxa
and ocamlopt
doesn't know where to find it. Moreover, you need to use camlp4
preprocessor, to enable syntax extensions. With ocamlfind
wrapper around ocamlopt
this can be achieved quite easily:
ocamlfind ocamlopt -thread -syntax camlp4o -package core.syntax algebra.ml -o exec
Here, -syntax camlp4o
enables syntax extensions, -package core.syntax
enables core and, also enables Core's syntax extensions.
But I still suggest to use corebuild
, at least for the start.
Upvotes: 4