| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Language.Haskell.Tools.AST.Ann
Description
Parts of AST representation for keeping extra data
- data RangeStage
- data NormRangeStage
- data RngTemplateStage
- data SrcTemplateStage
- data Dom name
- data IdDom
- type SemanticInfo (domain :: *) (node :: * -> * -> *) = SemanticInfo' domain (SemaInfoClassify node)
- data SemaInfoNameCls
- data SemaInfoLitCls
- data SemaInfoExprCls
- data SemaInfoImportCls
- data SemaInfoModuleCls
- data SemaInfoDefaultCls
- data SemaInfoWildcardCls
- type family SemaInfoClassify (node :: * -> * -> *) where ...
- type family SemanticInfo' (domain :: *) (nodecls :: *)
- type Domain d = (Typeable d, Data d, SemanticInfo' d SemaInfoDefaultCls ~ NoSemanticInfo, Data (SemanticInfo' d SemaInfoNameCls), Data (SemanticInfo' d SemaInfoLitCls), Data (SemanticInfo' d SemaInfoExprCls), Data (SemanticInfo' d SemaInfoImportCls), Data (SemanticInfo' d SemaInfoModuleCls), Data (SemanticInfo' d SemaInfoWildcardCls))
- type DomainWith e d = (Data (SemanticInfo' d (SemaInfoClassify e)), Domain d)
- class HasRange a where
- class (Typeable stage, Data stage, Data (SpanInfo stage), Data (ListInfo stage), Data (OptionalInfo stage), HasRange (SpanInfo stage), HasRange (ListInfo stage), HasRange (OptionalInfo stage)) => SourceInfo stage where
- shortShowSpan :: SrcSpan -> String
- shortShowSpanWithFile :: SrcSpan -> String
- shortShowLoc :: SrcLoc -> String
- class SourceInfo stage => RangeInfo stage where
- data NodeInfo sema src = NodeInfo {
- _semanticInfo :: sema
- _sourceInfo :: src
- sourceInfo :: forall sema src src'. Lens (NodeInfo sema src) (NodeInfo sema src') src src'
- semanticInfo :: forall sema src sema'. Lens (NodeInfo sema src) (NodeInfo sema' src) sema sema'
- data Ann elem dom stage = Ann {
- _annotation :: NodeInfo (SemanticInfo dom elem) (SpanInfo stage)
- _element :: elem dom stage
- element :: forall elem dom stage. Lens (Ann elem dom stage) (Ann elem dom stage) (elem dom stage) (elem dom stage)
- annotation :: forall elem dom stage. Lens (Ann elem dom stage) (Ann elem dom stage) (NodeInfo (SemanticInfo dom elem) (SpanInfo stage)) (NodeInfo (SemanticInfo dom elem) (SpanInfo stage))
- data AnnListG elem dom stage = AnnListG {
- _annListAnnot :: NodeInfo (SemanticInfo dom (AnnListG elem)) (ListInfo stage)
- _annListElems :: [Ann elem dom stage]
- annListElems :: forall elem dom stage. Lens (AnnListG elem dom stage) (AnnListG elem dom stage) [Ann elem dom stage] [Ann elem dom stage]
- annListAnnot :: forall elem dom stage. Lens (AnnListG elem dom stage) (AnnListG elem dom stage) (NodeInfo (SemanticInfo dom (AnnListG elem)) (ListInfo stage)) (NodeInfo (SemanticInfo dom (AnnListG elem)) (ListInfo stage))
- annList :: Traversal (AnnListG e d s) (AnnListG e d s) (Ann e d s) (Ann e d s)
- data AnnMaybeG elem dom stage = AnnMaybeG {
- _annMaybeAnnot :: NodeInfo (SemanticInfo dom (AnnMaybeG elem)) (OptionalInfo stage)
- _annMaybe :: Maybe (Ann elem dom stage)
- annMaybeAnnot :: forall elem dom stage. Lens (AnnMaybeG elem dom stage) (AnnMaybeG elem dom stage) (NodeInfo (SemanticInfo dom (AnnMaybeG elem)) (OptionalInfo stage)) (NodeInfo (SemanticInfo dom (AnnMaybeG elem)) (OptionalInfo stage))
- annMaybe :: forall elem dom stage. Lens (AnnMaybeG elem dom stage) (AnnMaybeG elem dom stage) (Maybe (Ann elem dom stage)) (Maybe (Ann elem dom stage))
- class HasSourceInfo e where
- type SourceInfoType e :: *
- annJust :: Partial (AnnMaybeG e d s) (AnnMaybeG e d s) (Ann e d s) (Ann e d s)
- annNil :: NodeInfo (SemanticInfo d (AnnListG e)) (ListInfo s) -> AnnListG e d s
- isAnnNothing :: AnnMaybeG e d s -> Bool
- isAnnJust :: AnnMaybeG e d s -> Bool
- annLength :: AnnListG e d s -> Int
- annNothing :: NodeInfo (SemanticInfo d (AnnMaybeG e)) (OptionalInfo s) -> AnnMaybeG e d s
- class ApplySemaChange cls where
- class ApplySemaChange (SemaInfoClassify a) => SemanticTraversal a where
- data SemaTrf f dom1 dom2 = SemaTrf {
- trfSemaNameCls :: SemanticInfo' dom1 SemaInfoNameCls -> f (SemanticInfo' dom2 SemaInfoNameCls)
- trfSemaExprCls :: SemanticInfo' dom1 SemaInfoExprCls -> f (SemanticInfo' dom2 SemaInfoExprCls)
- trfSemaLitCls :: SemanticInfo' dom1 SemaInfoLitCls -> f (SemanticInfo' dom2 SemaInfoLitCls)
- trfSemaImportCls :: SemanticInfo' dom1 SemaInfoImportCls -> f (SemanticInfo' dom2 SemaInfoImportCls)
- trfSemaModuleCls :: SemanticInfo' dom1 SemaInfoModuleCls -> f (SemanticInfo' dom2 SemaInfoModuleCls)
- trfSemaWildcardCls :: SemanticInfo' dom1 SemaInfoWildcardCls -> f (SemanticInfo' dom2 SemaInfoWildcardCls)
- trfSemaDefault :: SemanticInfo' dom1 SemaInfoDefaultCls -> f (SemanticInfo' dom2 SemaInfoDefaultCls)
- class SourceInfoTraversal a where
- data SourceInfoTrf f st1 st2 = SourceInfoTrf {
- trfSpanInfo :: SpanInfo st1 -> f (SpanInfo st2)
- trfListInfo :: ListInfo st1 -> f (ListInfo st2)
- trfOptionalInfo :: OptionalInfo st1 -> f (OptionalInfo st2)
Annotation type resolution
data RangeStage #
A stage in which the nodes are marked with the ranges in the source files which contain the source code of the given AST element.
Instances
data NormRangeStage #
A stage in which the nodes are still marked with ranges, but these ranges are normalized. Optional and list elements also have ranges in that state.
Instances
data RngTemplateStage #
A stage in which AST elements are marked with templates. These templates are hierarchical, and contain the places of the children elements of the node.
Instances
data SrcTemplateStage #
A stage where the annotation controls how the original source code can be retrieved from the AST. A source template is assigned to each node. It has holes where the content of an other node should be printed and ranges for the source code of the node.
Instances
With this domain, semantic information can be parameterized. In practice it is only used if the compilation cannot proceed past the type checking phase.
Instances
| (Data name, Typeable * name) => Data (Dom name) # | |
| type SemanticInfo' (Dom n) SemaInfoDefaultCls # | |
| type SemanticInfo' (Dom n) SemaInfoWildcardCls # | |
| type SemanticInfo' (Dom n) SemaInfoModuleCls # | |
| type SemanticInfo' (Dom n) SemaInfoImportCls # | |
| type SemanticInfo' (Dom n) SemaInfoExprCls # | |
| type SemanticInfo' (Dom n) SemaInfoLitCls # | |
| type SemanticInfo' (Dom n) SemaInfoNameCls # | |
Instances
| Data IdDom # | |
| type SemanticInfo' IdDom SemaInfoWildcardCls # | |
| type SemanticInfo' IdDom SemaInfoDefaultCls # | |
| type SemanticInfo' IdDom SemaInfoModuleCls # | |
| type SemanticInfo' IdDom SemaInfoImportCls # | |
| type SemanticInfo' IdDom SemaInfoExprCls # | |
| type SemanticInfo' IdDom SemaInfoLitCls # | |
| type SemanticInfo' IdDom SemaInfoNameCls # | |
type SemanticInfo (domain :: *) (node :: * -> * -> *) = SemanticInfo' domain (SemaInfoClassify node) #
data SemaInfoNameCls #
Instances
data SemaInfoLitCls #
Instances
| ApplySemaChange SemaInfoLitCls # | |
| type SemanticInfo' IdDom SemaInfoLitCls # | |
| type SemanticInfo' (Dom n) SemaInfoLitCls # | |
data SemaInfoExprCls #
Instances
data SemaInfoImportCls #
Instances
data SemaInfoModuleCls #
Instances
data SemaInfoDefaultCls #
Instances
data SemaInfoWildcardCls #
Instances
type family SemaInfoClassify (node :: * -> * -> *) where ... #
Equations
type family SemanticInfo' (domain :: *) (nodecls :: *) #
Instances
| type SemanticInfo' IdDom SemaInfoWildcardCls # | |
| type SemanticInfo' IdDom SemaInfoDefaultCls # | |
| type SemanticInfo' IdDom SemaInfoModuleCls # | |
| type SemanticInfo' IdDom SemaInfoImportCls # | |
| type SemanticInfo' IdDom SemaInfoExprCls # | |
| type SemanticInfo' IdDom SemaInfoLitCls # | |
| type SemanticInfo' IdDom SemaInfoNameCls # | |
| type SemanticInfo' (Dom n) SemaInfoDefaultCls # | |
| type SemanticInfo' (Dom n) SemaInfoWildcardCls # | |
| type SemanticInfo' (Dom n) SemaInfoModuleCls # | |
| type SemanticInfo' (Dom n) SemaInfoImportCls # | |
| type SemanticInfo' (Dom n) SemaInfoExprCls # | |
| type SemanticInfo' (Dom n) SemaInfoLitCls # | |
| type SemanticInfo' (Dom n) SemaInfoNameCls # | |
type Domain d = (Typeable d, Data d, SemanticInfo' d SemaInfoDefaultCls ~ NoSemanticInfo, Data (SemanticInfo' d SemaInfoNameCls), Data (SemanticInfo' d SemaInfoLitCls), Data (SemanticInfo' d SemaInfoExprCls), Data (SemanticInfo' d SemaInfoImportCls), Data (SemanticInfo' d SemaInfoModuleCls), Data (SemanticInfo' d SemaInfoWildcardCls)) #
A semantic domain for the AST. The semantic domain maps semantic information for the different types of nodes in the AST. The kind of semantic domain for an AST depends on which stages of the compilation it passed. However after transforming the GHC representation to our AST, the domain stays the same. The domain is not applied to the AST elements that are generated while refactoring.
type DomainWith e d = (Data (SemanticInfo' d (SemaInfoClassify e)), Domain d) #
Extracts or modifies the concrete range corresponding to a given source info. In case of lists and optional elements, it may not contain the elements inside.
Instances
| HasRange (SpanInfo NormRangeStage) # | |
| HasRange (SpanInfo RangeStage) # | |
| HasRange (ListInfo NormRangeStage) # | |
| HasRange (ListInfo RangeStage) # | |
| HasRange (OptionalInfo NormRangeStage) # | |
| HasRange (OptionalInfo RangeStage) # | |
| SourceInfo stage => HasRange (Ann elem dom stage) # | |
| SourceInfo stage => HasRange (AnnListG elem dom stage) # | |
| SourceInfo stage => HasRange (AnnMaybeG elem dom stage) # | |
class (Typeable stage, Data stage, Data (SpanInfo stage), Data (ListInfo stage), Data (OptionalInfo stage), HasRange (SpanInfo stage), HasRange (ListInfo stage), HasRange (OptionalInfo stage)) => SourceInfo stage #
Class for source information stages
Associated Types
UType of source info for normal AST elements
UType of source info for lists of AST elements
data OptionalInfo stage :: * #
UType of source info for optional AST elements
Instances
shortShowSpan :: SrcSpan -> String #
A short form of showing a range, without file name, for debugging purposes.
shortShowSpanWithFile :: SrcSpan -> String #
shortShowLoc :: SrcLoc -> String #
A short form of showing a range, without file name, for debugging purposes.
class SourceInfo stage => RangeInfo stage where #
A class for marking a source information stage. All programs, regardless of correct Haskell programs or not, must go through these stages to be refactored.
Minimal complete definition
Methods
nodeSpan :: Simple Lens (SpanInfo stage) SrcSpan #
listPos :: Simple Lens (ListInfo stage) SrcLoc #
optionalPos :: Simple Lens (OptionalInfo stage) SrcLoc #
Instances
Annotations
Semantic and source code related information for an AST node.
Constructors
| NodeInfo | |
Fields
| |
sourceInfo :: forall sema src src'. Lens (NodeInfo sema src) (NodeInfo sema src') src src' #
semanticInfo :: forall sema src sema'. Lens (NodeInfo sema src) (NodeInfo sema' src) sema sema' #
An element of the AST keeping extra information.
Constructors
| Ann | |
Fields
| |
Instances
element :: forall elem dom stage. Lens (Ann elem dom stage) (Ann elem dom stage) (elem dom stage) (elem dom stage) #
annotation :: forall elem dom stage. Lens (Ann elem dom stage) (Ann elem dom stage) (NodeInfo (SemanticInfo dom elem) (SpanInfo stage)) (NodeInfo (SemanticInfo dom elem) (SpanInfo stage)) #
data AnnListG elem dom stage #
A list of AST elements
Constructors
| AnnListG | |
Fields
| |
Instances
| SourceInfoTraversal e => SourceInfoTraversal (AnnListG e) # | |
| (ApplySemaChange (SemaInfoClassify e), SemanticTraversal e) => SemanticTraversal (AnnListG e) # | |
| SourceInfo stage => HasRange (AnnListG elem dom stage) # | |
| HasSourceInfo (AnnListG elem dom stage) # | |
| type Rep (AnnListG e dom stage) # | |
| type IgnoredFields (AnnListG elem dom stage) # | |
| type SourceInfoType (AnnListG elem dom stage) # | |
annListElems :: forall elem dom stage. Lens (AnnListG elem dom stage) (AnnListG elem dom stage) [Ann elem dom stage] [Ann elem dom stage] #
annListAnnot :: forall elem dom stage. Lens (AnnListG elem dom stage) (AnnListG elem dom stage) (NodeInfo (SemanticInfo dom (AnnListG elem)) (ListInfo stage)) (NodeInfo (SemanticInfo dom (AnnListG elem)) (ListInfo stage)) #
data AnnMaybeG elem dom stage #
An optional AST element
Constructors
| AnnMaybeG | |
Fields
| |
Instances
| SourceInfoTraversal e => SourceInfoTraversal (AnnMaybeG e) # | |
| (ApplySemaChange (SemaInfoClassify e), SemanticTraversal e) => SemanticTraversal (AnnMaybeG e) # | |
| SourceInfo stage => HasRange (AnnMaybeG elem dom stage) # | |
| HasSourceInfo (AnnMaybeG elem dom stage) # | |
| type Rep (AnnMaybeG e dom stage) # | |
| type IgnoredFields (AnnMaybeG elem dom stage) # | |
| type SourceInfoType (AnnMaybeG elem dom stage) # | |
annMaybeAnnot :: forall elem dom stage. Lens (AnnMaybeG elem dom stage) (AnnMaybeG elem dom stage) (NodeInfo (SemanticInfo dom (AnnMaybeG elem)) (OptionalInfo stage)) (NodeInfo (SemanticInfo dom (AnnMaybeG elem)) (OptionalInfo stage)) #
annMaybe :: forall elem dom stage. Lens (AnnMaybeG elem dom stage) (AnnMaybeG elem dom stage) (Maybe (Ann elem dom stage)) (Maybe (Ann elem dom stage)) #
class HasSourceInfo e where #
Minimal complete definition
Associated Types
type SourceInfoType e :: * #
Methods
srcInfo :: Simple Lens e (SourceInfoType e) #
Instances
| HasSourceInfo (Ann elem dom stage) # | |
| HasSourceInfo (AnnListG elem dom stage) # | |
| HasSourceInfo (AnnMaybeG elem dom stage) # | |
annNil :: NodeInfo (SemanticInfo d (AnnListG e)) (ListInfo s) -> AnnListG e d s #
An empty list of AST elements
isAnnNothing :: AnnMaybeG e d s -> Bool #
annNothing :: NodeInfo (SemanticInfo d (AnnMaybeG e)) (OptionalInfo s) -> AnnMaybeG e d s #
A non-existing AST part
Info types
class ApplySemaChange cls where #
A class for changing semantic information throught the AST.
Minimal complete definition
Methods
appSemaChange :: SemaTrf f dom1 dom2 -> SemanticInfo' dom1 cls -> f (SemanticInfo' dom2 cls) #
class ApplySemaChange (SemaInfoClassify a) => SemanticTraversal a where #
A class for traversing semantic information in an AST
Minimal complete definition
Methods
semaTraverse :: Monad f => SemaTrf f dom1 dom2 -> a dom1 st -> f (a dom2 st) #
Instances
| (ApplySemaChange (SemaInfoClassify e), SemanticTraversal e) => SemanticTraversal (Ann e) # | |
| (ApplySemaChange (SemaInfoClassify e), SemanticTraversal e) => SemanticTraversal (AnnListG e) # | |
| (ApplySemaChange (SemaInfoClassify e), SemanticTraversal e) => SemanticTraversal (AnnMaybeG e) # | |
A transformation on the possible semantic informations for a given domain
Constructors
| SemaTrf | |
Fields
| |
class SourceInfoTraversal a where #
A class for traversing source information in an AST
Minimal complete definition
sourceInfoTraverseUp, sourceInfoTraverseDown, sourceInfoTraverse
Methods
sourceInfoTraverseUp :: Monad f => SourceInfoTrf f st1 st2 -> f () -> f () -> a dom st1 -> f (a dom st2) #
sourceInfoTraverseDown :: Monad f => SourceInfoTrf f st1 st2 -> f () -> f () -> a dom st1 -> f (a dom st2) #
sourceInfoTraverse :: Monad f => SourceInfoTrf f st1 st2 -> a dom st1 -> f (a dom st2) #
Instances
| SourceInfoTraversal e => SourceInfoTraversal (Ann e) # | |
| SourceInfoTraversal e => SourceInfoTraversal (AnnListG e) # | |
| SourceInfoTraversal e => SourceInfoTraversal (AnnMaybeG e) # | |
data SourceInfoTrf f st1 st2 #
A transformation on the possible source informations
Constructors
| SourceInfoTrf | |
Fields
| |