Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
This module generalizes over types of code fragments that may need to be iterated upon and measured separately.
Synopsis
- class (Show c, Data (AST c), Data c) => CodeFragment c where
- fragmentName :: c -> String
- fragmentSlice :: c -> SrcSlice
- occurs :: (CodeFragment c, Data from) => from -> [c]
- occursOf :: (Data from, CodeFragment c) => Proxy c -> from -> [c]
- allOccurs :: (CodeFragment c, Data from) => from -> [c]
- allOccursOf :: (Data from, CodeFragment c) => Proxy c -> from -> [c]
- newtype Program = Program {
- allModules :: [Module SrcLoc]
- programT :: Proxy Program
- program :: [Module SrcLoc] -> Program
- data Module l
- moduleT :: Proxy (Module SrcLoc)
- data Function = Function {
- functionNames :: [String]
- functionLocations :: [SrcLoc]
- functionRhs :: [Rhs SrcLoc]
- functionBinds :: [Binds SrcLoc]
- functionT :: Proxy Function
- data DataDef = DataDef {
- dataDefName :: String
- dataDefCtors :: Either [QualConDecl SrcLoc] [GadtDecl SrcLoc]
- dataDefT :: Proxy DataDef
- data TypeSignature = TypeSignature {
- loc :: SrcLoc
- identifiers :: [Name SrcLoc]
- theType :: Type SrcLoc
- typeSignatureT :: Proxy TypeSignature
- data TypeClass = TypeClass {}
- typeClassT :: Proxy TypeClass
- fragmentLoc :: CodeFragment c => c -> SrcLoc
Documentation
class (Show c, Data (AST c), Data c) => CodeFragment c where Source #
Class CodeFragment
allows for:
* both selecting direct or all descendants
of the given type of object within another structure
(with occurs
and allOccurs
)
* naming the object to allow user to distinguish it.
In order to compute selection, we just need to know which
AST
nodes contain the given object, and how to extract
this given object from AST
, if it is there (matchAST
).:w
matchAST, fragmentName
fragmentName :: c -> String Source #
fragmentSlice :: c -> SrcSlice Source #
Instances
CodeFragment DataDef Source # | |
Defined in Language.Haskell.Homplexity.CodeFragment type AST DataDef | |
CodeFragment Function Source # | |
Defined in Language.Haskell.Homplexity.CodeFragment type AST Function | |
CodeFragment Program Source # | |
Defined in Language.Haskell.Homplexity.CodeFragment type AST Program | |
CodeFragment TypeClass Source # | |
Defined in Language.Haskell.Homplexity.CodeFragment type AST TypeClass | |
CodeFragment TypeSignature Source # | |
Defined in Language.Haskell.Homplexity.CodeFragment type AST TypeSignature matchAST :: AST TypeSignature -> Maybe TypeSignature fragmentName :: TypeSignature -> String Source # | |
CodeFragment (Module SrcLoc) Source # | |
Defined in Language.Haskell.Homplexity.CodeFragment type AST (Module SrcLoc) |
occurs :: (CodeFragment c, Data from) => from -> [c] Source #
Direct occurences of given CodeFragment
fragment within another structure.
occursOf :: (Data from, CodeFragment c) => Proxy c -> from -> [c] Source #
Explicitly typed variant of occurs
.
allOccurs :: (CodeFragment c, Data from) => from -> [c] Source #
allOccursOf :: (Data from, CodeFragment c) => Proxy c -> from -> [c] Source #
Explicitly typed variant of allOccurs
.
Program
Program | |
|
Instances
Data Program Source # | |
Defined in Language.Haskell.Homplexity.CodeFragment gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Program -> c Program gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Program dataTypeOf :: Program -> DataType dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Program) dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Program) gmapT :: (forall b. Data b => b -> b) -> Program -> Program gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Program -> r gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Program -> r gmapQ :: (forall d. Data d => d -> u) -> Program -> [u] gmapQi :: Int -> (forall d. Data d => d -> u) -> Program -> u gmapM :: Monad m => (forall d. Data d => d -> m d) -> Program -> m Program gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Program -> m Program gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Program -> m Program | |
Show Program Source # | |
CodeFragment Program Source # | |
Defined in Language.Haskell.Homplexity.CodeFragment type AST Program |
program :: [Module SrcLoc] -> Program Source #
Smart constructor for adding cross-references in the future.
Module l (Maybe (ModuleHead l)) [ModulePragma l] [ImportDecl l] [Decl l] | |
XmlPage l (ModuleName l) [ModulePragma l] (XName l) [XAttr l] (Maybe (Exp l)) [Exp l] | |
XmlHybrid l (Maybe (ModuleHead l)) [ModulePragma l] [ImportDecl l] [Decl l] (XName l) [XAttr l] (Maybe (Exp l)) [Exp l] |
Instances
Foldable Module | |
Defined in Language.Haskell.Exts.Syntax fold :: Monoid m => Module m -> m foldMap :: Monoid m => (a -> m) -> Module a -> m foldMap' :: Monoid m => (a -> m) -> Module a -> m foldr :: (a -> b -> b) -> b -> Module a -> b foldr' :: (a -> b -> b) -> b -> Module a -> b foldl :: (b -> a -> b) -> b -> Module a -> b foldl' :: (b -> a -> b) -> b -> Module a -> b foldr1 :: (a -> a -> a) -> Module a -> a foldl1 :: (a -> a -> a) -> Module a -> a elem :: Eq a => a -> Module a -> Bool maximum :: Ord a => Module a -> a | |
Traversable Module | |
Functor Module | |
ExactP Module | |
Defined in Language.Haskell.Exts.ExactPrint | |
AppFixity Module | |
Defined in Language.Haskell.Exts.Fixity applyFixities :: MonadFail m => [Fixity] -> Module SrcSpanInfo -> m (Module SrcSpanInfo) | |
Annotated Module | |
Data l => Data (Module l) | |
Defined in Language.Haskell.Exts.Syntax gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Module l -> c (Module l) gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Module l) toConstr :: Module l -> Constr dataTypeOf :: Module l -> DataType dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Module l)) dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Module l)) gmapT :: (forall b. Data b => b -> b) -> Module l -> Module l gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Module l -> r gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Module l -> r gmapQ :: (forall d. Data d => d -> u) -> Module l -> [u] gmapQi :: Int -> (forall d. Data d => d -> u) -> Module l -> u gmapM :: Monad m => (forall d. Data d => d -> m d) -> Module l -> m (Module l) gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Module l -> m (Module l) gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Module l -> m (Module l) | |
Generic (Module l) | |
Show l => Show (Module l) | |
Eq l => Eq (Module l) | |
Ord l => Ord (Module l) | |
Defined in Language.Haskell.Exts.Syntax | |
Pretty (Module pos) | |
Defined in Language.Haskell.Exts.Pretty prettyPrec :: Int -> Module pos -> Doc | |
CodeFragment (Module SrcLoc) Source # | |
Defined in Language.Haskell.Homplexity.CodeFragment type AST (Module SrcLoc) | |
type Rep (Module l) | |
Defined in Language.Haskell.Exts.Syntax type Rep (Module l) = D1 ('MetaData "Module" "Language.Haskell.Exts.Syntax" "haskell-src-exts-1.23.1-232fe581ea5b1e36619e557b053dfbe555d5bcad5cb120276359fe905944e816" 'False) (C1 ('MetaCons "Module" 'PrefixI 'False) ((S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 l) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe (ModuleHead l)))) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [ModulePragma l]) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [ImportDecl l]) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Decl l])))) :+: (C1 ('MetaCons "XmlPage" 'PrefixI 'False) ((S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 l) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (ModuleName l)) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [ModulePragma l]))) :*: ((S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (XName l)) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [XAttr l])) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe (Exp l))) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Exp l])))) :+: C1 ('MetaCons "XmlHybrid" 'PrefixI 'False) (((S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 l) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe (ModuleHead l)))) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [ModulePragma l]) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [ImportDecl l]))) :*: ((S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Decl l]) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (XName l))) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [XAttr l]) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe (Exp l))) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Exp l]))))))) |
Alias for a function declaration
Function | |
|
Instances
Data Function Source # | |
Defined in Language.Haskell.Homplexity.CodeFragment gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Function -> c Function gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Function toConstr :: Function -> Constr dataTypeOf :: Function -> DataType dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Function) dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Function) gmapT :: (forall b. Data b => b -> b) -> Function -> Function gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Function -> r gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Function -> r gmapQ :: (forall d. Data d => d -> u) -> Function -> [u] gmapQi :: Int -> (forall d. Data d => d -> u) -> Function -> u gmapM :: Monad m => (forall d. Data d => d -> m d) -> Function -> m Function gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Function -> m Function gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Function -> m Function | |
Show Function Source # | |
CodeFragment Function Source # | |
Defined in Language.Haskell.Homplexity.CodeFragment type AST Function | |
Metric Cyclomatic Function Source # | |
Defined in Language.Haskell.Homplexity.Cyclomatic measure :: Function -> Cyclomatic Source # | |
Metric Depth Function Source # | |
Alias for a data
declaration
DataDef | |
|
Instances
Data DataDef Source # | |
Defined in Language.Haskell.Homplexity.CodeFragment gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> DataDef -> c DataDef gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c DataDef dataTypeOf :: DataDef -> DataType dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c DataDef) dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c DataDef) gmapT :: (forall b. Data b => b -> b) -> DataDef -> DataDef gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> DataDef -> r gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> DataDef -> r gmapQ :: (forall d. Data d => d -> u) -> DataDef -> [u] gmapQi :: Int -> (forall d. Data d => d -> u) -> DataDef -> u gmapM :: Monad m => (forall d. Data d => d -> m d) -> DataDef -> m DataDef gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> DataDef -> m DataDef gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> DataDef -> m DataDef | |
Show DataDef Source # | |
CodeFragment DataDef Source # | |
Defined in Language.Haskell.Homplexity.CodeFragment type AST DataDef | |
Metric RecordFieldsCount DataDef Source # | |
Defined in Language.Haskell.Homplexity.RecordFieldsCount measure :: DataDef -> RecordFieldsCount Source # |
data TypeSignature Source #
Type alias for a type signature of a function as a CodeFragment
TypeSignature | |
|
Instances
Data TypeSignature Source # | |
Defined in Language.Haskell.Homplexity.CodeFragment gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> TypeSignature -> c TypeSignature gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c TypeSignature toConstr :: TypeSignature -> Constr dataTypeOf :: TypeSignature -> DataType dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c TypeSignature) dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TypeSignature) gmapT :: (forall b. Data b => b -> b) -> TypeSignature -> TypeSignature gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> TypeSignature -> r gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> TypeSignature -> r gmapQ :: (forall d. Data d => d -> u) -> TypeSignature -> [u] gmapQi :: Int -> (forall d. Data d => d -> u) -> TypeSignature -> u gmapM :: Monad m => (forall d. Data d => d -> m d) -> TypeSignature -> m TypeSignature gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> TypeSignature -> m TypeSignature gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> TypeSignature -> m TypeSignature | |
Show TypeSignature Source # | |
Defined in Language.Haskell.Homplexity.CodeFragment showsPrec :: Int -> TypeSignature -> ShowS show :: TypeSignature -> String showList :: [TypeSignature] -> ShowS | |
CodeFragment TypeSignature Source # | |
Defined in Language.Haskell.Homplexity.CodeFragment type AST TypeSignature matchAST :: AST TypeSignature -> Maybe TypeSignature fragmentName :: TypeSignature -> String Source # | |
Metric ConDepth TypeSignature Source # | |
Defined in Language.Haskell.Homplexity.TypeComplexity measure :: TypeSignature -> ConDepth Source # | |
Metric NumFunArgs TypeSignature Source # | |
Defined in Language.Haskell.Homplexity.TypeComplexity measure :: TypeSignature -> NumFunArgs Source # |
typeSignatureT :: Proxy TypeSignature Source #
Proxy for passing TypeSignature
type as an argument.
Alias for a class signature
Instances
Data TypeClass Source # | |
Defined in Language.Haskell.Homplexity.CodeFragment gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> TypeClass -> c TypeClass gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c TypeClass toConstr :: TypeClass -> Constr dataTypeOf :: TypeClass -> DataType dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c TypeClass) dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TypeClass) gmapT :: (forall b. Data b => b -> b) -> TypeClass -> TypeClass gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> TypeClass -> r gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> TypeClass -> r gmapQ :: (forall d. Data d => d -> u) -> TypeClass -> [u] gmapQi :: Int -> (forall d. Data d => d -> u) -> TypeClass -> u gmapM :: Monad m => (forall d. Data d => d -> m d) -> TypeClass -> m TypeClass gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> TypeClass -> m TypeClass gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> TypeClass -> m TypeClass | |
Show TypeClass Source # | |
CodeFragment TypeClass Source # | |
Defined in Language.Haskell.Homplexity.CodeFragment type AST TypeClass | |
Metric AssocTypeCount TypeClass Source # | |
Defined in Language.Haskell.Homplexity.TypeClassComplexity measure :: TypeClass -> AssocTypeCount Source # | |
Metric NonTypeDeclCount TypeClass Source # | |
Defined in Language.Haskell.Homplexity.TypeClassComplexity measure :: TypeClass -> NonTypeDeclCount Source # |
typeClassT :: Proxy TypeClass Source #
Proxy for passing TypeClass
type as an argument.
fragmentLoc :: CodeFragment c => c -> SrcLoc Source #
First location for each CodeFragment
- for convenient reporting.