diff options
author | Daniel Gröber <dxld@darkboxed.org> | 2018-10-14 01:37:46 +0200 |
---|---|---|
committer | Daniel Gröber <dxld@darkboxed.org> | 2018-10-27 19:53:16 +0200 |
commit | a355c72bd6be5fdbfeb3be843818922939d2f94a (patch) | |
tree | 2dd7af9e7df1c8e7262120fda7b052706c1a267c | |
parent | 8e5685ce57b296b7ba949173851a7f80c88e0ce2 (diff) |
Add 'allUnits' convenience query
-rw-r--r-- | lib/Distribution/Helper.hs | 7 | ||||
-rw-r--r-- | tests/GhcSession.hs | 6 |
2 files changed, 7 insertions, 6 deletions
diff --git a/lib/Distribution/Helper.hs b/lib/Distribution/Helper.hs index ad77eb3..4c51de2 100644 --- a/lib/Distribution/Helper.hs +++ b/lib/Distribution/Helper.hs @@ -46,6 +46,9 @@ module Distribution.Helper ( , UnitInfo(..) , unitQuery + -- ** Convenience Queries + , allUnits + -- * Query environment , QueryEnv -- abstract , mkQueryEnv @@ -268,7 +271,9 @@ projectUnits = Query $ \qe@QueryEnv{qeDistDir} -> unitQuery :: Unit -> Query pt UnitInfo unitQuery u = Query $ \qe -> getUnitInfo qe u - +-- | Get information on all units in a project. +allUnits :: (UnitInfo -> a) -> Query pt [a] +allUnits f = map f <$> (mapM unitQuery =<< projectUnits) -- | Run @cabal configure@ reconfigure :: MonadIO m diff --git a/tests/GhcSession.hs b/tests/GhcSession.hs index 88d5ebf..ca01abd 100644 --- a/tests/GhcSession.hs +++ b/tests/GhcSession.hs @@ -92,14 +92,10 @@ run x xs = do ExitSuccess <- rawSystem x xs return () -allComponents :: Query pt [ChComponentInfo] -allComponents = - concat . map (Map.elems . uiComponents) <$> (mapM unitQuery =<< projectUnits) - test :: FilePath -> IO [Bool] test dir = do qe <- mkQueryEnv (ProjDirV1 dir) (DistDirV1 $ dir </> "dist") - cs <- runQuery allComponents qe + cs <- runQuery (concat <$> allUnits (Map.elems . uiComponents)) qe forM cs $ \ChComponentInfo{..} -> do putStrLn $ "\n" ++ show ciComponentName ++ ":::: " ++ show ciNeedsBuildOutput |