packages feed

cayley-client 0.1.3.0 → 0.1.4.0

raw patch · 3 files changed

+26/−9 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Database.Cayley.Client: createQuad :: Text -> Text -> Text -> Maybe Text -> Maybe Quad
+ Database.Cayley.Client: isValid :: Quad -> Bool

Files

Database/Cayley/Client.hs view
@@ -12,7 +12,9 @@     , writeQuads     , deleteQuads     , writeNQuadFile-    -- * Helper function+    -- * Utils+    , isValid+    , createQuad     , successfulResults     ) where  @@ -26,11 +28,12 @@ import Data.Maybe (fromJust) import qualified Data.Text as T import Data.Text.Encoding (encodeUtf8)-import Database.Cayley.Internal-import Database.Cayley.Types import Network.HTTP.Client import Network.HTTP.Client.MultipartFormData +import Database.Cayley.Internal+import Database.Cayley.Types+ -- | Get a connection to Cayley with the given configuration. -- -- >λ> conn <- connectCayley defaultCayleyConfig@@ -154,6 +157,18 @@             Right r -> A.decode $ responseBody r             Left e  -> Just $                 A.object ["error" A..= T.pack (show (e :: SomeException))]++-- | A valid 'Quad' has its subject, predicate and object not empty.+isValid :: Quad -> Bool+isValid q = T.empty `notElem` [subject q, predicate q, object q]++-- | Given a subject, a predicate, an object and an optional label,+-- create a valid 'Quad'.+createQuad :: T.Text -> T.Text -> T.Text -> Maybe T.Text -> Maybe Quad+createQuad s p o l =+    if T.empty `notElem` [s,p,o]+        then Just Quad { subject = s, predicate = p, object = o, label = l }+        else Nothing  -- | Get amount of successful results from a write/delete 'Quad'(s) -- operation.
Database/Cayley/Types.hs view
@@ -45,20 +45,22 @@  instance Show Quad where     show (Quad s p o (Just l)) = T.unpack s-                                 ++ " "+                                 ++ " -- "                                  ++ T.unpack p-                                 ++ " "+                                 ++ " -> "                                  ++ T.unpack o                                  ++ " ("                                  ++ T.unpack l                                  ++ ")"     show (Quad s p o Nothing)  = T.unpack s-                                 ++ " "+                                 ++ " -- "                                  ++ T.unpack p-                                 ++ " "+                                 ++ " -> "                                  ++ T.unpack o++-- | Two quads are equals when subject, predicate, object /and/ label are equals. instance Eq Quad where-    Quad s p o _ == Quad s' p' o' _ = s == s' && p == p' && o == o'+    Quad s p o l == Quad s' p' o' l' = s == s' && p == p' && o == o' && l == l'  instance A.ToJSON Quad where     toJSON (Quad subject predicate object label) =
cayley-client.cabal view
@@ -1,5 +1,5 @@ name:                cayley-client-version:             0.1.3.0+version:             0.1.4.0 stability:           Experimental synopsis:            A Haskell client for the Cayley graph database description:         cayley-client implements the RESTful API of the Cayley graph database.