hs-inspector 0.1.0.0 → 0.2.0.0
raw patch · 2 files changed
+37/−1 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Language.Haskell.Inspector: hasComprehension :: Inspection
+ Language.Haskell.Inspector: hasDirectRecursion :: Inspection
+ Language.Haskell.Inspector: hasUsage :: String -> Inspection
Files
- hs-inspector.cabal +1/−1
- src/Language/Haskell/Inspector.hs +36/−0
hs-inspector.cabal view
@@ -2,7 +2,7 @@ -- http://haskell.org/cabal/users-guide/ name: hs-inspector-version: 0.1.0.0+version: 0.2.0.0 license: MIT license-file: LICENSE author: Franco Leonardo Bulgarelli
src/Language/Haskell/Inspector.hs view
@@ -11,21 +11,57 @@ type Code = String type Inspection = Binding -> Code -> Bool +-- | Inspection that tells whether a binding uses the composition operator '.'+-- in its definition hasComposition :: Inspection hasComposition = testAnyWithBindingExpr f where f (O (HsQVarOp (UnQual (HsSymbol ".")))) = True f _ = False +-- | Inspection that tells whether a binding uses guards+-- in its definition hasGuards :: Inspection hasGuards = testAnyWithBindingRhs f where f (HsGuardedRhss _) = True f _ = False ++-- | Inspection that tells whether a binding uses a lambda expression+-- in its definition hasLambda :: Inspection hasLambda = testAnyWithBindingExpr f where f (E (HsLambda _ _ _)) = True f _ = False ++-- | Inspection that tells whether a binding is direct recursive+hasDirectRecursion :: Inspection+hasDirectRecursion binding = hasUsage binding binding+++-- | Inspection that tells whether a binding uses the the given target binding+-- in its definition+hasUsage :: String -> Inspection+hasUsage target = testAnyWithBindingExpr f+ where f (O (HsQVarOp name)) = isTarget name+ f (E (HsVar name)) = isTarget name+ f _ = False++ isTarget (Qual _ (HsSymbol target)) = True+ isTarget (Qual _ (HsIdent target)) = True+ isTarget (UnQual (HsSymbol target)) = True+ isTarget (UnQual (HsIdent target)) = True+ isTarget _ = False+++-- | Inspection that tells whether a binding uses lists comprehensions+-- in its definition+hasComprehension :: Inspection+hasComprehension = testAnyWithBindingExpr f+ where f (E (HsListComp _ _)) = True+ f _ = False++-- | Inspection that tells whether a top level binding exists hasBinding :: Inspection hasBinding binding = isJust . findBindingRhs binding