-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Parse Haskell Language Extensions -- -- Parse Haskell Language Extensions. See README.md for more -- details. @package extensions @version 0.0.0.0 -- | Data types and functions to work with different types of -- Extensions. -- -- extensions library supports the following types of -- extensions: -- -- TODO: table module Extensions.Types -- | Main returned data type that includes merged OnOffExtensions -- and possibly one SafeHaskellExtension. data Extensions Extensions :: !Set OnOffExtension -> !Maybe SafeHaskellExtension -> Extensions [extensionsAll] :: Extensions -> !Set OnOffExtension [extensionsSafe] :: Extensions -> !Maybe SafeHaskellExtension -- | 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. data ParsedExtensions ParsedExtensions :: ![OnOffExtension] -> !Maybe SafeHaskellExtension -> ParsedExtensions [parsedExtensionsAll] :: ParsedExtensions -> ![OnOffExtension] [parsedExtensionsSafe] :: ParsedExtensions -> !Maybe SafeHaskellExtension -- | Stores extensions from .cabal file and module separately. data CabalAndModuleExtensions CabalAndModuleExtensions :: !ParsedExtensions -> !ParsedExtensions -> CabalAndModuleExtensions [cabalExtensions] :: CabalAndModuleExtensions -> !ParsedExtensions [moduleExtensions] :: CabalAndModuleExtensions -> !ParsedExtensions -- | Type alias for the result of extensions analysis. type ExtensionsResult = Either ExtensionsError Extensions -- | Represents possible errors during the work of extensions analyser. data ExtensionsError -- | Parse error during module extensions parsing. ModuleParseError :: FilePath -> ModuleParseError -> ExtensionsError -- | Error during .cabal file reading/parsing. CabalError :: CabalException -> ExtensionsError -- | File is in cabal file, but the source file is not provided where -- requested. SourceNotFound :: FilePath -> ExtensionsError -- | Source file is provided, but module is not in cabal file. NotCabalModule :: FilePath -> ExtensionsError -- | Conflicting SafeHaskellExtensions in one scope. SafeHaskellConflict :: NonEmpty SafeHaskellExtension -> ExtensionsError -- | Exception that gets thrown when working with .cabal files. data CabalException -- | The .cabal file is not found. CabalFileNotFound :: FilePath -> CabalException -- | Parsing errors in the .cabal file. CabalParseError :: Text -> CabalException -- | Conflicting SafeHaskellExtensions in one scope. CabalSafeExtensionsConflict :: NonEmpty SafeHaskellExtension -> CabalException -- | Error while parsing Haskell source file. data ModuleParseError -- | File parsing error. ParsecError :: ParseError -> ModuleParseError -- | Uknown extensions were used in the module. UnknownExtensions :: NonEmpty String -> ModuleParseError -- | Conflicting SafeHaskellExtensions in one scope. ModuleSafeHaskellConflict :: NonEmpty SafeHaskellExtension -> ModuleParseError -- | Module file not found. FileNotFound :: FilePath -> ModuleParseError -- | Empty Extensions with no specified SafeHaskellExtension. emptyExtensions :: Extensions -- | Empty ParsedExtensions with no specified -- SafeHaskellExtension. emptyParsedExtensions :: ParsedExtensions -- | Represents enabled/disabled extensions. data OnOffExtension On :: Extension -> OnOffExtension Off :: Extension -> OnOffExtension -- | Display OnOffExtension as GHC recognizes it. showOnOffExtension :: OnOffExtension -> Text -- | Parse OnOffExtension from a string that specifies extension. readOnOffExtension :: String -> Maybe OnOffExtension -- | Parse Extension from a string. Read instance for -- Extension doesn't always work since some extensions are named -- differently. readExtension :: String -> Maybe Extension -- | 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. mergeExtensions :: [OnOffExtension] -> Set OnOffExtension -- | Similar to mergeExtensions, but also merge -- SafeHaskellExtensions. In case of conflicting -- SafeHaskellExtension returns Left with the pair of -- conflicting extension constructors under SafeHaskellConflict -- error. mergeAnyExtensions :: ParsedExtensions -> ParsedExtensions -> ExtensionsResult -- | Default enabled extensions for Haskell2010 default2010Extensions :: [Extension] -- | Language extensions that are used by Safe Haskell to indicate safety -- of the code. -- -- To find out more, checkout the official documentation on -- SafeHaskell: -- --
-- {-# LANGUAGE XXX
-- , YYY ,
-- ZZZ
-- #-}
--
singleExtensionsP :: Parser [ParsedExtension]
-- | Parses all known and unknown OnOffExtensions or
-- SafeHaskellExtensions.
extensionP :: Parser ParsedExtension
-- | Parser for standard language pragma keywords: {-# LANGUAGE XXX
-- #-}
languagePragmaP :: Parser a -> Parser a
-- | Parser for GHC options pragma keywords: {-# OPTIONS_GHC YYY
-- #-}
optionsGhcP :: Parser [a]
-- | Parser for GHC pragmas with a given pragma word.
pragmaP :: Parser () -> Parser a -> Parser a
-- | Haskell comment parser. Supports both single-line comments:
--
-- -- -- I am a single comment -- ---- -- and multi-line comments: -- --
-- {- I
-- AM
-- MULTILINE
-- -}
--
--
commentP :: Parser [a]
-- | CPP syntax parser.
--
-- -- #if __GLASGOW_HASKELL__ < 810 -- -- Could be more Language pragmas that should be parsed -- #endif -- --cppP :: Parser [a] -- | Functions to extract extensions from the .cabal files. module Extensions.Cabal -- | Parse default extensions from a .cabal file under given -- FilePath. -- -- Throws: -- --