# Core with 4.04.1

**URL:** <https://discuss.ocaml.org/t/core-with-4-04-1/384>\
**Category:** Ecosystem\
**Tags:** core, real-world-ocaml\
**Created:** [June 9, 2017, 12:23am UTC](https://discuss.ocaml.org/t/core-with-4-04-1/384 "2017-06-09T00:23:42Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![vzaliva](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/vzaliva/32/206_2.png) [@vzaliva](https://discuss.ocaml.org/u/vzaliva)\
**Post date:** [June 9, 2017, 12:23am UTC](https://discuss.ocaml.org/t/core-with-4-04-1/384/1 "2017-06-09T00:23:42Z")

</div>

I am currently using ocaml-4.04.1. It seems the only version of Core and sexplib supporting it is v0.9.1.  
However, it does not seems to have sexplib.sytax package. Without it I am unsure how to define something as simple as a Set for my own type. All examples recommend `with sexp, compare` syntax.

By the way, there is no compatible version of ‘comparelib’:

```auto
$ opam install comparelib
The following dependencies couldn't be met:
  - comparelib -> type_conv < 112.02.00
Your request can't be satisfied:
  - type_conv.108.00.02 is not available because your system doesn't comply with ocaml-version >= "3.12.1" & ocaml-version < "4.03.0".
  - type_conv.108.07.00 is not available because your system doesn't comply with ocaml-version < "4.03.0".
  - type_conv.108.07.01 is not available because your system doesn't comply with ocaml-version >= "3.12.1" & ocaml-version < "4.03.0".
  - type_conv.108.08.00 is not available because your system doesn't comply with ocaml-version >= "3.12.1" & ocaml-version < "4.03.0".
  - type_conv.109.07.00 is not available because your system doesn't comply with ocaml-version >= "4.00.0" & ocaml-version < "4.03.0".
  - type_conv.109.08.00 is not available because your system doesn't comply with ocaml-version >= "4.00.0" & ocaml-version < "4.03.0".
  - type_conv.109.09.00 is not available because your system doesn't comply with ocaml-version >= "4.00.0" & ocaml-version < "4.03.0".
  - type_conv.109.10.00 is not available because your system doesn't comply with ocaml-version >= "4.00.0" & ocaml-version < "4.03.0".
  - type_conv.109.11.00 is not available because your system doesn't comply with ocaml-version >= "4.00.0" & ocaml-version < "4.03.0".
  - type_conv.109.12.00 is not available because your system doesn't comply with ocaml-version >= "4.00.0" & ocaml-version < "4.03.0".
  - type_conv.109.13.00 is not available because your system doesn't comply with ocaml-version >= "4.00.0" & ocaml-version < "4.03.0".
  - type_conv.109.14.00 is not available because your system doesn't comply with ocaml-version >= "4.00.0" & ocaml-version < "4.03.0".
  - type_conv<112.02.00 is not available because your system doesn't comply with ocaml-version >= "4.02.0" & ocaml-version < "4.03".
  - type_conv<=109.20.00 is not available because your system doesn't comply with ocaml-version >= "4.00.1" & ocaml-version < "4.03.0".
  - type_conv<=109.53.00 is not available because your system doesn't comply with ocaml-version >= "4.00.0" & ocaml-version < "4.03".
  - type_conv<=109.53.02 is not available because your system doesn't comply with ocaml-version >= "4.00.0" & ocaml-version < "4.03".

No solution found, exiting

```

Please advise, what can I do short of stopping using Core.

---

<div class="post-metadata">

**Author:** ![Yaron\_Minsky](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/yaron_minsky/32/11_2.png) [@Yaron\_Minsky](https://discuss.ocaml.org/u/Yaron_Minsky)\
**Post date:** [June 9, 2017, 12:47am UTC](https://discuss.ocaml.org/t/core-with-4-04-1/384/2 "2017-06-09T00:47:50Z")

</div>

The main problem here is that the original Real World OCaml uses syntax extensions based on camlp4, which is now pretty much deprecated in favor of PPX. So now, instead of installing comparelib, you should install ppx\_compare.

We’re in the process of refreshing RWO. It’s not complete, but here’s a snapshot of the [refresh-in-progress](http://rwo.ocamllabs.io:8080/). This shows the new syntax, e.g., `[@@deriving compare, bin_io]`, instead of the old `with` syntax.

y

---

<div class="post-metadata">

**Author:** ![vzaliva](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/vzaliva/32/206_2.png) [@vzaliva](https://discuss.ocaml.org/u/vzaliva)\
**Post date:** [June 9, 2017, 1:27am UTC](https://discuss.ocaml.org/t/core-with-4-04-1/384/3 "2017-06-09T01:27:37Z")

</div>

Thanks! I have figured out “deriving” syntax and it works for me for sexplib.

However I am still unable to install “comparelib” with my version of OCaml.

---

<div class="post-metadata">

**Author:** ![yawaramin](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/yawaramin/32/3384_2.png) [@yawaramin](https://discuss.ocaml.org/u/yawaramin)\
**Post date:** [June 9, 2017, 1:37am UTC](https://discuss.ocaml.org/t/core-with-4-04-1/384/4 "2017-06-09T01:37:38Z")

</div>

Does `ppx_compare` work for you?

---

<div class="post-metadata">

**Author:** ![vzaliva](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/vzaliva/32/206_2.png) [@vzaliva](https://discuss.ocaml.org/u/vzaliva)\
**Post date:** [June 9, 2017, 1:58am UTC](https://discuss.ocaml.org/t/core-with-4-04-1/384/5 "2017-06-09T01:58:25Z")

</div>

Yes! Thanks!

Last, quick newbie question. Assuming I have type:

```auto
  | A
  | B
 ... [@@deriving compare, sexp]

```

What is the easiest way to make a Set type for it? I am currently using:

```auto
  type t = itype
  let compare = compare_itype
  let sexp_of_t = sexp_of_itype
  let t_of_sexp = itype_of_sexp
end

module ITypeSet = Set.Make(IType)

```

Maybe there is a better way? Thanks!

---

<div class="post-metadata">

**Author:** ![Yaron\_Minsky](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/yaron_minsky/32/11_2.png) [@Yaron\_Minsky](https://discuss.ocaml.org/u/Yaron_Minsky)\
**Post date:** [June 9, 2017, 2:04am UTC](https://discuss.ocaml.org/t/core-with-4-04-1/384/6 "2017-06-09T02:04:56Z")

</div>

I’m not sure I’ve spelled this exactly right, but:

````ocaml
module M = struct type t = itype [@@deriving sexp, compare] end
module M_set = Set.Make(M)
```

FWIW, the usual Core-like idiom would be to not use the separate itype type, and instead do something like:

``` ocaml
module Itype = 
  module T = struct
      type t = | A | B [@@deriving sexp, compare]
  end
  include T
  include Set.Make(T)
end
```

You could also do `include Comparable.Make(T)`, which gives you sets and maps and other useful comparison-based operations.

y
````

---

<div class="post-metadata">

**Author:** ![vzaliva](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/vzaliva/32/206_2.png) [@vzaliva](https://discuss.ocaml.org/u/vzaliva)\
**Post date:** [June 9, 2017, 6:23pm UTC](https://discuss.ocaml.org/t/core-with-4-04-1/384/7 "2017-06-09T18:23:27Z")

</div>

Tanks again. Although idiomatic approach will require me to use `IType.t` instead of `itype`. I personally prefer the later, as less cluttered notation.
