getGhcInfo :: IO GhcInfo
getGhcInfo = do
  fields <- read <$> readProcess "ghc" ["--info"] ""
  let lookupField :: String -> IO String
      lookupField name = do
        let err = "Output from `ghc --info` does not contain the field " ++ show name
        maybe (dieLoc err) return (lookup name fields)
  GhcInfo
    <$> lookupField "Target platform"
    <*> lookupField "Project version"
    <*> (Path <$> lookupField "Global Package DB")
getGhcInfo :: IO GhcInfo
getGhcInfo = do
  fields <- read <$> readProcess "ghc" ["--info"] ""
  let lookupField :: String -> IO String
      lookupField name = do
        let err = "Output from `ghc --info` does not contain the field " ++ show name
        maybe (dieLoc err) return (lookup name fields)
  GhcInfo
    <$> lookupField "Target platform"
    <*> lookupField "Project version"
    <*> (Path <$> lookupField "Global Package DB")
getGhcInfo = do
  fields <- read <$> readProcess "ghc" ["--info"] ""
  let lookupField :: String -> IO String
      lookupField name = do
        let err = "Output from `ghc --info` does not contain the field " ++ show name
        maybe (dieLoc err) return (lookup name fields)
  GhcInfo
    <$> lookupField "Target platform"
    <*> lookupField "Project version"
    <*> (Path <$> lookupField "Global Package DB")