Maintainer | Toshio Ito <debug.ito@gmail.com> |
---|---|
Safe Haskell | None |
Language | Haskell2010 |
Extra utility functions implemented by Greskell.
Since: 0.2.3.0
Synopsis
- lookupAs :: (PMapKey k, NonEmptyLike c, PMapValue k ~ a, FromGraphSON a) => k -> PMap c GValue -> Either PMapLookupException a
- lookupAs' :: (PMapKey k, NonEmptyLike c, PMapValue k ~ Maybe a, FromGraphSON a) => k -> PMap c GValue -> Either PMapLookupException (Maybe a)
- lookupListAs :: (PMapKey k, NonEmptyLike c, PMapValue k ~ a, FromGraphSON a) => k -> PMap c GValue -> Either PMapLookupException (NonEmpty a)
- lookupListAs' :: (PMapKey k, NonEmptyLike c, PMapValue k ~ Maybe a, FromGraphSON a) => k -> PMap c GValue -> Either PMapLookupException [Maybe a]
- pMapToFail :: MonadFail m => Either PMapLookupException a -> m a
- writeKeyValues :: Element e => [KeyValue e] -> Walk SideEffect e e
- (<=:>) :: ToJSON b => Key a b -> b -> Binder (KeyValue a)
- (<=?>) :: ToJSON b => Key a (Maybe b) -> Maybe b -> Binder (KeyValue a)
- writePropertyKeyValues :: (ToJSON v, Element e) => [(Text, v)] -> Binder (Walk SideEffect e e)
- writePMapProperties :: (Foldable c, ToJSON v, Element e) => PMap c v -> Binder (Walk SideEffect e e)
Property readers
Re-export property readers.
Since: 1.0.0.0
lookupAs :: (PMapKey k, NonEmptyLike c, PMapValue k ~ a, FromGraphSON a) => k -> PMap c GValue -> Either PMapLookupException a Source #
Lookup the value and parse it into a
.
lookupAs' :: (PMapKey k, NonEmptyLike c, PMapValue k ~ Maybe a, FromGraphSON a) => k -> PMap c GValue -> Either PMapLookupException (Maybe a) Source #
lookupListAs :: (PMapKey k, NonEmptyLike c, PMapValue k ~ a, FromGraphSON a) => k -> PMap c GValue -> Either PMapLookupException (NonEmpty a) Source #
Look up the values and parse them into a
.
lookupListAs' :: (PMapKey k, NonEmptyLike c, PMapValue k ~ Maybe a, FromGraphSON a) => k -> PMap c GValue -> Either PMapLookupException [Maybe a] Source #
Similar to lookupListAs
, but this function accepts null
results.
If the key k
is not found in the map, it returns an empty
list. If the key k
is found and null
s are included in the
values, they are obtained as Nothing
.
pMapToFail :: MonadFail m => Either PMapLookupException a -> m a Source #
Convert the lookup result into a MonadFail
. It fails with the
description returned by pMapDecribeError
.
Property writers
writeKeyValues :: Element e => [KeyValue e] -> Walk SideEffect e e Source #
Make a series of .property
steps to write the given key-value
pairs as properties. Use <=:>
and <=?>
to make a KeyValue
within Binder
.
>>>
let keyAge = ("age" :: Key AVertex Int)
>>>
let keyName = ("name" :: Key AVertex Text)
>>>
let (walk, binding) = runBinder $ writeKeyValues <$> sequence [keyAge <=:> 21, keyName <=:> "Josh"]
>>>
toGremlin walk
"__.property(\"age\",__v0).property(\"name\",__v1).identity()">>>
sortBy (comparing fst) $ HashMap.toList binding
[("__v0",Number 21.0),("__v1",String "Josh")]
Since: 1.0.0.0
(<=?>) :: ToJSON b => Key a (Maybe b) -> Maybe b -> Binder (KeyValue a) Source #
Like <=:>
, but this one is for an optional property. If the
value is Just
, it's equivalent to <=:>
. If the value is
Nothing
, it returns KeyNoValue
.
>>>
let keyNName = ("nickname" :: Key AVertex (Maybe Text))
>>>
let keyCompany = ("company" :: Key AVertex (Maybe Text))
>>>
let (walk, binding) = runBinder $ writeKeyValues <$> sequence [keyNName <=?> Nothing, keyCompany <=?> Just "foobar.com"]
>>>
toGremlin walk
"__.property(\"company\",__v0).identity()">>>
sortBy (comparing fst) $ HashMap.toList binding
[("__v0",String "foobar.com")]
Since: 1.0.0.0
writePropertyKeyValues :: (ToJSON v, Element e) => [(Text, v)] -> Binder (Walk SideEffect e e) Source #
Make a series of .property
steps to write the given key-value
pairs as properties.
>>>
let binder = (writePropertyKeyValues [("age", (21 :: Int))] :: Binder (Walk SideEffect AVertex AVertex))
>>>
let (walk, binding) = runBinder binder
>>>
toGremlin walk
"__.property(\"age\",__v0).identity()">>>
sortBy (comparing fst) $ HashMap.toList binding
[("__v0",Number 21.0)]
Since: 0.2.3.0