-- 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.1.0.3 -- | 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: -- -- data SafeHaskellExtension Unsafe :: SafeHaskellExtension Trustworthy :: SafeHaskellExtension Safe :: SafeHaskellExtension instance GHC.Enum.Bounded Extensions.Types.SafeHaskellExtension instance GHC.Enum.Enum Extensions.Types.SafeHaskellExtension instance GHC.Classes.Ord Extensions.Types.SafeHaskellExtension instance GHC.Classes.Eq Extensions.Types.SafeHaskellExtension instance GHC.Read.Read Extensions.Types.SafeHaskellExtension instance GHC.Show.Show Extensions.Types.SafeHaskellExtension instance GHC.Classes.Eq Extensions.Types.ModuleParseError instance GHC.Show.Show Extensions.Types.ModuleParseError instance GHC.Exception.Type.Exception Extensions.Types.CabalException instance GHC.Classes.Eq Extensions.Types.CabalException instance GHC.Show.Show Extensions.Types.CabalException instance GHC.Classes.Eq Extensions.Types.ExtensionsError instance GHC.Show.Show Extensions.Types.ExtensionsError instance GHC.Classes.Ord Extensions.Types.OnOffExtension instance GHC.Classes.Eq Extensions.Types.OnOffExtension instance GHC.Show.Show Extensions.Types.OnOffExtension instance GHC.Classes.Eq Extensions.Types.ParsedExtensions instance GHC.Show.Show Extensions.Types.ParsedExtensions instance GHC.Classes.Eq Extensions.Types.CabalAndModuleExtensions instance GHC.Show.Show Extensions.Types.CabalAndModuleExtensions instance GHC.Classes.Eq Extensions.Types.Extensions instance GHC.Show.Show Extensions.Types.Extensions instance GHC.Read.Read GHC.LanguageExtensions.Type.Extension -- | Parser for Haskell Modules to get all Haskell Language Extensions -- used. module Extensions.Module -- | By the given file path, reads the file and returns -- ParsedExtensions, if parsing succeeds. parseFile :: FilePath -> IO (Either ModuleParseError ParsedExtensions) -- | By the given file source content, returns ParsedExtensions, if -- parsing succeeds. parseSource :: ByteString -> Either ModuleParseError ParsedExtensions -- | By the given file path and file source content, returns -- ParsedExtensions, if parsing succeeds. -- -- This function takes a path to a Haskell source file. The path is only -- used for error message. Pass empty string or use parseSource, -- if you don't have a path to a Haskell module. parseSourceWithPath :: FilePath -> ByteString -> Either ModuleParseError ParsedExtensions -- | The main parser of ParsedExtension. -- -- It parses language pragmas or comments until end of file or the first -- line with the functionimportmodule name. extensionsP :: Parser [ParsedExtension] -- | Single LANGUAGE pragma parser. -- --
--   {-# 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: -- -- parseCabalFileExtensions :: FilePath -> IO (Map FilePath ParsedExtensions) -- | Parse default extensions from a .cabal file content. This -- function takes a path to a .cabal file. The path is only used -- for error message. Pass empty string, if you don't have a path to -- .cabal file. -- -- Throws: -- -- parseCabalExtensions :: FilePath -> ByteString -> IO (Map FilePath ParsedExtensions) -- | Extract Haskell Language extensions from a Cabal package description. extractCabalExtensions :: GenericPackageDescription -> IO (Map FilePath ParsedExtensions) -- | Convert Extension to OnOffExtension or -- SafeHaskellExtension. cabalToGhcExtension :: Extension -> Maybe (Either SafeHaskellExtension OnOffExtension) -- | Convert KnownExtension to OnOffExtension. toGhcExtension :: KnownExtension -> Maybe Extension -- | Convert KnownExtension to SafeHaskellExtension. toSafeExtensions :: KnownExtension -> Maybe SafeHaskellExtension -- | Parse Haskell Language Extensions. module Extensions.Package -- | By given path to .cabal file, analyse extensions for each -- Haskell module and return the corresponding Map with -- ExtensionsResults. -- -- Throws: -- -- getPackageExtentions :: FilePath -> IO (Map FilePath ExtensionsResult) -- | By given path to .cabal file and Map of sources of all -- Haskell modules, analyse extensions for each Haskell module and return -- the corresponding Map with ExtensionsResults. getPackageExtentionsBySources :: FilePath -> Map FilePath ByteString -> IO (Map FilePath ExtensionsResult) -- | By given path to .cabal file and path to Haskell module of -- the corresponding package, analyse and return extensions for the given -- module separately from .cabal file and from the module itself. getModuleAndCabalExtentions :: FilePath -> FilePath -> IO (Either ExtensionsError CabalAndModuleExtensions) -- | By given path to .cabal file and path to Haskell module of -- the corresponding package, analyse and return summary set of -- extensions for the given module. getModuleExtentions :: FilePath -> FilePath -> IO ExtensionsResult -- | By given path to .cabal file and path to Haskell module of -- the corresponding package, analyse and return extensions extensions -- for the given module separately from .cabal file and from the module -- itself. getModuleAndCabalExtentionsBySource :: FilePath -> FilePath -> ByteString -> IO (Either ExtensionsError CabalAndModuleExtensions) -- | By given path to .cabal file and path to Haskell module of -- the corresponding package, analyse and return combined set of -- extensions for the given module. getModuleExtentionsBySource :: FilePath -> FilePath -> ByteString -> IO ExtensionsResult -- | Library to get Haskell Language Extensions from .cabal files, -- Haskell Modules, or get combined information from both sources -- preserving correct merge logic of extensions. module Extensions