# Cabal terminology: sublibraries

**URL:** <https://discourse.haskell.org/t/cabal-terminology-sublibraries/7940>\
**Category:** Learn\
**Created:** [October 25, 2023, 11:48am UTC](https://discourse.haskell.org/t/cabal-terminology-sublibraries/7940 "2023-10-25T11:48:42Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![mpilgrem](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/mpilgrem/32/2529_2.png) [@mpilgrem](https://discourse.haskell.org/u/mpilgrem)\
**Post date:** [October 25, 2023, 11:48am UTC](https://discourse.haskell.org/t/cabal-terminology-sublibraries/7940/1 "2023-10-25T11:48:42Z")

</div>

I would like to check that I am using the ‘correct’, current Cabal terminology around ‘sublibraries’ - as I want to be up-to-date and consistent in the naming of certain identifiers used in the Stack project. Is the following ‘accurate’?

> A Cabal package can include an optional ‘main’ library and zero or more named ‘sublibraries’. A sublibrary has a ‘visibility’ that is either ‘public’ or ‘private’. (The ‘main’ library is always public.) Before Cabal 3.0, all sublibraries were private and were referred to as ‘internal’ libraries. Before Cabal 2.0, a Cabal package could not include sublibraries.

EDIT (26 Oct 2023): Given the discussion below, I would now recast my text above as follows:

> A Cabal package can include zero or more library components, being an optional ‘main’ unnamed library and/or zero or more named ‘subsidiary’ or ‘ancillary’ libraries (abbreviated as ‘sublibraries’). A sublibrary has a ‘visibility’ that is either ‘public’ or ‘private’. (The ‘main’ unnamed library is always public.) Before Cabal 3.0, all sublibraries were private and were, consequently, referred to as ‘internal’ libraries. Before Cabal 2.0, a Cabal package could not include sublibraries.

---

<div class="post-metadata">

**Author:** ![Mikolaj](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/mikolaj/32/1041_2.png) [@Mikolaj](https://discourse.haskell.org/u/Mikolaj)\
**Post date:** [October 25, 2023, 2:34pm UTC](https://discourse.haskell.org/t/cabal-terminology-sublibraries/7940/2 "2023-10-25T14:34:35Z")

</div>

Thank you for asking. Let’s improve/clarify the terminology together.

I think “sublibrary” is rarely used nowadays and IMHO “component” is better. Libraries, exes, tests and benchmarks are components. One of the library components is the main library, which makes it only a bit special IIRC. The terminology gets more complex once you start talking about backpack mixins as well, but I don’t remember the details.

---

<div class="post-metadata">

**Author:** ![mpilgrem](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/mpilgrem/32/2529_2.png) [@mpilgrem](https://discourse.haskell.org/u/mpilgrem)\
**Post date:** [October 25, 2023, 3:26pm UTC](https://discourse.haskell.org/t/cabal-terminology-sublibraries/7940/3 "2023-10-25T15:26:43Z")

</div>

@Mikolaj, thanks - understood on ‘components’.

For my specific purpose, I am seeking to be clear on the preferred terminology for a library component that is not a ‘main’ library. I think that is ‘sublibrary’ rather than ‘internal library’ (the principal term used in the current Cabal User Guide).

(As an aside, I think the current Cabal User Guide needs a little attention in this area (see [6. Package Description — Cabal 3.10.1.0 User's Guide](https://cabal.readthedocs.io/en/stable/cabal-package.html#library)) - I may propose a pull request.

---

<div class="post-metadata">

**Author:** ![Mikolaj](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/mikolaj/32/1041_2.png) [@Mikolaj](https://discourse.haskell.org/u/Mikolaj)\
**Post date:** [October 25, 2023, 6:33pm UTC](https://discourse.haskell.org/t/cabal-terminology-sublibraries/7940/4 "2023-10-25T18:33:27Z")

</div>

Yes, “internal library” is at this point much worse for the non-main library than “sublibrary”. If the former got retained in the Cabal User Guide, a correction (and any number of other improvements) would be very much appreciated.

Perhaps I’m biased against “sublibrary” due to an automatic association with terms such as “subset” or “subobject” — there’s no such relation between a “sublibrary” and the main library, nor between their APIs nor anything else. The main library is not a sum of the library components, but just one of them. Am I missing something?

Perhaps “non-main libraries”? "Named libraries’ (IIRC, one can’t explicitly name the main library, even with the name of the package, though that’s effectively that its name is)? “Additional libraries”?

---

<div class="post-metadata">

**Author:** ![Lsmor](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/lsmor/32/3302_2.png) [@Lsmor](https://discourse.haskell.org/u/Lsmor)\
**Post date:** [October 25, 2023, 7:50pm UTC](https://discourse.haskell.org/t/cabal-terminology-sublibraries/7940/5 "2023-10-25T19:50:34Z")

</div>

> [@Mikolaj](#):
>
> Perhaps “non-main libraries”? "Named libraries’ (IIRC, one can’t explicitly name the main library, even with the name of the package, though that’s effectively that its name is)? “Additional libraries”?

what about extra-libraries? AFAIK, the purpose of them is to provide extra utilities which aren’t meant to be the main usage, for example `quickcheck` instances

---

<div class="post-metadata">

**Author:** ![mpilgrem](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/mpilgrem/32/2529_2.png) [@mpilgrem](https://discourse.haskell.org/u/mpilgrem)\
**Post date:** [October 25, 2023, 7:51pm UTC](https://discourse.haskell.org/t/cabal-terminology-sublibraries/7940/6 "2023-10-25T19:51:18Z")

</div>

In this instance, I think ‘sub’ is being used as an abbreviation of ‘subsidiary’ (in the sense of “supplementary to the ‘main’ unnamed library”), unlike the words that derive from the Latin _sub_. So, perhaps it should be ‘sub-library’ rather than ‘sublibrary’.

The ‘main’ unnamed library of a package does have a name, in this sense: you can refer to it expressly in a `build-depends:` by the name of the package that provides it (eg `my-package:my-package` refers to the ‘main’ unnamed library in package `my-package`). Given that, I assume that a named sub-library can’t be given the name of its package.

---

<div class="post-metadata">

**Author:** ![danidiaz](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/danidiaz/32/92_2.png) [@danidiaz](https://discourse.haskell.org/u/danidiaz)\
**Post date:** [October 25, 2023, 8:08pm UTC](https://discourse.haskell.org/t/cabal-terminology-sublibraries/7940/7 "2023-10-25T20:08:04Z")

</div>

How about [“ancillary”](https://www.wordnik.com/words/ancillary).

---

<div class="post-metadata">

**Author:** ![Mikolaj](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/mikolaj/32/1041_2.png) [@Mikolaj](https://discourse.haskell.org/u/Mikolaj)\
**Post date:** [October 25, 2023, 10:14pm UTC](https://discourse.haskell.org/t/cabal-terminology-sublibraries/7940/8 "2023-10-25T22:14:55Z")

</div>

> ‘subsidiary’

Oh, that suddenly makes sense. I’m fine with “sublibrary” given this etymology. It’s used in a couple of places in the cabal code and docs (in a sane way, too). so perhaps we can stick to it (and eradicate the others, I see @f-a already embarked on this purification quest here: [Make “sublibrary” standard terminology in docs by ffaf1 · Pull Request #9371 · haskell/cabal · GitHub](https://github.com/haskell/cabal/pull/9371)). We can have “extra” and “ancillary” as a backup to resolve ambiguities, to give an intuition for the “sublibrary” term, etc.

---

<div class="post-metadata">

**Author:** ![f-a](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/f-a/32/2740_2.png) [@f-a](https://discourse.haskell.org/u/f-a)\
**Post date:** [October 26, 2023, 11:40am UTC](https://discourse.haskell.org/t/cabal-terminology-sublibraries/7940/9 "2023-10-26T11:40:57Z")

</div>

On [Matrix](https://matrix.to/#/#hackage:matrix.org) there is a proposal which is getting some traction: “named”/“unnamed”. Opinions?

I have my preferences, but the only important things are:  
a) we avoid the objectively wrong “internal library”;  
b) we take care of this swiftly.

I see contributors with seniority from both Cabal and Stack are partecipating in this discussion, whatever they agree is gospel.
