hs-inspector 0.5.0.0 → 0.5.1.0
raw patch · 3 files changed
+22/−5 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Language.Haskell.Explorer: bindingsOf :: Binding -> Code -> [Binding]
+ Language.Haskell.Explorer: transitiveBindingsOf :: Binding -> Code -> [Binding]
Files
- hs-inspector.cabal +1/−1
- src/Language/Haskell/Explorer.hs +20/−0
- src/Language/Haskell/Inspector/Combiner.hs +1/−4
hs-inspector.cabal view
@@ -2,7 +2,7 @@ -- http://haskell.org/cabal/users-guide/ name: hs-inspector-version: 0.5.0.0+version: 0.5.1.0 license: MIT license-file: LICENSE author: Franco Leonardo Bulgarelli
src/Language/Haskell/Explorer.hs view
@@ -3,6 +3,8 @@ parseBindings, declsOf, rhssOf,+ bindingsOf,+ transitiveBindingsOf, expressionsOf, expressionToBinding, EO(..),@@ -12,6 +14,8 @@ import Language.Haskell.Syntax import Language.Haskell.Names import Language.Haskell.Parser+import Data.Maybe (maybeToList)+import Data.List (nub) type Binding = String type Code = String@@ -33,6 +37,14 @@ top <- topExpressions rhs unfoldExpression top +bindingsOf :: Binding -> Code -> [Binding]+bindingsOf binding code = nub $ do+ expr <- expressionsOf binding code+ maybeToList . expressionToBinding $ expr++transitiveBindingsOf :: Binding -> Code -> [Binding]+transitiveBindingsOf binding code = expand (`bindingsOf` code) binding+ parseDecls :: Code -> [HsDecl] parseDecls code | ParseOk (HsModule _ _ _ _ decls) <- parseModule code = decls@@ -76,4 +88,12 @@ rhsForBinding _ = [] concatRhs rhs l = [rhs] ++ concatMap rhsForBinding l+++expand :: Eq a => (a-> [a]) -> a -> [a]+expand f x = expand' [] f [x]++expand' _ _ [] = []+expand' ps f (x:xs) | elem x ps = expand' ps f xs+ | otherwise = [x] ++ expand' (x:ps) f (xs ++ f x)
src/Language/Haskell/Inspector/Combiner.hs view
@@ -5,7 +5,6 @@ import Language.Haskell.Inspector import Language.Haskell.Explorer-import Data.Maybe (maybeToList) detect :: Inspection -> Code -> [Binding] detect inspection code = filter (`inspection` code) $ parseBindings code@@ -15,6 +14,4 @@ transitive :: Inspection -> Inspection transitive inspection binding code = inspection binding code || inUsage- where inUsage = any (flip (transitive inspection) code) $ do- expr <- expressionsOf binding code- maybeToList . expressionToBinding $ expr+ where inUsage = any (`inspection` code) . transitiveBindingsOf binding $ code