Ormolu

fourmolu-0.17.0.0: A formatter for Haskell source code

Safe Haskell | None
Language | GHC2021

Ormolu

Contents

- Top-level formatting functions
- Configuration
- Cabal info
- Fixity overrides and module re-exports
- Working with exceptions

Description

A formatter for Haskell source code. This module exposes the official stable API, other modules may be not as reliable.

Synopsis

- ormolu :: MonadIO m => Config RegionIndices -> FilePath -> Text -> m Text
- ormoluFile :: MonadIO m => Config RegionIndices -> FilePath -> m Text
- ormoluStdin :: MonadIO m => Config RegionIndices -> m Text
- data Config region = Config {
  - cfgDynOptions :: ![DynOption]
  - cfgFixityOverrides :: !FixityOverrides
  - cfgModuleReexports :: !ModuleReexports
  - cfgDependencies :: !(Set PackageName)
  - cfgUnsafe :: !Bool
  - cfgDebug :: !Bool
  - cfgCheckIdempotence :: !Bool
  - cfgSourceType :: !SourceType
  - cfgColorMode :: !ColorMode
  - cfgRegion :: !region
  - cfgPrinterOpts :: !PrinterOptsTotal
  - cfgLocalModules :: !(Set ModuleName)
  }
- data ColorMode
  - = Never
  - | Always
  - | Auto
- data RegionIndices = RegionIndices {
  - regionStartLine :: !(Maybe Int)
  - regionEndLine :: !(Maybe Int)
  }
- data SourceType
  - = ModuleSource
  - | SignatureSource
- defaultConfig :: Config RegionIndices
- detectSourceType :: FilePath -> SourceType
- refineConfig :: SourceType -> Maybe CabalInfo -> Maybe FixityOverrides -> Maybe ModuleReexports -> Config region -> Config region
- newtype DynOption = DynOption {
  - unDynOption :: String
  }
- data PrinterOpts (f :: Type -> Type) = PrinterOpts {
  - poIndentation :: f Int
  - poColumnLimit :: f ColumnLimit
  - poFunctionArrows :: f FunctionArrowsStyle
  - poCommaStyle :: f CommaStyle
  - poImportExportStyle :: f ImportExportStyle
  - poImportGrouping :: f ImportGrouping
  - poIndentWheres :: f Bool
  - poRecordBraceSpace :: f Bool
  - poNewlinesBetweenDecls :: f Int
  - poHaddockStyle :: f HaddockPrintStyle
  - poHaddockStyleModule :: f HaddockPrintStyleModule
  - poLetStyle :: f LetStyle
  - poInStyle :: f InStyle
  - poSingleConstraintParens :: f SingleConstraintParens
  - poSingleDerivingParens :: f SingleDerivingParens
  - poSortConstraints :: f Bool
  - poSortDerivedClasses :: f Bool
  - poSortDerivingClauses :: f Bool
  - poTrailingSectionOperators :: f Bool
  - poUnicode :: f Unicode
  - poRespectful :: f Bool
  }
- type PrinterOptsPartial = PrinterOpts Maybe
- type PrinterOptsTotal = PrinterOpts Identity
- defaultPrinterOpts :: PrinterOpts Identity
- findConfigFile :: FilePath -> IO (Either ConfigNotFound FilePath)
- data ConfigNotFound = ConfigNotFound {
  - searchDirs :: [FilePath]
  }
- configFileName :: FilePath
- resolvePrinterOpts :: [PrinterOptsPartial] -> PrinterOptsTotal
- data CabalSearchResult
  - = CabalNotFound
  - | CabalDidNotMention CabalInfo
  - | CabalFound CabalInfo
- data CabalInfo = CabalInfo {
  - ciPackageName :: !PackageName
  - ciDynOpts :: ![DynOption]
  - ciDependencies :: !(Set PackageName)
  - ciCabalFilePath :: !FilePath
  - ciModules :: ![ModuleName]
  }
