Skip to content

Commit

Permalink
doc: Simplify executable and library example
Browse files Browse the repository at this point in the history
Use `hs-source-dirs` for the library and change the `other-modules`
names for the executables to avoid confusion.

Lowercase the `main-is` files to make it clear the filename need not be
a module name.

Add dependency on the internal library to the prog2 executable to
showcase common usage.

[ci skip]
  • Loading branch information
toonn authored and emilypi committed Jun 5, 2021
1 parent d391bfb commit 0638a48
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions doc/cabal-package.rst
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,12 @@ Example: A package containing executable programs

executable program1
build-depends: HUnit >= 1.1.1 && < 1.2
main-is: Main.hs
main-is: main.hs
hs-source-dirs: prog1

executable program2
-- A different Main.hs because of hs-source-dirs.
main-is: Main.hs
-- A different main.hs because of hs-source-dirs.
main-is: main.hs
build-depends: HUnit >= 1.1.1 && < 1.2
hs-source-dirs: prog2
other-modules: Utils
Expand All @@ -167,20 +167,21 @@ Example: A package containing a library and executable programs

library
build-depends: HUnit >= 1.1.1 && < 1.2
hs-source-dirs: lib
exposed-modules: A, B, C

executable program1
main-is: Main.hs
main-is: main.hs
hs-source-dirs: prog1
-- These modules are distinct from the library modules.
other-modules: A, B
other-modules: D, E

executable program2
-- A different Main.hs because of hs-source-dirs.
main-is: Main.hs
-- A different main.hs because of hs-source-dirs.
main-is: main.hs
-- No bound on internal libraries.
build-depends: TestPackage
hs-source-dirs: prog2
-- These modules are distinct from the library and program1 modules.
other-modules: A, C, Utils
other-modules: Utils

with ``Setup.hs`` the same as above. Note that any library modules
required (directly or indirectly) by an executable must be listed again.
Expand Down

0 comments on commit 0638a48

Please sign in to comment.