# Good examples of structuring a multi-module library?

**URL:** <https://discourse.haskell.org/t/good-examples-of-structuring-a-multi-module-library/3063>\
**Category:** Uncategorized\
**Created:** [September 4, 2021, 12:35am UTC](https://discourse.haskell.org/t/good-examples-of-structuring-a-multi-module-library/3063 "2021-09-04T00:35:13Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![stu002](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/stu002/32/872_2.png) [@stu002](https://discourse.haskell.org/u/stu002)\
**Post date:** [September 4, 2021, 12:35am UTC](https://discourse.haskell.org/t/good-examples-of-structuring-a-multi-module-library/3063/1 "2021-09-04T00:35:13Z")

</div>

I’m looking for good examples of Haskell libraries with multiple, possibly nested modules to see how they have handled project exports and ergonomic imports for library clients.

I notice some projects provide a project-specific “prelude”, allowing something like:

`import MyProject.Core`

and possibly:

`import MyProject.Extras`

if needed. I think to do this the `Core` module must be importing and reexporting the “core” internal library modules? I wonder if that module needs to also reexport third-party modules used in the module type definitions?

Any advice much appreciated.

---

<div class="post-metadata">

**Author:** ![bergmark](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/bergmark/32/418_2.png) [@bergmark](https://discourse.haskell.org/u/bergmark)\
**Post date:** [September 4, 2021, 10:53am UTC](https://discourse.haskell.org/t/good-examples-of-structuring-a-multi-module-library/3063/2 "2021-09-04T10:53:10Z")

</div>

I would re-export the common things from `MyProject` instead of a submodule. Re-exporting from other libraries is a versioning nightmare as a breaking change in those libraries may be a breaking change in your lib.

I think opaleye has a good module structure!

---

<div class="post-metadata">

**Author:** ![wiz](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/wiz/32/2408_2.png) [@wiz](https://discourse.haskell.org/u/wiz)\
**Post date:** [September 5, 2021, 11:28am UTC](https://discourse.haskell.org/t/good-examples-of-structuring-a-multi-module-library/3063/3 "2021-09-05T11:28:58Z")

</div>

IMO `Core` and `Extras` isn’t even a good split. How would one know without further digging what’s considered “extras”?

I’d rather have users making their own preludes and focus on providing a sane module tree grouped by functionality provided.

---

<div class="post-metadata">

**Author:** ![stu002](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/stu002/32/872_2.png) [@stu002](https://discourse.haskell.org/u/stu002)\
**Post date:** [September 6, 2021, 12:02am UTC](https://discourse.haskell.org/t/good-examples-of-structuring-a-multi-module-library/3063/4 "2021-09-06T00:02:43Z")

</div>

Thanks – I’ll checkout opealeye.

---

<div class="post-metadata">

**Author:** ![stu002](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/stu002/32/872_2.png) [@stu002](https://discourse.haskell.org/u/stu002)\
**Post date:** [September 6, 2021, 12:03am UTC](https://discourse.haskell.org/t/good-examples-of-structuring-a-multi-module-library/3063/5 "2021-09-06T00:03:04Z")

</div>

Good point – thanks.

---

<div class="post-metadata">

**Author:** ![ketzacoatl](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/ketzacoatl/32/1203_2.png) [@ketzacoatl](https://discourse.haskell.org/u/ketzacoatl)\
**Post date:** [September 26, 2021, 1:35am UTC](https://discourse.haskell.org/t/good-examples-of-structuring-a-multi-module-library/3063/6 "2021-09-26T01:35:47Z")

</div>

> [@stu002](#):
>
> I’m looking for good examples of Haskell libraries with multiple, possibly nested modules to see how they have handled project exports and ergonomic imports for library clients.

Here’s a plug for @NorfairKing 🙂 While you can get this from just about any of his projects, one of the purposes of [GitHub - NorfairKing/smos: A comprehensive self-management System](https://github.com/NorfairKing/smos) is to be an example we can learn from. The codebase explicitly aims for the extensive and ergonomic application of a variety of best practices (including module imports and exports, libraries, etc). This is a good example of what a moderately large project can look like with those practices applied, and is not just a couple commits in a fly-by-night toy blog post.

---

<div class="post-metadata">

**Author:** ![ChShersh](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/chshersh/32/2551_2.png) [@ChShersh](https://discourse.haskell.org/u/ChShersh)\
**Post date:** [September 26, 2021, 9:48am UTC](https://discourse.haskell.org/t/good-examples-of-structuring-a-multi-module-library/3063/7 "2021-09-26T09:48:41Z")

</div>

There’s an excellent blog post by Gabriella Gonzalez about structuring modules in Haskell projects:

- [Module organization guidelines for Haskell projects](https://www.haskellforall.com/2021/05/module-organization-guidelines-for.html)
