@@ -10,6 +10,7 @@ import Control.Arrow (first, (***))
10import Control.Monad (when)
10import Control.Monad (when)
11import Control.Monad.Error.Class (catchError)
11import Control.Monad.Error.Class (catchError)
13+import Data.Monoid ((<>))
13import Data.Aeson ((.=))
14import Data.Aeson ((.=))
14import Data.Aeson.BetterErrors
15import Data.Aeson.BetterErrors
15import Data.ByteString.Lazy (ByteString)
16import Data.ByteString.Lazy (ByteString)
@@ -358,8 +359,6 @@ displayPackageError e = case e of
358 "Invalid kind: \"" <> str <> "\""
359 "Invalid kind: \"" <> str <> "\""
359 InvalidDataDeclType str ->
360 InvalidDataDeclType str ->
360 "Invalid data declaration type: \"" <> str <> "\""
361 "Invalid data declaration type: \"" <> str <> "\""
364instance A.FromJSON a => A.FromJSON (Package a) where
363instance A.FromJSON a => A.FromJSON (Package a) where
365 parseJSON = toAesonParser displayPackageError
364 parseJSON = toAesonParser displayPackageError
@@ -413,7 +412,7 @@ asReExport =
414asInPackage :: Parse BowerError a -> Parse BowerError (InPackage a)
413asInPackage :: Parse BowerError a -> Parse BowerError (InPackage a)
415asInPackage inner =
414asInPackage inner =
416− build <$> key "package" (perhaps (withString parsePackageName))
415+ build <$> key "package" (perhaps (withText parsePackageName))
417 <*> key "item" inner
416 <*> key "item" inner
419 build Nothing = Local
418 build Nothing = Local
@@ -468,8 +467,8 @@ asTypeArguments = eachInArray asTypeArgument
469 asTypeArgument = (,) <$> nth 0 asText <*> nth 1 (perhaps asKind)
468 asTypeArgument = (,) <$> nth 0 asText <*> nth 1 (perhaps asKind)
471−asKind :: Parse e P.Kind
470+asKind :: Parse PackageError P.Kind
472−asKind = fromAesonParser
471+asKind = P.kindFromJSON .! InvalidKind
474asType :: Parse e P.Type
473asType :: Parse e P.Type
475asType = fromAesonParser
474asType = fromAesonParser
@@ -532,7 +531,7 @@ asBookmark =
533asResolvedDependencies :: Parse PackageError [(PackageName, Version)]
532asResolvedDependencies :: Parse PackageError [(PackageName, Version)]
534asResolvedDependencies =
533asResolvedDependencies =
535− eachInObjectWithKey (mapLeft ErrorInPackageMeta . parsePackageName . T.unpack) asVersion
534+ eachInObjectWithKey (mapLeft ErrorInPackageMeta . parsePackageName) asVersion
537 mapLeft f (Left x) = Left (f x)
536 mapLeft f (Left x) = Left (f x)
538 mapLeft _ (Right x) = Right x
537 mapLeft _ (Right x) = Right x
@@ -557,7 +556,7 @@ instance A.ToJSON a => A.ToJSON (Package a) where
557 , "versionTag" .= pkgVersionTag
556 , "versionTag" .= pkgVersionTag
558 , "modules" .= pkgModules
557 , "modules" .= pkgModules
559 , "bookmarks" .= map (fmap (first P.runModuleName)) pkgBookmarks
558 , "bookmarks" .= map (fmap (first P.runModuleName)) pkgBookmarks
560− , "resolvedDependencies" .= assocListToJSON (T.pack . runPackageName)
559+ , "resolvedDependencies" .= assocListToJSON runPackageName
561 (T.pack . showVersion)
560 (T.pack . showVersion)
562 pkgResolvedDependencies
561 pkgResolvedDependencies
563 , "github" .= pkgGithub
562 , "github" .= pkgGithub