Skip to content

Commit

Permalink
Bump version to 2.0.1.0, add elementMap step
Browse files Browse the repository at this point in the history
  • Loading branch information
ners committed Nov 16, 2022
1 parent 78d970a commit 85f9882
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 6 deletions.
3 changes: 2 additions & 1 deletion greskell/ChangeLog.md
@@ -1,10 +1,11 @@
# Revision history for greskell

## 2.0.0.1 -- ?
## 2.0.1.0

* Confirm test with ghc-9.2.1.
* Remove doctests. This was because it's become more and more difficult to run doctests in a cabal package.
* @ners helped a lot in https://github.com/debug-ito/greskell/pull/12
* Add the `gElementMap` function.

## 2.0.0.0 -- 2021-12-28

Expand Down
2 changes: 1 addition & 1 deletion greskell/greskell.cabal
@@ -1,5 +1,5 @@
name: greskell
version: 2.0.0.1
version: 2.0.1.0
author: Toshio Ito <debug.ito@gmail.com>
maintainer: Toshio Ito <debug.ito@gmail.com>
license: BSD3
Expand Down
20 changes: 16 additions & 4 deletions greskell/src/Data/Greskell/GTraversal.hs
Expand Up @@ -148,6 +148,7 @@ module Data.Greskell.GTraversal
, gId
, gLabel
, gValueMap
, gElementMap
, gSelect1
, gSelectN
, gSelectBy1
Expand Down Expand Up @@ -232,7 +233,7 @@ import Data.Greskell.AsLabel (AsLabel, LabeledP, SelectedMap)
import Data.Greskell.Graph (AEdge, AVertex, AVertexProperty, Cardinality, Edge,
Element (..), ElementID (..), Key, KeyValue (..),
Keys (..), Path, Property (..), T, Vertex, cList, tId,
(-:), (=:))
toGremlinKeys, (-:), (=:))
import Data.Greskell.GraphSON (FromGraphSON, GValue)
import Data.Greskell.Gremlin (Comparator (..), P, oDecr, oIncr, pBetween, pEq, pLte)
import Data.Greskell.Greskell (Greskell, ToGreskell (..), gvalueInt, toGremlin,
Expand Down Expand Up @@ -1391,9 +1392,14 @@ gValueMap :: Element s
=> Keys s
-> Walk Transform s (PMap (ElementPropertyContainer s) GValue)
gValueMap keys = unsafeWalk "valueMap" $ toGremlinKeys keys
where
toGremlinKeys KeysNil = []
toGremlinKeys (KeysCons k rest) = toGremlin k : toGremlinKeys rest

-- | @.elementMap@ step.
--
-- @since 2.0.1.0
gElementMap :: Element s
=> Keys s
-> Walk Transform s (PMap Single GValue)
gElementMap keys = unsafeWalk "elementMap" $ toGremlinKeys keys

-- | @.select@ step with one argument.
--
Expand Down Expand Up @@ -1819,6 +1825,12 @@ examples =
, ( toGremlin (source "g" & sV' [] &. gValueMap ("name" -: "age" -: KeysNil))
, "g.V().valueMap(\"name\",\"age\")"
)
, ( toGremlin (source "g" & sV' [] &. gElementMap KeysNil)
, "g.V().elementMap()"
)
, ( toGremlin (source "g" & sV' [] &. gElementMap ("name" -: "age" -: KeysNil))
, "g.V().elementMap(\"name\",\"age\")"
)
, ( let name_label = "a" :: AsLabel Text
name_key = "name" :: Key AVertex Text
count_label = "b" :: AsLabel Int
Expand Down
8 changes: 8 additions & 0 deletions greskell/src/Data/Greskell/Graph.hs
Expand Up @@ -44,6 +44,7 @@ module Data.Greskell.Graph
-- ** Heterogeneous list of keys
, Keys (..)
, singletonKeys
, toGremlinKeys
, (-:)
-- * Path
, Path (..)
Expand Down Expand Up @@ -298,6 +299,13 @@ instance Monoid (Keys a) where
singletonKeys :: Key a b -> Keys a
singletonKeys k = KeysCons k KeysNil

-- | Convert 'Keys' to a list of Gremlin scripts.
--
-- @since 2.0.1.0
toGremlinKeys :: Keys a -> [Text]
toGremlinKeys KeysNil = []
toGremlinKeys (KeysCons k rest) = toGremlin k : toGremlinKeys rest

-- | Prepend a 'Key' to 'Keys'.
--
-- @since 1.0.0.0
Expand Down

0 comments on commit 85f9882

Please sign in to comment.