dash-haskell 1.0.0.2 → 1.0.0.3
raw patch · 7 files changed
+37/−22 lines, 7 filesdep ~optparse-applicativedep ~system-fileio
Dependency ranges changed: optparse-applicative, system-fileio
Files
- README.md +1/−1
- dash-haskell.cabal +7/−3
- src/Main.hs +1/−1
- src/Options.hs +16/−6
- src/Options/CabalConstraints.hs +5/−5
- src/Options/DbProvider.hs +6/−5
- src/Pipes/Db.hs +1/−1
README.md view
@@ -9,7 +9,7 @@ **keyword, module, and package searching:**  -The purpose of the dash-haskell is to facilitate Haskell documentation in IDE(s), with the following qualities:+dash-haskell facilitates Haskell documentation in IDE(s) with the following qualities: * **Local**
dash-haskell.cabal view
@@ -1,5 +1,5 @@ name: dash-haskell-version: 1.0.0.2+version: 1.0.0.3 synopsis: Command line tool to generate Dash docsets (IDE docs) from package haddock homepage: http://www.github.com/jfeltz/dash-haskell Bug-reports: https://github.com/jfeltz/dash-haskell/issues@@ -130,11 +130,11 @@ , either >= 4.3 , ghc >= 7.8.3 , mtl >= 2.1.3.1- , optparse-applicative >= 0.10.0 && < 0.11+ , optparse-applicative >= 0.11.0 && <= 0.11.1 , pipes >= 4.1.0 , process >= 1.2.0.0 , sqlite-simple >= 0.4.5.0- , system-fileio >= 0.3.12 && < 0.3.15+ , system-fileio >= 0.3.12 && < 0.4.0 , system-filepath >= 0.3.1 && < 0.5 , tagsoup >= 0.12.7 , text >= 0.7.1@@ -144,3 +144,7 @@ ghc-options: -Wall -rtsopts hs-source-dirs: src default-language: Haskell2010++source-repository head+ type: git+ location: https://github.com/jfeltz/dash-haskell.git
src/Main.hs view
@@ -34,6 +34,6 @@ where parserInfo :: ParserInfo Options parserInfo = info (helper <*> parser) $- header "dash-haskell v1.0.0.2, a dash docset construction tool for Haskell packages"+ header "dash-haskell v1.0.0.3, a dash docset construction tool for Haskell packages" <> progDesc "additional help is available with \"dash-haskell help <topic|option>\"" <> footer "http://www.github.com/jfeltz/dash-haskell (C) John P. Feltz 2014"
src/Options.hs view
@@ -10,6 +10,7 @@ import qualified Distribution.Package as C import qualified Distribution.Version as CV import Distribution.Text+import Options.Applicative.Types (readerAsk) import Options.Applicative.Builder import Options.Applicative.Common import Options.Cabal@@ -18,7 +19,7 @@ import PackageId import Pipes import qualified Data.Set as S- + data Options = Options { dbprovider :: DbProvider, outputDir :: FilePath,@@ -28,6 +29,15 @@ packages :: [C.PackageId] } deriving Show +packageReadM :: Text a => ReadM a+packageReadM = do+ s <- readerAsk+ maybe + (readerError $ "failed parsing packages:\n " ++ s)+ return + -- Qualified, as simpleParse is a little obscure.+ (Distribution.Text.simpleParse s) + parser :: Parser Options parser = Options <$> @@ -47,7 +57,7 @@ <*> switch (long "quiet" <> short 'q' <> help "set to quiet output") <*>- option (return . Just) + option (Just <$> readerAsk) (long "cabal" <> short 'c' <> metavar "<file.cabal>" @@ -55,14 +65,14 @@ <> help "the cabal file to retrieve package dependencies from") <*> option toConstraints- (long "cabal-constraints" + (long "cabal-constraints" <> short 'r' <> value none <> metavar "executable=name, .." <> help "limit package results from a cabal file source, see documentation") <*> many (- argument simpleParse (metavar "packages" <> + argument packageReadM (metavar "packages" <> help "a list of packages to specifically build, e.g. either-1.0.1 text" )) @@ -77,7 +87,7 @@ -- an ascending list to determine a version fromAsc :: [C.PackageId] -> [C.PackageId] fromAsc [] = []- fromAsc (p:[]) = [p] + fromAsc ([p]) = [p] fromAsc (p:nxt:rest) | p == nxt = -- duplicate fromAsc (nxt:rest) @@ -88,7 +98,7 @@ p : nxt : fromAsc rest | otherwise = -- they're different packages p : fromAsc ( nxt : rest )- + versionless :: String -> C.PackageId versionless n = C.PackageIdentifier (C.PackageName n) $ CV.Version [] []
src/Options/CabalConstraints.hs view
@@ -84,9 +84,9 @@ notFollowedBy (char '=') return var -toConstraints :: String -> O.ReadM CabalConstraints-toConstraints expr = - O.ReadM $ +toConstraints :: O.ReadM CabalConstraints+toConstraints = do+ expr <- O.readerAsk case parse (constraints Nothing) [] expr of - Left err -> Left . O.ErrorMsg . show $ err- Right c -> Right c + Left err -> O.readerError . show $ err+ Right c -> return c
src/Options/DbProvider.hs view
@@ -37,7 +37,7 @@ fromParam [] = return Nothing fromParam (c':str)= if c' == c then- ReadM . Left . ErrorMsg $ "encountered delimeter(" ++ c:") twice" + readerError $ "encountered delimeter(" ++ c:") twice" else Just . maybe [c'] (c':) <$> fromParam str @@ -49,14 +49,15 @@ toExec (Db fp) = (,) "ghc-pkg" ("list":["--package-db=" ++ fp]) -toProvider :: String -> ReadM DbProvider-toProvider expr = do +toProvider :: ReadM DbProvider+toProvider = do+ expr <- readerAsk (prov, arg) <- fromSplit ',' expr join $ constructor prov <*> pure arg where constructor :: String -> ReadM (Maybe String -> ReadM DbProvider) constructor prov =- ReadM $ maybe (Left . ErrorMsg $ "invalid db provider") Right f+ maybe (readerError "invalid db provider") return f where f :: Maybe (Maybe String -> ReadM DbProvider) f = @@ -66,6 +67,6 @@ ("cabal" , return . CabalSandbox), ("dir" , maybe - (ReadM . Left . ErrorMsg $ "requires directory path")+ (readerError "requires directory path") (return . Db)) ]
src/Pipes/Db.hs view
@@ -164,7 +164,7 @@ lift . err $ L.intercalate "\n" ("The following packages were not found in searched package db's:" - : S.toList unfound ++ ["Please be sure to provide exact package versions."])+ : S.toList unfound) else -- yield over each returned file, -- types are added to make this _much_ easier to understand