fourmolu-0.18.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 Source #

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

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 Source #

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 Source #

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 Source # |
Instance details Defined in Ormolu.Config Methods fmap :: (a -> b) -> Config a -> Config b Source # (<$) :: a -> Config b -> Config a Source #
Generic (Config region) Source # |

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.18.0.0-5tTLGDubSihJcf8BAj2gCC" '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 Source #

to :: Rep (Config region) x -> Config region Source #

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

Instance details

Defined in Ormolu.Config

type Rep (Config region) = D1 ('MetaData "Config" "Ormolu.Config" "fourmolu-0.18.0.0-5tTLGDubSihJcf8BAj2gCC" '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 Source #

Whether to use colors and other features of ANSI terminals.

Constructors

Never |
Always |
Auto |

#### Instances

Instances details

Bounded ColorMode Source # |
Instance details Defined in Ormolu.Terminal Methods minBound :: ColorMode Source # maxBound :: ColorMode Source #
Enum ColorMode Source # |

Instance details

Defined in Ormolu.Terminal

Methods

succ :: ColorMode -> ColorMode Source #

pred :: ColorMode -> ColorMode Source #

toEnum :: Int -> ColorMode Source #

fromEnum :: ColorMode -> Int Source #

enumFrom :: ColorMode -> [ColorMode] Source #

enumFromThen :: ColorMode -> ColorMode -> [ColorMode] Source #

enumFromTo :: ColorMode -> ColorMode -> [ColorMode] Source #

enumFromThenTo :: ColorMode -> ColorMode -> ColorMode -> [ColorMode] Source #

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

data RegionIndices Source #

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

data SourceType Source #

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

defaultConfig :: Config RegionIndices Source #

Default ``Config` `RegionIndices``.

detectSourceType :: FilePath -> SourceType Source #

Detect `SourceType` based on the file extension.

refineConfig Source #

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 Source #

A wrapper for dynamic options.

Constructors

DynOption |

Fields

- unDynOption :: String

#### Instances

Instances details

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

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

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 Source # |
Instance details Defined in Ormolu.Config Methods mempty :: PrinterOptsPartial Source # mappend :: PrinterOptsPartial -> PrinterOptsPartial -> PrinterOptsPartial Source # mconcat :: [PrinterOptsPartial] -> PrinterOptsPartial Source #
Semigroup PrinterOptsPartial Source # |
Instance details Defined in Ormolu.Config Methods (<>) :: PrinterOptsPartial -> PrinterOptsPartial -> PrinterOptsPartial Source # sconcat :: NonEmpty PrinterOptsPartial -> PrinterOptsPartial Source # stimes :: Integral b => b -> PrinterOptsPartial -> PrinterOptsPartial Source #
Show PrinterOptsPartial Source # |
Instance details Defined in Ormolu.Config Methods showsPrec :: Int -> PrinterOptsPartial -> ShowS Source # show :: PrinterOptsPartial -> String Source # showList :: [PrinterOptsPartial] -> ShowS Source #
Show PrinterOptsTotal Source # |
Instance details Defined in Ormolu.Config Methods showsPrec :: Int -> PrinterOptsTotal -> ShowS Source # show :: PrinterOptsTotal -> String Source # showList :: [PrinterOptsTotal] -> ShowS Source #
Eq PrinterOptsPartial Source # |
Instance details Defined in Ormolu.Config Methods (==) :: PrinterOptsPartial -> PrinterOptsPartial -> Bool Source # (/=) :: PrinterOptsPartial -> PrinterOptsPartial -> Bool Source #
Eq PrinterOptsTotal Source # |
Instance details Defined in Ormolu.Config Methods (==) :: PrinterOptsTotal -> PrinterOptsTotal -> Bool Source # (/=) :: PrinterOptsTotal -> PrinterOptsTotal -> Bool Source #
Generic (PrinterOpts f) Source # |

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 Source #

to :: Rep (PrinterOpts f) x -> PrinterOpts f Source #

type Rep (PrinterOpts f) Source # |
Instance details Defined in Ormolu.Config.Gen type Rep (PrinterOpts f)

type PrinterOptsPartial = PrinterOpts Maybe Source #

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 Source #

A version of `PrinterOpts` without empty fields.

defaultPrinterOpts :: PrinterOpts Identity Source #

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

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 Source #

Constructors

ConfigNotFound |

Fields

- searchDirs :: [FilePath]

#### Instances

Instances details

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

configFileName :: FilePath Source #

Expected file name for YAML config.

resolvePrinterOpts :: [PrinterOptsPartial] -> PrinterOptsTotal Source #

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

# Cabal info

data CabalSearchResult Source #

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

data CabalInfo Source #

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

getCabalInfoForSourceFile Source #

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 Source #

Map from the operator name to its `FixityInfo`.

#### Instances

Instances details

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

defaultFixityOverrides :: FixityOverrides Source #

Fixity overrides to use by default.

data ModuleReexports Source #

Module re-exports

#### Instances

Instances details

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

defaultModuleReexports :: ModuleReexports Source #

Module re-exports to apply by default.

# Working with exceptions

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

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.