Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data NodeSelector = NodeSelector {
- nodeIdentifier :: Maybe Text
- nodeLabels :: [Text]
- nodeProperties :: [(Text, Value)]
- nodeParams :: [(Text, Text)]
- data RelSelector = RelSelector {}
- class SelectorLike a where
- (.:) :: SelectorLike a => a -> Text -> a
- (.#) :: SelectorLike a => a -> [(Text, Value)] -> a
- toNodeSelector :: Node -> NodeSelector
- toRelSelector :: URelationship -> RelSelector
- data PathSelector
- data PathPart
- (-:) :: NodeSelector -> PathPart -> PathSelector
- (<-:) :: NodeSelector -> PathPart -> PathSelector
- data Selector
- = PS PathSelector
- | TS Text
- type Selectors = [Selector]
- (#) :: a -> (a -> b) -> b
- defaultNode :: NodeSelector
- defN :: NodeSelector
- defaultRel :: RelSelector
- defR :: RelSelector
- data Cond
- data Conds
- type CypherDSL a = Free Expr a
- createF :: Selectors -> Free Expr ()
- matchF :: Selectors -> Free Expr ()
- optionalMatchF :: Selectors -> Free Expr ()
- mergeF :: Selectors -> Free Expr ()
- whereF :: Conds -> Free Expr ()
- setF :: [Text] -> Free Expr ()
- deleteF :: [Text] -> Free Expr ()
- detachDeleteF :: [Text] -> Free Expr ()
- removeF :: [Text] -> Free Expr ()
- returnF :: [Text] -> Free Expr ()
- withF :: [Text] -> Free Expr ()
- textF :: Text -> Free Expr ()
- formQuery :: Free Expr () -> Text
- data Expr next
Selectors for nodes, relations and paths
These data types let you specify Cypher queries.
With OverloadedLabels
and operators you can write selectors in very concise
Cypher-like form:
(#n .: "Name" .# ["name" =: "C42"]) -: (defR .: "NAME_OF") :!->: (#m .: "Molecule") (n:Name{name:"C42"})-[:NAME_OF]->(m:Molecule)
data NodeSelector Source #
Selector for Node
s.
This datatype has OverloadedLabels
instance to simplify specifying nodes. Labels produce
empty nodes.
#foo :: NodeSelector -- foo = NodeSelector (Just "foo") [] []
NodeSelector | |
|
Instances
Eq NodeSelector Source # | |
Defined in Database.Bolt.Extras.DSL.Internal.Types (==) :: NodeSelector -> NodeSelector -> Bool # (/=) :: NodeSelector -> NodeSelector -> Bool # | |
Show NodeSelector Source # | |
Defined in Database.Bolt.Extras.DSL.Internal.Types showsPrec :: Int -> NodeSelector -> ShowS # show :: NodeSelector -> String # showList :: [NodeSelector] -> ShowS # | |
ToCypher NodeSelector Source # | |
Defined in Database.Bolt.Extras.DSL.Internal.Instances toCypher :: NodeSelector -> Text Source # | |
SelectorLike NodeSelector Source # | |
Defined in Database.Bolt.Extras.DSL.Internal.Instances withIdentifier :: Text -> NodeSelector -> NodeSelector Source # withLabel :: Text -> NodeSelector -> NodeSelector Source # withProp :: (Text, Value) -> NodeSelector -> NodeSelector Source # withParam :: (Text, Text) -> NodeSelector -> NodeSelector Source # | |
KnownSymbol x => IsLabel x NodeSelector Source # | |
Defined in Database.Bolt.Extras.DSL.Internal.Instances |
data RelSelector Source #
Selector for URelationship
s.
This datatype has OverloadedLabels
instance as well, similar to NodeSelector
.
Instances
Eq RelSelector Source # | |
Defined in Database.Bolt.Extras.DSL.Internal.Types (==) :: RelSelector -> RelSelector -> Bool # (/=) :: RelSelector -> RelSelector -> Bool # | |
Show RelSelector Source # | |
Defined in Database.Bolt.Extras.DSL.Internal.Types showsPrec :: Int -> RelSelector -> ShowS # show :: RelSelector -> String # showList :: [RelSelector] -> ShowS # | |
ToCypher RelSelector Source # | |
Defined in Database.Bolt.Extras.DSL.Internal.Instances toCypher :: RelSelector -> Text Source # | |
SelectorLike RelSelector Source # | |
Defined in Database.Bolt.Extras.DSL.Internal.Instances withIdentifier :: Text -> RelSelector -> RelSelector Source # withLabel :: Text -> RelSelector -> RelSelector Source # withProp :: (Text, Value) -> RelSelector -> RelSelector Source # withParam :: (Text, Text) -> RelSelector -> RelSelector Source # | |
KnownSymbol x => IsLabel x RelSelector Source # | |
Defined in Database.Bolt.Extras.DSL.Internal.Instances |
class SelectorLike a where Source #
Class for Selectors, which can update identifier, labels and props.
withIdentifier :: Text -> a -> a Source #
withLabel :: Text -> a -> a Source #
Instances
SelectorLike RelSelector Source # | |
Defined in Database.Bolt.Extras.DSL.Internal.Instances withIdentifier :: Text -> RelSelector -> RelSelector Source # withLabel :: Text -> RelSelector -> RelSelector Source # withProp :: (Text, Value) -> RelSelector -> RelSelector Source # withParam :: (Text, Text) -> RelSelector -> RelSelector Source # | |
SelectorLike NodeSelector Source # | |
Defined in Database.Bolt.Extras.DSL.Internal.Instances withIdentifier :: Text -> NodeSelector -> NodeSelector Source # withLabel :: Text -> NodeSelector -> NodeSelector Source # withProp :: (Text, Value) -> NodeSelector -> NodeSelector Source # withParam :: (Text, Text) -> NodeSelector -> NodeSelector Source # |
(.:) :: SelectorLike a => a -> Text -> a infixl 9 Source #
Operator version of withLabel
. To be used with OverloadedLabels
instances.
#foo .: "Foo" :: NodeSelector
toNodeSelector :: Node -> NodeSelector Source #
data PathSelector Source #
PathSelector :-!: PathPart infixl 1 | not directed relation |
PathSelector :<-!: PathPart infixl 1 | directed relation |
P NodeSelector | starting node of Path |
Instances
Eq PathSelector Source # | |
Defined in Database.Bolt.Extras.DSL.Internal.Types (==) :: PathSelector -> PathSelector -> Bool # (/=) :: PathSelector -> PathSelector -> Bool # | |
Show PathSelector Source # | |
Defined in Database.Bolt.Extras.DSL.Internal.Types showsPrec :: Int -> PathSelector -> ShowS # show :: PathSelector -> String # showList :: [PathSelector] -> ShowS # | |
ToCypher PathSelector Source # | |
Defined in Database.Bolt.Extras.DSL.Internal.Instances toCypher :: PathSelector -> Text Source # |
Selector for paths.
RelSelector :!->: NodeSelector infixl 2 | directed relation |
RelSelector :!-: NodeSelector infixl 2 | not directed relation |
(-:) :: NodeSelector -> PathPart -> PathSelector infixl 1 Source #
(<-:) :: NodeSelector -> PathPart -> PathSelector infixl 1 Source #
PS PathSelector | path selector |
TS Text | free text selector |
Default selectors
defaultNode :: NodeSelector Source #
Empty NodeSelector
.
defN :: NodeSelector Source #
Shorter synonym for defaultRel
.
defaultRel :: RelSelector Source #
Empty RelSelector
.
defR :: RelSelector Source #
Shorter synonym for defaultRel
.
Cypher conditions
Conditions.
ID Text BoltId | ID(txt) = boltId |
IDs Text [BoltId] | ID(txt) IN [boltId1, boltId2, ... ] |
IN Text [Text] | txt IN [txt1, txt2, ... ] |
TC Text | free text condition |
Conds :&&: Conds infixr 3 |
|
Conds :||: Conds infixr 2 |
|
C Cond | single |
Not Conds | NOT |
DSL for Cypher
The free-monadic DSL lets you write Cypher queries in Haskell like this:
formQuery $ do matchF [ PS $ (#n .: "Name" .# ["name" =: "C42"]) -: (defR .: "NAME_OF") :!->: (#m .: "Molecule") ] returnF ["n", "m"]
DSL operations
Rendering Cypher queries
Implementation details
Expression in Cypher language.
Create Selectors next | CREATE query |
Match Selectors next | MATCH query |
OptionalMatch Selectors next | OPTIONAL MATCH query |
Merge Selectors next | MERGE query |
Where Conds next | WHERE query |
Set [Text] next | SET query |
Delete [Text] next | DELETE query |
DetachDelete [Text] next | DETACH DELETE query |
Remove [Text] next | REMOVE query |
Return [Text] next | RETURN query |
With [Text] next | WITH query |
Text Text next | free text query |