ocaml / dune

A composable build system for OCaml.
https://dune.build/
MIT License
1.63k stars 407 forks source link

Combining the Jane Street Core and basic-project examples #274

Open ELLIOTTCABLE opened 7 years ago

ELLIOTTCABLE commented 7 years ago

Hi!

I'm an OCaml newbie, trying to combine your basic project (in the examples/ directory) and Jane Street Core (from the documentation's ‘quick start guide’) examples:

lib/jbuild:
(jbuild_version 1)

(library
 ((name        ocameel)
  (public_name ocameel)
  (libraries (core))
  (preprocess (pps (ppx_jane)))
))
lib/ocameel.ml:
let print =
   Sexp.to_string_hum [%sexp ([3;4;5] : int list)]
bin/jbuild:
(jbuild_version 1)

(executables
 ((names (cli))
  (libraries (ocameel))))

(install
 ((section bin)
  (files ((cli.exe as ocameel)))))
lib/ocameel.ml:
open Core

let () =
   Ocameel.print ()
   |> print_endline

Unfortunately, I'm getting:

ocameel master ❯ jbuilder build @install
    ocamldep bin/cli.depends.ocamldep-output
    ocamlopt .ppx/ppx_jane/ppx.exe
         ppx lib/ocameel.pp.ml
    ocamldep lib/ocameel.depends.ocamldep-output
      ocamlc lib/ocameel.{cmi,cmo,cmt} (exit 2)
(cd _build/default && /usr/local/bin/ocamlc.opt -w -40 -g -bin-annot -I /Users/ec/.opam/system/lib/base -I /Users/ec/.opam/system/lib/base/caml -I /Users/ec/.opam/system/lib/base/shadow_stdlib -I /Users/ec/.opam/system/lib/bin_prot -I /Users/ec/.opam/system/lib/bin_prot/shape -I /Users/ec/.opam/system/lib/core -I /Users/ec/.opam/system/lib/core_kernel -I /Users/ec/.opam/system/lib/core_kernel/base_for_tests -I /Users/ec/.opam/system/lib/fieldslib -I /Users/ec/.opam/system/lib/jane-street-headers -I /Users/ec/.opam/system/lib/num -I /Users/ec/.opam/system/lib/ppx_assert/runtime-lib -I /Users/ec/.opam/system/lib/ppx_bench/runtime-lib -I /Users/ec/.opam/system/lib/ppx_compare/runtime-lib -I /Users/ec/.opam/system/lib/ppx_expect/collector -I /Users/ec/.opam/system/lib/ppx_expect/common -I /Users/ec/.opam/system/lib/ppx_expect/config -I /Users/ec/.opam/system/lib/ppx_hash/runtime-lib -I /Users/ec/.opam/system/lib/ppx_inline_test/config -I /Users/ec/.opam/system/lib/ppx_inline_test/runtime-lib -I /Users/ec/.opam/system/lib/sexplib -I /Users/ec/.opam/system/lib/sexplib/0 -I /Users/ec/.opam/system/lib/sexplib/unix -I /Users/ec/.opam/system/lib/spawn -I /Users/ec/.opam/system/lib/stdio -I /Users/ec/.opam/system/lib/typerep -I /Users/ec/.opam/system/lib/variantslib -I /usr/local/lib/ocaml -I /usr/local/lib/ocaml/threads -no-alias-deps -I lib -o lib/ocameel.cmo -c -impl lib/ocameel.pp.ml)
File "lib/ocameel.ml", line 2, characters 3-21:
Error: Unbound module Sexp

I hope my error isn't super-obvious; the documentation on “how to build your first OCaml package” has been a little scattered, and I've been through about a bajillion Google searches, two build systems (!!), and three paper books (!!!), trying to figure out how the heckage one does this!

Any response is appreciated; also, while I'm here, I'd like to suggest that this particular situation be blessed with its own examples/ example-project? Perhaps even with a link from the README? Maybe the things I'm reading are out-of-date, but it seems like Core is the go-to in the modern OCaml / ReasonML world; and if you're new to OCaml, like me, coming from Real World OCaml / ReasonML's documentation or similar … the very first thing you're probably going to try to do is create a new project with Jbuilder that you can start typing examples from RWO into (at least, I'd assume I'm not alone in this particular need!) It'd be really great to have a shortcut for beginners like myself!

ELLIOTTCABLE commented 7 years ago

Ayeee, after half a day banging my head against this, I hit submit about five minutes too soon!

Well, foolish beginner mistake (that I knew it would be) aside, go ahead and consider this a request for improved very-beginner documentation! ^_^