| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Database.Bolt.Extras.Template
Synopsis
- class FromValue a where
- type Label = Text
- class Labels a where
- data Node = Node {}
- class NodeLike a where
- class Properties a where
- type Property = (Text, Value)
- data Relationship = Relationship {}
- class ToValue a where
- class URelationLike a where
- data URelationship = URelationship {}
- data Value
- makeNodeLike :: Name -> Q [Dec]
- makeURelationLike :: Name -> Q [Dec]
Documentation
class FromValue a where Source #
Minimal complete definition
Instances
| FromValue Bool Source # | |
| FromValue Double Source # | |
| FromValue Float Source # | |
| FromValue Int Source # | |
| FromValue () Source # | |
Defined in Database.Bolt.Extras.Template.Instances | |
| FromValue Text Source # | |
| FromValue Structure Source # | |
| FromValue Value Source # | |
| FromValue a => FromValue [a] Source # | |
Defined in Database.Bolt.Extras.Template.Instances | |
| FromValue a => FromValue (Maybe a) Source # | |
| FromValue (Map Text Value) Source # | |
Minimal complete definition
Instances
| Labels Node Source # | |
| Labels URelationship Source # | |
Defined in Database.Bolt.Extras.Template.Types Methods getLabels :: URelationship -> [Label] Source # | |
Constructors
| Node | |
class Properties a where Source #
Minimal complete definition
Instances
| Properties Node Source # | |
| Properties URelationship Source # | |
Defined in Database.Bolt.Extras.Template.Types | |
data Relationship #
Constructors
| Relationship | |
Instances
| Eq Relationship | |
Defined in Database.Bolt.Value.Type | |
| Show Relationship | |
Defined in Database.Bolt.Value.Type Methods showsPrec :: Int -> Relationship -> ShowS # show :: Relationship -> String # showList :: [Relationship] -> ShowS # | |
| RecordValue Relationship | |
Defined in Database.Bolt.Record Methods exact :: Monad m => Value -> m Relationship # | |
| GetBoltId Relationship Source # | |
Defined in Database.Bolt.Extras.Persisted Methods getBoltId :: Relationship -> BoltId Source # | |
class ToValue a where Source #
Minimal complete definition
Instances
| ToValue Bool Source # | |
| ToValue Double Source # | |
| ToValue Float Source # | |
| ToValue Int Source # | |
| ToValue () Source # | |
Defined in Database.Bolt.Extras.Template.Instances | |
| ToValue Text Source # | |
| ToValue Structure Source # | |
| ToValue Value Source # | |
| ToValue a => ToValue [a] Source # | |
Defined in Database.Bolt.Extras.Template.Instances | |
| ToValue a => ToValue (Maybe a) Source # | |
| ToValue (Map Text Value) Source # | |
class URelationLike a where Source #
URelationLike class represents convertable into and from URelationship.
Minimal complete definition
data URelationship #
Constructors
| URelationship | |
Instances
| Eq URelationship | |
Defined in Database.Bolt.Value.Type Methods (==) :: URelationship -> URelationship -> Bool # (/=) :: URelationship -> URelationship -> Bool # | |
| Show URelationship | |
Defined in Database.Bolt.Value.Type Methods showsPrec :: Int -> URelationship -> ShowS # show :: URelationship -> String # showList :: [URelationship] -> ShowS # | |
| RecordValue URelationship | |
Defined in Database.Bolt.Record Methods exact :: Monad m => Value -> m URelationship # | |
| Properties URelationship Source # | |
Defined in Database.Bolt.Extras.Template.Types | |
| Labels URelationship Source # | |
Defined in Database.Bolt.Extras.Template.Types Methods getLabels :: URelationship -> [Label] Source # | |
| GetBoltId URelationship Source # | |
Defined in Database.Bolt.Extras.Persisted Methods getBoltId :: URelationship -> BoltId Source # | |
Instances
| Eq Value | |
| Show Value | |
| FromValue Value Source # | |
| ToValue Value Source # | |
| ToCypher Value Source # | Convertation for |
| ToCypher Property Source # | Converts property with |
| ToCypher [Property] Source # | Several properties are formatted with concatenation. |
| RecordValue (Map Text Value) | |
| FromValue (Map Text Value) Source # | |
| ToValue (Map Text Value) Source # | |
makeNodeLike :: Name -> Q [Dec] Source #
Make an instance of NodeLike class.
Only data types with one constructor are currently supported.
Each field is transformed into Text key and its value is transformed into a Value.
For example, we have a structure
data Foo = Bar { baz :: Double
, quux :: Text
, quuz :: Int
}You can make it instance of NodeClass by writing > makeNodeLike ''Foo
Then you may create example and convert it into from from Node:
ghci>:set -XOverloadedStrings
ghci> let foo = Bar 42.0 "Loren ipsum" 7
ghci> toNode foo
Node {nodeIdentity = -1, labels = ["Foo"], nodeProps = fromList [("baz",F 42.0),("quux",T "Loren ipsum"),("quuz",I 7)]}
ghci> fromNode . toNode $ foo :: Foo
Bar {baz = 42.0, quux = "Loren ipsum", quuz = 7}makeURelationLike :: Name -> Q [Dec] Source #
Make an instance of URelationLike class.
Transformations are the same as in NodeLike instance declaration with the only one difference:
URelationship holds only one label (or type), but Node holds list of labels.