ghc-9.12: The GHC API
Safe HaskellNone
LanguageGHC2021

GHC.Iface.Ext.Utils

Synopsis

Documentation

foldType :: (HieType a -> a) -> HieTypeFix -> a Source #

data EvidenceInfo a Source #

Instances

Instances details
Functor EvidenceInfo Source # 
Instance details

Defined in GHC.Iface.Ext.Utils

Methods

fmap :: (a -> b) -> EvidenceInfo a -> EvidenceInfo b #

(<$) :: a -> EvidenceInfo b -> EvidenceInfo a #

Outputable a => Outputable (EvidenceInfo a) Source # 
Instance details

Defined in GHC.Iface.Ext.Utils

Methods

ppr :: EvidenceInfo a -> SDoc Source #

Eq a => Eq (EvidenceInfo a) Source # 
Instance details

Defined in GHC.Iface.Ext.Utils

Ord a => Ord (EvidenceInfo a) Source # 
Instance details

Defined in GHC.Iface.Ext.Utils

combineAst :: HieAST Type -> HieAST Type -> HieAST Type Source #

One must contain the other. Leaf nodes cannot contain anything

insertAst :: HieAST Type -> [HieAST Type] -> [HieAST Type] Source #

Insert an AST in a sorted list of disjoint Asts

combineNodeInfo :: NodeInfo Type -> NodeInfo Type -> NodeInfo Type Source #

Merge two nodes together.

Precondition and postcondition: elements in nodeType are ordered.

mergeAsts :: [HieAST Type] -> [HieAST Type] -> [HieAST Type] Source #

Merge two sorted, disjoint lists of ASTs, combining when necessary.

In the absence of position-altering pragmas (ex: # line "file.hs" 3), different nodes in an AST tree should either have disjoint spans (in which case you can say for sure which one comes first) or one span should be completely contained in the other (in which case the contained span corresponds to some child node).

However, since Haskell does have position-altering pragmas it is possible for spans to be overlapping. Here is an example of a source file in which foozball and quuuuuux have overlapping spans:

module Baz where

# line 3 "Baz.hs"
foozball :: Int
foozball = 0

# line 3 "Baz.hs"
bar, quuuuuux :: Int
bar = 1
quuuuuux = 2

In these cases, we just do our best to produce sensible HieAST's. The blame should be laid at the feet of whoever wrote the line pragmas in the first place (usually the C preprocessor...).

mergeSortAsts :: [HieAST Type] -> [HieAST Type] Source #

combines and sorts ASTs using a merge sort

locOnly :: forall (m :: Type -> Type) a. Monad m => SrcSpan -> ReaderT NodeOrigin m [HieAST a] Source #

locOnlyE :: forall (m :: Type -> Type) a. Monad m => EpaLocation -> ReaderT NodeOrigin m [HieAST a] Source #

mkScope :: HasLoc a => a -> Scope Source #

makeNodeA Source #

Arguments

:: forall (m :: Type -> Type) a ann b. (Monad m, Data a) 
=> a

helps fill in nodeAnnotations (with Data)

-> EpAnn ann

return an empty list if this is unhelpful

-> ReaderT NodeOrigin m [HieAST b] 

makeNode Source #

Arguments

:: forall (m :: Type -> Type) a b. (Monad m, Data a) 
=> a

helps fill in nodeAnnotations (with Data)

-> SrcSpan

return an empty list if this is unhelpful

-> ReaderT NodeOrigin m [HieAST b] 

makeTypeNodeA Source #

Arguments

:: forall (m :: Type -> Type) a. (Monad m, Data a) 
=> a

helps fill in nodeAnnotations (with Data)

-> SrcSpanAnnA

return an empty list if this is unhelpful

-> Type

type to associate with the node

-> ReaderT NodeOrigin m [HieAST Type] 

makeTypeNode Source #

Arguments

:: forall (m :: Type -> Type) a. (Monad m, Data a) 
=> a

helps fill in nodeAnnotations (with Data)

-> SrcSpan

return an empty list if this is unhelpful

-> Type

type to associate with the node

-> ReaderT NodeOrigin m [HieAST Type]