ormolu-0.3.0.1: A formatter for Haskell source code
Safe HaskellNone
LanguageHaskell2010

Ormolu

Description

A formatter for Haskell source code.

Synopsis

Documentation

ormolu Source #

Arguments

:: MonadIO m 
=> Config RegionIndices

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 require IO. There should be no visible side-effects though.
  • Takes file name just to use it in parse error messages.
  • Throws OrmoluException.

ormoluFile Source #

Arguments

:: MonadIO m 
=> Config RegionIndices

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

ormoluStdin Source #

Arguments

:: MonadIO m 
=> Config RegionIndices

Ormolu configuration

-> m Text

Resulting rendition

Read input from stdin and format it.

ormoluStdin cfg =
  liftIO (hGetContents stdin) >>= ormolu cfg "<stdin>"

data Config region Source #

Ormolu configuration.

Constructors

Config 

Fields

Instances

Instances details
Functor Config Source # 
Instance details

Defined in Ormolu.Config

Methods

fmap :: (a -> b) -> Config a -> Config b #

(<$) :: a -> Config b -> Config a #

Eq region => Eq (Config region) Source # 
Instance details

Defined in Ormolu.Config

Methods

(==) :: Config region -> Config region -> Bool #

(/=) :: Config region -> Config region -> Bool #

Show region => Show (Config region) Source # 
Instance details

Defined in Ormolu.Config

Methods

showsPrec :: Int -> Config region -> ShowS #

show :: Config region -> String #

showList :: [Config region] -> ShowS #

data ColorMode Source #

Whether to use colors and other features of ANSI terminals.

Constructors

Never 
Always 
Auto 

Instances

Instances details
Eq ColorMode Source # 
Instance details

Defined in Ormolu.Terminal

Show ColorMode Source # 
Instance details

Defined in Ormolu.Terminal

data RegionIndices Source #

Region selection as the combination of start and end line numbers.

Constructors

RegionIndices 

Fields

Instances

Instances details
Eq RegionIndices Source # 
Instance details

Defined in Ormolu.Config

Show RegionIndices Source # 
Instance details

Defined in Ormolu.Config

newtype DynOption Source #

A wrapper for dynamic options.

Constructors

DynOption 

Fields

Instances

Instances details
Eq DynOption Source # 
Instance details

Defined in Ormolu.Config

Ord DynOption Source # 
Instance details

Defined in Ormolu.Config

Show DynOption Source # 
Instance details

Defined in Ormolu.Config

data OrmoluException Source #

Ormolu exception representing all cases when Ormolu can fail.

Constructors

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 TextDiff

Formatted source code is not idempotent

OrmoluUnrecognizedOpts (NonEmpty String)

Some GHC options were not recognized

OrmoluCabalFileParsingFailed FilePath

Cabal file parsing failed

OrmoluMissingStdinInputFile

Missing input file path when using stdin input and accounting for .cabal files

withPrettyOrmoluExceptions Source #

Arguments

:: ColorMode

Color mode

-> IO ExitCode

Action that may throw an exception

-> IO ExitCode 

Inside this wrapper OrmoluException will be caught and displayed nicely.