Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query handler example - incomplete information #3633

Open
robertblackwell opened this issue May 27, 2022 · 1 comment
Open

Query handler example - incomplete information #3633

robertblackwell opened this issue May 27, 2022 · 1 comment

Comments

@robertblackwell
Copy link

This is by way of a bit of a whinge, though by publishing this info it might help some other poor newbie like me.

Its also a more general comment about what I have found to be an impediment and discouragement to learning Ocaml. Namely a lot of simple things are left un-said and they accumulate to be a real impediment.

I am working on the query handler given as an example in "Real World Ocaml" and got to the point of

#require ppx_jane";;
type u = {a:int; b: float} [@@deriving sexp];;

to which I got the error message "Error: Unbound value int_of_sexp"

well a few hours, and much hair tearing, latter I had the following series of utop commands

#require "base";;
open Base;;
#require ppx_jane";;
type u = {a:int; b: float} [@@deriving sexp];;
sexp_of_u {a=3; b=7.}

which gave :

- : Sexp.t =
Sexplib0.Sexp.List
 [Sexplib0.Sexp.List [Sexplib0.Sexp.Atom "a"; Sexplib0.Sexp.Atom "3"];
  Sexplib0.Sexp.List [Sexplib0.Sexp.Atom "b"; Sexplib0.Sexp.Atom "6"]]

Not at all what I expected nor what the book predicted. So more searching and eventually the additional command

#install_printer Sexplib.Sexp.pp_hum

gave the expected output.

@yminsky
Copy link
Member

yminsky commented May 28, 2022

Yeah, this is a general problem in the book. There are installation instructions that tell you what you need to do (linked to from the guided tour and from the prologue:

http://dev.realworldocaml.org/install.html

but the document is a little long, and it's easy to miss the right invocation:

#use "topfind";;
#thread;;
#require "core.top";;

And the "open Core" is at the top of the chapter, as it is at the top of nearly every chapter. ("open Base" works too for what you did.)

I'm honestly not sure how to make this better. Open to suggestions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants