# Finding which package defines a module

**URL:** <https://discuss.ocaml.org/t/finding-which-package-defines-a-module/2138>\
**Category:** Learning\
**Created:** [June 13, 2018, 2:58pm UTC](https://discuss.ocaml.org/t/finding-which-package-defines-a-module/2138 "2018-06-13T14:58:18Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![shinzui](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/shinzui/32/798_2.png) [@shinzui](https://discuss.ocaml.org/u/shinzui)\
**Post date:** [June 13, 2018, 2:58pm UTC](https://discuss.ocaml.org/t/finding-which-package-defines-a-module/2138/1 "2018-06-13T14:58:18Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![rizo](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/rizo/32/93_2.png) [@rizo](https://discuss.ocaml.org/u/rizo)\
**Post date:** [June 13, 2018, 4:48pm UTC](https://discuss.ocaml.org/t/finding-which-package-defines-a-module/2138/2 "2018-06-13T16:48:28Z")

</div>

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

```auto
$ ocp-index locate Lwt_unix.sleep
/Users/rizo/.opam/4.06.1/.opam-switch/build/lwt.4.0.1/src/unix/lwt_unix.cppo.ml:139:4

```

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`](http://erratique.ch/software/odig/doc/Odig.html) might be able to give you this information in the future.

---

<div class="post-metadata">

**Author:** ![dbuenzli](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/dbuenzli/32/18_2.png) [@dbuenzli](https://discuss.ocaml.org/u/dbuenzli)\
**Post date:** [June 13, 2018, 5:01pm UTC](https://discuss.ocaml.org/t/finding-which-package-defines-a-module/2138/3 "2018-06-13T17:01:56Z")

</div>

> [@shinzui](#):
>
> Is there a way in utop to find which opam package defines a module?

May I ask what you want this for ?

---

<div class="post-metadata">

**Author:** ![shinzui](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/shinzui/32/798_2.png) [@shinzui](https://discuss.ocaml.org/u/shinzui)\
**Post date:** [June 13, 2018, 5:16pm UTC](https://discuss.ocaml.org/t/finding-which-package-defines-a-module/2138/4 "2018-06-13T17:16:30Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![shinzui](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/shinzui/32/798_2.png) [@shinzui](https://discuss.ocaml.org/u/shinzui)\
**Post date:** [June 13, 2018, 5:25pm UTC](https://discuss.ocaml.org/t/finding-which-package-defines-a-module/2138/5 "2018-06-13T17:25:41Z")

</div>

Thank you. I’ll use that for now.

---

<div class="post-metadata">

**Author:** ![rizo](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/rizo/32/93_2.png) [@rizo](https://discuss.ocaml.org/u/rizo)\
**Post date:** [June 13, 2018, 5:30pm UTC](https://discuss.ocaml.org/t/finding-which-package-defines-a-module/2138/6 "2018-06-13T17:30:48Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![shinzui](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/shinzui/32/798_2.png) [@shinzui](https://discuss.ocaml.org/u/shinzui)\
**Post date:** [June 13, 2018, 5:35pm UTC](https://discuss.ocaml.org/t/finding-which-package-defines-a-module/2138/7 "2018-06-13T17:35:05Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![UnixJunkie](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/unixjunkie/32/638_2.png) [@UnixJunkie](https://discuss.ocaml.org/u/UnixJunkie)\
**Post date:** [June 14, 2018, 12:23am UTC](https://discuss.ocaml.org/t/finding-which-package-defines-a-module/2138/8 "2018-06-14T00:23:48Z")

</div>

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