fourmolu-0.17.0.0: A formatter for Haskell source code

Safe Haskell | None
Language | GHC2021

Ormolu.Fixity.Internal

Synopsis

- data OpName
- pattern OpName :: Text -> OpName
- unOpName :: OpName -> Text
- occOpName :: OccName -> OpName
- data FixityDirection
  - = InfixL
  - | InfixR
  - | InfixN
- data FixityInfo = FixityInfo {
  - fiDirection :: FixityDirection
  - fiPrecedence :: Int
  }
- colonFixityInfo :: FixityInfo
- defaultFixityInfo :: FixityInfo
- data FixityApproximation = FixityApproximation {
  - faDirection :: Maybe FixityDirection
  - faMinPrecedence :: Int
  - faMaxPrecedence :: Int
  }
- defaultFixityApproximation :: FixityApproximation
- newtype HackageInfo = HackageInfo (Map PackageName (Map ModuleName (Map OpName FixityInfo)))
- newtype FixityOverrides = FixityOverrides {
  - unFixityOverrides :: Map OpName FixityInfo
  }
- defaultFixityOverrides :: FixityOverrides
- newtype ModuleReexports = ModuleReexports {
  - unModuleReexports :: Map ModuleName (NonEmpty (Maybe PackageName, ModuleName))
  }
- defaultModuleReexports :: ModuleReexports
- newtype PackageFixityMap = PackageFixityMap (Map OpName (NonEmpty (PackageName, ModuleName, FixityInfo)))
- newtype ModuleFixityMap = ModuleFixityMap (Map OpName FixityProvenance)
- data FixityProvenance
  - = Given FixityInfo
  - | FromModuleImports (NonEmpty (FixityQualification, FixityInfo))
- data FixityQualification
  - = UnqualifiedAndQualified ModuleName
  - | OnlyQualified ModuleName
- inferFixity :: Choice "debug" -> RdrName -> ModuleFixityMap -> FixityApproximation

# Documentation

data OpName #

An operator name.

#### Instances

Instances details

Binary OpName # |
Instance details Defined in Ormolu.Fixity.Internal Methods put :: OpName -> Put # get :: Get OpName # putList :: [OpName] -> Put #
NFData OpName # |
Instance details Defined in Ormolu.Fixity.Internal Methods rnf :: OpName -> () #
IsString OpName # |
Instance details Defined in Ormolu.Fixity.Internal Methods fromString :: String -> OpName #
Show OpName # |
Instance details Defined in Ormolu.Fixity.Internal Methods showsPrec :: Int -> OpName -> ShowS # show :: OpName -> String # showList :: [OpName] -> ShowS #
Eq OpName # |
Instance details Defined in Ormolu.Fixity.Internal Methods (==) :: OpName -> OpName -> Bool # (/=) :: OpName -> OpName -> Bool #
Ord OpName # |
Instance details Defined in Ormolu.Fixity.Internal Methods compare :: OpName -> OpName -> Ordering # (<) :: OpName -> OpName -> Bool # (<=) :: OpName -> OpName -> Bool # (>) :: OpName -> OpName -> Bool # (>=) :: OpName -> OpName -> Bool # max :: OpName -> OpName -> OpName # min :: OpName -> OpName -> OpName #

pattern OpName :: Text -> OpName #

unOpName :: OpName -> Text #

Convert an `OpName` to `Text`.

occOpName :: OccName -> OpName #

Convert an 'OccName to an `OpName`.

data FixityDirection #

Fixity direction.

Constructors

InfixL |
InfixR |
InfixN |

#### Instances

Instances details

Binary FixityDirection # |
Instance details Defined in Ormolu.Fixity.Internal Methods put :: FixityDirection -> Put # get :: Get FixityDirection # putList :: [FixityDirection] -> Put #
NFData FixityDirection # |
Instance details Defined in Ormolu.Fixity.Internal Methods rnf :: FixityDirection -> () #
Generic FixityDirection # |

Instance details

Defined in Ormolu.Fixity.Internal

Associated Types

