haskell-tools-debug 0.8.1.0 → 0.9.0.0
raw patch · 9 files changed
+584/−581 lines, 9 filesdep +haskell-tools-builtin-refactoringsdep +splitdep ~ghcdep ~haskell-tools-astdep ~haskell-tools-backend-ghc
Dependencies added: haskell-tools-builtin-refactorings, split
Dependency ranges changed: ghc, haskell-tools-ast, haskell-tools-backend-ghc, haskell-tools-prettyprint, haskell-tools-refactor
Files
- Language/Haskell/Tools/Debug.hs +13/−12
- Language/Haskell/Tools/Debug/DebugGhcAST.hs +365/−0
- Language/Haskell/Tools/Debug/RangeDebug.hs +50/−0
- Language/Haskell/Tools/Debug/RangeDebugInstances.hs +143/−0
- Language/Haskell/Tools/DebugGhcAST.hs +0/−365
- Language/Haskell/Tools/RangeDebug.hs +0/−50
- Language/Haskell/Tools/RangeDebug/Instances.hs +0/−143
- exe/Main.hs +2/−2
- haskell-tools-debug.cabal +11/−9
Language/Haskell/Tools/Debug.hs view
@@ -4,9 +4,10 @@ #-} module Language.Haskell.Tools.Debug where -import Control.Monad -import Control.Reference +import Control.Monad (Monad(..), (=<<), forM_) import Control.Monad.IO.Class (MonadIO(..)) +import Control.Reference ((^.)) +import Data.List.Split (splitOn) import Data.Maybe (Maybe(..), fromJust) import GHC.Generics (Generic(..)) import System.FilePath (pathSeparator, (</>), (<.>)) @@ -18,16 +19,14 @@ import StringBuffer (hGetStringBuffer) import Language.Haskell.Tools.AST (NodeInfo(..)) -import Language.Haskell.Tools.AST.FromGHC -import Language.Haskell.Tools.DebugGhcAST () +import Language.Haskell.Tools.BackendGHC +import Language.Haskell.Tools.Debug.DebugGhcAST () +import Language.Haskell.Tools.Debug.RangeDebug (srcInfoDebug) +import Language.Haskell.Tools.Debug.RangeDebugInstances () import Language.Haskell.Tools.PrettyPrint (prettyPrint) -import Language.Haskell.Tools.RangeDebug (srcInfoDebug) -import Language.Haskell.Tools.RangeDebug.Instances () -import Language.Haskell.Tools.Refactor.Perform (performCommand, readCommand) -import Language.Haskell.Tools.Refactor.RefactorBase -import Language.Haskell.Tools.Refactor.Prepare -import Language.Haskell.Tools.Refactor.RefactorBase (RefactorChange(..), SourceFileKey(..)) -import Language.Haskell.Tools.Transform +import Language.Haskell.Tools.PrettyPrint.Prepare +import Language.Haskell.Tools.Refactor +import Language.Haskell.Tools.Refactor.Builtin (builtinRefactorings) -- | Should be only used for testing demoRefactor :: String -> String -> [String] -> String -> IO () @@ -78,7 +77,9 @@ liftIO $ putStrLn "=========== pretty printed:" let prettyPrinted = prettyPrint sourced liftIO $ putStrLn prettyPrinted - transformed <- performCommand (either error id $ readCommand command) ((SourceFileKey (moduleSourceFile moduleName) moduleName), sourced) [] + transformed <- performCommand builtinRefactorings (splitOn " " command) + (Right ((SourceFileKey (moduleSourceFile moduleName) moduleName), sourced)) + [] case transformed of Right changes -> do forM_ changes $ \case
+ Language/Haskell/Tools/Debug/DebugGhcAST.hs view
@@ -0,0 +1,365 @@+{-# LANGUAGE StandaloneDeriving + , TypeSynonymInstances + , FlexibleInstances + #-} +-- | A module for showing GHC's syntax tree representation. +module Language.Haskell.Tools.Debug.DebugGhcAST where + +import Language.Haskell.Tools.AST (shortShowSpan) + +import Bag (bagToList, Bag(..)) +import BasicTypes +import BooleanFormula (BooleanFormula(..)) +import Coercion (Var(..), Role(..)) +import ConLike (ConLike(..)) +import CoreSyn (Tickish(..)) +import FieldLabel (FieldLbl(..)) +import ForeignCall +import GHC +import Module (UnitId(..), Module(..), ModuleName(..)) +import OccName (OccName(..)) +import Outputable (Outputable(..), OutputableBndr(..), showSDocUnsafe) +import PatSyn (PatSyn(..)) +import RdrName (RdrName(..)) +import TcEvidence +import UniqFM (UniqFM(..)) + +instance Show a => Show (Located a) where + show (L l a) = "L(" ++ shortShowSpan l ++ ") (" ++ show a ++ ")" + +deriving instance Show (ABExport RdrName) +deriving instance Show (AmbiguousFieldOcc RdrName) +deriving instance Show (AnnDecl RdrName) +deriving instance Show (AnnProvenance RdrName) +deriving instance Show (ApplicativeArg RdrName RdrName) +deriving instance Show (ArithSeqInfo RdrName) +deriving instance Show (BooleanFormula (Located RdrName)) +deriving instance Show (ClsInstDecl RdrName) +deriving instance Show (ConDecl RdrName) +deriving instance Show (ConDeclField RdrName) +deriving instance Show (DataFamInstDecl RdrName) +deriving instance Show (DefaultDecl RdrName) +deriving instance Show (DerivDecl RdrName) +deriving instance Show (FamilyDecl RdrName) +deriving instance Show (FamilyInfo RdrName) +deriving instance Show (FamilyResultSig RdrName) +deriving instance Show (FieldLbl RdrName) +deriving instance Show (FieldOcc RdrName) +deriving instance Show (FixitySig RdrName) +deriving instance Show (ForeignDecl RdrName) +deriving instance Show a => Show (GRHS RdrName a) +deriving instance Show a => Show (GRHSs RdrName a) +deriving instance Show (InjectivityAnn RdrName) +deriving instance Show (HsAppType RdrName) +deriving instance Show (HsBindLR RdrName RdrName) +deriving instance Show (HsBracket RdrName) +deriving instance Show (HsCmd RdrName) +deriving instance Show (HsCmdTop RdrName) +deriving instance Show (HsConDeclDetails RdrName) +deriving instance Show (HsConPatDetails RdrName) +deriving instance Show (HsDataDefn RdrName) +deriving instance Show (HsDecl RdrName) +deriving instance Show (HsExpr RdrName) +deriving instance Show (HsGroup RdrName) +deriving instance Show (HsLocalBindsLR RdrName RdrName) +deriving instance Show (HsMatchContext RdrName) +deriving instance Show (HsModule RdrName) +deriving instance Show (HsOverLit RdrName) +deriving instance Show (HsPatSynDetails (Located RdrName)) +deriving instance Show (HsPatSynDir RdrName) +deriving instance Show (HsRecFields RdrName (LPat RdrName)) +deriving instance Show (HsRecordBinds RdrName) +deriving instance Show (HsSplice RdrName) +deriving instance Show (HsSplicedThing RdrName) +deriving instance Show (HsStmtContext RdrName) +deriving instance Show (HsTupArg RdrName) +deriving instance Show (HsTyVarBndr RdrName) +deriving instance Show (HsType RdrName) +deriving instance Show (HsValBindsLR RdrName RdrName) +deriving instance Show (HsWildCardInfo RdrName) +deriving instance Show (IE RdrName) +deriving instance Show (ImportDecl RdrName) +deriving instance Show (InstDecl RdrName) +deriving instance Show (LHsQTyVars RdrName) +deriving instance Show a => Show (Match RdrName a) +deriving instance Show (MatchFixity RdrName) +deriving instance Show a => Show (MatchGroup RdrName a) +deriving instance Show (ParStmtBlock RdrName RdrName) +deriving instance Show (Pat RdrName) +deriving instance Show (PatSynBind RdrName RdrName) +deriving instance Show (RecordPatSynField (Located RdrName)) +deriving instance Show (RoleAnnotDecl RdrName) +deriving instance Show (RuleBndr RdrName) +deriving instance Show (RuleDecl RdrName) +deriving instance Show (RuleDecls RdrName) +deriving instance Show (Sig RdrName) +deriving instance Show (SpliceDecl RdrName) +deriving instance Show (SyntaxExpr RdrName) +deriving instance Show a => Show (StmtLR RdrName RdrName a) +deriving instance Show (TyClDecl RdrName) +deriving instance Show (TyClGroup RdrName) +deriving instance Show a => Show (TyFamEqn RdrName a) +deriving instance Show (TyFamInstDecl RdrName) +deriving instance Show (VectDecl RdrName) +deriving instance Show (WarnDecl RdrName) +deriving instance Show (WarnDecls RdrName) + + +deriving instance Show (ABExport Name) +deriving instance Show (AmbiguousFieldOcc Name) +deriving instance Show (AnnDecl Name) +deriving instance Show (AnnProvenance Name) +deriving instance Show (ApplicativeArg Name Name) +deriving instance Show (ArithSeqInfo Name) +deriving instance Show (BooleanFormula (Located Name)) +deriving instance Show (ClsInstDecl Name) +deriving instance Show (ConDecl Name) +deriving instance Show (ConDeclField Name) +deriving instance Show (DataFamInstDecl Name) +deriving instance Show (DefaultDecl Name) +deriving instance Show (DerivDecl Name) +deriving instance Show (FamilyDecl Name) +deriving instance Show (FamilyInfo Name) +deriving instance Show (FamilyResultSig Name) +deriving instance Show (FieldLbl Name) +deriving instance Show (FieldOcc Name) +deriving instance Show (FixitySig Name) +deriving instance Show (ForeignDecl Name) +deriving instance Show a => Show (GRHS Name a) +deriving instance Show a => Show (GRHSs Name a) +deriving instance Show (InjectivityAnn Name) +deriving instance Show (HsAppType Name) +deriving instance Show (HsBindLR Name Name) +deriving instance Show (HsBracket Name) +deriving instance Show (HsCmd Name) +deriving instance Show (HsCmdTop Name) +deriving instance Show (HsConDeclDetails Name) +deriving instance Show (HsConPatDetails Name) +deriving instance Show (HsDataDefn Name) +deriving instance Show (HsDecl Name) +deriving instance Show (HsExpr Name) +deriving instance Show (HsGroup Name) +deriving instance Show (HsLocalBindsLR Name Name) +deriving instance Show (HsMatchContext Name) +deriving instance Show (HsModule Name) +deriving instance Show (HsOverLit Name) +deriving instance Show (HsPatSynDetails (Located Name)) +deriving instance Show (HsPatSynDir Name) +deriving instance Show (HsRecFields Name (LPat Name)) +deriving instance Show (HsRecordBinds Name) +deriving instance Show (HsSplice Name) +deriving instance Show (HsSplicedThing Name) +deriving instance Show (HsStmtContext Name) +deriving instance Show (HsTupArg Name) +deriving instance Show (HsTyVarBndr Name) +deriving instance Show (HsType Name) +deriving instance Show (HsValBindsLR Name Name) +deriving instance Show (HsWildCardInfo Name) +deriving instance Show (IE Name) +deriving instance Show (ImportDecl Name) +deriving instance Show (InstDecl Name) +deriving instance Show (LHsQTyVars Name) +deriving instance Show a => Show (Match Name a) +deriving instance Show (MatchFixity Name) +deriving instance Show a => Show (MatchGroup Name a) +deriving instance Show (ParStmtBlock Name Name) +deriving instance Show (Pat Name) +deriving instance Show (PatSynBind Name Name) +deriving instance Show (RecordPatSynField (Located Name)) +deriving instance Show (RoleAnnotDecl Name) +deriving instance Show (RuleBndr Name) +deriving instance Show (RuleDecl Name) +deriving instance Show (RuleDecls Name) +deriving instance Show (Sig Name) +deriving instance Show (SpliceDecl Name) +deriving instance Show (SyntaxExpr Name) +deriving instance Show a => Show (StmtLR Name Name a) +deriving instance Show (TyClDecl Name) +deriving instance Show (TyClGroup Name) +deriving instance Show a => Show (TyFamEqn Name a) +deriving instance Show (TyFamInstDecl Name) +deriving instance Show (VectDecl Name) +deriving instance Show (WarnDecl Name) +deriving instance Show (WarnDecls Name) + + +deriving instance Show (ABExport Id) +deriving instance Show (AmbiguousFieldOcc Id) +deriving instance Show (AnnDecl Id) +deriving instance Show (AnnProvenance Id) +deriving instance Show (ApplicativeArg Id Id) +deriving instance Show (ArithSeqInfo Id) +deriving instance Show (BooleanFormula (Located Id)) +deriving instance Show (ClsInstDecl Id) +deriving instance Show (ConDecl Id) +deriving instance Show (ConDeclField Id) +deriving instance Show (DataFamInstDecl Id) +deriving instance Show (DefaultDecl Id) +deriving instance Show (DerivDecl Id) +deriving instance Show (FamilyDecl Id) +deriving instance Show (FamilyInfo Id) +deriving instance Show (FamilyResultSig Id) +deriving instance Show (FieldLbl Id) +deriving instance Show (FieldOcc Id) +deriving instance Show (FixitySig Id) +deriving instance Show (ForeignDecl Id) +deriving instance Show a => Show (GRHS Id a) +deriving instance Show a => Show (GRHSs Id a) +deriving instance Show (InjectivityAnn Id) +deriving instance Show (HsAppType Id) +deriving instance Show (HsBindLR Id Id) +deriving instance Show (HsBracket Id) +deriving instance Show (HsCmd Id) +deriving instance Show (HsCmdTop Id) +deriving instance Show (HsConDeclDetails Id) +deriving instance Show (HsConPatDetails Id) +deriving instance Show (HsDataDefn Id) +deriving instance Show (HsDecl Id) +deriving instance Show (HsExpr Id) +deriving instance Show (HsGroup Id) +deriving instance Show (HsLocalBindsLR Id Id) +deriving instance Show (HsMatchContext Id) +deriving instance Show (HsModule Id) +deriving instance Show (HsOverLit Id) +deriving instance Show (HsPatSynDetails (Located Id)) +deriving instance Show (HsPatSynDir Id) +deriving instance Show (HsRecFields Id (LPat Id)) +deriving instance Show (HsRecordBinds Id) +deriving instance Show (HsSplice Id) +deriving instance Show (HsSplicedThing Id) +deriving instance Show (HsStmtContext Id) +deriving instance Show (HsTupArg Id) +deriving instance Show (HsTyVarBndr Id) +deriving instance Show (HsType Id) +deriving instance Show (HsValBindsLR Id Id) +deriving instance Show (HsWildCardInfo Id) +deriving instance Show (IE Id) +deriving instance Show (ImportDecl Id) +deriving instance Show (InstDecl Id) +deriving instance Show (LHsQTyVars Id) +deriving instance Show a => Show (Match Id a) +deriving instance Show (MatchFixity Id) +deriving instance Show a => Show (MatchGroup Id a) +deriving instance Show (ParStmtBlock Id Id) +deriving instance Show (Pat Id) +deriving instance Show (PatSynBind Id Id) +deriving instance Show (RecordPatSynField (Located Id)) +deriving instance Show (RoleAnnotDecl Id) +deriving instance Show (RuleBndr Id) +deriving instance Show (RuleDecl Id) +deriving instance Show (RuleDecls Id) +deriving instance Show (Sig Id) +deriving instance Show (SpliceDecl Id) +deriving instance Show (SyntaxExpr Id) +deriving instance Show a => Show (StmtLR Id Id a) +deriving instance Show (TyClDecl Id) +deriving instance Show (TyClGroup Id) +deriving instance Show a => Show (TyFamEqn Id a) +deriving instance Show (TyFamInstDecl Id) +deriving instance Show (VectDecl Id) +deriving instance Show (WarnDecl Id) +deriving instance Show (WarnDecls Id) + +deriving instance Show Activation +deriving instance Show HsArrAppType +deriving instance Show Boxity +deriving instance Show CType +deriving instance Show CImportSpec +deriving instance Show CExportSpec +deriving instance Show CCallConv +deriving instance Show CCallTarget +deriving instance Show ConLike +deriving instance Show DocDecl +deriving instance Show Fixity +deriving instance Show FixityDirection +deriving instance Show ForeignImport +deriving instance Show ForeignExport +deriving instance Show Header +deriving instance Show HsIPName +deriving instance Show HsLit +deriving instance Show HsTupleSort +deriving instance Show HsSrcBang +deriving instance Show InlinePragma +deriving instance Show NewOrData +deriving instance Show Origin +deriving instance Show OverLitVal +deriving instance Show OverlapMode +deriving instance Show PlaceHolder +deriving instance Show Role +deriving instance Show RecFlag +deriving instance Show SpliceExplicitFlag +deriving instance Show TcSpecPrag +deriving instance Show TcSpecPrags +deriving instance Show TransForm +deriving instance Show WarningTxt +deriving instance Show PendingRnSplice +deriving instance Show PendingTcSplice + +instance Show UnboundVar where + show (OutOfScope n _) = "OutOfScope " ++ show n + show (TrueExprHole n) = "TrueExprHole " ++ show n + + + +instance Show ModuleName where + show = showSDocUnsafe . ppr +instance Show TyCon where + show = showSDocUnsafe . ppr +instance Show ClsInst where + show = showSDocUnsafe . ppr +instance Show Type where + show = showSDocUnsafe . ppr +instance Show OccName where + show = showSDocUnsafe . ppr +-- instance Show RdrName where + -- show = showSDocUnsafe . ppr + +deriving instance Show RdrName +deriving instance Show Module +deriving instance Show StringLiteral +deriving instance Show UntypedSpliceFlavour +deriving instance Show SrcUnpackedness +deriving instance Show SrcStrictness +deriving instance Show IEWildcard + +deriving instance Show t => Show (HsImplicitBndrs RdrName t) +deriving instance Show t => Show (HsImplicitBndrs Name t) +deriving instance Show t => Show (HsImplicitBndrs Id t) +deriving instance Show t => Show (HsWildCardBndrs RdrName t) +deriving instance Show t => Show (HsWildCardBndrs Name t) +deriving instance Show t => Show (HsWildCardBndrs Id t) +deriving instance (Show a, Show b) => Show (HsRecField' a b) + + +instance Show UnitId where + show = showSDocUnsafe . ppr +instance Show Name where + show = showSDocUnsafe . ppr +instance Show HsTyLit where + show = showSDocUnsafe . ppr +instance Show Var where + show = showSDocUnsafe . ppr +instance Show DataCon where + show = showSDocUnsafe . ppr +instance Show PatSyn where + show = showSDocUnsafe . ppr +instance Show TcEvBinds where + show = showSDocUnsafe . ppr +instance Show HsWrapper where + show = showSDocUnsafe . ppr +instance Show Class where + show = showSDocUnsafe . ppr +instance Show TcCoercion where + show = showSDocUnsafe . ppr +instance Outputable a => Show (UniqFM a) where + show = showSDocUnsafe . ppr +instance Outputable a => Show (Tickish a) where + show = showSDocUnsafe . ppr +instance OutputableBndr a => Show (HsIPBinds a) where + show = showSDocUnsafe . ppr + +instance Show a => Show (Bag a) where + show = show . bagToList + +instance Show ThModFinalizers where + show _ = ""
+ Language/Haskell/Tools/Debug/RangeDebug.hs view
@@ -0,0 +1,50 @@+{-# LANGUAGE TypeOperators + , DefaultSignatures + , StandaloneDeriving + , FlexibleContexts + , FlexibleInstances + , MultiParamTypeClasses + , TypeFamilies + #-} +-- | A module for displaying debug info about the source annotations of the syntax tree in different phases. +module Language.Haskell.Tools.Debug.RangeDebug where + +import Control.Reference () +import GHC.Generics +import Language.Haskell.Tools.AST (SourceInfo(..), Domain(..)) +import Language.Haskell.Tools.BackendGHC () +import Language.Haskell.Tools.PrettyPrint.Prepare () + +srcInfoDebug :: TreeDebug e dom st => e dom st -> String +srcInfoDebug = treeDebug' 0 + +class (SourceInfo st, Domain dom, Show (e dom st)) + => TreeDebug e dom st where + treeDebug' :: Int -> e dom st -> String + default treeDebug' :: (GTreeDebug (Rep (e dom st)), Generic (e dom st), Domain dom) => Int -> e dom st -> String + treeDebug' i = gTreeDebug i . from + +class GTreeDebug f where + gTreeDebug :: Int -> f p -> String + +instance GTreeDebug V1 where + gTreeDebug _ = error "GTreeDebug V1" + +instance GTreeDebug U1 where + gTreeDebug _ U1 = "" + +instance (GTreeDebug f, GTreeDebug g) => GTreeDebug (f :+: g) where + gTreeDebug i (L1 x) = gTreeDebug i x + gTreeDebug i (R1 x) = gTreeDebug i x + +instance (GTreeDebug f, GTreeDebug g) => GTreeDebug (f :*: g) where + gTreeDebug i (x :*: y) = gTreeDebug i x ++ gTreeDebug i y + +instance {-# OVERLAPPING #-} TreeDebug e dom st => GTreeDebug (K1 i (e dom st)) where + gTreeDebug i (K1 x) = treeDebug' i x + +instance {-# OVERLAPPABLE #-} GTreeDebug (K1 i c) where + gTreeDebug _ (K1 _) = "" + +instance GTreeDebug f => GTreeDebug (M1 i t f) where + gTreeDebug i (M1 x) = gTreeDebug i x
+ Language/Haskell/Tools/Debug/RangeDebugInstances.hs view
@@ -0,0 +1,143 @@+{-# LANGUAGE FlexibleContexts + , FlexibleInstances + , MultiParamTypeClasses + , StandaloneDeriving + , DeriveGeneric + , UndecidableInstances + #-} +module Language.Haskell.Tools.Debug.RangeDebugInstances where + +import Language.Haskell.Tools.Debug.RangeDebug (TreeDebug(..)) + +import Control.Reference ((^.)) +import GHC.Generics (Generic(..)) + +import Language.Haskell.Tools.AST + +-- Annotations +instance TreeDebug e dom st => TreeDebug (Ann e) dom st where + treeDebug' i (Ann a e) = identLine i ++ show (a ^. sourceInfo) ++ " " ++ take 40 (show e) ++ "..." ++ treeDebug' (i+1) e + +identLine :: Int -> String +identLine i = "\n" ++ replicate (i*2) ' ' + +instance TreeDebug e dom st => TreeDebug (AnnListG e) dom st where + treeDebug' i (AnnListG a ls) = identLine i ++ show (a ^. sourceInfo) ++ " <*>" ++ concatMap (treeDebug' (i + 1)) ls + +instance TreeDebug e dom st => TreeDebug (AnnMaybeG e) dom st where + treeDebug' i (AnnMaybeG a e) = identLine i ++ show (a ^. sourceInfo) ++ " <?>" ++ maybe "" (\e -> treeDebug' (i + 1) e) e + +-- Modules +instance (SourceInfo st, Domain dom) => TreeDebug UModule dom st +instance (SourceInfo st, Domain dom) => TreeDebug UModuleHead dom st +instance (SourceInfo st, Domain dom) => TreeDebug UExportSpecs dom st +instance (SourceInfo st, Domain dom) => TreeDebug UExportSpec dom st +instance (SourceInfo st, Domain dom) => TreeDebug UIESpec dom st +instance (SourceInfo st, Domain dom) => TreeDebug USubSpec dom st +instance (SourceInfo st, Domain dom) => TreeDebug UModulePragma dom st +instance (SourceInfo st, Domain dom) => TreeDebug UFilePragma dom st +instance (SourceInfo st, Domain dom) => TreeDebug UImportDecl dom st +instance (SourceInfo st, Domain dom) => TreeDebug UImportSpec dom st +instance (SourceInfo st, Domain dom) => TreeDebug UImportModifier dom st +instance (SourceInfo st, Domain dom) => TreeDebug UImportQualified dom st +instance (SourceInfo st, Domain dom) => TreeDebug UImportSource dom st +instance (SourceInfo st, Domain dom) => TreeDebug UImportSafe dom st +instance (SourceInfo st, Domain dom) => TreeDebug UTypeNamespace dom st +instance (SourceInfo st, Domain dom) => TreeDebug UImportRenaming dom st + +-- Declarations +instance (SourceInfo st, Domain dom) => TreeDebug UDecl dom st +instance (SourceInfo st, Domain dom) => TreeDebug UClassBody dom st +instance (SourceInfo st, Domain dom) => TreeDebug UClassElement dom st +instance (SourceInfo st, Domain dom) => TreeDebug UDeclHead dom st +instance (SourceInfo st, Domain dom) => TreeDebug UInstBody dom st +instance (SourceInfo st, Domain dom) => TreeDebug UInstBodyDecl dom st +instance (SourceInfo st, Domain dom) => TreeDebug UGadtConDecl dom st +instance (SourceInfo st, Domain dom) => TreeDebug UGadtConType dom st +instance (SourceInfo st, Domain dom) => TreeDebug UFieldWildcard dom st +instance (SourceInfo st, Domain dom) => TreeDebug UFunDeps dom st +instance (SourceInfo st, Domain dom) => TreeDebug UFunDep dom st +instance (SourceInfo st, Domain dom) => TreeDebug UConDecl dom st +instance (SourceInfo st, Domain dom) => TreeDebug UFieldDecl dom st +instance (SourceInfo st, Domain dom) => TreeDebug UDeriving dom st +instance (SourceInfo st, Domain dom) => TreeDebug UInstanceRule dom st +instance (SourceInfo st, Domain dom) => TreeDebug UInstanceHead dom st +instance (SourceInfo st, Domain dom) => TreeDebug UTypeEqn dom st +instance (SourceInfo st, Domain dom) => TreeDebug UKindConstraint dom st +instance (SourceInfo st, Domain dom) => TreeDebug UTyVar dom st +instance (SourceInfo st, Domain dom) => TreeDebug UType dom st +instance (SourceInfo st, Domain dom) => TreeDebug UKind dom st +instance (SourceInfo st, Domain dom) => TreeDebug UContext dom st +instance (SourceInfo st, Domain dom) => TreeDebug UAssertion dom st +instance (SourceInfo st, Domain dom) => TreeDebug UExpr dom st +instance (SourceInfo st, Domain dom, TreeDebug expr dom st, Generic (expr dom st)) => TreeDebug (UStmt' expr) dom st +instance (SourceInfo st, Domain dom) => TreeDebug UCompStmt dom st +instance (SourceInfo st, Domain dom) => TreeDebug UValueBind dom st +instance (SourceInfo st, Domain dom) => TreeDebug UPattern dom st +instance (SourceInfo st, Domain dom) => TreeDebug UPatternField dom st +instance (SourceInfo st, Domain dom) => TreeDebug USplice dom st +instance (SourceInfo st, Domain dom) => TreeDebug QQString dom st +instance (SourceInfo st, Domain dom) => TreeDebug UMatch dom st +instance (SourceInfo st, Domain dom, TreeDebug expr dom st, Generic (expr dom st)) => TreeDebug (UAlt' expr) dom st +instance (SourceInfo st, Domain dom) => TreeDebug URhs dom st +instance (SourceInfo st, Domain dom) => TreeDebug UGuardedRhs dom st +instance (SourceInfo st, Domain dom) => TreeDebug UFieldUpdate dom st +instance (SourceInfo st, Domain dom) => TreeDebug UBracket dom st +instance (SourceInfo st, Domain dom) => TreeDebug UTopLevelPragma dom st +instance (SourceInfo st, Domain dom) => TreeDebug URule dom st +instance (SourceInfo st, Domain dom) => TreeDebug URuleVar dom st +instance (SourceInfo st, Domain dom) => TreeDebug UAnnotationSubject dom st +instance (SourceInfo st, Domain dom) => TreeDebug UMinimalFormula dom st +instance (SourceInfo st, Domain dom) => TreeDebug UExprPragma dom st +instance (SourceInfo st, Domain dom) => TreeDebug USourceRange dom st +instance (SourceInfo st, Domain dom) => TreeDebug Number dom st +instance (SourceInfo st, Domain dom) => TreeDebug UQuasiQuote dom st +instance (SourceInfo st, Domain dom) => TreeDebug URhsGuard dom st +instance (SourceInfo st, Domain dom) => TreeDebug ULocalBind dom st +instance (SourceInfo st, Domain dom) => TreeDebug ULocalBinds dom st +instance (SourceInfo st, Domain dom) => TreeDebug UFixitySignature dom st +instance (SourceInfo st, Domain dom) => TreeDebug UTypeSignature dom st +instance (SourceInfo st, Domain dom) => TreeDebug UListCompBody dom st +instance (SourceInfo st, Domain dom) => TreeDebug UTupSecElem dom st +instance (SourceInfo st, Domain dom) => TreeDebug UTypeFamily dom st +instance (SourceInfo st, Domain dom) => TreeDebug UTypeFamilySpec dom st +instance (SourceInfo st, Domain dom) => TreeDebug UInjectivityAnn dom st +instance (SourceInfo st, Domain dom, TreeDebug expr dom st, Generic (expr dom st)) => TreeDebug (UCaseRhs' expr) dom st +instance (SourceInfo st, Domain dom, TreeDebug expr dom st, Generic (expr dom st)) => TreeDebug (UGuardedCaseRhs' expr) dom st +instance (SourceInfo st, Domain dom) => TreeDebug UPatternSynonym dom st +instance (SourceInfo st, Domain dom) => TreeDebug UPatSynRhs dom st +instance (SourceInfo st, Domain dom) => TreeDebug UPatSynLhs dom st +instance (SourceInfo st, Domain dom) => TreeDebug UPatSynWhere dom st +instance (SourceInfo st, Domain dom) => TreeDebug UPatternTypeSignature dom st +instance (SourceInfo st, Domain dom) => TreeDebug URole dom st +instance (SourceInfo st, Domain dom) => TreeDebug UCmd dom st +instance (SourceInfo st, Domain dom) => TreeDebug ULanguageExtension dom st +instance (SourceInfo st, Domain dom) => TreeDebug UMatchLhs dom st +instance (SourceInfo st, Domain dom) => TreeDebug UInlinePragma dom st +instance (SourceInfo st, Domain dom) => TreeDebug USpecializePragma dom st + +-- ULiteral +instance (SourceInfo st, Domain dom) => TreeDebug ULiteral dom st +instance (SourceInfo st, Domain dom, TreeDebug k dom st, Generic (k dom st)) => TreeDebug (UPromoted k) dom st + +-- Base +instance (SourceInfo st, Domain dom) => TreeDebug UOperator dom st +instance (SourceInfo st, Domain dom) => TreeDebug UName dom st +instance (SourceInfo st, Domain dom) => TreeDebug UQualifiedName dom st +instance (SourceInfo st, Domain dom) => TreeDebug UModuleName dom st +instance (SourceInfo st, Domain dom) => TreeDebug UNamePart dom st +instance (SourceInfo st, Domain dom) => TreeDebug UStringNode dom st +instance (SourceInfo st, Domain dom) => TreeDebug UDataOrNewtypeKeyword dom st +instance (SourceInfo st, Domain dom) => TreeDebug UDoKind dom st +instance (SourceInfo st, Domain dom) => TreeDebug TypeKeyword dom st +instance (SourceInfo st, Domain dom) => TreeDebug UOverlapPragma dom st +instance (SourceInfo st, Domain dom) => TreeDebug UCallConv dom st +instance (SourceInfo st, Domain dom) => TreeDebug UArrowAppl dom st +instance (SourceInfo st, Domain dom) => TreeDebug USafety dom st +instance (SourceInfo st, Domain dom) => TreeDebug UConlikeAnnot dom st +instance (SourceInfo st, Domain dom) => TreeDebug Assoc dom st +instance (SourceInfo st, Domain dom) => TreeDebug Precedence dom st +instance (SourceInfo st, Domain dom) => TreeDebug LineNumber dom st +instance (SourceInfo st, Domain dom) => TreeDebug UPhaseControl dom st +instance (SourceInfo st, Domain dom) => TreeDebug PhaseNumber dom st +instance (SourceInfo st, Domain dom) => TreeDebug PhaseInvert dom st
− Language/Haskell/Tools/DebugGhcAST.hs
@@ -1,365 +0,0 @@-{-# LANGUAGE StandaloneDeriving - , TypeSynonymInstances - , FlexibleInstances - #-} --- | A module for showing GHC's syntax tree representation. -module Language.Haskell.Tools.DebugGhcAST where - -import Language.Haskell.Tools.AST (shortShowSpan) - -import Bag (bagToList, Bag(..)) -import BasicTypes -import BooleanFormula (BooleanFormula(..)) -import Coercion (Var(..), Role(..)) -import ConLike (ConLike(..)) -import CoreSyn (Tickish(..)) -import FieldLabel (FieldLbl(..)) -import ForeignCall -import GHC -import Module (UnitId(..), Module(..), ModuleName(..)) -import OccName (OccName(..)) -import Outputable (Outputable(..), OutputableBndr(..), showSDocUnsafe) -import PatSyn (PatSyn(..)) -import RdrName (RdrName(..)) -import TcEvidence -import UniqFM (UniqFM(..)) - -instance Show a => Show (Located a) where - show (L l a) = "L(" ++ shortShowSpan l ++ ") (" ++ show a ++ ")" - -deriving instance Show (ABExport RdrName) -deriving instance Show (AmbiguousFieldOcc RdrName) -deriving instance Show (AnnDecl RdrName) -deriving instance Show (AnnProvenance RdrName) -deriving instance Show (ApplicativeArg RdrName RdrName) -deriving instance Show (ArithSeqInfo RdrName) -deriving instance Show (BooleanFormula (Located RdrName)) -deriving instance Show (ClsInstDecl RdrName) -deriving instance Show (ConDecl RdrName) -deriving instance Show (ConDeclField RdrName) -deriving instance Show (DataFamInstDecl RdrName) -deriving instance Show (DefaultDecl RdrName) -deriving instance Show (DerivDecl RdrName) -deriving instance Show (FamilyDecl RdrName) -deriving instance Show (FamilyInfo RdrName) -deriving instance Show (FamilyResultSig RdrName) -deriving instance Show (FieldLbl RdrName) -deriving instance Show (FieldOcc RdrName) -deriving instance Show (FixitySig RdrName) -deriving instance Show (ForeignDecl RdrName) -deriving instance Show a => Show (GRHS RdrName a) -deriving instance Show a => Show (GRHSs RdrName a) -deriving instance Show (InjectivityAnn RdrName) -deriving instance Show (HsAppType RdrName) -deriving instance Show (HsBindLR RdrName RdrName) -deriving instance Show (HsBracket RdrName) -deriving instance Show (HsCmd RdrName) -deriving instance Show (HsCmdTop RdrName) -deriving instance Show (HsConDeclDetails RdrName) -deriving instance Show (HsConPatDetails RdrName) -deriving instance Show (HsDataDefn RdrName) -deriving instance Show (HsDecl RdrName) -deriving instance Show (HsExpr RdrName) -deriving instance Show (HsGroup RdrName) -deriving instance Show (HsLocalBindsLR RdrName RdrName) -deriving instance Show (HsMatchContext RdrName) -deriving instance Show (HsModule RdrName) -deriving instance Show (HsOverLit RdrName) -deriving instance Show (HsPatSynDetails (Located RdrName)) -deriving instance Show (HsPatSynDir RdrName) -deriving instance Show (HsRecFields RdrName (LPat RdrName)) -deriving instance Show (HsRecordBinds RdrName) -deriving instance Show (HsSplice RdrName) -deriving instance Show (HsSplicedThing RdrName) -deriving instance Show (HsStmtContext RdrName) -deriving instance Show (HsTupArg RdrName) -deriving instance Show (HsTyVarBndr RdrName) -deriving instance Show (HsType RdrName) -deriving instance Show (HsValBindsLR RdrName RdrName) -deriving instance Show (HsWildCardInfo RdrName) -deriving instance Show (IE RdrName) -deriving instance Show (ImportDecl RdrName) -deriving instance Show (InstDecl RdrName) -deriving instance Show (LHsQTyVars RdrName) -deriving instance Show a => Show (Match RdrName a) -deriving instance Show (MatchFixity RdrName) -deriving instance Show a => Show (MatchGroup RdrName a) -deriving instance Show (ParStmtBlock RdrName RdrName) -deriving instance Show (Pat RdrName) -deriving instance Show (PatSynBind RdrName RdrName) -deriving instance Show (RecordPatSynField (Located RdrName)) -deriving instance Show (RoleAnnotDecl RdrName) -deriving instance Show (RuleBndr RdrName) -deriving instance Show (RuleDecl RdrName) -deriving instance Show (RuleDecls RdrName) -deriving instance Show (Sig RdrName) -deriving instance Show (SpliceDecl RdrName) -deriving instance Show (SyntaxExpr RdrName) -deriving instance Show a => Show (StmtLR RdrName RdrName a) -deriving instance Show (TyClDecl RdrName) -deriving instance Show (TyClGroup RdrName) -deriving instance Show a => Show (TyFamEqn RdrName a) -deriving instance Show (TyFamInstDecl RdrName) -deriving instance Show (VectDecl RdrName) -deriving instance Show (WarnDecl RdrName) -deriving instance Show (WarnDecls RdrName) - - -deriving instance Show (ABExport Name) -deriving instance Show (AmbiguousFieldOcc Name) -deriving instance Show (AnnDecl Name) -deriving instance Show (AnnProvenance Name) -deriving instance Show (ApplicativeArg Name Name) -deriving instance Show (ArithSeqInfo Name) -deriving instance Show (BooleanFormula (Located Name)) -deriving instance Show (ClsInstDecl Name) -deriving instance Show (ConDecl Name) -deriving instance Show (ConDeclField Name) -deriving instance Show (DataFamInstDecl Name) -deriving instance Show (DefaultDecl Name) -deriving instance Show (DerivDecl Name) -deriving instance Show (FamilyDecl Name) -deriving instance Show (FamilyInfo Name) -deriving instance Show (FamilyResultSig Name) -deriving instance Show (FieldLbl Name) -deriving instance Show (FieldOcc Name) -deriving instance Show (FixitySig Name) -deriving instance Show (ForeignDecl Name) -deriving instance Show a => Show (GRHS Name a) -deriving instance Show a => Show (GRHSs Name a) -deriving instance Show (InjectivityAnn Name) -deriving instance Show (HsAppType Name) -deriving instance Show (HsBindLR Name Name) -deriving instance Show (HsBracket Name) -deriving instance Show (HsCmd Name) -deriving instance Show (HsCmdTop Name) -deriving instance Show (HsConDeclDetails Name) -deriving instance Show (HsConPatDetails Name) -deriving instance Show (HsDataDefn Name) -deriving instance Show (HsDecl Name) -deriving instance Show (HsExpr Name) -deriving instance Show (HsGroup Name) -deriving instance Show (HsLocalBindsLR Name Name) -deriving instance Show (HsMatchContext Name) -deriving instance Show (HsModule Name) -deriving instance Show (HsOverLit Name) -deriving instance Show (HsPatSynDetails (Located Name)) -deriving instance Show (HsPatSynDir Name) -deriving instance Show (HsRecFields Name (LPat Name)) -deriving instance Show (HsRecordBinds Name) -deriving instance Show (HsSplice Name) -deriving instance Show (HsSplicedThing Name) -deriving instance Show (HsStmtContext Name) -deriving instance Show (HsTupArg Name) -deriving instance Show (HsTyVarBndr Name) -deriving instance Show (HsType Name) -deriving instance Show (HsValBindsLR Name Name) -deriving instance Show (HsWildCardInfo Name) -deriving instance Show (IE Name) -deriving instance Show (ImportDecl Name) -deriving instance Show (InstDecl Name) -deriving instance Show (LHsQTyVars Name) -deriving instance Show a => Show (Match Name a) -deriving instance Show (MatchFixity Name) -deriving instance Show a => Show (MatchGroup Name a) -deriving instance Show (ParStmtBlock Name Name) -deriving instance Show (Pat Name) -deriving instance Show (PatSynBind Name Name) -deriving instance Show (RecordPatSynField (Located Name)) -deriving instance Show (RoleAnnotDecl Name) -deriving instance Show (RuleBndr Name) -deriving instance Show (RuleDecl Name) -deriving instance Show (RuleDecls Name) -deriving instance Show (Sig Name) -deriving instance Show (SpliceDecl Name) -deriving instance Show (SyntaxExpr Name) -deriving instance Show a => Show (StmtLR Name Name a) -deriving instance Show (TyClDecl Name) -deriving instance Show (TyClGroup Name) -deriving instance Show a => Show (TyFamEqn Name a) -deriving instance Show (TyFamInstDecl Name) -deriving instance Show (VectDecl Name) -deriving instance Show (WarnDecl Name) -deriving instance Show (WarnDecls Name) - - -deriving instance Show (ABExport Id) -deriving instance Show (AmbiguousFieldOcc Id) -deriving instance Show (AnnDecl Id) -deriving instance Show (AnnProvenance Id) -deriving instance Show (ApplicativeArg Id Id) -deriving instance Show (ArithSeqInfo Id) -deriving instance Show (BooleanFormula (Located Id)) -deriving instance Show (ClsInstDecl Id) -deriving instance Show (ConDecl Id) -deriving instance Show (ConDeclField Id) -deriving instance Show (DataFamInstDecl Id) -deriving instance Show (DefaultDecl Id) -deriving instance Show (DerivDecl Id) -deriving instance Show (FamilyDecl Id) -deriving instance Show (FamilyInfo Id) -deriving instance Show (FamilyResultSig Id) -deriving instance Show (FieldLbl Id) -deriving instance Show (FieldOcc Id) -deriving instance Show (FixitySig Id) -deriving instance Show (ForeignDecl Id) -deriving instance Show a => Show (GRHS Id a) -deriving instance Show a => Show (GRHSs Id a) -deriving instance Show (InjectivityAnn Id) -deriving instance Show (HsAppType Id) -deriving instance Show (HsBindLR Id Id) -deriving instance Show (HsBracket Id) -deriving instance Show (HsCmd Id) -deriving instance Show (HsCmdTop Id) -deriving instance Show (HsConDeclDetails Id) -deriving instance Show (HsConPatDetails Id) -deriving instance Show (HsDataDefn Id) -deriving instance Show (HsDecl Id) -deriving instance Show (HsExpr Id) -deriving instance Show (HsGroup Id) -deriving instance Show (HsLocalBindsLR Id Id) -deriving instance Show (HsMatchContext Id) -deriving instance Show (HsModule Id) -deriving instance Show (HsOverLit Id) -deriving instance Show (HsPatSynDetails (Located Id)) -deriving instance Show (HsPatSynDir Id) -deriving instance Show (HsRecFields Id (LPat Id)) -deriving instance Show (HsRecordBinds Id) -deriving instance Show (HsSplice Id) -deriving instance Show (HsSplicedThing Id) -deriving instance Show (HsStmtContext Id) -deriving instance Show (HsTupArg Id) -deriving instance Show (HsTyVarBndr Id) -deriving instance Show (HsType Id) -deriving instance Show (HsValBindsLR Id Id) -deriving instance Show (HsWildCardInfo Id) -deriving instance Show (IE Id) -deriving instance Show (ImportDecl Id) -deriving instance Show (InstDecl Id) -deriving instance Show (LHsQTyVars Id) -deriving instance Show a => Show (Match Id a) -deriving instance Show (MatchFixity Id) -deriving instance Show a => Show (MatchGroup Id a) -deriving instance Show (ParStmtBlock Id Id) -deriving instance Show (Pat Id) -deriving instance Show (PatSynBind Id Id) -deriving instance Show (RecordPatSynField (Located Id)) -deriving instance Show (RoleAnnotDecl Id) -deriving instance Show (RuleBndr Id) -deriving instance Show (RuleDecl Id) -deriving instance Show (RuleDecls Id) -deriving instance Show (Sig Id) -deriving instance Show (SpliceDecl Id) -deriving instance Show (SyntaxExpr Id) -deriving instance Show a => Show (StmtLR Id Id a) -deriving instance Show (TyClDecl Id) -deriving instance Show (TyClGroup Id) -deriving instance Show a => Show (TyFamEqn Id a) -deriving instance Show (TyFamInstDecl Id) -deriving instance Show (VectDecl Id) -deriving instance Show (WarnDecl Id) -deriving instance Show (WarnDecls Id) - -deriving instance Show Activation -deriving instance Show HsArrAppType -deriving instance Show Boxity -deriving instance Show CType -deriving instance Show CImportSpec -deriving instance Show CExportSpec -deriving instance Show CCallConv -deriving instance Show CCallTarget -deriving instance Show ConLike -deriving instance Show DocDecl -deriving instance Show Fixity -deriving instance Show FixityDirection -deriving instance Show ForeignImport -deriving instance Show ForeignExport -deriving instance Show Header -deriving instance Show HsIPName -deriving instance Show HsLit -deriving instance Show HsTupleSort -deriving instance Show HsSrcBang -deriving instance Show InlinePragma -deriving instance Show NewOrData -deriving instance Show Origin -deriving instance Show OverLitVal -deriving instance Show OverlapMode -deriving instance Show PlaceHolder -deriving instance Show Role -deriving instance Show RecFlag -deriving instance Show SpliceExplicitFlag -deriving instance Show TcSpecPrag -deriving instance Show TcSpecPrags -deriving instance Show TransForm -deriving instance Show WarningTxt -deriving instance Show PendingRnSplice -deriving instance Show PendingTcSplice - -instance Show UnboundVar where - show (OutOfScope n _) = "OutOfScope " ++ show n - show (TrueExprHole n) = "TrueExprHole " ++ show n - - - -instance Show ModuleName where - show = showSDocUnsafe . ppr -instance Show TyCon where - show = showSDocUnsafe . ppr -instance Show ClsInst where - show = showSDocUnsafe . ppr -instance Show Type where - show = showSDocUnsafe . ppr -instance Show OccName where - show = showSDocUnsafe . ppr --- instance Show RdrName where - -- show = showSDocUnsafe . ppr - -deriving instance Show RdrName -deriving instance Show Module -deriving instance Show StringLiteral -deriving instance Show UntypedSpliceFlavour -deriving instance Show SrcUnpackedness -deriving instance Show SrcStrictness -deriving instance Show IEWildcard - -deriving instance Show t => Show (HsImplicitBndrs RdrName t) -deriving instance Show t => Show (HsImplicitBndrs Name t) -deriving instance Show t => Show (HsImplicitBndrs Id t) -deriving instance Show t => Show (HsWildCardBndrs RdrName t) -deriving instance Show t => Show (HsWildCardBndrs Name t) -deriving instance Show t => Show (HsWildCardBndrs Id t) -deriving instance (Show a, Show b) => Show (HsRecField' a b) - - -instance Show UnitId where - show = showSDocUnsafe . ppr -instance Show Name where - show = showSDocUnsafe . ppr -instance Show HsTyLit where - show = showSDocUnsafe . ppr -instance Show Var where - show = showSDocUnsafe . ppr -instance Show DataCon where - show = showSDocUnsafe . ppr -instance Show PatSyn where - show = showSDocUnsafe . ppr -instance Show TcEvBinds where - show = showSDocUnsafe . ppr -instance Show HsWrapper where - show = showSDocUnsafe . ppr -instance Show Class where - show = showSDocUnsafe . ppr -instance Show TcCoercion where - show = showSDocUnsafe . ppr -instance Outputable a => Show (UniqFM a) where - show = showSDocUnsafe . ppr -instance Outputable a => Show (Tickish a) where - show = showSDocUnsafe . ppr -instance OutputableBndr a => Show (HsIPBinds a) where - show = showSDocUnsafe . ppr - -instance Show a => Show (Bag a) where - show = show . bagToList - -instance Show ThModFinalizers where - show _ = ""
− Language/Haskell/Tools/RangeDebug.hs
@@ -1,50 +0,0 @@-{-# LANGUAGE TypeOperators - , DefaultSignatures - , StandaloneDeriving - , FlexibleContexts - , FlexibleInstances - , MultiParamTypeClasses - , TypeFamilies - #-} --- | A module for displaying debug info about the source annotations of the syntax tree in different phases. -module Language.Haskell.Tools.RangeDebug where - -import Control.Reference () -import GHC.Generics -import Language.Haskell.Tools.AST (SourceInfo(..), Domain(..)) -import Language.Haskell.Tools.AST.FromGHC () -import Language.Haskell.Tools.Transform () - -srcInfoDebug :: TreeDebug e dom st => e dom st -> String -srcInfoDebug = treeDebug' 0 - -class (SourceInfo st, Domain dom, Show (e dom st)) - => TreeDebug e dom st where - treeDebug' :: Int -> e dom st -> String - default treeDebug' :: (GTreeDebug (Rep (e dom st)), Generic (e dom st), Domain dom) => Int -> e dom st -> String - treeDebug' i = gTreeDebug i . from - -class GTreeDebug f where - gTreeDebug :: Int -> f p -> String - -instance GTreeDebug V1 where - gTreeDebug _ = error "GTreeDebug V1" - -instance GTreeDebug U1 where - gTreeDebug _ U1 = "" - -instance (GTreeDebug f, GTreeDebug g) => GTreeDebug (f :+: g) where - gTreeDebug i (L1 x) = gTreeDebug i x - gTreeDebug i (R1 x) = gTreeDebug i x - -instance (GTreeDebug f, GTreeDebug g) => GTreeDebug (f :*: g) where - gTreeDebug i (x :*: y) = gTreeDebug i x ++ gTreeDebug i y - -instance {-# OVERLAPPING #-} TreeDebug e dom st => GTreeDebug (K1 i (e dom st)) where - gTreeDebug i (K1 x) = treeDebug' i x - -instance {-# OVERLAPPABLE #-} GTreeDebug (K1 i c) where - gTreeDebug i (K1 x) = "" - -instance GTreeDebug f => GTreeDebug (M1 i t f) where - gTreeDebug i (M1 x) = gTreeDebug i x
− Language/Haskell/Tools/RangeDebug/Instances.hs
@@ -1,143 +0,0 @@-{-# LANGUAGE FlexibleContexts - , FlexibleInstances - , MultiParamTypeClasses - , StandaloneDeriving - , DeriveGeneric - , UndecidableInstances - #-} -module Language.Haskell.Tools.RangeDebug.Instances where - -import Language.Haskell.Tools.RangeDebug (TreeDebug(..)) - -import Control.Reference ((^.)) -import GHC.Generics (Generic(..)) - -import Language.Haskell.Tools.AST - --- Annotations -instance TreeDebug e dom st => TreeDebug (Ann e) dom st where - treeDebug' i (Ann a e) = identLine i ++ show (a ^. sourceInfo) ++ " " ++ take 40 (show e) ++ "..." ++ treeDebug' (i+1) e - -identLine :: Int -> String -identLine i = "\n" ++ replicate (i*2) ' ' - -instance TreeDebug e dom st => TreeDebug (AnnListG e) dom st where - treeDebug' i (AnnListG a ls) = identLine i ++ show (a ^. sourceInfo) ++ " <*>" ++ concatMap (treeDebug' (i + 1)) ls - -instance TreeDebug e dom st => TreeDebug (AnnMaybeG e) dom st where - treeDebug' i (AnnMaybeG a e) = identLine i ++ show (a ^. sourceInfo) ++ " <?>" ++ maybe "" (\e -> treeDebug' (i + 1) e) e - --- Modules -instance (SourceInfo st, Domain dom) => TreeDebug UModule dom st -instance (SourceInfo st, Domain dom) => TreeDebug UModuleHead dom st -instance (SourceInfo st, Domain dom) => TreeDebug UExportSpecs dom st -instance (SourceInfo st, Domain dom) => TreeDebug UExportSpec dom st -instance (SourceInfo st, Domain dom) => TreeDebug UIESpec dom st -instance (SourceInfo st, Domain dom) => TreeDebug USubSpec dom st -instance (SourceInfo st, Domain dom) => TreeDebug UModulePragma dom st -instance (SourceInfo st, Domain dom) => TreeDebug UFilePragma dom st -instance (SourceInfo st, Domain dom) => TreeDebug UImportDecl dom st -instance (SourceInfo st, Domain dom) => TreeDebug UImportSpec dom st -instance (SourceInfo st, Domain dom) => TreeDebug UImportModifier dom st -instance (SourceInfo st, Domain dom) => TreeDebug UImportQualified dom st -instance (SourceInfo st, Domain dom) => TreeDebug UImportSource dom st -instance (SourceInfo st, Domain dom) => TreeDebug UImportSafe dom st -instance (SourceInfo st, Domain dom) => TreeDebug UTypeNamespace dom st -instance (SourceInfo st, Domain dom) => TreeDebug UImportRenaming dom st - --- Declarations -instance (SourceInfo st, Domain dom) => TreeDebug UDecl dom st -instance (SourceInfo st, Domain dom) => TreeDebug UClassBody dom st -instance (SourceInfo st, Domain dom) => TreeDebug UClassElement dom st -instance (SourceInfo st, Domain dom) => TreeDebug UDeclHead dom st -instance (SourceInfo st, Domain dom) => TreeDebug UInstBody dom st -instance (SourceInfo st, Domain dom) => TreeDebug UInstBodyDecl dom st -instance (SourceInfo st, Domain dom) => TreeDebug UGadtConDecl dom st -instance (SourceInfo st, Domain dom) => TreeDebug UGadtConType dom st -instance (SourceInfo st, Domain dom) => TreeDebug UFieldWildcard dom st -instance (SourceInfo st, Domain dom) => TreeDebug UFunDeps dom st -instance (SourceInfo st, Domain dom) => TreeDebug UFunDep dom st -instance (SourceInfo st, Domain dom) => TreeDebug UConDecl dom st -instance (SourceInfo st, Domain dom) => TreeDebug UFieldDecl dom st -instance (SourceInfo st, Domain dom) => TreeDebug UDeriving dom st -instance (SourceInfo st, Domain dom) => TreeDebug UInstanceRule dom st -instance (SourceInfo st, Domain dom) => TreeDebug UInstanceHead dom st -instance (SourceInfo st, Domain dom) => TreeDebug UTypeEqn dom st -instance (SourceInfo st, Domain dom) => TreeDebug UKindConstraint dom st -instance (SourceInfo st, Domain dom) => TreeDebug UTyVar dom st -instance (SourceInfo st, Domain dom) => TreeDebug UType dom st -instance (SourceInfo st, Domain dom) => TreeDebug UKind dom st -instance (SourceInfo st, Domain dom) => TreeDebug UContext dom st -instance (SourceInfo st, Domain dom) => TreeDebug UAssertion dom st -instance (SourceInfo st, Domain dom) => TreeDebug UExpr dom st -instance (SourceInfo st, Domain dom, TreeDebug expr dom st, Generic (expr dom st)) => TreeDebug (UStmt' expr) dom st -instance (SourceInfo st, Domain dom) => TreeDebug UCompStmt dom st -instance (SourceInfo st, Domain dom) => TreeDebug UValueBind dom st -instance (SourceInfo st, Domain dom) => TreeDebug UPattern dom st -instance (SourceInfo st, Domain dom) => TreeDebug UPatternField dom st -instance (SourceInfo st, Domain dom) => TreeDebug USplice dom st -instance (SourceInfo st, Domain dom) => TreeDebug QQString dom st -instance (SourceInfo st, Domain dom) => TreeDebug UMatch dom st -instance (SourceInfo st, Domain dom, TreeDebug expr dom st, Generic (expr dom st)) => TreeDebug (UAlt' expr) dom st -instance (SourceInfo st, Domain dom) => TreeDebug URhs dom st -instance (SourceInfo st, Domain dom) => TreeDebug UGuardedRhs dom st -instance (SourceInfo st, Domain dom) => TreeDebug UFieldUpdate dom st -instance (SourceInfo st, Domain dom) => TreeDebug UBracket dom st -instance (SourceInfo st, Domain dom) => TreeDebug UTopLevelPragma dom st -instance (SourceInfo st, Domain dom) => TreeDebug URule dom st -instance (SourceInfo st, Domain dom) => TreeDebug URuleVar dom st -instance (SourceInfo st, Domain dom) => TreeDebug UAnnotationSubject dom st -instance (SourceInfo st, Domain dom) => TreeDebug UMinimalFormula dom st -instance (SourceInfo st, Domain dom) => TreeDebug UExprPragma dom st -instance (SourceInfo st, Domain dom) => TreeDebug USourceRange dom st -instance (SourceInfo st, Domain dom) => TreeDebug Number dom st -instance (SourceInfo st, Domain dom) => TreeDebug UQuasiQuote dom st -instance (SourceInfo st, Domain dom) => TreeDebug URhsGuard dom st -instance (SourceInfo st, Domain dom) => TreeDebug ULocalBind dom st -instance (SourceInfo st, Domain dom) => TreeDebug ULocalBinds dom st -instance (SourceInfo st, Domain dom) => TreeDebug UFixitySignature dom st -instance (SourceInfo st, Domain dom) => TreeDebug UTypeSignature dom st -instance (SourceInfo st, Domain dom) => TreeDebug UListCompBody dom st -instance (SourceInfo st, Domain dom) => TreeDebug UTupSecElem dom st -instance (SourceInfo st, Domain dom) => TreeDebug UTypeFamily dom st -instance (SourceInfo st, Domain dom) => TreeDebug UTypeFamilySpec dom st -instance (SourceInfo st, Domain dom) => TreeDebug UInjectivityAnn dom st -instance (SourceInfo st, Domain dom, TreeDebug expr dom st, Generic (expr dom st)) => TreeDebug (UCaseRhs' expr) dom st -instance (SourceInfo st, Domain dom, TreeDebug expr dom st, Generic (expr dom st)) => TreeDebug (UGuardedCaseRhs' expr) dom st -instance (SourceInfo st, Domain dom) => TreeDebug UPatternSynonym dom st -instance (SourceInfo st, Domain dom) => TreeDebug UPatSynRhs dom st -instance (SourceInfo st, Domain dom) => TreeDebug UPatSynLhs dom st -instance (SourceInfo st, Domain dom) => TreeDebug UPatSynWhere dom st -instance (SourceInfo st, Domain dom) => TreeDebug UPatternTypeSignature dom st -instance (SourceInfo st, Domain dom) => TreeDebug URole dom st -instance (SourceInfo st, Domain dom) => TreeDebug UCmd dom st -instance (SourceInfo st, Domain dom) => TreeDebug ULanguageExtension dom st -instance (SourceInfo st, Domain dom) => TreeDebug UMatchLhs dom st -instance (SourceInfo st, Domain dom) => TreeDebug UInlinePragma dom st -instance (SourceInfo st, Domain dom) => TreeDebug USpecializePragma dom st - --- ULiteral -instance (SourceInfo st, Domain dom) => TreeDebug ULiteral dom st -instance (SourceInfo st, Domain dom, TreeDebug k dom st, Generic (k dom st)) => TreeDebug (UPromoted k) dom st - --- Base -instance (SourceInfo st, Domain dom) => TreeDebug UOperator dom st -instance (SourceInfo st, Domain dom) => TreeDebug UName dom st -instance (SourceInfo st, Domain dom) => TreeDebug UQualifiedName dom st -instance (SourceInfo st, Domain dom) => TreeDebug UModuleName dom st -instance (SourceInfo st, Domain dom) => TreeDebug UNamePart dom st -instance (SourceInfo st, Domain dom) => TreeDebug UStringNode dom st -instance (SourceInfo st, Domain dom) => TreeDebug UDataOrNewtypeKeyword dom st -instance (SourceInfo st, Domain dom) => TreeDebug UDoKind dom st -instance (SourceInfo st, Domain dom) => TreeDebug TypeKeyword dom st -instance (SourceInfo st, Domain dom) => TreeDebug UOverlapPragma dom st -instance (SourceInfo st, Domain dom) => TreeDebug UCallConv dom st -instance (SourceInfo st, Domain dom) => TreeDebug UArrowAppl dom st -instance (SourceInfo st, Domain dom) => TreeDebug USafety dom st -instance (SourceInfo st, Domain dom) => TreeDebug UConlikeAnnot dom st -instance (SourceInfo st, Domain dom) => TreeDebug Assoc dom st -instance (SourceInfo st, Domain dom) => TreeDebug Precedence dom st -instance (SourceInfo st, Domain dom) => TreeDebug LineNumber dom st -instance (SourceInfo st, Domain dom) => TreeDebug UPhaseControl dom st -instance (SourceInfo st, Domain dom) => TreeDebug PhaseNumber dom st -instance (SourceInfo st, Domain dom) => TreeDebug PhaseInvert dom st
exe/Main.hs view
@@ -1,7 +1,7 @@ module Main where -import Language.Haskell.Tools.Debug -import System.Environment +import Language.Haskell.Tools.Debug (demoRefactor) +import System.Environment (getProgName, getArgs) main :: IO () main = do args <- getArgs
haskell-tools-debug.cabal view
@@ -1,5 +1,5 @@ name: haskell-tools-debug -version: 0.8.1.0 +version: 0.9.0.0 synopsis: Debugging Tools for Haskell-tools description: Debugging Tools for Haskell-tools homepage: https://github.com/haskell-tools/haskell-tools @@ -13,19 +13,21 @@ library exposed-modules: Language.Haskell.Tools.Debug - other-modules: Language.Haskell.Tools.DebugGhcAST - , Language.Haskell.Tools.RangeDebug - , Language.Haskell.Tools.RangeDebug.Instances + other-modules: Language.Haskell.Tools.Debug.DebugGhcAST + , Language.Haskell.Tools.Debug.RangeDebug + , Language.Haskell.Tools.Debug.RangeDebugInstances build-depends: base >= 4.9 && < 4.10 , filepath >= 1.4 && < 1.5 , template-haskell >= 2.11 && < 2.12 , references >= 0.3 && < 0.4 - , ghc >= 8.0 && < 8.3 + , split >= 0.2 && < 0.3 + , ghc >= 8.0 && < 8.1 , ghc-paths >= 0.1 && < 0.2 - , haskell-tools-ast >= 0.8 && < 0.9 - , haskell-tools-backend-ghc >= 0.8 && < 0.9 - , haskell-tools-refactor >= 0.8 && < 0.9 - , haskell-tools-prettyprint >= 0.8 && < 0.9 + , haskell-tools-ast >= 0.9 && < 0.10 + , haskell-tools-backend-ghc >= 0.9 && < 0.10 + , haskell-tools-refactor >= 0.9 && < 0.10 + , haskell-tools-prettyprint >= 0.9 && < 0.10 + , haskell-tools-builtin-refactorings >= 0.9 && < 0.10 default-language: Haskell2010 executable ht-debug