Safe Haskell | None |
---|---|
Language | Haskell2010 |
A formatter for Haskell source code.
Synopsis
- ormolu :: MonadIO m => Config -> FilePath -> String -> m Text
- ormoluFile :: MonadIO m => Config -> FilePath -> m Text
- ormoluStdin :: MonadIO m => Config -> m Text
- data Config = Config {
- cfgDynOptions :: ![DynOption]
- cfgUnsafe :: !Bool
- cfgDebug :: !Bool
- cfgTolerateCpp :: !Bool
- cfgCheckIdempotency :: !Bool
- defaultConfig :: Config
- newtype DynOption = DynOption {}
- data OrmoluException
- withPrettyOrmoluExceptions :: IO a -> IO a
Documentation
:: MonadIO m | |
=> Config | Ormolu configuration |
-> FilePath | Location of source file |
-> String | Input to format |
-> m Text |
Format a String
, return formatted version as Text
.
The function
- Takes
String
because that's what GHC parser accepts. - Needs
IO
because some functions from GHC that are necessary to setup parsing context requireIO
. There should be no visible side-effects though. - Takes file name just to use it in parse error messages.
- Throws
OrmoluException
.
:: MonadIO m | |
=> Config | Ormolu configuration |
-> FilePath | Location of source file |
-> m Text | Resulting rendition |
Load a file and format it. The file stays intact and the rendered
version is returned as Text
.
ormoluFile cfg path = liftIO (readFile path) >>= ormolu cfg path
Read input from stdin and format it.
ormoluStdin cfg = liftIO (hGetContents stdin) >>= ormolu cfg "<stdin>"
Ormolu configuration.
Config | |
|
defaultConfig :: Config Source #
Default Config
.
A wrapper for dynamic options.
data OrmoluException Source #
Ormolu exception representing all cases when Ormolu can fail.
OrmoluCppEnabled FilePath | Ormolu does not work with source files that use CPP |
OrmoluParsingFailed SrcSpan String | Parsing of original source code failed |
OrmoluOutputParsingFailed SrcSpan String | Parsing of formatted source code failed |
OrmoluASTDiffers FilePath [SrcSpan] | Original and resulting ASTs differ |
OrmoluNonIdempotentOutput RealSrcLoc Text Text | Formatted source code is not idempotent |
Instances
Eq OrmoluException Source # | |
Defined in Ormolu.Exception (==) :: OrmoluException -> OrmoluException -> Bool # (/=) :: OrmoluException -> OrmoluException -> Bool # | |
Show OrmoluException Source # | |
Defined in Ormolu.Exception showsPrec :: Int -> OrmoluException -> ShowS # show :: OrmoluException -> String # showList :: [OrmoluException] -> ShowS # | |
Exception OrmoluException Source # | |
Defined in Ormolu.Exception |
withPrettyOrmoluExceptions Source #
Inside this wrapper OrmoluException
will be caught and displayed
nicely using displayException
.