Safe Haskell | None |
---|---|
Language | Haskell2010 |
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 SameInfoNameCls
- data SameInfoExprCls
- data SameInfoImportCls
- data SameInfoModuleCls
- data SameInfoDefaultCls
- data SameInfoWildcardCls
- type family SemaInfoClassify (node :: * -> * -> *) where ...
- type family SemanticInfo' (domain :: *) (nodecls :: *)
- class (Typeable d, Data d, SemanticInfo' d SameInfoDefaultCls ~ NoSemanticInfo, Data (SemanticInfo' d SameInfoNameCls), Data (SemanticInfo' d SameInfoExprCls), Data (SemanticInfo' d SameInfoImportCls), Data (SemanticInfo' d SameInfoModuleCls), Data (SemanticInfo' d SameInfoWildcardCls), Show (SemanticInfo' d SameInfoNameCls), Show (SemanticInfo' d SameInfoExprCls), Show (SemanticInfo' d SameInfoImportCls), Show (SemanticInfo' d SameInfoModuleCls), Show (SemanticInfo' d SameInfoWildcardCls)) => Domain d
- class (Data (SemanticInfo' d (SemaInfoClassify e)), Show (SemanticInfo' d (SemaInfoClassify e)), Domain d) => DomainWith e d
- class HasRange a where
- class (Typeable stage, Data stage, Data (SpanInfo stage), Data (ListInfo stage), Data (OptionalInfo stage), Show (SpanInfo stage), Show (ListInfo stage), Show (OptionalInfo stage), HasRange (SpanInfo stage), HasRange (ListInfo stage), HasRange (OptionalInfo stage)) => SourceInfo stage where
- shortShowSpan :: 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))
- 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 SameInfoNameCls -> f (SemanticInfo' dom2 SameInfoNameCls)
- trfSemaExprCls :: SemanticInfo' dom1 SameInfoExprCls -> f (SemanticInfo' dom2 SameInfoExprCls)
- trfSemaImportCls :: SemanticInfo' dom1 SameInfoImportCls -> f (SemanticInfo' dom2 SameInfoImportCls)
- trfSemaModuleCls :: SemanticInfo' dom1 SameInfoModuleCls -> f (SemanticInfo' dom2 SameInfoModuleCls)
- trfSemaWildcardCls :: SemanticInfo' dom1 SameInfoWildcardCls -> f (SemanticInfo' dom2 SameInfoWildcardCls)
- trfSemaDefault :: SemanticInfo' dom1 SameInfoDefaultCls -> f (SemanticInfo' dom2 SameInfoDefaultCls)
- 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 Source #
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.
data NormRangeStage Source #
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.
data RngTemplateStage Source #
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.
data SrcTemplateStage Source #
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.
With this domain, semantic information can be parameterized. In practice it is only used if the compilation cannot proceed past the type checking phase.
(Data name, Typeable * name) => Data (Dom name) Source # | |
type SemanticInfo' (Dom n) SameInfoDefaultCls Source # | |
type SemanticInfo' (Dom n) SameInfoWildcardCls Source # | |
type SemanticInfo' (Dom n) SameInfoModuleCls Source # | |
type SemanticInfo' (Dom n) SameInfoImportCls Source # | |
type SemanticInfo' (Dom n) SameInfoExprCls Source # | |
type SemanticInfo' (Dom n) SameInfoNameCls Source # | |
type SemanticInfo domain node = SemanticInfo' domain (SemaInfoClassify node) Source #
data SameInfoNameCls Source #
data SameInfoExprCls Source #
data SameInfoImportCls Source #
data SameInfoModuleCls Source #
data SameInfoDefaultCls Source #
data SameInfoWildcardCls Source #
type family SemaInfoClassify (node :: * -> * -> *) where ... Source #
SemaInfoClassify UQualifiedName = SameInfoNameCls | |
SemaInfoClassify UExpr = SameInfoExprCls | |
SemaInfoClassify UImportDecl = SameInfoImportCls | |
SemaInfoClassify UModule = SameInfoModuleCls | |
SemaInfoClassify UFieldWildcard = SameInfoWildcardCls | |
SemaInfoClassify a = SameInfoDefaultCls |
type family SemanticInfo' (domain :: *) (nodecls :: *) Source #
type SemanticInfo' IdDom SameInfoWildcardCls Source # | |
type SemanticInfo' IdDom SameInfoDefaultCls Source # | |
type SemanticInfo' IdDom SameInfoModuleCls Source # | |
type SemanticInfo' IdDom SameInfoImportCls Source # | |
type SemanticInfo' IdDom SameInfoExprCls Source # | |
type SemanticInfo' IdDom SameInfoNameCls Source # | |
type SemanticInfo' (Dom n) SameInfoDefaultCls Source # | |
type SemanticInfo' (Dom n) SameInfoWildcardCls Source # | |
type SemanticInfo' (Dom n) SameInfoModuleCls Source # | |
type SemanticInfo' (Dom n) SameInfoImportCls Source # | |
type SemanticInfo' (Dom n) SameInfoExprCls Source # | |
type SemanticInfo' (Dom n) SameInfoNameCls Source # | |
class (Typeable d, Data d, SemanticInfo' d SameInfoDefaultCls ~ NoSemanticInfo, Data (SemanticInfo' d SameInfoNameCls), Data (SemanticInfo' d SameInfoExprCls), Data (SemanticInfo' d SameInfoImportCls), Data (SemanticInfo' d SameInfoModuleCls), Data (SemanticInfo' d SameInfoWildcardCls), Show (SemanticInfo' d SameInfoNameCls), Show (SemanticInfo' d SameInfoExprCls), Show (SemanticInfo' d SameInfoImportCls), Show (SemanticInfo' d SameInfoModuleCls), Show (SemanticInfo' d SameInfoWildcardCls)) => Domain d Source #
Class for domain configuration markers
(Typeable * d, Data d, (~) * (SemanticInfo' d SameInfoDefaultCls) NoSemanticInfo, Data (SemanticInfo' d SameInfoNameCls), Data (SemanticInfo' d SameInfoExprCls), Data (SemanticInfo' d SameInfoImportCls), Data (SemanticInfo' d SameInfoModuleCls), Data (SemanticInfo' d SameInfoWildcardCls), Show (SemanticInfo' d SameInfoNameCls), Show (SemanticInfo' d SameInfoExprCls), Show (SemanticInfo' d SameInfoImportCls), Show (SemanticInfo' d SameInfoModuleCls), Show (SemanticInfo' d SameInfoWildcardCls)) => Domain d Source # | 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 did it pass. However after transforming the GHC representation to our AST, the domain keeps the same. The domain is not applied to the AST elements that are generated while refactoring. |
class (Data (SemanticInfo' d (SemaInfoClassify e)), Show (SemanticInfo' d (SemaInfoClassify e)), Domain d) => DomainWith e d Source #
(Data (SemanticInfo' d (SemaInfoClassify e)), Show (SemanticInfo' d (SemaInfoClassify e)), Domain d) => DomainWith e d Source # | |
class HasRange a where Source #
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.
HasRange (SpanInfo NormRangeStage) Source # | |
HasRange (SpanInfo RangeStage) Source # | |
HasRange (ListInfo NormRangeStage) Source # | |
HasRange (ListInfo RangeStage) Source # | |
HasRange (OptionalInfo NormRangeStage) Source # | |
HasRange (OptionalInfo RangeStage) Source # | |
SourceInfo stage => HasRange (Ann elem dom stage) Source # | |
SourceInfo stage => HasRange (AnnListG elem dom stage) Source # | |
SourceInfo stage => HasRange (AnnMaybeG elem dom stage) Source # | |
class (Typeable stage, Data stage, Data (SpanInfo stage), Data (ListInfo stage), Data (OptionalInfo stage), Show (SpanInfo stage), Show (ListInfo stage), Show (OptionalInfo stage), HasRange (SpanInfo stage), HasRange (ListInfo stage), HasRange (OptionalInfo stage)) => SourceInfo stage Source #
Class for source information stages
shortShowSpan :: SrcSpan -> String Source #
A short form of showing a range, without file name, for debugging purposes.
shortShowLoc :: SrcLoc -> String Source #
A short form of showing a range, without file name, for debugging purposes.
class SourceInfo stage => RangeInfo stage where Source #
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.
Annotations
data NodeInfo sema src Source #
Semantic and source code related information for an AST node.
NodeInfo | |
|
semanticInfo :: forall sema src sema'. Lens (NodeInfo sema src) (NodeInfo sema' src) sema sema' Source #
data Ann elem dom stage Source #
An element of the AST keeping extra information.
Ann | |
|
SourceInfoTraversal e => SourceInfoTraversal (Ann e) Source # | |
(ApplySemaChange (SemaInfoClassify e), SemanticTraversal e) => SemanticTraversal (Ann e) Source # | |
SourceInfo stage => HasRange (Ann elem dom stage) Source # | |
HasImplicitFieldsInfo dom => HasImplicitFieldsInfo' (Ann UFieldWildcard dom st) Source # | |
HasImportInfo dom => HasImportInfo' (Ann UImportDecl dom st) Source # | |
HasModuleInfo dom => HasModuleInfo' (Ann UModule dom st) Source # | |
HasDefiningInfo dom => HasDefiningInfo' (Ann UQualifiedName dom st) Source # | |
HasScopeInfo dom => HasScopeInfo' (Ann UQualifiedName dom st) Source # | |
HasScopeInfo dom => HasScopeInfo' (Ann UExpr dom st) Source # | |
HasFixityInfo dom => HasFixityInfo' (Ann UQualifiedName dom st) Source # | |
HasIdInfo dom => HasIdInfo' (Ann UQualifiedName dom st) Source # | |
HasNameInfo dom => HasNameInfo' (Ann UQualifiedName dom st) Source # | |
type Rep (Ann e dom stage) Source # | |
element :: forall elem dom stage. Lens (Ann elem dom stage) (Ann elem dom stage) (elem dom stage) (elem dom stage) Source #
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)) Source #
data AnnListG elem dom stage Source #
A list of AST elements
AnnListG | |
|
SourceInfoTraversal e => SourceInfoTraversal (AnnListG e) Source # | |
(ApplySemaChange (SemaInfoClassify e), SemanticTraversal e) => SemanticTraversal (AnnListG e) Source # | |
SourceInfo stage => HasRange (AnnListG elem dom stage) Source # | |
type Rep (AnnListG e dom stage) Source # | |
annListElems :: forall elem dom stage. Lens (AnnListG elem dom stage) (AnnListG elem dom stage) [Ann elem dom stage] [Ann elem dom stage] Source #
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)) Source #
data AnnMaybeG elem dom stage Source #
An optional AST element
AnnMaybeG | |
|
SourceInfoTraversal e => SourceInfoTraversal (AnnMaybeG e) Source # | |
(ApplySemaChange (SemaInfoClassify e), SemanticTraversal e) => SemanticTraversal (AnnMaybeG e) Source # | |
SourceInfo stage => HasRange (AnnMaybeG elem dom stage) Source # | |
type Rep (AnnMaybeG e dom stage) Source # | |
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)) Source #
annMaybe :: forall elem dom stage. Lens (AnnMaybeG elem dom stage) (AnnMaybeG elem dom stage) (Maybe (Ann elem dom stage)) (Maybe (Ann elem dom stage)) Source #
annNil :: NodeInfo (SemanticInfo d (AnnListG e)) (ListInfo s) -> AnnListG e d s Source #
An empty list of AST elements
isAnnNothing :: AnnMaybeG e d s -> Bool Source #
annNothing :: NodeInfo (SemanticInfo d (AnnMaybeG e)) (OptionalInfo s) -> AnnMaybeG e d s Source #
A non-existing AST part
Info types
class ApplySemaChange cls where Source #
A class for changing semantic information throught the AST.
appSemaChange :: SemaTrf f dom1 dom2 -> SemanticInfo' dom1 cls -> f (SemanticInfo' dom2 cls) Source #
class ApplySemaChange (SemaInfoClassify a) => SemanticTraversal a where Source #
A class for traversing semantic information in an AST
semaTraverse :: Monad f => SemaTrf f dom1 dom2 -> a dom1 st -> f (a dom2 st) Source #
(ApplySemaChange (SemaInfoClassify e), SemanticTraversal e) => SemanticTraversal (Ann e) Source # | |
(ApplySemaChange (SemaInfoClassify e), SemanticTraversal e) => SemanticTraversal (AnnListG e) Source # | |
(ApplySemaChange (SemaInfoClassify e), SemanticTraversal e) => SemanticTraversal (AnnMaybeG e) Source # | |
data SemaTrf f dom1 dom2 Source #
A transformation on the possible semantic informations for a given domain
SemaTrf | |
|
class SourceInfoTraversal a where Source #
A class for traversing source information in an AST
sourceInfoTraverseUp :: Monad f => SourceInfoTrf f st1 st2 -> f () -> f () -> a dom st1 -> f (a dom st2) Source #
sourceInfoTraverseDown :: Monad f => SourceInfoTrf f st1 st2 -> f () -> f () -> a dom st1 -> f (a dom st2) Source #
sourceInfoTraverse :: Monad f => SourceInfoTrf f st1 st2 -> a dom st1 -> f (a dom st2) Source #
SourceInfoTraversal e => SourceInfoTraversal (Ann e) Source # | |
SourceInfoTraversal e => SourceInfoTraversal (AnnListG e) Source # | |
SourceInfoTraversal e => SourceInfoTraversal (AnnMaybeG e) Source # | |
data SourceInfoTrf f st1 st2 Source #
A transformation on the possible source informations
SourceInfoTrf | |
|