janestreet / opam-repository

Opam repository for the development version of Jane Street packages
101 stars 10 forks source link

public_name <> library name in Async_rpc_websocket,Async_websocket packages #16

Closed ghost closed 1 year ago

ghost commented 2 years ago

I'm not entirely sure this is the appropriate place to raise this but I note that there are packages in this repository that have a dependency name (the name you must specify in the dune file) that is different from the library/module name that must be referenced in your code to actually use the package. I don't know that this is actually a bug...but it is confusing.

My environment: dune 2.9.1, ocaml-base-compiler.4.12.1

Example error:

;; dune
(library
 (name example)
 (libraries async_rpc_websocket core)
 (preprocess
  (pps ppx_jane)))
;; main.ml
 Async_rpc_websocket.Rpc.serve
      ~on_handler_error:`Ignore
      ~mode:`TCP
      ~where_to_listen:(Tcp.Where_to_listen.of_port port)
      ~implementations
      ~initial_connection_state:initialize_connection
      ()

Produces the error:

Error: Unbound module Async_rpc_websocket

The fix is s/Async_rpc_websocket/Rpc_websocket:

;; main.ml
Rpc_websocket.Rpc.serve
      ~on_handler_error:`Ignore
      ~mode:`TCP
      ~where_to_listen:(Tcp.Where_to_listen.of_port port)
      ~implementations
      ~initial_connection_state:initialize_connection
      ()

I have noticed this issue exists with Async_websocket as well which must be referred to as Websocket.

I am not certain how many other examples there might be but I found the second example by grepping through $(ocamlfind printconf path) for [main_module_name] and tried an example where the directory/package name did not match [main_module_name].

I realize that this may not be the best place to bring this up as this likely has more to do with the maintenance of these individual packages rather than this repository but I thought this might be a good central location to raise the issue.