ormolu-0.7.4.0: A formatter for Haskell source code
Safe HaskellSafe-Inferred
LanguageGHC2021

Ormolu.Fixity

Description

Definitions for fixity analysis.

Synopsis

Documentation

data OpName Source #

An operator name.

Instances

Instances details
IsString OpName Source # 
Instance details

Defined in Ormolu.Fixity.Internal

Methods

fromString :: String -> OpName #

Show OpName Source # 
Instance details

Defined in Ormolu.Fixity.Internal

Binary OpName Source # 
Instance details

Defined in Ormolu.Fixity.Internal

Methods

put :: OpName -> Put #

get :: Get OpName #

putList :: [OpName] -> Put #

NFData OpName Source # 
Instance details

Defined in Ormolu.Fixity.Internal

Methods

rnf :: OpName -> () #

Eq OpName Source # 
Instance details

Defined in Ormolu.Fixity.Internal

Methods

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

(/=) :: OpName -> OpName -> Bool #

Ord OpName Source # 
Instance details

Defined in Ormolu.Fixity.Internal

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
Generic FixityDirection Source # 
Instance details

Defined in Ormolu.Fixity.Internal

Associated Types

type Rep FixityDirection :: Type -> Type #

Show FixityDirection Source # 
Instance details

Defined in Ormolu.Fixity.Internal

Binary FixityDirection Source # 
Instance details

Defined in Ormolu.Fixity.Internal

NFData FixityDirection Source # 
Instance details

Defined in Ormolu.Fixity.Internal

Methods

rnf :: FixityDirection -> () #

Eq FixityDirection Source # 
Instance details

Defined in Ormolu.Fixity.Internal

Ord FixityDirection Source # 
Instance details

Defined in Ormolu.Fixity.Internal

type Rep FixityDirection Source # 
Instance details

Defined in Ormolu.Fixity.Internal

type Rep FixityDirection = D1 ('MetaData "FixityDirection" "Ormolu.Fixity.Internal" "ormolu-0.7.4.0-CiGvIG7IoPvIoKzgn74S6B" '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

Instances

Instances details
Generic FixityInfo Source # 
Instance details

Defined in Ormolu.Fixity.Internal

Associated Types

type Rep FixityInfo :: Type -> Type #

Show FixityInfo Source # 
Instance details

Defined in Ormolu.Fixity.Internal

Binary FixityInfo Source # 
Instance details

Defined in Ormolu.Fixity.Internal

NFData FixityInfo Source # 
Instance details

Defined in Ormolu.Fixity.Internal

Methods

rnf :: FixityInfo -> () #

Eq FixityInfo Source # 
Instance details

Defined in Ormolu.Fixity.Internal

Ord FixityInfo Source # 
Instance details

Defined in Ormolu.Fixity.Internal

type Rep FixityInfo Source # 
Instance details

Defined in Ormolu.Fixity.Internal

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

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

Instances

Instances details
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

Generic FixityApproximation Source # 
Instance details

Defined in Ormolu.Fixity.Internal

Associated Types

type Rep FixityApproximation :: Type -> Type #

Show FixityApproximation Source # 
Instance details

Defined in Ormolu.Fixity.Internal

Binary FixityApproximation Source # 
Instance details

Defined in Ormolu.Fixity.Internal

NFData FixityApproximation Source # 
Instance details

Defined in Ormolu.Fixity.Internal

Methods

rnf :: FixityApproximation -> () #

Eq FixityApproximation Source # 
Instance details

Defined in Ormolu.Fixity.Internal

Ord FixityApproximation Source # 
Instance details

Defined in Ormolu.Fixity.Internal

type Rep FixityApproximation Source # 
Instance details

Defined in Ormolu.Fixity.Internal

type Rep FixityApproximation = D1 ('MetaData "FixityApproximation" "Ormolu.Fixity.Internal" "ormolu-0.7.4.0-CiGvIG7IoPvIoKzgn74S6B" '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 Source #

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

newtype FixityOverrides Source #

Map from the operator name to its FixityInfo.

defaultFixityOverrides :: FixityOverrides Source #

Fixity overrides to use by default.

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.

newtype ModuleFixityMap Source #

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

inferFixity Source #

Arguments

:: Bool

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.

newtype HackageInfo Source #

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

Instances

Instances details
Generic HackageInfo Source # 
Instance details

Defined in Ormolu.Fixity.Internal

Associated Types

type Rep HackageInfo :: Type -> Type #

Binary HackageInfo Source # 
Instance details

Defined in Ormolu.Fixity.Internal

NFData HackageInfo Source # 
Instance details

Defined in Ormolu.Fixity.Internal

Methods

rnf :: HackageInfo -> () #

type Rep HackageInfo Source # 
Instance details

Defined in Ormolu.Fixity.Internal

type Rep HackageInfo = D1 ('MetaData "HackageInfo" "Ormolu.Fixity.Internal" "ormolu-0.7.4.0-CiGvIG7IoPvIoKzgn74S6B" 'True) (C1 ('MetaCons "HackageInfo" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Map PackageName (Map ModuleName (Map OpName FixityInfo))))))

hackageInfo :: HackageInfo Source #

The built-in HackageInfo used by Ormolu.

defaultDependencies :: Set PackageName Source #

Default set of packages to assume as dependencies e.g. when no Cabal file is found or taken into consideration.

packageFixityMap Source #

Arguments

:: Set PackageName

Set of packages to select

-> PackageFixityMap

Package fixity map

Compute the fixity map that is specific to the package we are formatting.

packageFixityMap' Source #

Arguments

:: HackageInfo

Hackage info

-> Set PackageName

Set of packages to select

-> PackageFixityMap

Package fixity map

The same as packageFixityMap, except this specific version of the function allows the user to specify HackageInfo used to build the final fixity map.

moduleFixityMap Source #

Arguments

:: PackageFixityMap

Fixity information selected from dependencies of this package

-> [FixityImport]

A simplified representation of the import list in this module

-> ModuleFixityMap

Fixity map specific to this module

Compute the fixity map that is specific to the module we are formatting.

applyFixityOverrides Source #

Arguments

:: FixityOverrides

User overrides

-> ModuleFixityMap

Module fixity map

-> ModuleFixityMap

Module fixity map with overrides applied

Apply fixity overrides.