packages feed

implicit-hie 0.1.2.0 → 0.1.2.1

raw patch · 6 files changed

+207/−181 lines, 6 filessetup-changedPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

Setup.hs view
@@ -1,2 +1,3 @@ import Distribution.Simple+ main = defaultMain
app/Main.hs view
@@ -4,18 +4,12 @@  import Control.Monad import Control.Monad.Trans.Maybe-import Data.Attoparsec.Text-import Data.List import Data.Maybe-import qualified Data.Text as T-import qualified Data.Text.IO as T-import Hie.Cabal.Parser import Hie.Locate import Hie.Yaml import System.Directory-import System.Directory.Internal-import System.FilePath.Posix import System.Environment+import System.FilePath.Posix  main :: IO () main = do@@ -24,10 +18,11 @@   cfs <- runMaybeT $ case name of     "cabal" -> cabalPkgs pwd     _ -> stackYamlPkgs pwd-  when (null cfs) $ error $-    "No .cabal files found under"-      <> pwd-      <> "\n You may need to run stack build."+  when (null cfs) $+    error $+      "No .cabal files found under"+        <> pwd+        <> "\n You may need to run stack build."   pkgs <- catMaybes <$> mapM (nestedPkg pwd) (concat cfs)   putStr <$> hieYaml name $ fmtPkgs name pkgs @@ -37,7 +32,8 @@   files <- listDirectory pwd   let fileNames = map takeFileName files       name =-        if  | "--cabal" `elem` args -> "cabal"+        if+            | "--cabal" `elem` args -> "cabal"             | "--stack" `elem` args -> "stack"             | "dist-newstyle" `elem` fileNames -> "cabal"             | ".stack-work" `elem` fileNames -> "stack"@@ -45,4 +41,3 @@             | "stack.yaml" `elem` fileNames -> "stack"             | otherwise -> "cabal"   return name-
implicit-hie.cabal view
@@ -1,4 +1,4 @@-cabal-version: 2.0+cabal-version:      2.0  -- This file has been generated from package.yaml by hpack version 0.33.0. --@@ -6,68 +6,76 @@ -- -- hash: b2b829a658e33ea328c725dea732391089d03ffd2a216d413a75d88aefa7c181 -name:           implicit-hie-version:        0.1.2.0-description:    Auto generate a stack or cabal multi component hie.yaml file-category:       Development, Tools, Hie, HLS-synopsis:       Auto generate hie-bios cradles & hie.yaml-homepage:       https://github.com/Avi-D-coder/implicit-hie#readme-bug-reports:    https://github.com/Avi-D-coder/implicit-hie/issues-author:         Avi Dessauer-maintainer:     avi.the.coder@gmail.com-copyright:      2020-license:        BSD3-license-file:   LICENSE-tested-with:    GHC==8.8.3-build-type:     Simple+name:               implicit-hie+version:            0.1.2.1+description:+  Auto generate a stack or cabal multi component hie.yaml file++category:           Development, Tools, Hie, HLS+synopsis:           Auto generate hie-bios cradles & hie.yaml+homepage:           https://github.com/Avi-D-coder/implicit-hie#readme+bug-reports:        https://github.com/Avi-D-coder/implicit-hie/issues+author:             Avi Dessauer+maintainer:         avi.the.coder@gmail.com+copyright:          2020+license:            BSD3+license-file:       LICENSE+tested-with:        GHC ==8.8.3+build-type:         Simple extra-source-files:-    README.md-    ChangeLog.md-    test/benchSection-    test/cabal.project-    test/hie.yaml.cbl-    test/stackHie.yaml-    test/haskell-language-server-cabal+  ChangeLog.md+  README.md+  test/benchSection+  test/cabal.project+  test/haskell-language-server-cabal+  test/hie.yaml.cbl+  test/stackHie.yaml  source-repository head-  type: git+  type:     git   location: https://github.com/Avi-D-coder/implicit-hie  library   exposed-modules:-      Hie.Cabal.Parser-      Hie.Locate-      Hie.Yaml-  other-modules:-      Paths_implicit_hie-  autogen-modules:-      Paths_implicit_hie-  hs-source-dirs:-      src-  ghc-options: -Wall -Wincomplete-record-updates -Wincomplete-uni-patterns -fno-warn-unused-imports -fno-warn-unused-binds -fno-warn-name-shadowing -fwarn-redundant-constraints+    Hie.Cabal.Parser+    Hie.Locate+    Hie.Yaml++  other-modules:    Paths_implicit_hie+  autogen-modules:  Paths_implicit_hie+  hs-source-dirs:   src+  ghc-options:+    -Wall -Wincomplete-record-updates -Wincomplete-uni-patterns+    -fno-warn-unused-imports -fno-warn-unused-binds+    -fno-warn-name-shadowing -fwarn-redundant-constraints+    -fwrite-ide-info -hiedir=.hie+   build-depends:-      attoparsec >= 0.13-    , base >=4.7 && <5-    , directory >= 1.3-    , filepath >= 1.4-    , filepattern >= 0.1-    , text >= 1.2-    , transformers >= 0.5-    , yaml >= 0.5+      attoparsec    >=0.13+    , base          >=4.7  && <5+    , directory     >=1.3+    , filepath      >=1.4+    , filepattern   >=0.1+    , text          >=1.2+    , transformers  >=0.5+    , yaml          >=0.5+   default-language: Haskell2010  executable gen-hie-  main-is: Main.hs-  other-modules:-      Paths_implicit_hie-  autogen-modules:-      Paths_implicit_hie-  hs-source-dirs:-      app-  ghc-options: -Wall -Wincomplete-record-updates -Wincomplete-uni-patterns -fno-warn-unused-imports -fno-warn-unused-binds -fno-warn-name-shadowing -fwarn-redundant-constraints -threaded -rtsopts -with-rtsopts=-N+  main-is:          Main.hs+  other-modules:    Paths_implicit_hie+  autogen-modules:  Paths_implicit_hie+  hs-source-dirs:   app+  ghc-options:+    -Wall -Wincomplete-record-updates -Wincomplete-uni-patterns+    -fno-warn-unused-imports -fno-warn-unused-binds+    -fno-warn-name-shadowing -fwarn-redundant-constraints -threaded+    -rtsopts -with-rtsopts=-N -fwrite-ide-info -hiedir=.hie+   build-depends:       attoparsec-    , base >=4.7 && <5+    , base          >=4.7 && <5     , directory     , filepath     , filepattern@@ -75,21 +83,24 @@     , text     , transformers     , yaml+   default-language: Haskell2010  test-suite implicit-hie-test-  type: exitcode-stdio-1.0-  main-is: Spec.hs-  other-modules:-      Paths_implicit_hie-  autogen-modules:-      Paths_implicit_hie-  hs-source-dirs:-      test-  ghc-options: -Wall -Wincomplete-record-updates -Wincomplete-uni-patterns -fno-warn-unused-imports -fno-warn-unused-binds -fno-warn-name-shadowing -fwarn-redundant-constraints -threaded -rtsopts -with-rtsopts=-N+  type:             exitcode-stdio-1.0+  main-is:          Spec.hs+  other-modules:    Paths_implicit_hie+  autogen-modules:  Paths_implicit_hie+  hs-source-dirs:   test+  ghc-options:+    -Wall -Wincomplete-record-updates -Wincomplete-uni-patterns+    -fno-warn-unused-imports -fno-warn-unused-binds+    -fno-warn-name-shadowing -fwarn-redundant-constraints -threaded+    -rtsopts -with-rtsopts=-N -fwrite-ide-info -hiedir=.hie+   build-depends:       attoparsec-    , base >=4.7 && <5+    , base              >=4.7 && <5     , directory     , filepath     , filepattern@@ -99,4 +110,5 @@     , text     , transformers     , yaml+   default-language: Haskell2010
src/Hie/Cabal/Parser.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE LambdaCase #-} {-# LANGUAGE OverloadedStrings #-}  module Hie.Cabal.Parser where@@ -93,24 +94,23 @@ unqualName :: Parser Text unqualName = takeWhile1 (not . (\c -> isSpace c || c == ',')) --- | Skip spaces and if enf of line is reached, skip it as well and require that+-- | Skip spaces and if end of line is reached, skip it as well and require that -- next one starts with indent. -- -- Used for parsing fields. optSkipToNextLine :: Indent -> Parser () optSkipToNextLine i = do   skipMany $ satisfy (\c -> isSpace c && not (isEndOfLine c))-  mChar <- peekChar-  case mChar of-    Just c | isEndOfLine c ->-      char c *> indent i $> ()+  skipMany $ skipSpace >> "--" >> takeTill isEndOfLine+  peekChar >>= \case+    Just c+      | isEndOfLine c ->+        endOfLine *> indent i $> ()     _ -> pure ()  -- | Comma or space separated list, with optional new lines. parseList :: Indent -> Parser [Text]-parseList i = items <|> (emptyOrComLine >> indent i >> items)-  where-    items = sepBy parseString (optSkipToNextLine i *> skipMany (char ',') *> optSkipToNextLine i)+parseList i = sepBy parseString (optSkipToNextLine i *> skipMany (char ',') *> optSkipToNextLine i)  pathMain :: Indent -> [Text] -> Text -> [Text] -> [Text] -> Parser [Text] pathMain i p m o a =
src/Hie/Locate.hs view
@@ -8,9 +8,7 @@   ) where -import Control.Applicative import Control.Exception-import Control.Monad import Control.Monad.IO.Class import Control.Monad.Trans.Maybe import Data.Attoparsec.Text (parseOnly)@@ -20,9 +18,7 @@ import qualified Data.Text as T import qualified Data.Text.IO as T import Data.Yaml-import GHC.Generics import Hie.Cabal.Parser-import Hie.Yaml import System.Directory import System.FilePath.Posix import System.FilePattern.Directory (getDirectoryFiles)@@ -35,22 +31,24 @@   parseJSON _ = fail "could not read packages from stack.yaml"  stackYamlPkgs :: FilePath -> MaybeT IO [FilePath]-stackYamlPkgs p = liftIO $-  decodeFileEither (p </> "stack.yaml") >>= \case-    Right (Pkgs f) ->-      liftIO $-        map (p </>)-          <$> getDirectoryFiles p (map (</> "*.cabal") f)-    Left e -> fail $ show e+stackYamlPkgs p =+  liftIO $+    decodeFileEither (p </> "stack.yaml") >>= \case+      Right (Pkgs f) ->+        liftIO $+          map (p </>)+            <$> getDirectoryFiles p (map (</> "*.cabal") f)+      Left e -> fail $ show e  cabalPkgs :: FilePath -> MaybeT IO [FilePath] cabalPkgs p = do   cp <- cabalP "cabal.project"   cl <- cabalP "cabal.project.local"   case concat . rights $ map (parseOnly extractPkgs) $ rights [cp, cl] of-    [] -> liftIO (cfs p) >>= \case-      [] -> fail "no cabal files found"-      h : _ -> pure [p </> h]+    [] ->+      liftIO (cfs p) >>= \case+        [] -> fail "no cabal files found"+        h : _ -> pure [p </> h]     xs -> do       cd <- liftIO $ map (p </>) <$> getDirectoryFiles p (map (matchDirs . T.unpack) xs)       cf <-@@ -71,9 +69,10 @@   case parsePackage' f' of     Right (Package n cs) -> do       let dir =-            fromJust $ stripPrefix (splitDirectories parrent)-              $ splitDirectories-              $ fst (splitFileName child)+            fromJust $+              stripPrefix (splitDirectories parrent) $+                splitDirectories $+                  fst (splitFileName child)           pkg =             Package n $               map
test/Spec.hs view
@@ -1,7 +1,6 @@ {-# LANGUAGE OverloadedStrings #-}  import Data.Attoparsec.Text-import qualified Data.Text as T import Data.Text (Text) import qualified Data.Text.IO as T import Hie.Cabal.Parser@@ -14,89 +13,109 @@  spec :: Spec spec = do-  describe "Should Succeed"-    $ it "successfully parses executable section"-    $ exeSection ~> parseExe 0-      `shouldParse` [Comp Exe "gen-hie" "app/Main.hs"]-  describe "Should Succeed"-    $ it "successfully parses test section"-    $ testSection ~> parseTestSuite 0-      `shouldParse` [Comp Test "implicit-hie-test" "test"]-  describe "Should Succeed"-    $ it "successfully parses library section"-    $ libSection ~> parseLib 0-      `shouldParse` [Comp Lib "" "src"]-  describe "Should Succeed"-    $ it "successfully parses library section with 2 hs-source-dirs"-    $ libSection2 ~> parseLib 0-      `shouldParse` [Comp Lib "" "src", Comp Lib "" "src2"]-  describe "Should Succeed"-    $ it "successfully parses library section with 2 paths under hs-source-dirs"-    $ libSection3 ~> parseLib 0-      `shouldParse` [Comp Lib "" "src", Comp Lib "" "src2"]-  describe "Should Succeed"-    $ it "successfully parses bench section"-    $ do-      bs <- T.readFile "test/benchSection"-      bs ~> parseBench 0-        `shouldParse` [Comp Bench "folds" "benchmarks/folds.hs"]-  describe "Should Succeed"-    $ it "successfully parses package"-    $ do-      cf <- T.readFile "implicit-hie.cabal"-      cf ~> parsePackage-        `shouldParse` Package-          "implicit-hie"-          [ Comp Lib "" "src",-            Comp Exe "gen-hie" "app/Main.hs",-            Comp Test "implicit-hie-test" "test"-          ]-  describe "Should Succeed"-    $ it+  describe "Should Succeed" $+    it "successfully parses executable section" $+      exeSection ~> parseExe 0+        `shouldParse` [Comp Exe "gen-hie" "app/Main.hs"]+  describe "Should Succeed" $+    it "successfully parses test section" $+      testSection ~> parseTestSuite 0+        `shouldParse` [Comp Test "implicit-hie-test" "test"]+  describe "Should Succeed" $+    it "successfully parses library section" $+      libSection ~> parseLib 0+        `shouldParse` [Comp Lib "" "src"]+  describe "Should Succeed" $+    it "successfully parses library section with 2 hs-source-dirs" $+      libSection2 ~> parseLib 0+        `shouldParse` [Comp Lib "" "src", Comp Lib "" "src2"]+  describe "Should Succeed" $+    it "successfully parses library section with 2 paths under hs-source-dirs" $+      libSection3 ~> parseLib 0+        `shouldParse` [Comp Lib "" "src", Comp Lib "" "src2"]+  describe "Should Succeed" $+    it "successfully parses bench section" $+      do+        bs <- T.readFile "test/benchSection"+        bs ~> parseBench 0+          `shouldParse` [Comp Bench "folds" "benchmarks/folds.hs"]+  describe "Should Succeed" $+    it "successfully parses package" $+      do+        cf <- T.readFile "implicit-hie.cabal"+        cf ~> parsePackage+          `shouldParse` Package+            "implicit-hie"+            [ Comp Lib "" "src",+              Comp Exe "gen-hie" "app/Main.hs",+              Comp Test "implicit-hie-test" "test"+            ]+  describe "Should Succeed" $+    it       "skips to end of block section"-    $ let r = "test\n"-       in (libSection <> r) ~?> parseLib 0-            `leavesUnconsumed` r-  describe "Should Succeed"-    $ it "successfully generates stack hie.yaml"-    $ do-      sf <- readFile "test/stackHie.yaml"-      cf <- T.readFile "implicit-hie.cabal"-      (hieYaml "stack" . fmtPkgs "stack" . (: []) <$> parseOnly parsePackage cf)-        `shouldBe` Right sf-  describe "Should Succeed"-    $ it "successfully generates cabal hie.yaml for haskell-language-server"-    $ do-      f <- T.readFile "test/haskell-language-server-cabal"-      o <- readFile "test/hie.yaml.cbl"-      (hieYaml "cabal" . fmtPkgs "cabal" . (: []) <$> parseOnly parsePackage f)-        `shouldBe` Right o-  describe "Should Succeed"-    $ it "successfully parses comma list"-    $ ("one, two" :: Text) ~> parseList 1 `shouldParse` ["one", "two"]-  describe "Should Succeed"-    $ it "successfully parses newline list"-    $ ("one\n two \n three3" :: Text) ~> parseList 1-      `shouldParse` ["one", "two", "three3"]-  describe "Should Succeed"-    $ it "successfully parses newline comma list"-    $ ("one\n two,  three3" :: Text) ~> parseList 1-      `shouldParse` ["one", "two", "three3"]-  describe "Should Succeed"-    $ it "quoted list"-    $ ("\"one\"\n two\n three3" :: Text) ~> parseList 1-      `shouldParse` ["one", "two", "three3"]-  describe "Should Succeed"-    $ it "list with leading commas"-    $ ("one\n , two\n , three3" :: Text) ~> parseList 1-      `shouldParse` ["one", "two", "three3"]-  describe "Should Succeed"-    $ it "succesfully parses exe component with other-modules containing dots"-    $ exeSection2 ~> parseExe 0 -      `shouldParse` [ Comp Exe "gen-hie" "app/Main.hs"-                    , Comp Exe "gen-hie" "app/Hie/Executable/Helper.hs"-                    , Comp Exe "gen-hie" "app/Hie/Executable/Utils.hs"-                    ]+      $ let r = "test\n"+         in (libSection <> r) ~?> parseLib 0+              `leavesUnconsumed` r+  describe "Should Succeed" $+    it "successfully generates stack hie.yaml" $+      do+        sf <- readFile "test/stackHie.yaml"+        cf <- T.readFile "implicit-hie.cabal"+        (hieYaml "stack" . fmtPkgs "stack" . (: []) <$> parseOnly parsePackage cf)+          `shouldBe` Right sf+  describe "Should Succeed" $+    it "successfully generates cabal hie.yaml for haskell-language-server" $+      do+        f <- T.readFile "test/haskell-language-server-cabal"+        o <- readFile "test/hie.yaml.cbl"+        (hieYaml "cabal" . fmtPkgs "cabal" . (: []) <$> parseOnly parsePackage f)+          `shouldBe` Right o+  describe "Should Succeed" $+    it "successfully parses comma list" $+      ("one, two" :: Text) ~> parseList 1 `shouldParse` ["one", "two"]+  describe "Should Succeed" $+    it "successfully parses newline list" $+      ("one\n two \n three3" :: Text) ~> parseList 1+        `shouldParse` ["one", "two", "three3"]+  describe "Should Succeed" $+    it "successfully parses newline comma list" $+      ("one\n two,  three3" :: Text) ~> parseList 1+        `shouldParse` ["one", "two", "three3"]+  describe "Should Succeed" $+    it "quoted list" $+      ("\"one\"\n two\n three3" :: Text) ~> parseList 1+        `shouldParse` ["one", "two", "three3"]+  describe "Should Succeed" $+    it "list with leading commas" $+      ("one\n , two\n , three3" :: Text) ~> parseList 1+        `shouldParse` ["one", "two", "three3"]+  describe "Should Succeed" $+    it "list with a comment" $+      ("foo\n  -- need to include this too\n  bar\n" :: Text) ~> parseList 1+        `shouldParse` ["foo", "bar"]+  describe "Should Succeed" $+    it "list with a comment" $+      ("foo  -- need to include this too\n  bar\n" :: Text) ~> parseList 1+        `shouldParse` ["foo", "bar"]+  describe "Should Succeed" $+    it "list with a comment" $+      ("foo  -- need to include this too\n  bar" :: Text) ~> parseList 1+        `shouldParse` ["foo", "bar"]+  describe "Should Succeed" $+    it "list with a comment" $+      ("foo\n bar\n  -- need to include this too" :: Text) ~> parseList 1+        `shouldParse` ["foo", "bar"]+  describe "Should Succeed" $+    it "list with a comment" $+      ("foo\n bar -- need to include this too" :: Text) ~> parseList 1+        `shouldParse` ["foo", "bar"]+  describe "Should Succeed" $+    it "succesfully parses exe component with other-modules containing dots" $+      exeSection2 ~> parseExe 0+        `shouldParse` [ Comp Exe "gen-hie" "app/Main.hs",+                        Comp Exe "gen-hie" "app/Hie/Executable/Helper.hs",+                        Comp Exe "gen-hie" "app/Hie/Executable/Utils.hs"+                      ]  exeSection :: Text exeSection =