cayley-client 0.2.1.0 → 0.2.1.1
raw patch · 2 files changed
+21/−27 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- Database/Cayley/Client.hs +18/−24
- cayley-client.cabal +3/−3
Database/Cayley/Client.hs view
@@ -34,8 +34,8 @@ import Control.Monad.Catch import Control.Monad.Reader import qualified Data.Aeson as A-import Data.Aeson.Lens (key)-import qualified Data.Attoparsec.Text as AT+import qualified Data.Aeson.Lens as L+import qualified Data.Attoparsec.Text as APT import qualified Data.Text as T import Data.Text.Encoding (encodeUtf8) import Network.HTTP.Client@@ -71,10 +71,10 @@ serverPort (RequestBodyBS _q) return $ case r of Just a ->- case a ^? key "result" of+ case a ^? L.key "result" of Just v -> Right v Nothing ->- case a ^? key "error" of+ case a ^? L.key "error" of Just e -> case A.fromJSON e of A.Success s -> Left s@@ -213,28 +213,22 @@ -> IO (Either String Int) successfulResults m = return $ case m of- Just a ->- case a ^? key "result" of- Just v ->- case A.fromJSON v of- A.Success s ->- case AT.parse getAmount s of- AT.Done "" b -> Right b- _ -> Left "Can't get amount of successful results"- A.Error e -> Left e+ Just v ->+ case v ^? L.key "result" . L._String of+ Just r ->+ case APT.parse getAmount r of+ APT.Done "" i -> Right i+ _ -> fail "Can't get amount of successful results" Nothing ->- case a ^? key "error" of- Just e ->- case A.fromJSON e of- A.Success s -> Left s- A.Error r -> Left r- Nothing -> Left "No JSON response from Cayley server"- Nothing -> Left "Can't get any response from Cayley server"+ case v ^? L.key "error" . L._String of+ Just e -> fail (T.unpack e)+ Nothing -> fail "No JSON response from Cayley server"+ Nothing -> fail "Can't get any response from Cayley server" where getAmount = do- _ <- AT.string "Successfully "- _ <- AT.string "deleted " <|> AT.string "wrote "- a <- AT.decimal- _ <- AT.string " quads."+ _ <- APT.string "Successfully "+ _ <- APT.string "deleted " <|> APT.string "wrote "+ a <- APT.decimal+ _ <- APT.string " quads." return a
cayley-client.cabal view
@@ -1,5 +1,5 @@ name: cayley-client-version: 0.2.1.0+version: 0.2.1.1 synopsis: A Haskell client for the Cayley graph database description: cayley-client implements the RESTful API of the Cayley graph database. homepage: https://github.com/MichelBoucey/cayley-client@@ -23,7 +23,7 @@ , Database.Cayley.Types other-modules: Database.Cayley.Internal other-extensions: OverloadedStrings- build-depends: base >=4.7 && <5+ build-depends: base >=4.8 && <5 , mtl >=2.1 , transformers >=0.3 , attoparsec >=0.12@@ -46,7 +46,7 @@ hs-source-dirs: tests main-is: hspec.hs build-depends: hspec >= 2.2.2- , base >= 4.7 && < 5+ , base >= 4.8 && < 5 , cayley-client , aeson >=0.8 , unordered-containers >= 0.2.5