- getCabalInfoForSourceFile :: MonadIO m => FilePath -> m CabalSearchResult
- data FixityOverrides
- defaultFixityOverrides :: FixityOverrides
- data ModuleReexports
- defaultModuleReexports :: ModuleReexports
- data OrmoluException
  - = OrmoluParsingFailed SrcSpan String
  - | OrmoluOutputParsingFailed SrcSpan String
  - | OrmoluASTDiffers TextDiff [RealSrcSpan]
  - | OrmoluNonIdempotentOutput TextDiff
  - | OrmoluUnrecognizedOpts (NonEmpty String)
  - | OrmoluCabalFileParsingFailed FilePath (NonEmpty PError)
  - | OrmoluMissingStdinInputFile
  - | OrmoluFixityOverridesParseError (ParseErrorBundle Text Void)
- withPrettyOrmoluExceptions :: ColorMode -> IO ExitCode -> IO ExitCode

# Top-level formatting functions

ormolu #

Arguments

:: MonadIO m |
=> Config RegionIndices | Ormolu configuration
-> FilePath | Location of source file
-> Text | Input to format
-> m Text |

Format a `Text`.

The function

- 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`.

NOTE: The caller is responsible for setting the appropriate value in the `cfgSourceType` field. Autodetection of source type won't happen here, see `detectSourceType`.

ormoluFile #

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`.

NOTE: The caller is responsible for setting the appropriate value in the `cfgSourceType` field. Autodetection of source type won't happen here, see `detectSourceType`.

ormoluStdin #

Arguments

:: MonadIO m |
=> Config RegionIndices | Ormolu configuration
-> m Text | Resulting rendition

Read input from stdin and format it.

NOTE: The caller is responsible for setting the appropriate value in the `cfgSourceType` field. Autodetection of source type won't happen here, see `detectSourceType`.

# Configuration

data Config region #

Ormolu configuration.

Constructors

Config |
Fields cfgDynOptions :: ![DynOption] Dynamic options to pass to GHC parser cfgFixityOverrides :: !FixityOverrides Fixity overrides cfgModuleReexports :: !ModuleReexports Module reexports to take into account when doing fixity resolution cfgDependencies :: !(Set PackageName) Known dependencies, if any cfgUnsafe :: !Bool Do formatting faster but without automatic detection of defects cfgDebug :: !Bool Output information useful for debugging cfgCheckIdempotence :: !Bool Checks if re-formatting the result is idempotent cfgSourceType :: !SourceType How to parse the input (regular haskell module or Backpack file) cfgColorMode :: !ColorMode Whether to use colors and other features of ANSI terminals cfgRegion :: !region Region selection cfgPrinterOpts :: !PrinterOptsTotal cfgLocalModules :: !(Set ModuleName)

#### Instances

Instances details

