Finding which package defines a module


Is there a way in utop to find which opam package defines a module? I’m looking for something similar to #show_module but that includes the name of the package in the output.


You can use ocp-index to locate the specific file that contains a module or even a definition:

$ ocp-index locate Lwt_unix.sleep

From here you can easily see that the package is lwt.

I’m not sure if there’s something that can work in utop. I think odig might be able to give you this information in the future.


May I ask what you want this for ?


Some Modules include other modules defined in different packages. I wanted an easy way to know where to look for documentation. I usually use utop to learn how to use packages, so having that information there would be very useful.


Thank you. I’ll use that for now.


I think another related use case is listing all modules defined by an OPAM package groupped by sub-packages (ie archives). I know that this information is already generated in the docs with odig but having it exposed in the top-level would be very useful IMO. Unfortunately many packages still don’t wrap all defined modules into a single user-facing one.


100% agree. I wanted that also early on, but I got used to going to the docs.


you can use ocp-browser to have a look at the ocamldoc from a terminal