@@ -849,11 +849,18 @@ The library section should contain the following fields:
849
849
850
850
:since: 3.0
851
851
852
- :default: ``private `` for internal libraries. Cannot be set for public library.
852
+ :default:
853
+ ``private `` for internal libraries. Cannot be set for main
854
+ (unnamed) library, which is always public.
853
855
854
- Cabal recognizes ``public `` and ``private `` here...
856
+ Can be ``public `` or ``private ``.
857
+ Makes it possible to have multiple public libraries in a single package.
858
+ If set to ``public ``, depending on this library from another package is
859
+ allowed. If set to ``private ``, depending on this library is allowed only
860
+ from the same package.
855
861
856
- Multiple public libraries...
862
+ See section on :ref: `Internal Libraries <sublibs >` for examples and more
863
+ information.
857
864
858
865
.. pkg-field :: reexported-modules: exportlist
859
866
:since: 1.22
@@ -991,6 +998,18 @@ a real-world use case:
991
998
992
999
default-language: Haskell2010
993
1000
1001
+ **Multiple public libraries **
1002
+
1003
+ Cabal 3.0 and later support exposing multiple libraries from a single package
1004
+ through the field :pkg-field: `library:visibility `.
1005
+ Having multiple public libraries is useful for separating the unit of
1006
+ distribution (package) from the unit of buildable code (library).
1007
+ For more information about the rationale and some examples, see
1008
+ `this blog post <https://fgaz.me/posts/2019-11-14-cabal-multiple-libraries/ >`__.
1009
+
1010
+ ..
1011
+ TODO inline the blog post
1012
+
994
1013
995
1014
Opening an interpreter session
996
1015
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -1561,16 +1580,16 @@ system-dependent values for these fields.
1561
1580
**Library Names **
1562
1581
1563
1582
External libraries are identified by the package's name they're
1564
- provided by (currently a package can only publicly expose its
1565
- main library component; in future, packages with multiple exposed
1566
- public library components will be supported and a syntax for
1567
- referring to public sub-libraries will be provided).
1568
-
1569
- In order to specify an intra- package dependency on an internal
1570
- library component you can use the unqualified name of the
1571
- library component. Note that locally defined sub-library
1572
- names shadow external package names of the same name. See section on
1573
- :ref: ` Internal Libraries < sublibs >` for examples and more information.
1583
+ provided by, optionally followed by a colon and the library name
1584
+ (available from `` cabal-version: 3.0 ``).
1585
+ If the library name is absent, the main (unnamed) library will be used.
1586
+ To refer to the main (unnamed) library explicitly, use the name of the
1587
+ package (`` foo:foo ``).
1588
+ Multiple libraries from the same package can be specified with the shorthand
1589
+ syntax `` pkg:{lib1,lib2}` ``.
1590
+
1591
+ See section on :ref: ` Internal Libraries < sublibs >` for examples and more
1592
+ information.
1574
1593
1575
1594
**Version Constraints **
1576
1595
0 commit comments