packages feed

language-haskell-extract 0.1.2 → 0.2.0

raw patch · 2 files changed

+39/−35 lines, 2 filesdep ~haskell-src-extsdep ~haskell98PVP ok

version bump matches the API change (PVP)

Dependency ranges changed: haskell-src-exts, haskell98

API changes (from Hackage documentation)

Files

language-haskell-extract.cabal view
@@ -1,11 +1,11 @@ name: language-haskell-extract-version: 0.1.2-cabal-version: -any+version: 0.2.0+cabal-version: >=1.6 build-type: Simple license: BSD3 license-file: "BSD3.txt" maintainer: Oscar Finnsson-build-depends: base >= 4 && < 5, haskell98, regex-posix, haskell-src-exts, template-haskell+ stability: stable homepage: http://github.com/finnsson/template-helper package-url:@@ -48,32 +48,12 @@    > tcString = "hej" category: Template Haskell author: Oscar Finnsson & Emil Nordling-tested-with:-data-files:-data-dir: ""-extra-source-files:-extra-tmp-files:-exposed-modules: Language.Haskell.Extract -exposed: True-buildable: True-build-tools:-cpp-options:-cc-options:-ld-options:-pkgconfig-depends:-frameworks:-c-sources:-extensions:-extra-libraries:-extra-lib-dirs:-includes:-install-includes:-include-dirs:-hs-source-dirs: src-other-modules:-ghc-prof-options:-ghc-shared-options:-ghc-options:-hugs-options:-nhc98-options:-jhc-options:+ +library+  hs-source-dirs: src+  exposed-modules: Language.Haskell.Extract+  build-depends: base >= 4 && < 5, haskell98, regex-posix, haskell-src-exts, template-haskell++source-repository head+  type:     git+  location: https://github.com/finnsson/language-haskell-extract/
src/Language/Haskell/Extract.hs view
@@ -5,17 +5,24 @@ ) where import Language.Haskell.TH import Language.Haskell.Exts.Parser+import Language.Haskell.Exts (parseFileContentsWithMode) import Language.Haskell.Exts.Syntax import Text.Regex.Posix import Maybe+import Data.List import Language.Haskell.Exts.Extension  extractAllFunctions :: String -> String-> [String]-extractAllFunctions pattern  = -  allMatchingFunctions pattern . parsedModule+extractAllFunctions pattern file  = +--  allMatchingFunctions pattern . parsedModule+  nub $ filter (\f->f=~pattern::Bool) $ map (fst . head . lex) $ lines file +-- nub $ filter ("prop_" `isPrefixOf`) $+-- map (fst . head . lex) $ lines ct++ parsedModule moduleCode = -  let pMod = parseModuleWithMode ( ParseMode "test" [TemplateHaskell] False False [] ) moduleCode+  let pMod = parseFileContentsWithMode (defaultParseMode { extensions = knownExtensions } ) moduleCode       moduleOrDefault (ParseFailed _ _) = Module (SrcLoc "unknown" 1 1) (ModuleName "unknown") [] Nothing Nothing [] []       moduleOrDefault (ParseOk m) = m   in moduleOrDefault pMod @@ -52,6 +59,13 @@      return $ ListE $ map makePair functions  +-- functionExtractor' :: String -> Q [String]+-- functionExtractor' pattern =+--   do loc <- location+--      moduleCode <- runIO $ readFile $ loc_filename loc+--      let functions = extractAllFunctions pattern moduleCode+--      return functions+ -- | Extract the names and functions from the module and apply a function to every pair. --  -- Is very useful if the common denominator of the functions is just a type class.@@ -78,6 +92,16 @@      fn <- funcName      let makePair n = AppE (AppE (fn) (LitE $ StringL n)) (VarE $ mkName n)      return $ ListE $ map makePair functions ++-- functionExtractorExpMap :: String -> (Exp -> ExpQ) -> ExpQ+-- functionExtractorExpMap pattern func =+--   do loc <- location+--      moduleCode <- runIO $ readFile $ loc_filename loc+--      let functions :: [String]+--          functions = extractAllFunctions pattern moduleCode+--      fn <- funcName+--      let makePair n = AppE (AppE (fn) (LitE $ StringL n)) (VarE $ mkName n)+--      return $ ListE $ map makePair functions     -- | Extract the name of the current module. locationModule :: ExpQ