# \[Tooling Tip\] relevant if you use private sublibraries in cabal

**URL:** <https://discourse.haskell.org/t/tooling-tip-relevant-if-you-use-private-sublibraries-in-cabal/10970>\
**Category:** Learn\
**Created:** [December 7, 2024, 11:22am UTC](https://discourse.haskell.org/t/tooling-tip-relevant-if-you-use-private-sublibraries-in-cabal/10970 "2024-12-07T11:22:10Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![hellwolf](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/hellwolf/32/3020_2.png) [@hellwolf](https://discourse.haskell.org/u/hellwolf)\
**Post date:** [December 7, 2024, 11:22am UTC](https://discourse.haskell.org/t/tooling-tip-relevant-if-you-use-private-sublibraries-in-cabal/10970/1 "2024-12-07T11:22:11Z")

</div>

Cabal supports sublibraries, wherein you could specify multiple libraries to be built in addition to the main one (the one without a name) in the package.

Cabal also supports specifying the visibility of these sublibraries, public or private, which by default is “private.” (EDIT: it is private per [doc](https://cabal.readthedocs.io/en/stable/cabal-package-description-file.html).)

An example:

```haskell
library lvm
  import: basic-options
  visibility: private
  --
  hs-source-dirs: ./internal/lvm
  exposed-modules: ...
  build-depends: ...

```

However, I recently learned that my default setup doesn’t jibe well with this setting. I am using haskell-language-server (HLS) 2.9.0.0 and Emacs 29.4. As far as I am aware, this tip should also apply to vscode + HLS too.

What I did to make my setup work better are:

**cabal.project**

```haskell
multi-repl: true

```

[doc link:](https://cabal.readthedocs.io/en/stable/cabal-commands.html#cmdoption-enable-multi-repl)

> –enable-multi-repl[](https://cabal.readthedocs.io/en/stable/cabal-commands.html#cmdoption-enable-multi-repl)
> 
> Allow starting GHCi with multiple targets. This requires GHC with multiple home unit support (GHC-9.4+)
> 
> The closure of required components will be loaded.

**emacs’s lsp-haskell configuration**

```haskell
(use-package haskell-mode
;; ...
:custom
  (lsp-haskell-session-loading "multipleComponents")
;;

```

**vscode HLS configuration**

According to people using vscode, similarly, you should use:

```haskell
haskell.sessionLoading: "multipleComponents"

```

I am not aware of the full story behind these settings, and I wonder if this option should become the default. But in any case, hope it can be helpful to you too.

---

<div class="post-metadata">

**Author:** ![jaror](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/jaror/32/3271_2.png) [@jaror](https://discourse.haskell.org/u/jaror)\
**Post date:** [December 7, 2024, 11:35am UTC](https://discourse.haskell.org/t/tooling-tip-relevant-if-you-use-private-sublibraries-in-cabal/10970/2 "2024-12-07T11:35:40Z")

</div>

Well-Typed has a blog post describing this: [Multi Component Support in HLS with cabal-install 3.12 - Well-Typed: The Haskell Consultants](https://well-typed.com/blog/2024/07/hls-multi/)

In particular this setting requires:

> - GHC version 9.4 or later
> - cabal-install version 3.12.0.0 or later
> - HLS version 2.6.0.0 or later

---

<div class="post-metadata">

**Author:** ![hellwolf](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/hellwolf/32/3020_2.png) [@hellwolf](https://discourse.haskell.org/u/hellwolf)\
**Post date:** [December 7, 2024, 11:38am UTC](https://discourse.haskell.org/t/tooling-tip-relevant-if-you-use-private-sublibraries-in-cabal/10970/3 "2024-12-07T11:38:38Z")

</div>

Thanks, I had not known. I quote the relevant section in the blog post on why it is not a default setting yet:

> We disabled the feature by default because we discovered that HLS did not handle the setup dependency requirement gracefully: it would fail if any package in your dependency tree did not support version 3.12.0.0 of the Cabal library. In due course, we hope to re-enable this feature by default as more libraries become compatible with newer versions of the `Cabal` library.

---

<div class="post-metadata">

**Author:** ![MangoIV](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/mangoiv/32/3519_2.png) [@MangoIV](https://discourse.haskell.org/u/MangoIV)\
**Post date:** [December 7, 2024, 12:21pm UTC](https://discourse.haskell.org/t/tooling-tip-relevant-if-you-use-private-sublibraries-in-cabal/10970/4 "2024-12-07T12:21:30Z")

</div>

thank you for posting this ~ I was wondering why I got the bug with the not loaded libraries since that was enabled ~ it turns out that the blogpost linked by @jaror has a typo (and I blindly copied from there), it’s  
`multipleComponents` as you said, not `multiComponent` as shown in the blogpost!

---

<div class="post-metadata">

**Author:** ![jaror](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/jaror/32/3271_2.png) [@jaror](https://discourse.haskell.org/u/jaror)\
**Post date:** [December 7, 2024, 12:37pm UTC](https://discourse.haskell.org/t/tooling-tip-relevant-if-you-use-private-sublibraries-in-cabal/10970/5 "2024-12-07T12:37:28Z")

</div>

Ah, perhaps @adamgundry can fix the typo?

---

<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:** [December 7, 2024, 2:10pm UTC](https://discourse.haskell.org/t/tooling-tip-relevant-if-you-use-private-sublibraries-in-cabal/10970/6 "2024-12-07T14:10:06Z")

</div>

The specification of the Cabal package format is that the `visibility` of named sub-libraries is `private` by default. That default is consistent with the history of the feature (no sub-libraries and then only ‘internal’ sub-libraries). See: [1. Package Description — \<package\>.cabal File — Cabal 3.12.1.0 User's Guide](https://cabal.readthedocs.io/en/stable/cabal-package-description-file.html#pkg-field-library-visibility)

Is Cabal behaving differently to the specification?

---

<div class="post-metadata">

**Author:** ![hellwolf](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/hellwolf/32/3020_2.png) [@hellwolf](https://discourse.haskell.org/u/hellwolf)\
**Post date:** [December 7, 2024, 2:14pm UTC](https://discourse.haskell.org/t/tooling-tip-relevant-if-you-use-private-sublibraries-in-cabal/10970/7 "2024-12-07T14:14:37Z")

</div>

You are right; I edited my post. Doc says it is private by default.

---

<div class="post-metadata">

**Author:** ![adamgundry](https://avatars.discourse-cdn.com/v4/letter/a/34f0e0/32.png) [@adamgundry](https://discourse.haskell.org/u/adamgundry)\
**Post date:** [December 9, 2024, 8:10am UTC](https://discourse.haskell.org/t/tooling-tip-relevant-if-you-use-private-sublibraries-in-cabal/10970/8 "2024-12-09T08:10:51Z")

</div>

Thanks, the post will be fixed on the next deploy of the site. This is the peril of writing posts before the feature implementation has fully stabilized…

---

<div class="post-metadata">

**Author:** ![srid](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/srid/32/5514_2.png) [@srid](https://discourse.haskell.org/u/srid)\
**Post date:** [August 22, 2025, 3:27pm UTC](https://discourse.haskell.org/t/tooling-tip-relevant-if-you-use-private-sublibraries-in-cabal/10970/9 "2025-08-22T15:27:17Z")

</div>

> [@hellwolf](#):
>
> I am not aware of the full story behind these settings, and I wonder if this option [`haskell.sessionLoading: "multipleComponents"`] should become the default.

This may be relevant: [Multi Component Support in HLS with cabal-install 3.12 - Well-Typed: The Haskell Consultants](https://well-typed.com/blog/2024/07/hls-multi/#enabling-multi-component-support-in-hls) _“We disabled the feature by default because we discovered that HLS did not handle the setup dependency requirement gracefully: it would fail if any package in your dependency tree did not support version 3.12.0.0 of the Cabal library. In due course, we hope to re-enable this feature by default as more libraries become compatible with newer versions of the `Cabal` library.“_
