cayley-client-0.4.19.3: A Haskell client for the Cayley graph database
Safe HaskellSafe-Inferred
LanguageHaskell2010

Database.Cayley.Client

Synopsis

Documentation

data Quad Source #

Constructors

Quad 

Fields

Instances

Instances details
FromJSON Quad Source # 
Instance details

Defined in Database.Cayley.Types

ToJSON Quad Source # 
Instance details

Defined in Database.Cayley.Types

Generic Quad Source # 
Instance details

Defined in Database.Cayley.Types

Associated Types

type Rep Quad :: Type -> Type #

Methods

from :: Quad -> Rep Quad x #

to :: Rep Quad x -> Quad #

Show Quad Source # 
Instance details

Defined in Database.Cayley.Types

Methods

showsPrec :: Int -> Quad -> ShowS #

show :: Quad -> String #

showList :: [Quad] -> ShowS #

Binary Quad Source # 
Instance details

Defined in Database.Cayley.Types

Methods

put :: Quad -> Put #

get :: Get Quad #

putList :: [Quad] -> Put #

Eq Quad Source #

Two quads are equals when subject, predicate, object and label are equals.

Instance details

Defined in Database.Cayley.Types

Methods

(==) :: Quad -> Quad -> Bool #

(/=) :: Quad -> Quad -> Bool #

type Rep Quad Source # 
Instance details

Defined in Database.Cayley.Types

type Rep Quad = D1 ('MetaData "Quad" "Database.Cayley.Types" "cayley-client-0.4.19.3-DEELHK4hWB6K79WI6a0ukH" 'False) (C1 ('MetaCons "Quad" 'PrefixI 'True) ((S1 ('MetaSel ('Just "subject") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Text) :*: S1 ('MetaSel ('Just "predicate") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Text)) :*: (S1 ('MetaSel ('Just "object") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Text) :*: S1 ('MetaSel ('Just "label") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Maybe Text)))))

Connection

defaultCayleyConfig :: CayleyConfig Source #

CayleyConfig { serverPort = 64210 , serverName = "localhost" , apiVersion = V1 , queryLang = Gremlin }

connectCayley :: CayleyConfig -> IO CayleyConnection Source #

Get a connection to Cayley with the given configuration.

λ> conn <- connectCayley defaultCayleyConfig

Operations

query :: CayleyConnection -> Query -> IO (Either String Value) Source #

Perform a query, in Gremlin graph query language per default (or in MQL).

λ> query conn "graph.Vertex('Humphrey Bogart').In('name').All()"
Right (Array (fromList [Object (fromList [("id",String "/en/humphrey_bogart")])]))

data Shape Source #

Instances

Instances details
FromJSON Shape Source # 
Instance details

Defined in Database.Cayley.Types

Show Shape Source # 
Instance details

Defined in Database.Cayley.Types

Methods

showsPrec :: Int -> Shape -> ShowS #

show :: Shape -> String #

showList :: [Shape] -> ShowS #

Eq Shape Source # 
Instance details

Defined in Database.Cayley.Types

Methods

(==) :: Shape -> Shape -> Bool #

(/=) :: Shape -> Shape -> Bool #

queryShape :: CayleyConnection -> Query -> IO (Either String Shape) Source #

Return the description of the given executed query.

write :: CayleyConnection -> Quad -> IO (Maybe Value) Source #

Write the given Quad.

writeQuad :: CayleyConnection -> Subject -> Predicate -> Object -> Maybe Label -> IO (Maybe Value) Source #

Write a Quad with the given subject, predicate, object and optional label. Throw result or extract amount of query results from it.

λ> writeQuad conn "Humphrey" "loves" "Lauren" (Just "In love")
Just (Object (fromList [("result",String "Successfully wrote 1 quads.")]))

writeQuads :: CayleyConnection -> [Quad] -> IO (Maybe Value) Source #

Write the given list of Quad(s).

writeNQuadFile :: (MonadThrow m, MonadIO m) => CayleyConnection -> FilePath -> m (Maybe Value) Source #

Write a N-Quad file.

λ> writeNQuadFile conn "testdata.nq"
Just (Object (fromList [("result",String "Successfully wrote 11 quads.")]))

delete :: CayleyConnection -> Quad -> IO (Maybe Value) Source #

Delete the given Quad.

deleteQuad :: CayleyConnection -> Subject -> Predicate -> Object -> Maybe Label -> IO (Maybe Value) Source #

Delete the Quad defined by the given subject, predicate, object and optional label.

deleteQuads :: CayleyConnection -> [Quad] -> IO (Maybe Value) Source #

Delete the given list of Quad(s).

Utils

createQuad :: Subject -> Predicate -> Object -> Maybe Label -> Maybe Quad Source #

Given a subject, a predicate, an object and an optional label, create a valid Quad.

isValid :: Quad -> Bool Source #

A valid Quad has its subject, predicate and object not empty.

results :: Maybe Value -> IO (Either String Int) Source #

Get amount of results from a write/delete Quad(s) operation, or an explicite error message.

λ> writeNQuadFile conn "testdata.nq" >>= results
Right 11