module Seminal.Enumerator.Declarations(enumerateChangesInDeclaration, enumerateChangesInTypeDeclaration) where
import Seminal.Enumerator.Enumerator (Enumerator)
import Seminal.Compiler.API
import Seminal.Enumerator.Bindings (enumerateChangesInBinding)
import Seminal.Change ((<&&>), forceRewrite)
import Seminal.Enumerator.Signatures (enumerateChangeInSignature)
import Seminal.Enumerator.Types (enumerateChangeInType)
import Data.Functor ((<&>))
enumerateChangesInDeclaration :: Enumerator (HsDecl GhcPs)
enumerateChangesInDeclaration :: Enumerator (HsDecl GhcPs)
enumerateChangesInDeclaration (TyClD XTyClD GhcPs
x TyClDecl GhcPs
typDecl) SrcSpan
loc = Enumerator (TyClDecl GhcPs)
enumerateChangesInTypeDeclaration TyClDecl GhcPs
typDecl SrcSpan
loc
[Change (TyClDecl GhcPs)]
-> (TyClDecl GhcPs -> HsDecl GhcPs) -> [Change (HsDecl GhcPs)]
forall a b. [Change a] -> (a -> b) -> [Change b]
<&&> (XTyClD GhcPs -> TyClDecl GhcPs -> HsDecl GhcPs
forall p. XTyClD p -> TyClDecl p -> HsDecl p
TyClD XTyClD GhcPs
x)
enumerateChangesInDeclaration (InstD XInstD GhcPs
_ InstDecl GhcPs
_) SrcSpan
_ = []
enumerateChangesInDeclaration (DerivD XDerivD GhcPs
_ DerivDecl GhcPs
_) SrcSpan
_ = []
enumerateChangesInDeclaration (ValD XValD GhcPs
i HsBind GhcPs
e) SrcSpan
loc = Enumerator (HsBind GhcPs)
enumerateChangesInBinding HsBind GhcPs
e SrcSpan
loc [Change (HsBind GhcPs)]
-> (HsBind GhcPs -> HsDecl GhcPs) -> [Change (HsDecl GhcPs)]
forall a b. [Change a] -> (a -> b) -> [Change b]
<&&> (XValD GhcPs -> HsBind GhcPs -> HsDecl GhcPs
forall p. XValD p -> HsBind p -> HsDecl p
ValD XValD GhcPs
i)
enumerateChangesInDeclaration (SigD XSigD GhcPs
x Sig GhcPs
sig) SrcSpan
loc = Enumerator (Sig GhcPs)
enumerateChangeInSignature Sig GhcPs
sig SrcSpan
loc [Change (Sig GhcPs)]
-> (Sig GhcPs -> HsDecl GhcPs) -> [Change (HsDecl GhcPs)]
forall a b. [Change a] -> (a -> b) -> [Change b]
<&&> (XSigD GhcPs -> Sig GhcPs -> HsDecl GhcPs
forall p. XSigD p -> Sig p -> HsDecl p
SigD XSigD GhcPs
x)
enumerateChangesInDeclaration HsDecl GhcPs
_ SrcSpan
_ = []
enumerateChangesInTypeDeclaration :: Enumerator (TyClDecl GhcPs)
enumerateChangesInTypeDeclaration :: Enumerator (TyClDecl GhcPs)
enumerateChangesInTypeDeclaration TyClDecl GhcPs
decl SrcSpan
_ = case TyClDecl GhcPs
decl of
(SynDecl XSynDecl GhcPs
x LIdP GhcPs
name LHsQTyVars GhcPs
var LexicalFixity
fixity (L SrcSpanAnn' (EpAnn AnnListItem)
l HsType GhcPs
typeValue)) -> Enumerator (HsType GhcPs)
enumerateChangeInType HsType GhcPs
typeValue (SrcSpanAnn' (EpAnn AnnListItem) -> SrcSpan
forall a. SrcSpanAnn' a -> SrcSpan
locA SrcSpanAnn' (EpAnn AnnListItem)
l)
[Change (HsType GhcPs)]
-> (HsType GhcPs -> TyClDecl GhcPs) -> [Change (TyClDecl GhcPs)]
forall a b. [Change a] -> (a -> b) -> [Change b]
<&&> (XSynDecl GhcPs
-> LIdP GhcPs
-> LHsQTyVars GhcPs
-> LexicalFixity
-> LHsType GhcPs
-> TyClDecl GhcPs
forall pass.
XSynDecl pass
-> LIdP pass
-> LHsQTyVars pass
-> LexicalFixity
-> LHsType pass
-> TyClDecl pass
SynDecl XSynDecl GhcPs
x LIdP GhcPs
name LHsQTyVars GhcPs
var LexicalFixity
fixity (GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsType GhcPs)
-> TyClDecl GhcPs)
-> (HsType GhcPs
-> GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsType GhcPs))
-> HsType GhcPs
-> TyClDecl GhcPs
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SrcSpanAnn' (EpAnn AnnListItem)
-> HsType GhcPs
-> GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsType GhcPs)
forall l e. l -> e -> GenLocated l e
L SrcSpanAnn' (EpAnn AnnListItem)
l)
[Change (TyClDecl GhcPs)]
-> (Change (TyClDecl GhcPs) -> Change (TyClDecl GhcPs))
-> [Change (TyClDecl GhcPs)]
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> Change (TyClDecl GhcPs) -> Change (TyClDecl GhcPs)
forall node. Outputable node => Change node -> Change node
forceRewrite
TyClDecl GhcPs
_ -> []