Functor Config # |
Instance details Defined in Ormolu.Config Methods fmap :: (a -> b) -> Config a -> Config b # (<$) :: a -> Config b -> Config a #
Generic (Config region) # |
Instance details Defined in Ormolu.Config Associated Types
type Rep (Config region) |
Instance details Defined in Ormolu.Config type Rep (Config region) = D1 ('MetaData "Config" "Ormolu.Config" "fourmolu-0.17.0.0-3YMEcBLevRzEJ6gJbl7GNk" 'False) (C1 ('MetaCons "Config" 'PrefixI 'True) (((S1 ('MetaSel ('Just "cfgDynOptions") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 [DynOption]) :*: (S1 ('MetaSel ('Just "cfgFixityOverrides") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 FixityOverrides) :*: S1 ('MetaSel ('Just "cfgModuleReexports") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 ModuleReexports))) :*: (S1 ('MetaSel ('Just "cfgDependencies") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Set PackageName)) :*: (S1 ('MetaSel ('Just "cfgUnsafe") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Bool) :*: S1 ('MetaSel ('Just "cfgDebug") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Bool)))) :*: ((S1 ('MetaSel ('Just "cfgCheckIdempotence") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Bool) :*: (S1 ('MetaSel ('Just "cfgSourceType") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 SourceType) :*: S1 ('MetaSel ('Just "cfgColorMode") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 ColorMode))) :*: (S1 ('MetaSel ('Just "cfgRegion") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 region) :*: (S1 ('MetaSel ('Just "cfgPrinterOpts") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 PrinterOptsTotal) :*: S1 ('MetaSel ('Just "cfgLocalModules") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Set ModuleName)))))))
Methods from :: Config region -> Rep (Config region) x # to :: Rep (Config region) x -> Config region #
Show region => Show (Config region) # |
Instance details Defined in Ormolu.Config Methods showsPrec :: Int -> Config region -> ShowS # show :: Config region -> String # showList :: [Config region] -> ShowS #
Eq region => Eq (Config region) # |
Instance details Defined in Ormolu.Config Methods (==) :: Config region -> Config region -> Bool # (/=) :: Config region -> Config region -> Bool #
type Rep (Config region) # |
Instance details Defined in Ormolu.Config type Rep (Config region) = D1 ('MetaData "Config" "Ormolu.Config" "fourmolu-0.17.0.0-3YMEcBLevRzEJ6gJbl7GNk" 'False) (C1 ('MetaCons "Config" 'PrefixI 'True) (((S1 ('MetaSel ('Just "cfgDynOptions") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 [DynOption]) :*: (S1 ('MetaSel ('Just "cfgFixityOverrides") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 FixityOverrides) :*: S1 ('MetaSel ('Just "cfgModuleReexports") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 ModuleReexports))) :*: (S1 ('MetaSel ('Just "cfgDependencies") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Set PackageName)) :*: (S1 ('MetaSel ('Just "cfgUnsafe") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Bool) :*: S1 ('MetaSel ('Just "cfgDebug") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Bool)))) :*: ((S1 ('MetaSel ('Just "cfgCheckIdempotence") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Bool) :*: (S1 ('MetaSel ('Just "cfgSourceType") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 SourceType) :*: S1 ('MetaSel ('Just "cfgColorMode") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 ColorMode))) :*: (S1 ('MetaSel ('Just "cfgRegion") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 region) :*: (S1 ('MetaSel ('Just "cfgPrinterOpts") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 PrinterOptsTotal) :*: S1 ('MetaSel ('Just "cfgLocalModules") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Set ModuleName)))))))

data ColorMode #

Whether to use colors and other features of ANSI terminals.

Constructors

Never |
Always |
Auto |

#### Instances

Instances details

Bounded ColorMode # |
Instance details Defined in Ormolu.Terminal Methods minBound :: ColorMode # maxBound :: ColorMode #
Enum ColorMode # |
Instance details Defined in Ormolu.Terminal Methods succ :: ColorMode -> ColorMode # pred :: ColorMode -> ColorMode # toEnum :: Int -> ColorMode # fromEnum :: ColorMode -> Int # enumFrom :: ColorMode -> [ColorMode] # enumFromThen :: ColorMode -> ColorMode -> [ColorMode] # enumFromTo :: ColorMode -> ColorMode -> [ColorMode] # enumFromThenTo :: ColorMode -> ColorMode -> ColorMode -> [ColorMode] #
Show ColorMode # |
Instance details Defined in Ormolu.Terminal Methods showsPrec :: Int -> ColorMode -> ShowS # show :: ColorMode -> String # showList :: [ColorMode] -> ShowS #
Eq ColorMode # |
Instance details Defined in Ormolu.Terminal Methods (==) :: ColorMode -> ColorMode -> Bool # (/=) :: ColorMode -> ColorMode -> Bool #

data RegionIndices #

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

Constructors

RegionIndices |
Fields regionStartLine :: !(Maybe Int) Start line of the region to format regionEndLine :: !(Maybe Int) End line of the region to format

#### Instances

Instances details

Show RegionIndices # |
Instance details Defined in Ormolu.Config Methods showsPrec :: Int -> RegionIndices -> ShowS # show :: RegionIndices -> String # showList :: [RegionIndices] -> ShowS #
Eq RegionIndices # |
Instance details Defined in Ormolu.Config Methods (==) :: RegionIndices -> RegionIndices -> Bool # (/=) :: RegionIndices -> RegionIndices -> Bool #

data SourceType #

Type of sources that can be formatted by Ormolu.

Constructors

ModuleSource | Consider the input as a regular Haskell module
SignatureSource | Consider the input as a Backpack module signature

#### Instances

Instances details

Show SourceType # |
Instance details Defined in Ormolu.Config Methods showsPrec :: Int -> SourceType -> ShowS # show :: SourceType -> String # showList :: [SourceType] -> ShowS #
Eq SourceType # |
Instance details Defined in Ormolu.Config Methods (==) :: SourceType -> SourceType -> Bool # (/=) :: SourceType -> SourceType -> Bool #

defaultConfig :: Config RegionIndices #

Default ``Config` `RegionIndices``.

detectSourceType :: FilePath -> SourceType #

Detect `SourceType` based on the file extension.

refineConfig #

Arguments

:: SourceType | Source type to use
-> Maybe CabalInfo | Cabal info for the file, if available
-> Maybe FixityOverrides | Fixity overrides, if available
-> Maybe ModuleReexports | Module re-exports, if available
-> Config region | `Config` to refine
-> Config region | Refined `Config`

Refine a `Config` by incorporating given `SourceType`, `CabalInfo`, and fixity overrides `FixityMap`. You can use `detectSourceType` to deduce `SourceType` based on the file extension, `getCabalInfoForSourceFile` to obtain `CabalInfo` and `getFixityOverridesForSourceFile` for `FixityMap`.

Since: 0.5.3.0

newtype DynOption #

A wrapper for dynamic options.

Constructors

DynOption |
Fields unDynOption :: String

#### Instances

Instances details

Show DynOption # |
Instance details Defined in Ormolu.Config Methods showsPrec :: Int -> DynOption -> ShowS # show :: DynOption -> String # showList :: [DynOption] -> ShowS #
Eq DynOption # |
Instance details Defined in Ormolu.Config Methods (==) :: DynOption -> DynOption -> Bool # (/=) :: DynOption -> DynOption -> Bool #
Ord DynOption # |
Instance details Defined in Ormolu.Config Methods compare :: DynOption -> DynOption -> Ordering # (<) :: DynOption -> DynOption -> Bool # (<=) :: DynOption -> DynOption -> Bool # (>) :: DynOption -> DynOption -> Bool # (>=) :: DynOption -> DynOption -> Bool # max :: DynOption -> DynOption -> DynOption # min :: DynOption -> DynOption -> DynOption #

data PrinterOpts (f :: Type -> Type) #

Options controlling formatting output.

Constructors

PrinterOpts |
Fields poIndentation :: f Int Number of spaces per indentation step poColumnLimit :: f ColumnLimit Max line length for automatic line breaking poFunctionArrows :: f FunctionArrowsStyle Styling of arrows in type signatures poCommaStyle :: f CommaStyle How to place commas in multi-line lists, records, etc. poImportExportStyle :: f ImportExportStyle Styling of import/export lists poImportGrouping :: f ImportGrouping Rules for grouping import declarations poIndentWheres :: f Bool Whether to full-indent or half-indent 'where' bindings past the preceding body poRecordBraceSpace :: f Bool Whether to leave a space before an opening record brace poNewlinesBetweenDecls :: f Int Number of spaces between top-level declarations poHaddockStyle :: f HaddockPrintStyle How to print Haddock comments poHaddockStyleModule :: f HaddockPrintStyleModule How to print module docstring poLetStyle :: f LetStyle Styling of let blocks poInStyle :: f InStyle How to align the 'in' keyword with respect to the 'let' keyword poSingleConstraintParens :: f SingleConstraintParens Whether to put parentheses around a single constraint poSingleDerivingParens :: f SingleDerivingParens Whether to put parentheses around a single deriving class poSortConstraints :: f Bool Whether to sort constraints poSortDerivedClasses :: f Bool Whether to sort derived classes poSortDerivingClauses :: f Bool Whether to sort deriving clauses poTrailingSectionOperators :: f Bool Whether to place section operators (those that are infixr 0, such as $) in trailing position, continuing the expression indented below poUnicode :: f Unicode Output Unicode syntax poRespectful :: f Bool Give the programmer more choice on where to insert blank lines

#### Instances

Instances details

FromJSON PrinterOptsPartial # |
Instance details Defined in Ormolu.Config Methods parseJSON :: Value -> Parser PrinterOptsPartial # parseJSONList :: Value -> Parser [PrinterOptsPartial] # omittedField :: Maybe PrinterOptsPartial #
Monoid PrinterOptsPartial # |
Instance details Defined in Ormolu.Config Methods mempty :: PrinterOptsPartial # mappend :: PrinterOptsPartial -> PrinterOptsPartial -> PrinterOptsPartial # mconcat :: [PrinterOptsPartial] -> PrinterOptsPartial #
Semigroup PrinterOptsPartial # |
Instance details Defined in Ormolu.Config Methods (<>) :: PrinterOptsPartial -> PrinterOptsPartial -> PrinterOptsPartial # sconcat :: NonEmpty PrinterOptsPartial -> PrinterOptsPartial # stimes :: Integral b => b -> PrinterOptsPartial -> PrinterOptsPartial #
Show PrinterOptsPartial # |
Instance details Defined in Ormolu.Config Methods showsPrec :: Int -> PrinterOptsPartial -> ShowS # show :: PrinterOptsPartial -> String # showList :: [PrinterOptsPartial] -> ShowS #
Show PrinterOptsTotal # |
Instance details Defined in Ormolu.Config Methods showsPrec :: Int -> PrinterOptsTotal -> ShowS # show :: PrinterOptsTotal -> String # showList :: [PrinterOptsTotal] -> ShowS #
Eq PrinterOptsPartial # |
Instance details Defined in Ormolu.Config Methods (==) :: PrinterOptsPartial -> PrinterOptsPartial -> Bool # (/=) :: PrinterOptsPartial -> PrinterOptsPartial -> Bool #
Eq PrinterOptsTotal # |
Instance details Defined in Ormolu.Config Methods (==) :: PrinterOptsTotal -> PrinterOptsTotal -> Bool # (/=) :: PrinterOptsTotal -> PrinterOptsTotal -> Bool #
Generic (PrinterOpts f) # |
Instance details Defined in Ormolu.Config.Gen Associated Types
type Rep (PrinterOpts f) |
Instance details Defined in Ormolu.Config.Gen type Rep (PrinterOpts f)
Methods from :: PrinterOpts f -> Rep (PrinterOpts f) x # to :: Rep (PrinterOpts f) x -> PrinterOpts f #
type Rep (PrinterOpts f) # |
Instance details Defined in Ormolu.Config.Gen type Rep (PrinterOpts f)

type PrinterOptsPartial = PrinterOpts Maybe #

A version of `PrinterOpts` where any field can be empty. This corresponds to the information in a config file or in CLI options.

type PrinterOptsTotal = PrinterOpts Identity #

A version of `PrinterOpts` without empty fields.

defaultPrinterOpts :: PrinterOpts Identity #

findConfigFile :: FilePath -> IO (Either ConfigNotFound FilePath) #

Find a fourmolu configuration file.

Looks for a file named fourmolu.yaml, first in the given path and its parents, and then in the XDG config directory.

data ConfigNotFound #

Constructors

ConfigNotFound |
Fields searchDirs :: [FilePath]

#### Instances

Instances details

Show ConfigNotFound # |
Instance details Defined in Ormolu.Config Methods showsPrec :: Int -> ConfigNotFound -> ShowS # show :: ConfigNotFound -> String # showList :: [ConfigNotFound] -> ShowS #

configFileName :: FilePath #

Expected file name for YAML config.

resolvePrinterOpts :: [PrinterOptsPartial] -> PrinterOptsTotal #

Apply the given configuration in order (later options override earlier).

# Cabal info

data CabalSearchResult #

The result of searching for a `.cabal` file.

Since: 0.5.3.0

Constructors

CabalNotFound | Cabal file could not be found
CabalDidNotMention CabalInfo | Cabal file was found, but it did not mention the source file in question
CabalFound CabalInfo | Cabal file was found and it mentions the source file in question

#### Instances

Instances details

Show CabalSearchResult # |
Instance details Defined in Ormolu.Utils.Cabal Methods showsPrec :: Int -> CabalSearchResult -> ShowS # show :: CabalSearchResult -> String # showList :: [CabalSearchResult] -> ShowS #
Eq CabalSearchResult # |
Instance details Defined in Ormolu.Utils.Cabal Methods (==) :: CabalSearchResult -> CabalSearchResult -> Bool # (/=) :: CabalSearchResult -> CabalSearchResult -> Bool #

data CabalInfo #

Cabal information of interest to Ormolu.

Constructors

CabalInfo |
Fields ciPackageName :: !PackageName Package name ciDynOpts :: ![DynOption] Extension and language settings in the form of `DynOption`s ciDependencies :: !(Set PackageName) Direct dependencies ciCabalFilePath :: !FilePath Absolute path to the cabal file ciModules :: ![ModuleName] Local modules

#### Instances

Instances details

Show CabalInfo # |
Instance details Defined in Ormolu.Utils.Cabal Methods showsPrec :: Int -> CabalInfo -> ShowS # show :: CabalInfo -> String # showList :: [CabalInfo] -> ShowS #
Eq CabalInfo # |
Instance details Defined in Ormolu.Utils.Cabal Methods (==) :: CabalInfo -> CabalInfo -> Bool # (/=) :: CabalInfo -> CabalInfo -> Bool #

getCabalInfoForSourceFile #

Arguments

:: MonadIO m |
=> FilePath | Haskell source file
-> m CabalSearchResult | Extracted cabal info, if any

Locate a `.cabal` file corresponding to the given Haskell source file and obtain `CabalInfo` from it.

# Fixity overrides and module re-exports

data FixityOverrides #

Map from the operator name to its `FixityInfo`.

#### Instances

Instances details

Show FixityOverrides # |
Instance details Defined in Ormolu.Fixity.Internal Methods showsPrec :: Int -> FixityOverrides -> ShowS # show :: FixityOverrides -> String # showList :: [FixityOverrides] -> ShowS #
Eq FixityOverrides # |
Instance details Defined in Ormolu.Fixity.Internal Methods (==) :: FixityOverrides -> FixityOverrides -> Bool # (/=) :: FixityOverrides -> FixityOverrides -> Bool #

defaultFixityOverrides :: FixityOverrides #

Fixity overrides to use by default.

data ModuleReexports #

Module re-exports

#### Instances

Instances details

Show ModuleReexports # |
Instance details Defined in Ormolu.Fixity.Internal Methods showsPrec :: Int -> ModuleReexports -> ShowS # show :: ModuleReexports -> String # showList :: [ModuleReexports] -> ShowS #
Eq ModuleReexports # |
Instance details Defined in Ormolu.Fixity.Internal Methods (==) :: ModuleReexports -> ModuleReexports -> Bool # (/=) :: ModuleReexports -> ModuleReexports -> Bool #

defaultModuleReexports :: ModuleReexports #

Module re-exports to apply by default.

# Working with exceptions

data OrmoluException #

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 TextDiff [RealSrcSpan] | Original and resulting ASTs differ
OrmoluNonIdempotentOutput TextDiff | Formatted source code is not idempotent
OrmoluUnrecognizedOpts (NonEmpty String) | Some GHC options were not recognized
OrmoluCabalFileParsingFailed FilePath (NonEmpty PError) | Cabal file parsing failed
OrmoluMissingStdinInputFile | Missing input file path when using stdin input and accounting for .cabal files
OrmoluFixityOverridesParseError (ParseErrorBundle Text Void) | A parse error in a fixity overrides file

#### Instances

Instances details

Exception OrmoluException # |
Instance details Defined in Ormolu.Exception Methods toException :: OrmoluException -> SomeException # fromException :: SomeException -> Maybe OrmoluException # displayException :: OrmoluException -> String # backtraceDesired :: OrmoluException -> Bool #
Show OrmoluException # |
Instance details Defined in Ormolu.Exception Methods showsPrec :: Int -> OrmoluException -> ShowS # show :: OrmoluException -> String # showList :: [OrmoluException] -> ShowS #

withPrettyOrmoluExceptions #

Arguments

:: ColorMode | Color mode
-> IO ExitCode | Action that may throw an exception
-> IO ExitCode |

Inside this wrapper `OrmoluException` will be caught and displayed nicely.