-
Notifications
You must be signed in to change notification settings - Fork 104
Complete documentation of Hpack's main
field
#609
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -332,7 +332,7 @@ This is done to allow compatibility with a wider range of `Cabal` versions. | |||||||||||||||
|
||||||||||||||||
| Hpack | Cabal | Default | Notes | | ||||||||||||||||
| --- | --- | --- | --- | | ||||||||||||||||
| `main` | `main-is` | | | | ||||||||||||||||
| `main` | `main-is` | | Unlike `Cabal`, also accepts a module name or qualified name (see ['Main' IO action](#main-io-action). | | ||||||||||||||||
| `other-modules` | · | All modules in `source-dirs` less `main` less any modules mentioned in `when` | | | ||||||||||||||||
| `generated-other-modules` | | | Added to `other-modules` and `autogen-modules`. Since `0.23.0`. | ||||||||||||||||
|
||||||||||||||||
|
@@ -341,7 +341,7 @@ This is done to allow compatibility with a wider range of `Cabal` versions. | |||||||||||||||
| Hpack | Cabal | Default | Notes | | ||||||||||||||||
| --- | --- | --- | --- | | ||||||||||||||||
| | `type` | `exitcode-stdio-1.0` | | | ||||||||||||||||
| `main` | `main-is` | | | | ||||||||||||||||
| `main` | `main-is` | | Unlike `Cabal`, also accepts a module name or qualified name (see ['Main' IO action](#main-io-action). | | ||||||||||||||||
| `other-modules` | · | All modules in `source-dirs` less `main` less any modules mentioned in `when` | | | ||||||||||||||||
| `generated-other-modules` | | | Added to `other-modules` and `autogen-modules`. Since `0.23.0`. | ||||||||||||||||
|
||||||||||||||||
|
@@ -350,7 +350,7 @@ This is done to allow compatibility with a wider range of `Cabal` versions. | |||||||||||||||
| Hpack | Cabal | Default | Notes | | ||||||||||||||||
| --- | --- | --- | --- | | ||||||||||||||||
| | `type` | `exitcode-stdio-1.0` | | | ||||||||||||||||
| `main` | `main-is` | | | | ||||||||||||||||
| `main` | `main-is` | | Unlike `Cabal`, also accepts a module name or qualified name (see ['Main' IO action](#main-io-action). | | ||||||||||||||||
| `other-modules` | · | All modules in `source-dirs` less `main` less any modules mentioned in `when` | | | ||||||||||||||||
| `generated-other-modules` | | | Added to `other-modules` and `autogen-modules`. Since `0.23.0`. | ||||||||||||||||
|
||||||||||||||||
|
@@ -481,6 +481,63 @@ becomes | |||||||||||||||
**Note:** Conditionals with `condition: false` are omitted from the generated | ||||||||||||||||
`.cabal` file. | ||||||||||||||||
|
||||||||||||||||
#### 'Main' IO action | ||||||||||||||||
|
||||||||||||||||
By convention, a Haskell program must have a module called `Main` which exports | ||||||||||||||||
an IO action named `main`. When the program is executed, the action is | ||||||||||||||||
performed. However, GHC's `main-is` option can be used to change the name of the | ||||||||||||||||
relevant IO action. | ||||||||||||||||
|
||||||||||||||||
Hpack's `main` field accepts a module name, a qualified name or a source file | ||||||||||||||||
name. Hpack assumes that anything that does not have the format of the first two | ||||||||||||||||
possibilities is a source file name. For the first two possibilities, Hpack | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not entirely accurate. It's roughly:
Or in other words, Hpack does not accept entry points named Lines 55 to 61 in e11cf4f
|
||||||||||||||||
assumes that the relevant source file is named after the module. | ||||||||||||||||
|
||||||||||||||||
For example, | ||||||||||||||||
|
||||||||||||||||
```yaml | ||||||||||||||||
executables: | ||||||||||||||||
my-app: | ||||||||||||||||
main: MyMainModule # A module name | ||||||||||||||||
``` | ||||||||||||||||
|
||||||||||||||||
becomes | ||||||||||||||||
|
||||||||||||||||
executable my-app | ||||||||||||||||
main-is: MyMainModule.hs | ||||||||||||||||
ghc-options: -main-is MyMainModule | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we don't frequently document things in terms of how they desugar to I'm not saying this is necessarily bad, just want to bring it up. |
||||||||||||||||
|
||||||||||||||||
and, | ||||||||||||||||
|
||||||||||||||||
```yaml | ||||||||||||||||
executables: | ||||||||||||||||
my-app: | ||||||||||||||||
main: MyMainModule.myMainFunc # A qualified name | ||||||||||||||||
``` | ||||||||||||||||
|
||||||||||||||||
becomes | ||||||||||||||||
|
||||||||||||||||
executable my-app | ||||||||||||||||
main-is: MyMainModule.hs | ||||||||||||||||
ghc-options: -main-is MyMainModule.myMainFunc | ||||||||||||||||
|
||||||||||||||||
and, | ||||||||||||||||
|
||||||||||||||||
```yaml | ||||||||||||||||
executables: | ||||||||||||||||
my-app: | ||||||||||||||||
main: MyMainSourceFile.hs # A source file name | ||||||||||||||||
``` | ||||||||||||||||
|
||||||||||||||||
becomes | ||||||||||||||||
|
||||||||||||||||
executable my-app | ||||||||||||||||
main-is: MyMainSourceFile.hs | ||||||||||||||||
|
||||||||||||||||
**Note:** Unlike GHC's `main-is` option, a lower-case identifier is not | ||||||||||||||||
accepted as the name of the relevant IO action. Hpack will assume it is a | ||||||||||||||||
source file name. | ||||||||||||||||
|
||||||||||||||||
### File globbing | ||||||||||||||||
|
||||||||||||||||
At place where you can specify a list of files you can also use glob patterns. | ||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.