Couldn't make `ppx_rapper` work with `dream`

Hello friends, I’m new to OCaml and I’d like to do a toy project with dream and ppx_rapper.

It seems the latest version of dream(1.0.0~alpha8) is not compatible with ppx_rapper(details at the end of the post). I see a few things I could do but not sure what’s best for a newcomer:

  1. reach out to ppx_rapper and see if it’s possible to upgrade it to support Caqti 2
  2. reach out to dream to see if it can relax requirement of Caqti to below 2
  3. using Caqti without ppx_rapper - tried, but
    • auto generated documentation of Caqti is hard to decipher for me. i.e. where can I find how to build a simple select query?
    • examples of Caqti usage seems scarce. The documented example uses Caqti template which is marked as experimental
    • finally found another example using Caqti request, but the types and infix operators make it a bit intimidating - I really wish ppx_rapper could work to hide that complexity :worried:

version conflict between dream and ppx_rapper
Example .opam file:

# This file is generated by dune, edit dune-project instead
opam-version: "2.0"
maintainer: ["Han Liang <blurrcat@pm.me>"]
authors: ["Han Liang <blurrcat@pm.me>"]
license: "LICENSE"
homepage: "https://github.com/blurrcat/foo"
bug-reports: "https://github.com/blurrcat/foo/issues"
synopsis: "Blah."
depends: [
  "ocaml" {>= "5.3"}
  "dune" {>= "3.17" & >= "3"}
  "dream" {= "1.0.0~alpha8"}
  "caqti-driver-sqlite3"
  "ppx_rapper"
  "ppx_rapper_lwt"
]
build: [
  ["dune" "subst"] {dev}
  [
    "dune"
    "build"
    "-p"
    name
    "-j"
    jobs
    "@install"
    "@runtest" {with-test}
    "@doc" {with-doc}
  ]
]
dev-repo: "git+https://github.com/blurrcat/foo.git"

When I run opam install:

➜  rapper opam install . --deps-only
[ERROR] Package conflict!
  * No agreement on the version of caqti:
    - deps-of-rapper -> dream >= 1.0.0~alpha8 -> caqti >= 2.0.0
    - deps-of-rapper -> ppx_rapper_lwt -> ppx_rapper = 3.0.0 -> caqti < 2.0.0~
  * No agreement on the version of ocaml:
    - (invariant) -> ocaml-base-compiler = 5.3.0 -> ocaml-compiler = 5.3.0 -> ocaml = 5.3.0
    - deps-of-rapper -> ppx_rapper_lwt -> ppx_rapper = 3.0.0 -> caqti < 2.0.0~ -> ocaml < 5.0
    You can temporarily relax the switch invariant with `--update-invariant'

No solution found, exiting

ppx_rapper only works with caqti < 2.0.0 but dream requires caqti >= 2.0.0.

Here’s a complete example dream/example/h-sql at master · aantron/dream · GitHub

Make sure to also have a look at the “caqti-study”

It was designed to be very beginner friendly and I believe it should help with your use case.

Have a look at the opam pin command here:

I’m on my phone so I can’t very if that pinning is still necessary though.