Copyright | (c) 2020-2022 Kowainik |
---|---|
License | MPL-2.0 |
Maintainer | Kowainik <[email protected]> |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Extensions.Module
Contents
Description
Parser for Haskell Modules to get all Haskell Language Extensions used.
Synopsis
- parseFile :: FilePath -> IO (Either ModuleParseError ParsedExtensions)
- parseSource :: ByteString -> Either ModuleParseError ParsedExtensions
- parseSourceWithPath :: FilePath -> ByteString -> Either ModuleParseError ParsedExtensions
- extensionsP :: Parser [ParsedExtension]
- singleExtensionsP :: Parser [ParsedExtension]
- extensionP :: Parser ParsedExtension
- languagePragmaP :: Parser a -> Parser a
- optionsGhcP :: Parser [a]
- pragmaP :: Parser () -> Parser a -> Parser a
- commentP :: Parser [a]
- cppP :: Parser [a]
Documentation
parseFile :: FilePath -> IO (Either ModuleParseError ParsedExtensions) Source #
By the given file path, reads the file and returns ParsedExtensions
, if
parsing succeeds.
parseSource :: ByteString -> Either ModuleParseError ParsedExtensions Source #
By the given file source content, returns ParsedExtensions
, if parsing
succeeds.
parseSourceWithPath :: FilePath -> ByteString -> Either ModuleParseError ParsedExtensions Source #
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.
Internal Parsers
extensionsP :: Parser [ParsedExtension] Source #
The main parser of ParsedExtension
.
It parses language pragmas or comments until end of file or the first line with the functionimportmodule name.
singleExtensionsP :: Parser [ParsedExtension] Source #
Single LANGUAGE pragma parser.
{-# LANGUAGE XXX , YYY , ZZZ #-}
extensionP :: Parser ParsedExtension Source #
Parses all known and unknown OnOffExtension
s or SafeHaskellExtension
s.
languagePragmaP :: Parser a -> Parser a Source #
Parser for standard language pragma keywords: {-# LANGUAGE XXX #-}
optionsGhcP :: Parser [a] Source #
Parser for GHC options pragma keywords: {-# OPTIONS_GHC YYY #-}
pragmaP :: Parser () -> Parser a -> Parser a Source #
Parser for GHC pragmas with a given pragma word.