|
|
# Proposal: [LanguagePragma](language-pragma)
|
|
|
|
|
|
|
|
|
<table><tr><th> Ticket </th>
|
|
|
<th>[\#128](https://gitlab.haskell.org//haskell/prime/issues/128)</th></tr>
|
|
|
<th> [\#128](https://gitlab.haskell.org//haskell/prime/issues/128)
|
|
|
</th></tr>
|
|
|
<tr><th> Dependencies </th>
|
|
|
<th> none
|
|
|
</th></tr>
|
|
|
<tr><th> Related </th>
|
|
|
<th> specific item in [NewPragmas](new-pragmas)</th></tr></table>
|
|
|
<th> specific item in [NewPragmas](new-pragmas)
|
|
|
</th></tr></table>
|
|
|
|
|
|
|
|
|
## Compiler support (to-be-filled-in)
|
|
|
|
|
|
## Compiler support
|
|
|
|
|
|
<table><tr><th> GHC </th>
|
|
|
<th> full
|
|
|
<th> \[ full (flagname) \| partial (flagname) (comments) \| none \]
|
|
|
</th></tr>
|
|
|
<tr><th> nhc98 </th>
|
|
|
<th> none
|
|
|
<th> \[ full (flagname) \| partial (flagname) (comments) \| none \]
|
|
|
</th></tr>
|
|
|
<tr><th> Hugs </th>
|
|
|
<th> none
|
|
|
<th> \[ full (flagname) \| partial (flagname) (comments) \| none \]
|
|
|
</th></tr>
|
|
|
<tr><th> UHC </th>
|
|
|
<th> none
|
|
|
<th> \[ full (flagname) \| partial (flagname) (comments) \| none \]
|
|
|
</th></tr>
|
|
|
<tr><th> JHC </th>
|
|
|
<th> none
|
|
|
<th> \[ full (flagname) \| partial (flagname) (comments) \| none \]
|
|
|
</th></tr>
|
|
|
<tr><th> LHC </th>
|
|
|
<th> full
|
|
|
<th> \[ full (flagname) \| partial (flagname) (comments) \| none \]
|
|
|
</th></tr></table>
|
|
|
|
|
|
|
|
|
## Summary
|
|
|
|
|
|
|
|
|
Document the minimum guarantees provided by the LANGUAGE pragma.
|
|
|
|
|
|
## Description
|
|
|
Document the minimum guarantees provided by the LANGUAGE pragma so that Haskell 2010 users can reliably use it to portable control access to non-Haskell 2010 language features.
|
|
|
|
|
|
|
|
|
GHC and Cabal (via Language.Haskell.Extension) have been successfully using the LANGUAGE pragma for the following two purposes:
|
|
|
## Description
|
|
|
|
|
|
1. Document the post-Haskell98 language extensions a source file requires.
|
|
|
|
|
|
1. Locally enable those required language extensions when compiling an extension-using source file.
|
|
|
|
|
|
To-be-completed.
|
|
|
|
|
|
The goal of this proposal is to specify the minimum guarantees provided LANGUAGE pragma so that it can be used portably for those same purposes across Haskell 2010 implementations.
|
|
|
|
|
|
## References
|
|
|
|
|
|
|
|
|
- [ Compiler Pragmas](http://www.haskell.org/onlinereport/pragmas.html) in Haskell 98
|
|
|
|
|
|
- [ Pragmas](http://www.haskell.org/ghc/docs/latest/html/users_guide/pragmas.html) in the GHC User's Guide
|
... | ... | @@ -61,33 +65,7 @@ The goal of this proposal is to specify the minimum guarantees provided LANGUAGE |
|
|
## Report Delta
|
|
|
|
|
|
|
|
|
Replace the the following sentence in [ http://www.haskell.org/onlinereport/pragmas.html](http://www.haskell.org/onlinereport/pragmas.html)**11 Compiler Pragmas**:
|
|
|
|
|
|
|
|
|
An implementation is not required to respect any pragma, but the pragma should be ignored if an implementation is not prepared to handle it.
|
|
|
|
|
|
|
|
|
with
|
|
|
|
|
|
|
|
|
An implementation is not required to respect any pragma and any pragma can be ignored if an implementation is not prepared to handle it. However, implementations are strongly encouraged to support the LANGUAGE pragma described below as there are many language extensions being used in practice.
|
|
|
|
|
|
|
|
|
Add the following subsection
|
|
|
|
|
|
**11.3 Language Extensions**
|
|
|
|
|
|
|
|
|
The LANGUAGE pragma is a file-header pragma. A file-header pragma must precede the module keyword in a source file. There can be as many file-header pragmas as you please, and they can be preceded or followed by comments. An individual language pragma begins with the keyword LANGUAGE and is followed by a comma-separated list of named language extensions.
|
|
|
|
|
|
|
|
|
For example, to enable the FFI and preprocessing with CPP:
|
|
|
|
|
|
|
|
|
{-\# LANGUAGE [ForeignFunctionInterface](foreign-function-interface), CPP \#-}
|
|
|
|
|
|
|
|
|
If a Haskell implementation does not recognize or support a particular language extension that a source file requests (or cannot support the combination of language extensions requested), any attempt to compile or otherwise use that file with that Haskell implementation must fail with an error.
|
|
|
To-be-completed.
|
|
|
|
|
|
|
|
|
In the interests of portability, multiple attempts to enable the same, supported language features (e.g. via command-line arguments, implementation-specific extension dependencies or non-standard pragmas) are specifically permitted. Haskell 2010 implementations that support the LANGUAGE pragma are required to support {-\# LANGUAGE Haskell2010 -\#}. Those implementations are also encouraged to support the following named language extensions: [DoAndIfThenElse](do-and-if-then-else), [HierarchicalModules](hierarchical-modules), [FixityResolution](fixity-resolution), [PatternGuards](pattern-guards), NoNPlusKPatterns, [RelaxedDependencyAnalysis](relaxed-dependency-analysis), [LineCommentSyntax](line-comment-syntax), [EmptyDataDeclarations](empty-data-declarations), [LanguagePragma](language-pragma) and [ForeignFunctionInterface](foreign-function-interface). These are the named language extensions, supported by some pre-Haskell 2010 implementations, that have been integrated into this report. |