| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
StylishCabal
Description
Cabal file formatter.
- pretty :: GenericPackageDescription -> Doc
- prettyOpts :: RenderOptions -> GenericPackageDescription -> Doc
- data RenderOptions = RenderOptions {}
- render :: Int -> Doc -> SimpleDoc
- parsePackageDescription :: String -> Result GenericPackageDescription
- readPackageDescription :: Maybe FilePath -> String -> IO GenericPackageDescription
- data Result a
- result :: (Maybe LineNo -> String -> b) -> ([PWarning] -> b) -> (a -> b) -> Result a -> b
- printWarnings :: Maybe FilePath -> [PWarning] -> IO a
- displayError :: Maybe FilePath -> Maybe LineNo -> String -> IO a
- class Default a where
- data Doc :: *
- renderDescription :: DocH () Identifier -> Doc
- plain :: Doc -> Doc
- displayIO :: Handle -> SimpleDoc -> IO ()
- displayS :: SimpleDoc -> ShowS
Formatting Cabal files
pretty :: GenericPackageDescription -> Doc Source #
pretty pkg produces a colorized, formatted textual representation of
a given GenericPackageDescription,
using Default options.
To remove syntax highlighting, you can use plain.
prettyOpts :: RenderOptions -> GenericPackageDescription -> Doc Source #
pretty with specified options.
data RenderOptions Source #
Constructors
| RenderOptions | |
Fields
| |
Instances
Parsing utilities
parsePackageDescription :: String -> Result GenericPackageDescription Source #
This function is similar to Cabal's own file parser, except that it treats warnings as a separate failure case. There are a wide range of different behaviors accepted by different Cabal parser versions. Parse warnings generally indicate a version-related inconsistency, so we play it safe here.
readPackageDescription :: Maybe FilePath -> String -> IO GenericPackageDescription Source #
Shorthand to combine parsePackageDescription and one of printWarnings or
displayError. The given FilePath is used only for error messages and
is not read from.
Like Cabal's ParseResult, but treats warnings as a separate failure
case.
Constructors
| Error (Maybe LineNo) String | Parse error on the given line. |
| Warn [PWarning] | Warnings emitted during parse. |
| Success a | The input is a compliant package description. |
Instances
| Functor Result Source # | |
| Eq1 Result Source # | |
| Show1 Result Source # | |
| Eq a => Eq (Result a) Source # | |
| Data a => Data (Result a) Source # | |
| Show a => Show (Result a) Source # | |
| Generic (Result a) Source # | |
| NFData a => NFData (Result a) Source # | |
| Generic1 * Result Source # | |
| type Rep (Result a) Source # | |
| type Rep1 * Result Source # | |
result :: (Maybe LineNo -> String -> b) -> ([PWarning] -> b) -> (a -> b) -> Result a -> b Source #
Case analysis for Result.
printWarnings :: Maybe FilePath -> [PWarning] -> IO a Source #
Print some warnings to stderr and exit.
displayError :: Maybe FilePath -> Maybe LineNo -> String -> IO a Source #
Print a parse error to stderr, annotated with filepath and line
number (if available), then exit.
Reexports
A class for types with a default value.
Instances
The abstract data type Doc represents pretty documents.
More specifically, a value of type Doc represents a non-empty set of
possible renderings of a document. The rendering functions select one of
these possibilities.
Doc is an instance of the Show class. (show doc) pretty
prints document doc with a page width of 80 characters and a
ribbon width of 32 characters.
show (text "hello" <$> text "world")
Which would return the string "hello\nworld", i.e.
hello world
renderDescription :: DocH () Identifier -> Doc Source #
displayIO :: Handle -> SimpleDoc -> IO () #
(displayIO handle simpleDoc) writes simpleDoc to the file
handle handle. This function is used for example by hPutDoc:
hPutDoc handle doc = displayIO handle (renderPretty 0.4 80 doc)
Any ANSI colorisation in simpleDoc will be output.
displayS :: SimpleDoc -> ShowS #
(displayS simpleDoc) takes the output simpleDoc from a
rendering function and transforms it to a ShowS type (for use in
the Show class).
showWidth :: Int -> Doc -> String showWidth w x = displayS (renderPretty 0.4 w x) ""
ANSI color information will be discarded by this function unless you are running on a Unix-like operating system. This is due to a technical limitation in Windows ANSI support.