diff --git a/src/Stack/Types/Config.hs b/src/Stack/Types/Config.hs index be67b98e49..cc370bbbf5 100644 --- a/src/Stack/Types/Config.hs +++ b/src/Stack/Types/Config.hs @@ -4,8 +4,10 @@ {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE TemplateHaskell #-} +{-# LANGUAGE TupleSections #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE RecordWildCards #-} +{-# LANGUAGE ScopedTypeVariables #-} -- | The Config type. @@ -336,7 +338,7 @@ instance ToJSON PackageEntry where ] instance FromJSON (PackageEntry, [JSONWarning]) where parseJSON (String t) = do - loc <- parseJSON $ String t + (loc, _::[JSONWarning]) <- parseJSON $ String t return (PackageEntry { peExtraDepMaybe = Nothing , peValidWanted = Nothing @@ -346,7 +348,7 @@ instance FromJSON (PackageEntry, [JSONWarning]) where parseJSON v = withObjectWarnings "PackageEntry" (\o -> PackageEntry <$> o ..:? "extra-dep" <*> o ..:? "valid-wanted" - <*> o ..: "location" + <*> jsonSubWarnings (o ..: "location") <*> o ..:? "subdirs" ..!= []) v data PackageLocation @@ -361,17 +363,17 @@ instance ToJSON PackageLocation where toJSON (PLFilePath fp) = toJSON fp toJSON (PLHttpTarball t) = toJSON t toJSON (PLGit x y) = toJSON $ T.unwords ["git", x, y] -instance FromJSON PackageLocation where - parseJSON v = git v <|> withText "PackageLocation" (\t -> http t <|> file t) v +instance FromJSON (PackageLocation, [JSONWarning]) where + parseJSON v = git v <|> ((,[]) <$> withText "PackageLocation" (\t -> http t <|> file t) v) where file t = pure $ PLFilePath $ T.unpack t http t = case parseUrl $ T.unpack t of Left _ -> mzero Right _ -> return $ PLHttpTarball t - git = withObject "PackageGitLocation" $ \o -> PLGit - <$> o .: "git" - <*> o .: "commit" + git = withObjectWarnings "PackageGitLocation" $ \o -> PLGit + <$> o ..: "git" + <*> o ..: "commit" -- | A project is a collection of packages. We can have multiple stack.yaml -- files, but only one of them may contain project information.