0
我試圖編譯下面的例子的OCaml的書例如在Hashtbl
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;;
與camlopt -o exec core.cmxa algebra.ml
,可以在此book中查到,但是其結果是,我得到一個錯誤與SEXP聲明。我哪裏錯了?
那麼這個庫完全替代標準的OCaml嗎?在同一個源代碼中,我有一個聲明模塊IntSet = Set.Make( struct let compare = Pervasives.compare type t = int end)'。所以我必須用來自其他基礎庫的集合來替換它? – jackb
是的。而且你必須小心不要意外擊中庫存。好消息是,它們已經爲所有類型實例化了地圖,集合,哈希表等。例如,'IntSet'在'Int.Set'下可用。還有'Int.Map','Int.Table','Int.Hash_set'等等 – ivg