Skip to content

Commit d39a04f

Browse files
committed
Refactor partial functions
Closes: #21 Signed-off-by: hololeap <hololeap@protonmail.com>
1 parent d15f475 commit d39a04f

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

Distribution/Gentoo/GHC.hs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import Distribution.Gentoo.Packages
2424
-- Cabal imports
2525
import qualified Distribution.Simple.Utils as DSU
2626
import Distribution.Verbosity(silent)
27-
import Distribution.Package(PackageIdentifier, packageId)
27+
import Distribution.Package(packageId)
2828
import Distribution.InstalledPackageInfo(InstalledPackageInfo)
2929
import Distribution.Text(display)
3030

@@ -51,7 +51,13 @@ import Output
5151

5252
-- Get only the first line of output
5353
rawSysStdOutLine :: FilePath -> [String] -> IO String
54-
rawSysStdOutLine app = fmap (head . lines) . rawCommand app
54+
rawSysStdOutLine app args = do
55+
out <- rawCommand app args
56+
case lines out of
57+
[] -> error $ unwords
58+
[ "rawSysStdOutLine: Empty output from rawCommand"
59+
, show app, show args ]
60+
(s:_) -> pure s
5561

5662
rawCommand :: FilePath -> [String] -> IO String
5763
rawCommand cmd args = do (out,_,_) <- DSU.rawSystemStdInOut
@@ -157,11 +163,9 @@ parse_as_cabal_package cont =
157163
-- ebuilds that have CABAL_CORE_LIB_GHC_PV set
158164
-- for this version of GHC will have a .conf
159165
-- file containing just []
160-
[([],_)] -> Nothing
161-
rd -> Just $ CPV $ display $ cfNm rd
162-
where
163-
cfNm :: [([InstalledPackageInfo], String)] -> PackageIdentifier
164-
cfNm = packageId . head . fst . head
166+
(([] ,_):_) -> Nothing
167+
((i:_,_):_) -> Just $ CPV $ display
168+
$ packageId (i :: InstalledPackageInfo)
165169

166170
-- ghc package text format
167171
-- "name: zlib-conduit\n

0 commit comments

Comments
 (0)