Copyright | (c) 2020 Kowainik |
---|---|
License | MPL-2.0 |
Maintainer | Kowainik <xrom.xkov@gmail.com> |
Safe Haskell | None |
Language | Haskell2010 |
Data types and functions to work with different types of Extension
s.
extensions
library supports the following types of extensions:
Haskell2010 Default Enabled Extensions | On of OnOffExtension s |
Haskell2010 Default Disabled Extensions | Off of OnOffExtension s |
SafeHaskell Extensions | SafeHaskellExtension s |
Synopsis
- data Extensions = Extensions {}
- data ParsedExtensions = ParsedExtensions {}
- data CabalAndModuleExtensions = CabalAndModuleExtensions {}
- type ExtensionsResult = Either ExtensionsError Extensions
- data ExtensionsError
- data CabalException
- data ModuleParseError
- emptyExtensions :: Extensions
- emptyParsedExtensions :: ParsedExtensions
- data OnOffExtension
- showOnOffExtension :: OnOffExtension -> Text
- readOnOffExtension :: String -> Maybe OnOffExtension
- readExtension :: String -> Maybe Extension
- mergeExtensions :: [OnOffExtension] -> Set OnOffExtension
- mergeAnyExtensions :: ParsedExtensions -> ParsedExtensions -> ExtensionsResult
- default2010Extensions :: [Extension]
- data SafeHaskellExtension
- = Unsafe
- | Trustworthy
- | Safe
Documentation
data Extensions Source #
Main returned data type that includes merged OnOffExtension
s and possibly
one SafeHaskellExtension
.
Instances
Eq Extensions Source # | |
Defined in Extensions.Types (==) :: Extensions -> Extensions -> Bool # (/=) :: Extensions -> Extensions -> Bool # | |
Show Extensions Source # | |
Defined in Extensions.Types showsPrec :: Int -> Extensions -> ShowS # show :: Extensions -> String # showList :: [Extensions] -> ShowS # |
data ParsedExtensions Source #
Extensions that are collected in the result of parsing .cabal
file or
Haskell module (both OnOffExtension
and possibly one SafeHaskellExtension
).
OnOffExtension
s are not necessary unique. They reflect exactly the extensions
found during parsing.
Instances
Eq ParsedExtensions Source # | |
Defined in Extensions.Types (==) :: ParsedExtensions -> ParsedExtensions -> Bool # (/=) :: ParsedExtensions -> ParsedExtensions -> Bool # | |
Show ParsedExtensions Source # | |
Defined in Extensions.Types showsPrec :: Int -> ParsedExtensions -> ShowS # show :: ParsedExtensions -> String # showList :: [ParsedExtensions] -> ShowS # |
data CabalAndModuleExtensions Source #
Stores extensions from .cabal
file and module separately.
Instances
Eq CabalAndModuleExtensions Source # | |
Defined in Extensions.Types | |
Show CabalAndModuleExtensions Source # | |
Defined in Extensions.Types showsPrec :: Int -> CabalAndModuleExtensions -> ShowS # show :: CabalAndModuleExtensions -> String # showList :: [CabalAndModuleExtensions] -> ShowS # |
type ExtensionsResult = Either ExtensionsError Extensions Source #
Type alias for the result of extensions analysis.
Errors
data ExtensionsError Source #
Represents possible errors during the work of extensions analyser.
ModuleParseError FilePath ModuleParseError | Parse error during module extensions parsing. |
CabalError CabalException | Error during |
SourceNotFound FilePath | File is in cabal file, but the source file is not provided where requested. |
NotCabalModule FilePath | Source file is provided, but module is not in cabal file. |
SafeHaskellConflict (NonEmpty SafeHaskellExtension) | Conflicting |
Instances
Eq ExtensionsError Source # | |
Defined in Extensions.Types (==) :: ExtensionsError -> ExtensionsError -> Bool # (/=) :: ExtensionsError -> ExtensionsError -> Bool # | |
Show ExtensionsError Source # | |
Defined in Extensions.Types showsPrec :: Int -> ExtensionsError -> ShowS # show :: ExtensionsError -> String # showList :: [ExtensionsError] -> ShowS # |
data CabalException Source #
Exception that gets thrown when working with .cabal
files.
CabalFileNotFound FilePath | The |
CabalParseError Text | Parsing errors in the |
CabalSafeExtensionsConflict (NonEmpty SafeHaskellExtension) | Conflicting |
Instances
Eq CabalException Source # | |
Defined in Extensions.Types (==) :: CabalException -> CabalException -> Bool # (/=) :: CabalException -> CabalException -> Bool # | |
Show CabalException Source # | |
Defined in Extensions.Types showsPrec :: Int -> CabalException -> ShowS # show :: CabalException -> String # showList :: [CabalException] -> ShowS # | |
Exception CabalException Source # | |
Defined in Extensions.Types |
data ModuleParseError Source #
Error while parsing Haskell source file.
ParsecError ParseError | File parsing error. |
UnknownExtensions (NonEmpty String) | Uknown extensions were used in the module. |
ModuleSafeHaskellConflict (NonEmpty SafeHaskellExtension) | Conflicting |
FileNotFound FilePath | Module file not found. |
Instances
Eq ModuleParseError Source # | |
Defined in Extensions.Types (==) :: ModuleParseError -> ModuleParseError -> Bool # (/=) :: ModuleParseError -> ModuleParseError -> Bool # | |
Show ModuleParseError Source # | |
Defined in Extensions.Types showsPrec :: Int -> ModuleParseError -> ShowS # show :: ModuleParseError -> String # showList :: [ModuleParseError] -> ShowS # |
Defaults / empty data types
emptyExtensions :: Extensions Source #
Empty Extensions
with no specified SafeHaskellExtension
.
emptyParsedExtensions :: ParsedExtensions Source #
Empty ParsedExtensions
with no specified SafeHaskellExtension
.
Enabled/Disabled Haskell2010 Extensions
data OnOffExtension Source #
Represents enabled/disabled extensions.
Instances
Eq OnOffExtension Source # | |
Defined in Extensions.Types (==) :: OnOffExtension -> OnOffExtension -> Bool # (/=) :: OnOffExtension -> OnOffExtension -> Bool # | |
Ord OnOffExtension Source # | |
Defined in Extensions.Types compare :: OnOffExtension -> OnOffExtension -> Ordering # (<) :: OnOffExtension -> OnOffExtension -> Bool # (<=) :: OnOffExtension -> OnOffExtension -> Bool # (>) :: OnOffExtension -> OnOffExtension -> Bool # (>=) :: OnOffExtension -> OnOffExtension -> Bool # max :: OnOffExtension -> OnOffExtension -> OnOffExtension # min :: OnOffExtension -> OnOffExtension -> OnOffExtension # | |
Show OnOffExtension Source # | |
Defined in Extensions.Types showsPrec :: Int -> OnOffExtension -> ShowS # show :: OnOffExtension -> String # showList :: [OnOffExtension] -> ShowS # |
showOnOffExtension :: OnOffExtension -> Text Source #
Display OnOffExtension
as GHC recognizes it.
readOnOffExtension :: String -> Maybe OnOffExtension Source #
Parse OnOffExtension
from a string that specifies extension.
mergeExtensions :: [OnOffExtension] -> Set OnOffExtension Source #
Take accumulated OnOffExtension
s, and merge them into one Set
,
excluding enabling of default2010Extensions
.
If the default extension is enabled manually it still won't count as it doesn't affect real behaviour. However, disabling of default extension will be included in the list.
So, basically, this set will only have On
extensions that are not defaults,
and Off
extensions of defaults.
'foldl'' is used in order to process them in the right order: first all cabal extensions and then extensions from the module in the order of appearance.
:: ParsedExtensions | Cabal parsed extensions. |
-> ParsedExtensions | Module parsed extensions. |
-> ExtensionsResult |
Similar to mergeExtensions
, but also merge SafeHaskellExtension
s.
In case of conflicting SafeHaskellExtension
returns Left
with the pair of
conflicting extension constructors under SafeHaskellConflict
error.
default2010Extensions :: [Extension] Source #
Default enabled extensions for Haskell2010
Safe Haskell Extensions
data SafeHaskellExtension Source #
Language extensions that are used by Safe Haskell to indicate safety of the code.
To find out more, checkout the official documentation on SafeHaskell
: