extensions-0.0.0.1: Parse Haskell Language Extensions
Copyright(c) 2020 Kowainik
LicenseMPL-2.0
MaintainerKowainik <xrom.xkov@gmail.com>
Safe HaskellNone
LanguageHaskell2010

Extensions.Types

Description

Data types and functions to work with different types of Extensions.

extensions library supports the following types of extensions:

Haskell2010 Default Enabled Extensions On of OnOffExtensions
Haskell2010 Default Disabled Extensions Off of OnOffExtensions
SafeHaskell Extensions SafeHaskellExtensions
Synopsis

Documentation

data Extensions Source #

Main returned data type that includes merged OnOffExtensions and possibly one SafeHaskellExtension.

Instances

Instances details
Eq Extensions Source # 
Instance details

Defined in Extensions.Types

Show Extensions Source # 
Instance details

Defined in Extensions.Types

data ParsedExtensions Source #

Extensions that are collected in the result of parsing .cabal file or Haskell module (both OnOffExtension and possibly one SafeHaskellExtension).

OnOffExtensions are not necessary unique. They reflect exactly the extensions found during parsing.

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.

Constructors

ModuleParseError FilePath ModuleParseError

Parse error during module extensions parsing.

CabalError CabalException

Error during .cabal file reading/parsing.

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 SafeHaskellExtensions in one scope.

Instances

Instances details
Eq ExtensionsError Source # 
Instance details

Defined in Extensions.Types

Show ExtensionsError Source # 
Instance details

Defined in Extensions.Types

data CabalException Source #

Exception that gets thrown when working with .cabal files.

Constructors

CabalFileNotFound FilePath

The .cabal file is not found.

CabalParseError Text

Parsing errors in the .cabal file.

CabalSafeExtensionsConflict (NonEmpty SafeHaskellExtension)

Conflicting SafeHaskellExtensions in one scope.

data ModuleParseError Source #

Error while parsing Haskell source file.

Constructors

ParsecError ParseError

File parsing error.

UnknownExtensions (NonEmpty String)

Uknown extensions were used in the module.

ModuleSafeHaskellConflict (NonEmpty SafeHaskellExtension)

Conflicting SafeHaskellExtensions in one scope.

FileNotFound FilePath

Module file not found.

Defaults / empty data types

Enabled/Disabled Haskell2010 Extensions

showOnOffExtension :: OnOffExtension -> Text Source #

Display OnOffExtension as GHC recognizes it.

readOnOffExtension :: String -> Maybe OnOffExtension Source #

Parse OnOffExtension from a string that specifies extension.

readExtension :: String -> Maybe Extension Source #

Parse Extension from a string. Read instance for Extension doesn't always work since some extensions are named differently.

mergeExtensions :: [OnOffExtension] -> Set OnOffExtension Source #

Take accumulated OnOffExtensions, 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.

mergeAnyExtensions Source #

Arguments

:: ParsedExtensions

Cabal parsed extensions.

-> ParsedExtensions

Module parsed extensions.

-> ExtensionsResult 

Similar to mergeExtensions, but also merge SafeHaskellExtensions. 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:

Constructors

Unsafe 
Trustworthy 
Safe 

Instances

Instances details
Bounded SafeHaskellExtension Source # 
Instance details

Defined in Extensions.Types

Enum SafeHaskellExtension Source # 
Instance details

Defined in Extensions.Types

Eq SafeHaskellExtension Source # 
Instance details

Defined in Extensions.Types

Ord SafeHaskellExtension Source # 
Instance details

Defined in Extensions.Types

Read SafeHaskellExtension Source # 
Instance details

Defined in Extensions.Types

Show SafeHaskellExtension Source # 
Instance details

Defined in Extensions.Types

Orphan instances