ormolu-0.8.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 :: Double
  }
- colonFixityInfo :: FixityInfo
- defaultFixityInfo :: FixityInfo
- data FixityApproximation = FixityApproximation {
  - faDirection :: Maybe FixityDirection
  - faMinPrecedence :: Double
  - faMaxPrecedence :: Double
  }
- 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 Source #

An operator name.

#### Instances

Instances details

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

pattern OpName :: Text -> OpName Source #

unOpName :: OpName -> Text Source #

Convert an `OpName` to `Text`.

occOpName :: OccName -> OpName Source #

Convert an 'OccName to an `OpName`.

data FixityDirection Source #

Fixity direction.

Constructors

InfixL |
InfixR |
InfixN |

#### Instances

Instances details

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

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" "ormolu-0.8.0.0-DvLudsiHp1rK2d5joOJjbz" '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 Source #

to :: Rep FixityDirection x -> FixityDirection Source #

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

Instance details

Defined in Ormolu.Fixity.Internal

Methods

compare :: FixityDirection -> FixityDirection -> Ordering Source #

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

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

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

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

max :: FixityDirection -> FixityDirection -> FixityDirection Source #

min :: FixityDirection -> FixityDirection -> FixityDirection Source #

type Rep FixityDirection Source # |
Instance details Defined in Ormolu.Fixity.Internal type Rep FixityDirection = D1 ('MetaData "FixityDirection" "Ormolu.Fixity.Internal" "ormolu-0.8.0.0-DvLudsiHp1rK2d5joOJjbz" '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 Source #

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

Constructors

FixityInfo |

Fields

- fiDirection :: FixityDirection

  Fixity direction

- fiPrecedence :: Double

  Precedence

#### Instances

Instances details

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

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" "ormolu-0.8.0.0-DvLudsiHp1rK2d5joOJjbz" 'False) (C1 ('MetaCons "FixityInfo" 'PrefixI 'True) (S1 ('MetaSel ('Just "fiDirection") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 FixityDirection) :*: S1 ('MetaSel ('Just "fiPrecedence") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Double)))

Methods

from :: FixityInfo -> Rep FixityInfo x Source #

to :: Rep FixityInfo x -> FixityInfo Source #

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

Instance details

Defined in Ormolu.Fixity.Internal

Methods

compare :: FixityInfo -> FixityInfo -> Ordering Source #

(<) :: FixityInfo -> FixityInfo -> Bool Source #

(<=) :: FixityInfo -> FixityInfo -> Bool Source #

(>) :: FixityInfo -> FixityInfo -> Bool Source #

(>=) :: FixityInfo -> FixityInfo -> Bool Source #

max :: FixityInfo -> FixityInfo -> FixityInfo Source #

min :: FixityInfo -> FixityInfo -> FixityInfo Source #

type Rep FixityInfo Source # |

Instance details

Defined in Ormolu.Fixity.Internal

type Rep FixityInfo = D1 ('MetaData "FixityInfo" "Ormolu.Fixity.Internal" "ormolu-0.8.0.0-DvLudsiHp1rK2d5joOJjbz" 'False) (C1 ('MetaCons "FixityInfo" 'PrefixI 'True) (S1 ('MetaSel ('Just "fiDirection") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 FixityDirection) :*: S1 ('MetaSel ('Just "fiPrecedence") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Double)))

colonFixityInfo :: FixityInfo Source #

Fixity info of the built-in colon data constructor.

defaultFixityInfo :: FixityInfo Source #

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

data FixityApproximation Source #

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 :: Double

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

- faMaxPrecedence :: Double

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

#### Instances

Instances details

Binary FixityApproximation Source # |
Instance details Defined in Ormolu.Fixity.Internal Methods put :: FixityApproximation -> Put Source # get :: Get FixityApproximation Source # putList :: [FixityApproximation] -> Put Source #
Semigroup FixityApproximation Source # | 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 Source # sconcat :: NonEmpty FixityApproximation -> FixityApproximation Source # stimes :: Integral b => b -> FixityApproximation -> FixityApproximation Source #
Generic FixityApproximation Source # |

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" "ormolu-0.8.0.0-DvLudsiHp1rK2d5joOJjbz" 'False) (C1 ('MetaCons "FixityApproximation" 'PrefixI 'True) (S1 ('MetaSel ('Just "faDirection") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe FixityDirection)) :*: (S1 ('MetaSel ('Just "faMinPrecedence") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Double) :*: S1 ('MetaSel ('Just "faMaxPrecedence") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Double))))

Methods

from :: FixityApproximation -> Rep FixityApproximation x Source #

to :: Rep FixityApproximation x -> FixityApproximation Source #

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

Instance details

Defined in Ormolu.Fixity.Internal

Methods

compare :: FixityApproximation -> FixityApproximation -> Ordering Source #

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

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

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

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

max :: FixityApproximation -> FixityApproximation -> FixityApproximation Source #

min :: FixityApproximation -> FixityApproximation -> FixityApproximation Source #

type Rep FixityApproximation Source # |

Instance details

Defined in Ormolu.Fixity.Internal

type Rep FixityApproximation = D1 ('MetaData "FixityApproximation" "Ormolu.Fixity.Internal" "ormolu-0.8.0.0-DvLudsiHp1rK2d5joOJjbz" 'False) (C1 ('MetaCons "FixityApproximation" 'PrefixI 'True) (S1 ('MetaSel ('Just "faDirection") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe FixityDirection)) :*: (S1 ('MetaSel ('Just "faMinPrecedence") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Double) :*: S1 ('MetaSel ('Just "faMaxPrecedence") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Double))))

defaultFixityApproximation :: FixityApproximation Source #

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

newtype HackageInfo Source #

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 Source # |
Instance details Defined in Ormolu.Fixity.Internal Methods put :: HackageInfo -> Put Source # get :: Get HackageInfo Source # putList :: [HackageInfo] -> Put Source #
Generic HackageInfo Source # |

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" "ormolu-0.8.0.0-DvLudsiHp1rK2d5joOJjbz" '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 Source #

to :: Rep HackageInfo x -> HackageInfo Source #

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

newtype FixityOverrides Source #

Map from the operator name to its `FixityInfo`.

Constructors

FixityOverrides |

Fields

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

newtype ModuleReexports Source #

Module re-exports

Constructors

ModuleReexports |

Fields

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

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

newtype PackageFixityMap Source #

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

newtype ModuleFixityMap Source #

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

Constructors

ModuleFixityMap (Map OpName FixityProvenance) |

#### Instances

Instances details

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

data FixityProvenance Source #

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

data FixityQualification Source #

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

inferFixity Source #

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.