type Rep FixityDirection |
Instance details Defined in Ormolu.Fixity.Internal type Rep FixityDirection = D1 ('MetaData "FixityDirection" "Ormolu.Fixity.Internal" "fourmolu-0.17.0.0-3YMEcBLevRzEJ6gJbl7GNk" 'False) (C1 ('MetaCons "InfixL" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "InfixR" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "InfixN" 'PrefixI 'False) (U1 :: Type -> Type)))

Methods

from :: FixityDirection -> Rep FixityDirection x #

to :: Rep FixityDirection x -> FixityDirection #

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

Instance details

Defined in Ormolu.Fixity.Internal

Methods

compare :: FixityDirection -> FixityDirection -> Ordering #

(<) :: FixityDirection -> FixityDirection -> Bool #

(<=) :: FixityDirection -> FixityDirection -> Bool #

(>) :: FixityDirection -> FixityDirection -> Bool #

(>=) :: FixityDirection -> FixityDirection -> Bool #

max :: FixityDirection -> FixityDirection -> FixityDirection #

min :: FixityDirection -> FixityDirection -> FixityDirection #

type Rep FixityDirection # |
Instance details Defined in Ormolu.Fixity.Internal type Rep FixityDirection = D1 ('MetaData "FixityDirection" "Ormolu.Fixity.Internal" "fourmolu-0.17.0.0-3YMEcBLevRzEJ6gJbl7GNk" 'False) (C1 ('MetaCons "InfixL" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "InfixR" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "InfixN" 'PrefixI 'False) (U1 :: Type -> Type)))

data FixityInfo #

Fixity information about an infix operator. This type provides precise information as opposed to `FixityApproximation`.

Constructors

FixityInfo |

Fields

- fiDirection :: FixityDirection

  Fixity direction

- fiPrecedence :: Int

  Precedence

#### Instances

Instances details

Binary FixityInfo # |
Instance details Defined in Ormolu.Fixity.Internal Methods put :: FixityInfo -> Put # get :: Get FixityInfo # putList :: [FixityInfo] -> Put #
NFData FixityInfo # |
Instance details Defined in Ormolu.Fixity.Internal Methods rnf :: FixityInfo -> () #
Generic FixityInfo # |

Instance details

Defined in Ormolu.Fixity.Internal

Associated Types

type Rep FixityInfo |

Instance details

Defined in Ormolu.Fixity.Internal

type Rep FixityInfo = D1 ('MetaData "FixityInfo" "Ormolu.Fixity.Internal" "fourmolu-0.17.0.0-3YMEcBLevRzEJ6gJbl7GNk" 'False) (C1 ('MetaCons "FixityInfo" 'PrefixI 'True) (S1 ('MetaSel ('Just "fiDirection") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 FixityDirection) :*: S1 ('MetaSel ('Just "fiPrecedence") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int)))

Methods

from :: FixityInfo -> Rep FixityInfo x #

to :: Rep FixityInfo x -> FixityInfo #

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

Instance details

Defined in Ormolu.Fixity.Internal

type Rep FixityInfo = D1 ('MetaData "FixityInfo" "Ormolu.Fixity.Internal" "fourmolu-0.17.0.0-3YMEcBLevRzEJ6gJbl7GNk" 'False) (C1 ('MetaCons "FixityInfo" 'PrefixI 'True) (S1 ('MetaSel ('Just "fiDirection") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 FixityDirection) :*: S1 ('MetaSel ('Just "fiPrecedence") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int)))

colonFixityInfo :: FixityInfo #

Fixity info of the built-in colon data constructor.

defaultFixityInfo :: FixityInfo #

Fixity that is implicitly assumed if no fixity declaration is present.

data FixityApproximation #

Approximation of fixity information that takes the uncertainty that can arise from conflicting definitions into account.

Constructors

FixityApproximation |

Fields

- faDirection :: Maybe FixityDirection

  Fixity direction if it is known

- faMinPrecedence :: Int

  Minimum precedence level found in the (maybe conflicting) definitions for the operator (inclusive)

- faMaxPrecedence :: Int

  Maximum precedence level found in the (maybe conflicting) definitions for the operator (inclusive)

#### Instances

Instances details

Binary FixityApproximation # |
Instance details Defined in Ormolu.Fixity.Internal Methods put :: FixityApproximation -> Put # get :: Get FixityApproximation # putList :: [FixityApproximation] -> Put #
NFData FixityApproximation # |
Instance details Defined in Ormolu.Fixity.Internal Methods rnf :: FixityApproximation -> () #
Semigroup FixityApproximation # | Gives the ability to merge two (maybe conflicting) definitions for an operator, keeping the higher level of compatible information from both.
Instance details Defined in Ormolu.Fixity.Internal Methods (<>) :: FixityApproximation -> FixityApproximation -> FixityApproximation # sconcat :: NonEmpty FixityApproximation -> FixityApproximation # stimes :: Integral b => b -> FixityApproximation -> FixityApproximation #
Generic FixityApproximation # |

Instance details

Defined in Ormolu.Fixity.Internal

Associated Types

type Rep FixityApproximation |

Instance details

Defined in Ormolu.Fixity.Internal

type Rep FixityApproximation = D1 ('MetaData "FixityApproximation" "Ormolu.Fixity.Internal" "fourmolu-0.17.0.0-3YMEcBLevRzEJ6gJbl7GNk" 'False) (C1 ('MetaCons "FixityApproximation" 'PrefixI 'True) (S1 ('MetaSel ('Just "faDirection") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe FixityDirection)) :*: (S1 ('MetaSel ('Just "faMinPrecedence") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int) :*: S1 ('MetaSel ('Just "faMaxPrecedence") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int))))

Methods

from :: FixityApproximation -> Rep FixityApproximation x #

to :: Rep FixityApproximation x -> FixityApproximation #

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

Instance details

Defined in Ormolu.Fixity.Internal

Methods

compare :: FixityApproximation -> FixityApproximation -> Ordering #

(<) :: FixityApproximation -> FixityApproximation -> Bool #

(<=) :: FixityApproximation -> FixityApproximation -> Bool #

(>) :: FixityApproximation -> FixityApproximation -> Bool #

(>=) :: FixityApproximation -> FixityApproximation -> Bool #

max :: FixityApproximation -> FixityApproximation -> FixityApproximation #

min :: FixityApproximation -> FixityApproximation -> FixityApproximation #

type Rep FixityApproximation # |

Instance details

Defined in Ormolu.Fixity.Internal

type Rep FixityApproximation = D1 ('MetaData "FixityApproximation" "Ormolu.Fixity.Internal" "fourmolu-0.17.0.0-3YMEcBLevRzEJ6gJbl7GNk" 'False) (C1 ('MetaCons "FixityApproximation" 'PrefixI 'True) (S1 ('MetaSel ('Just "faDirection") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe FixityDirection)) :*: (S1 ('MetaSel ('Just "faMinPrecedence") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int) :*: S1 ('MetaSel ('Just "faMaxPrecedence") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int))))

defaultFixityApproximation :: FixityApproximation #

The lowest level of information we can have about an operator.

newtype HackageInfo #

The map of operators declared by each package grouped by module name.

Constructors

HackageInfo (Map PackageName (Map ModuleName (Map OpName FixityInfo))) |

#### Instances

Instances details

Binary HackageInfo # |
Instance details Defined in Ormolu.Fixity.Internal Methods put :: HackageInfo -> Put # get :: Get HackageInfo # putList :: [HackageInfo] -> Put #
NFData HackageInfo # |
Instance details Defined in Ormolu.Fixity.Internal Methods rnf :: HackageInfo -> () #
Generic HackageInfo # |

Instance details

Defined in Ormolu.Fixity.Internal

Associated Types

type Rep HackageInfo |
Instance details Defined in Ormolu.Fixity.Internal type Rep HackageInfo = D1 ('MetaData "HackageInfo" "Ormolu.Fixity.Internal" "fourmolu-0.17.0.0-3YMEcBLevRzEJ6gJbl7GNk" 'True) (C1 ('MetaCons "HackageInfo" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Map PackageName (Map ModuleName (Map OpName FixityInfo))))))

Methods

from :: HackageInfo -> Rep HackageInfo x #

to :: Rep HackageInfo x -> HackageInfo #

type Rep HackageInfo # |
Instance details Defined in Ormolu.Fixity.Internal type Rep HackageInfo = D1 ('MetaData "HackageInfo" "Ormolu.Fixity.Internal" "fourmolu-0.17.0.0-3YMEcBLevRzEJ6gJbl7GNk" 'True) (C1 ('MetaCons "HackageInfo" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Map PackageName (Map ModuleName (Map OpName FixityInfo))))))

newtype FixityOverrides #

Map from the operator name to its `FixityInfo`.

Constructors

FixityOverrides |

Fields

- unFixityOverrides :: Map OpName 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.

newtype ModuleReexports #

Module re-exports

Constructors

ModuleReexports |

Fields

- unModuleReexports :: Map ModuleName (NonEmpty (Maybe PackageName, ModuleName))

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

newtype PackageFixityMap #

Fixity information that is specific to a package being formatted. It requires module-specific imports in order to be usable.

Constructors

PackageFixityMap (Map OpName (NonEmpty (PackageName, ModuleName, FixityInfo))) |

#### Instances

Instances details

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

newtype ModuleFixityMap #

Fixity map that takes into account imports in a particular module.

Constructors

ModuleFixityMap (Map OpName FixityProvenance) |

#### Instances

Instances details

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

data FixityProvenance #

Provenance of fixity info.

Constructors

Given FixityInfo | `FixityInfo` of a built-in operator or provided by a user override.
FromModuleImports (NonEmpty (FixityQualification, FixityInfo)) | `FixityInfo` to be inferred from module imports.

#### Instances

Instances details

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

data FixityQualification #

Fixity qualification that determines how `FixityInfo` matches a particular use of an operator, given whether it is qualified or unqualified and the module name used.

Constructors

UnqualifiedAndQualified ModuleName |
OnlyQualified ModuleName |

#### Instances

Instances details

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

inferFixity #

Arguments

:: Choice "debug" | Whether to print debug info regarding fixity inference
-> RdrName | Operator name
-> ModuleFixityMap | Module fixity map
-> FixityApproximation | The resulting fixity approximation

Get a `FixityApproximation` of an operator.