-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Haskell binding for Gremlin graph query language -- -- Haskell binding for Gremlin graph query language. See -- README.md for detail. -- -- This package is the main entry point of greskell family. It re-exports -- greskell-core package, and adds some useful functions to it. @package greskell @version 2.0.3.0 -- | This modules defines types and functions for utility classes in -- Gremlin. module Data.Greskell.Gremlin -- | java.util.function.Predicate interface. -- -- A Predicate p is a function that takes -- PredicateArg p and returns Bool. class Predicate p where { type PredicateArg p; } -- | .and method. pAnd :: Predicate p => Greskell p -> Greskell p -> Greskell p -- | .or method. pOr :: Predicate p => Greskell p -> Greskell p -> Greskell p -- | .test method. pTest :: Predicate p => Greskell p -> Greskell (PredicateArg p) -> Greskell Bool -- | .nagate method. pNegate :: Predicate p => Greskell p -> Greskell p -- | Type for anonymous class of Predicate interface. newtype PredicateA a PredicateA :: (a -> Bool) -> PredicateA a [unPredicateA] :: PredicateA a -> a -> Bool -- | org.apache.tinkerpop.gremlin.process.traversal.P class. -- -- P a keeps data of type a and compares it with data -- of type a given as the Predicate argument. data P a -- | Type that is compatible with P. You can construct a value of -- type Greskell p using values of PParameter p. -- -- Note that the type of constuctor arguments (i.e. GreskellReturn -- (PParameter p)) should implement Java's Comparable -- interface. This is true for most types, so greskell doesn't have any -- explicit constraint about it. class (ToGreskell (PParameter p)) => PLike p where { type PParameter p; } -- | P.not static method. pNot :: PLike p => Greskell p -> Greskell p -- | P.eq static method. pEq :: PLike p => PParameter p -> Greskell p -- | P.neq static method. pNeq :: PLike p => PParameter p -> Greskell p -- | P.lt static method. pLt :: PLike p => PParameter p -> Greskell p -- | P.lte static method. pLte :: PLike p => PParameter p -> Greskell p -- | P.gt static method. pGt :: PLike p => PParameter p -> Greskell p -- | P.gte static method. pGte :: PLike p => PParameter p -> Greskell p -- | P.inside static method. pInside :: PLike p => PParameter p -> PParameter p -> Greskell p -- | P.outside static method. pOutside :: PLike p => PParameter p -> PParameter p -> Greskell p -- | P.between static method. pBetween :: PLike p => PParameter p -> PParameter p -> Greskell p -- | P.within static method. pWithin :: PLike p => [PParameter p] -> Greskell p -- | P.without static method. pWithout :: PLike p => [PParameter p] -> Greskell p -- | java.util.Comparator interface. -- -- Comparator compares two data of type CompareArg -- c. class Comparator c where { type CompareArg c; } -- | .compare method. cCompare :: Comparator c => Greskell c -> Greskell (CompareArg c) -> Greskell (CompareArg c) -> Greskell Int -- | .reversed method. cReversed :: Comparator c => Greskell c -> Greskell c -- | .thenComparing method. cThenComparing :: Comparator c => Greskell c -> Greskell c -> Greskell c -- | Type for anonymous class of Comparator interface. newtype ComparatorA a ComparatorA :: (a -> a -> Int) -> ComparatorA a [unComparatorA] :: ComparatorA a -> a -> a -> Int -- | org.apache.tinkerpop.gremlin.process.traversal.Order enum. data Order a -- | desc order. oDesc :: Greskell (Order a) -- | asc order. oAsc :: Greskell (Order a) -- | decr order. -- -- Note that decr was removed in TinkerPop 3.5.0. Use -- oDesc instead. oDecr :: Greskell (Order a) -- | incr order. -- -- Note that incr was removed in TinkerPop 3.5.0. Use -- oAsc instead. oIncr :: Greskell (Order a) -- | shuffle order. oShuffle :: Greskell (Order a) -- | Examples of using this module. See the source. The fst of the -- output is the testee, while the snd is the expectation. examples :: [(Text, Text)] instance Data.Greskell.Gremlin.Comparator (Data.Greskell.Gremlin.Order a) instance Data.Greskell.GraphSON.GraphSONTyped.GraphSONTyped (Data.Greskell.Gremlin.Order a) instance Data.Greskell.Gremlin.Comparator (Data.Greskell.Gremlin.ComparatorA a) instance Data.Greskell.Gremlin.PLike (Data.Greskell.Gremlin.P a) instance Data.Greskell.Gremlin.Predicate (Data.Greskell.Gremlin.P a) instance Data.Greskell.GraphSON.GraphSONTyped.GraphSONTyped (Data.Greskell.Gremlin.P a) instance Data.Greskell.Gremlin.Predicate (Data.Greskell.Gremlin.PredicateA a) -- | Developer note: This module defines Logic, a data structure for -- logic operation tree. There are already similar packages to this -- module, but, none of them satisfy our requirements. -- -- Boolean/logic tree data structures -- --
-- (gSideEffect w == gIdentity) AND (gFilter w == w) ---- -- If Walks w1 and w2 are Filter type, -- then -- --
-- gAnd [w1, w2] == w1 >>> w2 == w2 >>> w1 --data Filter -- | WalkType for steps without any side-effects. This includes -- transformations, reordring, injections and graph traversal actions. -- -- A Walk w is Transform type iff: -- --
-- gSideEffect w == gIdentity ---- -- Obviously, every Filter type Walks are also -- Transform type. data Transform -- | WalkType for steps that may have side-effects. -- -- A side-effect here means manipulation of the "sideEffect" in Gremlin -- context (i.e. the stash of data kept in a Traversal object), as well -- as interaction with the world outside the Traversal object. -- -- For example, the following steps (in Gremlin) all have side-effects. -- --
-- .addE('label')
-- .aggregate('x')
-- .sideEffect(System.out.&println)
-- .map { some_variable += 1 }
--
data SideEffect
-- | Relation of WalkTypes where one includes the other.
-- from can be lifted to to, because to is
-- more powerful than from.
class Lift from to
-- | Relation of WalkTypes where the child walk c is split
-- from the parent walk p.
--
-- When splitting, transformation effect done in the child walk is rolled
-- back (canceled) in the parent walk.
class Split c p
-- | Create GraphTraversalSource from a varible name in Gremlin
source :: Text -> Greskell GraphTraversalSource
-- | .V() method on GraphTraversalSource.
sV :: Vertex v => [Greskell (ElementID v)] -> Greskell GraphTraversalSource -> GTraversal Transform () v
-- | Monomorphic version of sV.
sV' :: [Greskell (ElementID AVertex)] -> Greskell GraphTraversalSource -> GTraversal Transform () AVertex
-- | .E() method on GraphTraversalSource.
sE :: Edge e => [Greskell (ElementID e)] -> Greskell GraphTraversalSource -> GTraversal Transform () e
-- | Monomorphic version of sE.
sE' :: [Greskell (ElementID AEdge)] -> Greskell GraphTraversalSource -> GTraversal Transform () AEdge
-- | .addV() method on GraphTraversalSource.
sAddV :: Vertex v => Greskell Text -> Greskell GraphTraversalSource -> GTraversal SideEffect () v
-- | Monomorphic version of sAddV.
sAddV' :: Greskell Text -> Greskell GraphTraversalSource -> GTraversal SideEffect () AVertex
-- | Apply the Walk to the GTraversal. In Gremlin, this means
-- calling a chain of methods on the Traversal object.
(&.) :: GTraversal c a b -> Walk c b d -> GTraversal c a d
infixl 1 &.
-- | Same as &. with arguments flipped.
($.) :: Walk c b d -> GTraversal c a b -> GTraversal c a d
infixr 0 $.
-- | Similar to <$>, but for $..
(<$.>) :: Functor f => Walk c b d -> f (GTraversal c a b) -> f (GTraversal c a d)
infixr 0 <$.>
-- | Similar to <*>, but for $..
(<*.>) :: Applicative f => f (Walk c b d) -> f (GTraversal c a b) -> f (GTraversal c a d)
infixr 0 <*.>
-- | .iterate method on GraphTraversal.
--
-- gIterate is not a Walk because it's usually used to
-- terminate the method chain of Gremlin steps. The returned
-- GTraversal outputs nothing, thus its end type is ().
gIterate :: WalkType c => GTraversal c s e -> GTraversal c s ()
-- | Unsafely create GTraversal from the given raw Gremlin script.
unsafeGTraversal :: Text -> GTraversal c s e
-- | Unsafely create a Walk that represents a single method call on
-- a GraphTraversal.
unsafeWalk :: WalkType c => Text -> [Text] -> Walk c s e
-- | Optionally modulate the main Walk with some modulating
-- Walks.
modulateWith :: WalkType c => Walk c s e -> [Walk c e e] -> Walk c s e
-- | .identity step.
gIdentity :: WalkType c => Walk c s s
-- | Monomorphic version of gIdentity.
gIdentity' :: Walk Filter s s
-- | .filter step that takes a traversal.
gFilter :: (ToGTraversal g, WalkType c, WalkType p, Split c p) => g c s e -> Walk p s s
-- | .cyclicPath step.
gCyclicPath :: WalkType c => Walk c a a
-- | Monomorphic version of gCyclicPath.
gCyclicPath' :: Walk Filter a a
-- | .simplePath step.
gSimplePath :: WalkType c => Walk c a a
-- | Monomorphic version of gSimplePath.
gSimplePath' :: Walk Filter a a
-- | .is step of simple equality.
gIs :: WalkType c => Greskell v -> Walk c v v
-- | Monomorphic version of gIs.
gIs' :: Greskell v -> Walk Filter v v
-- | .is step with predicate P.
gIsP :: WalkType c => Greskell (P v) -> Walk c v v
-- | Monomorphic version of gIsP.
gIsP' :: Greskell (P v) -> Walk Filter v v
-- | .has step with one argument.
gHas1 :: (WalkType c, Element s) => Key s v -> Walk c s s
-- | Monomorphic version of gHas1.
gHas1' :: Element s => Key s v -> Walk Filter s s
-- | .has step with two arguments.
gHas2 :: (WalkType c, Element s) => Key s v -> Greskell v -> Walk c s s
-- | Monomorphic verson of gHas2.
gHas2' :: Element s => Key s v -> Greskell v -> Walk Filter s s
-- | .has step with two arguments and P type.
gHas2P :: (WalkType c, Element s) => Key s v -> Greskell (P v) -> Walk c s s
-- | Monomorphic version of gHas2P.
gHas2P' :: Element s => Key s v -> Greskell (P v) -> Walk Filter s s
-- | .hasLabel step.
gHasLabel :: (Element s, WalkType c) => Greskell Text -> Walk c s s
-- | Monomorphic version of gHasLabel.
gHasLabel' :: Element s => Greskell Text -> Walk Filter s s
-- | .hasLabel step with P type. Supported since TinkerPop
-- 3.2.7.
gHasLabelP :: (Element s, WalkType c) => Greskell (P Text) -> Walk c s s
-- | Monomorphic version of gHasLabelP.
gHasLabelP' :: Element s => Greskell (P Text) -> Walk Filter s s
-- | .hasId step.
gHasId :: (Element s, WalkType c) => Greskell (ElementID s) -> Walk c s s
-- | Monomorphic version of gHasId.
gHasId' :: Element s => Greskell (ElementID s) -> Walk Filter s s
-- | .hasId step with P type. Supported since TinkerPop
-- 3.2.7.
gHasIdP :: (Element s, WalkType c) => Greskell (P (ElementID s)) -> Walk c s s
-- | Monomorphic version of gHasIdP.
gHasIdP' :: Element s => Greskell (P (ElementID s)) -> Walk Filter s s
-- | .hasKey step. The input type should be a VertexProperty.
gHasKey :: (Element (p v), Property p, WalkType c) => Greskell Text -> Walk c (p v) (p v)
-- | Monomorphic version of gHasKey.
gHasKey' :: (Element (p v), Property p) => Greskell Text -> Walk Filter (p v) (p v)
-- | .hasKey step with P type. Supported since TinkerPop
-- 3.2.7.
gHasKeyP :: (Element (p v), Property p, WalkType c) => Greskell (P Text) -> Walk c (p v) (p v)
-- | Monomorphic version of gHasKeyP.
gHasKeyP' :: (Element (p v), Property p) => Greskell (P Text) -> Walk Filter (p v) (p v)
-- | .hasValue step. The input type should be a VertexProperty.
gHasValue :: (Element (p v), Property p, WalkType c) => Greskell v -> Walk c (p v) (p v)
-- | Monomorphic version of gHasValue.
gHasValue' :: (Element (p v), Property p) => Greskell v -> Walk Filter (p v) (p v)
-- | .hasValue step with P type. Supported since TinkerPop
-- 3.2.7.
gHasValueP :: (Element (p v), Property p, WalkType c) => Greskell (P v) -> Walk c (p v) (p v)
-- | Monomorphic version of gHasValueP.
gHasValueP' :: (Element (p v), Property p) => Greskell (P v) -> Walk Filter (p v) (p v)
-- | .and step.
gAnd :: (ToGTraversal g, WalkType c, WalkType p, Split c p) => [g c s e] -> Walk p s s
-- | .or step.
gOr :: (ToGTraversal g, WalkType c, WalkType p, Split c p) => [g c s e] -> Walk p s s
-- | .not step.
gNot :: (ToGTraversal g, WalkType c, WalkType p, Split c p) => g c s e -> Walk p s s
-- | .where step with P argument only.
--
-- If the ByProjection argument is Nothing, comparison is
-- performed on the type a. You have to ensure that the
-- comparator included in the LabeledP argument can handle the
-- type a. Usually this means the type a should
-- implement Java's Comparable interface (this is true for most
-- Java classes).
--
-- If the ByProjection argument is given, comparison is performed
-- on the projected values of type b. So, the type b
-- should implement Java's Comparable interface.
gWhereP1 :: WalkType c => Greskell (LabeledP a) -> Maybe (ByProjection a b) -> Walk c a a
-- | Monomorphic version of gWhereP1.
gWhereP1' :: Greskell (LabeledP a) -> Maybe (ByProjection a b) -> Walk Filter a a
-- | .where step with the starting label and P arguments.
-- See also gWhereP1.
gWhereP2 :: WalkType c => AsLabel a -> Greskell (LabeledP a) -> Maybe (ByProjection a b) -> Walk c x x
-- | Monomorphic version of gWhereP2.
gWhereP2' :: AsLabel a -> Greskell (LabeledP a) -> Maybe (ByProjection a b) -> Walk Filter x x
-- | .order step.
--
-- ByComparator is an IsString, meaning projection by the
-- given key.
gOrder :: [ByComparator s] -> Walk Transform s s
-- | .range step. This step is not a Filter, because the
-- filtering decision by this step is based on position of each element,
-- not the element itself. This violates Filter law.
gRange :: Greskell Int -> Greskell Int -> Walk Transform s s
-- | .limit step.
gLimit :: Greskell Int -> Walk Transform s s
-- | .tail step.
gTail :: Greskell Int -> Walk Transform s s
-- | .skip step.
gSkip :: Greskell Int -> Walk Transform s s
-- | .repeat step.
gRepeat :: (ToGTraversal g, WalkType c) => Maybe RepeatLabel -> Maybe (RepeatPos, RepeatUntil c s) -> Maybe (RepeatPos, RepeatEmit c s) -> g c s s -> Walk c s s
-- | .times modulator before the .repeat step. It always
-- returns Just.
gTimes :: Greskell Int -> Maybe (RepeatPos, RepeatUntil c s)
-- | .until modulator before the .repeat step. It always
-- returns Just.
gUntilHead :: (ToGTraversal g, WalkType c, WalkType cc, Split cc c) => g cc s e -> Maybe (RepeatPos, RepeatUntil c s)
-- | .until modulator after the .repeat step. It always
-- returns Just.
gUntilTail :: (ToGTraversal g, WalkType c, WalkType cc, Split cc c) => g cc s e -> Maybe (RepeatPos, RepeatUntil c s)
-- | .emit modulator without argument before the .repeat
-- step. It always returns Just.
gEmitHead :: Maybe (RepeatPos, RepeatEmit c s)
-- | .emit modulator without argument after the .repeat
-- step. It always returns Just.
gEmitTail :: Maybe (RepeatPos, RepeatEmit c s)
-- | .emit modulator with a sub-traversal argument before the
-- .repeat step. It always returns Just.
gEmitHeadT :: (ToGTraversal g, WalkType c, WalkType cc, Split cc c) => g cc s e -> Maybe (RepeatPos, RepeatEmit c s)
-- | .emit modulator with a sub-traversal argument after the
-- .repeat step. It always returns Just.
gEmitTailT :: (ToGTraversal g, WalkType c, WalkType cc, Split cc c) => g cc s e -> Maybe (RepeatPos, RepeatEmit c s)
-- | .loops step.
gLoops :: Maybe RepeatLabel -> Walk Transform s Int
-- | .until or .times modulator step.
--
-- Type c is the WalkType of the parent .repeat
-- step. Type s is the start (and end) type of the
-- .repeat step.
data RepeatUntil c s
-- | .times modulator.
[RepeatTimes] :: Greskell Int -> RepeatUntil c s
-- | .until modulator with a sub-traversal as the predicate to
-- decide if the repetition should stop.
[RepeatUntilT] :: (WalkType cc, WalkType c, Split cc c) => GTraversal cc s e -> RepeatUntil c s
-- | .emit modulator step.
--
-- Type c is the WalkType of the parent .repeat
-- step. Type s is the start (and end) type of the
-- .repeat step.
data RepeatEmit c s
-- | .emit modulator without argument. It always emits the input
-- traverser of type s.
[RepeatEmit] :: RepeatEmit c s
-- | .emit modulator with a sub-traversal as the predicate to
-- decide if it emits the traverser.
[RepeatEmitT] :: (WalkType cc, WalkType c, Split cc c) => GTraversal cc s e -> RepeatEmit c s
-- | Position of a step modulator relative to .repeat step.
data RepeatPos
-- | Modulator before the .repeat step.
RepeatHead :: RepeatPos
-- | Modulator after the .repeat step.
RepeatTail :: RepeatPos
-- | A label that points to a loop created by .repeat step. It can
-- be used by .loops step to specify the loop.
newtype RepeatLabel
RepeatLabel :: Text -> RepeatLabel
[unRepeatLabel] :: RepeatLabel -> Text
-- | .local step.
gLocal :: (ToGTraversal g, WalkType c) => g c s e -> Walk c s e
-- | .union step.
gUnion :: (ToGTraversal g, WalkType c) => [g c s e] -> Walk c s e
-- | .coalesce step.
--
-- Like gFlatMap, gCoalesce always modifies path history.
gCoalesce :: (ToGTraversal g, Split cc c, Lift Transform c, WalkType c, WalkType cc) => [g cc s e] -> Walk c s e
-- | .choose step with if-then-else style.
gChoose3 :: (ToGTraversal g, Split cc c, WalkType cc, WalkType c) => g cc s ep -> g c s e -> g c s e -> Walk c s e
-- | .barrier step.
gBarrier :: WalkType c => Maybe (Greskell Int) -> Walk c s s
-- | .dedup step without argument.
--
-- .dedup step is Transform because the filtering
-- decision depends on the sequence (order) of input elements.
gDedup :: Maybe (ByProjection s e) -> Walk Transform s s
-- | .dedup step with at least one argument. The tuple specified
-- by the AsLabels is used as the criterion of deduplication.
gDedupN :: AsLabel a -> [AsLabel a] -> Maybe (ByProjection a e) -> Walk Transform s s
-- | .flatMap step.
--
-- .flatMap step is at least as powerful as Transform,
-- even if the child walk is Filter type. This is because
-- .flatMap step always modifies the path of the Traverser.
gFlatMap :: (Lift Transform c, Split cc c, ToGTraversal g, WalkType c, WalkType cc) => g cc s e -> Walk c s e
-- | Monomorphic version of gFlatMap.
gFlatMap' :: ToGTraversal g => g Transform s e -> Walk Transform s e
-- | .V step.
--
-- For each input item, .V step emits vertices selected by the
-- argument (or all vertices if the empty list is passed.)
gV :: Vertex v => [Greskell (ElementID v)] -> Walk Transform s v
-- | Monomorphic version of gV.
gV' :: [Greskell (ElementID AVertex)] -> Walk Transform s AVertex
-- | .constant step.
gConstant :: Greskell a -> Walk Transform s a
-- | .project step.
gProject :: LabeledByProjection s -> [LabeledByProjection s] -> Walk Transform s (PMap Single GValue)
-- | .as step.
--
-- .as step is Transform because it adds the label to the
-- traverser.
gAs :: AsLabel a -> Walk Transform a a
-- | .values step.
gValues :: Element s => [Key s e] -> Walk Transform s e
-- | .properties step.
gProperties :: (Element s, Property p, ElementProperty s ~ p) => [Key s v] -> Walk Transform s (p v)
-- | .id step.
gId :: Element s => Walk Transform s (ElementID s)
-- | .label step.
gLabel :: Element s => Walk Transform s Text
-- | .valueMap step.
gValueMap :: Element s => Keys s -> Walk Transform s (PMap (ElementPropertyContainer s) GValue)
-- | .elementMap step.
gElementMap :: Element s => Keys s -> Walk Transform s (PMap Single GValue)
-- | .select step with one argument.
gSelect1 :: AsLabel a -> Walk Transform s a
-- | .select step with more than one arguments.
gSelectN :: AsLabel a -> AsLabel b -> [AsLabel c] -> Walk Transform s (SelectedMap GValue)
-- | .select step with one argument followed by .by step.
gSelectBy1 :: AsLabel a -> ByProjection a b -> Walk Transform s b
-- | .select step with more than one arguments followed by
-- .by step.
gSelectByN :: AsLabel a -> AsLabel a -> [AsLabel a] -> ByProjection a b -> Walk Transform s (SelectedMap b)
-- | .unfold step.
--
-- Note that we use AsIterator here because basically the
-- .unfold step does the same thing as
-- IteratorUtils.asIterator function in Tinkerpop. However,
-- Tinkerpop's implementation of .unfold step doesn't
-- necessarily use asIterator, so there may be some corner cases
-- where asIterator and .unfold step behave
-- differently.
gUnfold :: AsIterator a => Walk Transform a (IteratorItem a)
-- | .path step without modulation.
gPath :: Walk Transform s (Path GValue)
-- | .path step with one or more .by modulations.
gPathBy :: ByProjection a b -> [ByProjection a b] -> Walk Transform s (Path b)
-- | .fold step.
gFold :: Walk Transform a [a]
-- | .count step.
gCount :: Walk Transform a Int
-- | .out step
gOut :: (Vertex v1, Vertex v2) => [Greskell Text] -> Walk Transform v1 v2
-- | Monomorphic version of gOut.
gOut' :: Vertex v => [Greskell Text] -> Walk Transform v AVertex
-- | .outE step
gOutE :: (Vertex v, Edge e) => [Greskell Text] -> Walk Transform v e
-- | Monomorphic version of gOutE.
gOutE' :: Vertex v => [Greskell Text] -> Walk Transform v AEdge
-- | .outV step.
gOutV :: (Edge e, Vertex v) => Walk Transform e v
-- | Monomorphic version of gOutV.
gOutV' :: Edge e => Walk Transform e AVertex
-- | .in step
gIn :: (Vertex v1, Vertex v2) => [Greskell Text] -> Walk Transform v1 v2
-- | Monomorphic version of gIn.
gIn' :: Vertex v => [Greskell Text] -> Walk Transform v AVertex
-- | .inE step.
gInE :: (Vertex v, Edge e) => [Greskell Text] -> Walk Transform v e
-- | Monomorphic version of gInE.
gInE' :: Vertex v => [Greskell Text] -> Walk Transform v AEdge
-- | .inV step.
gInV :: (Edge e, Vertex v) => Walk Transform e v
-- | Monomorphic version of gInV.
gInV' :: Edge e => Walk Transform e AVertex
-- | .match step.
--
-- If the top-level Logic of the argument is And, the
-- patterns are directly passed to the .match step arguments.
--
-- The result of .match step, MatchResult, is an opaque
-- type. Basically you should not use it. Instead, you should use
-- gSelectN etc to access the path history labels inside the
-- MatchPattern.
--
-- See also:
-- https://groups.google.com/g/gremlin-users/c/HVtldzV0Xk8
gMatch :: Logic MatchPattern -> Walk Transform a MatchResult
-- | A pattern for .match step.
data MatchPattern
-- | A pattern with the starting .as label followed by traversal
-- steps.
[MatchPattern] :: AsLabel a -> Walk Transform a b -> MatchPattern
-- | A convenient function to make a MatchPattern wrapped by
-- Leaf.
mPattern :: (WalkType c, Lift c Transform) => AsLabel a -> Walk c a b -> Logic MatchPattern
-- | Result of .match step.
data MatchResult
-- | .sideEffect step that takes a traversal.
gSideEffect :: (ToGTraversal g, WalkType c, WalkType p, Split c p) => g c s e -> Walk p s s
-- | Monomorphic version of gSideEffect. The result walk is always
-- SideEffect type.
gSideEffect' :: (ToGTraversal g, WalkType c, Split c SideEffect) => g c s e -> Walk SideEffect s s
-- | .addV step with a label.
gAddV :: Vertex v => Greskell Text -> Walk SideEffect a v
-- | Monomorphic version of gAddV.
gAddV' :: Greskell Text -> Walk SideEffect a AVertex
-- | .addE step. Supported since TinkerPop 3.1.0.
gAddE :: (Vertex vs, Vertex ve, Edge e) => Greskell Text -> AddAnchor vs ve -> Walk SideEffect vs e
-- | Monomorphic version of gAddE.
gAddE' :: Greskell Text -> AddAnchor AVertex AVertex -> Walk SideEffect AVertex AEdge
-- | Vertex anchor for gAddE. It corresponds to .from or
-- .to step following an .addE step.
--
-- Type s is the input Vertex for the .addE step. Type
-- e is the type of the anchor Vertex that the AddAnchor
-- yields. So, .addE step creates an edge between s and
-- e.
data AddAnchor s e
-- | .from step with a traversal.
gFrom :: ToGTraversal g => g Transform s e -> AddAnchor s e
-- | .to step with a traversal.
gTo :: ToGTraversal g => g Transform s e -> AddAnchor s e
-- | .drop step on Element.
gDrop :: Element e => Walk SideEffect e e
-- | .drop step on Property.
gDropP :: Property p => Walk SideEffect (p a) (p a)
-- | Simple .property step. It adds a value to the property.
gProperty :: Element e => Key e v -> Greskell v -> Walk SideEffect e e
-- | .property step for Vertex.
gPropertyV :: (Vertex e, vp ~ ElementProperty e, Property vp, Element (vp v)) => Maybe (Greskell Cardinality) -> Key e v -> Greskell v -> [KeyValue (vp v)] -> Walk SideEffect e e
-- | Projection from type s to type e used in
-- .by step. You can also use gBy to construct
-- ByProjection.
data ByProjection s e
[ByProjection] :: (ProjectionLike p, ToGreskell p) => p -> ByProjection (ProjectionLikeStart p) (ProjectionLikeEnd p)
-- | Data types that mean a projection from one type to another.
class ProjectionLike p where {
-- | The start type of the projection.
type ProjectionLikeStart p;
-- | The end type of the projection.
type ProjectionLikeEnd p;
}
-- | Comparison of type s used in .by step. You can also
-- use gBy1 and gBy2 to construct ByComparator.
data ByComparator s
-- | Type s is projected to type e, and compared by the
-- natural comparator of type e.
[ByComparatorProj] :: ByProjection s e -> ByComparator s
-- | Type s is compared by the Comparator comp.
[ByComparatorComp] :: Comparator comp => Greskell comp -> ByComparator (CompareArg comp)
-- | Type s is projected to type CompareArg comp, and
-- compared by the Comparator comp.
[ByComparatorProjComp] :: Comparator comp => ByProjection s (CompareArg comp) -> Greskell comp -> ByComparator s
-- | A ByProjection associated with an AsLabel. You can
-- construct it by gByL.
data LabeledByProjection s
[LabeledByProjection] :: AsLabel a -> ByProjection s a -> LabeledByProjection s
-- | .by step with 1 argument, used for projection.
gBy :: (ProjectionLike p, ToGreskell p) => p -> ByProjection (ProjectionLikeStart p) (ProjectionLikeEnd p)
-- | .by step with 1 argument, used for comparison.
gBy1 :: (ProjectionLike p, ToGreskell p) => p -> ByComparator (ProjectionLikeStart p)
-- | .by step with 2 arguments, used for comparison.
gBy2 :: (ProjectionLike p, ToGreskell p, Comparator comp, ProjectionLikeEnd p ~ CompareArg comp) => p -> Greskell comp -> ByComparator (ProjectionLikeStart p)
-- | .by step associated with an AsLabel.
gByL :: (ProjectionLike p, ToGreskell p) => AsLabel (ProjectionLikeEnd p) -> p -> LabeledByProjection (ProjectionLikeStart p)
-- | Examples of using this module. See the source. The fst of the
-- output is the testee, while the snd is the expectation.
examples :: [(Text, Text)]
-- | Only for tests.
showWalkType :: WalkType t => Proxy t -> String
-- | Only for tests.
showLift :: Lift from to => Proxy from -> Proxy to -> String
-- | Only for tests.
showSplit :: Split c p => Proxy c -> Proxy p -> String
instance GHC.Show.Show (Data.Greskell.GTraversal.GraphTraversal c s e)
instance GHC.Show.Show (Data.Greskell.GTraversal.GTraversal c s e)
instance GHC.Show.Show (Data.Greskell.GTraversal.Walk c s e)
instance GHC.Show.Show Data.Greskell.GTraversal.GraphTraversalSource
instance GHC.Show.Show Data.Greskell.GTraversal.RepeatLabel
instance GHC.Classes.Ord Data.Greskell.GTraversal.RepeatLabel
instance Data.String.IsString Data.Greskell.GTraversal.RepeatLabel
instance GHC.Classes.Eq Data.Greskell.GTraversal.RepeatLabel
instance GHC.Show.Show Data.Greskell.GTraversal.RepeatPos
instance GHC.Classes.Ord Data.Greskell.GTraversal.RepeatPos
instance GHC.Classes.Eq Data.Greskell.GTraversal.RepeatPos
instance GHC.Enum.Enum Data.Greskell.GTraversal.RepeatPos
instance GHC.Enum.Bounded Data.Greskell.GTraversal.RepeatPos
instance GHC.Show.Show (Data.Greskell.GTraversal.MWalk c s e)
instance GHC.Show.Show (Data.Greskell.GTraversal.RepeatUntil c s)
instance GHC.Show.Show (Data.Greskell.GTraversal.RepeatEmit c s)
instance Data.Greskell.GTraversal.WalkType c => GHC.Base.Semigroup (Data.Greskell.GTraversal.MWalk c s s)
instance Data.Greskell.GTraversal.WalkType c => GHC.Base.Monoid (Data.Greskell.GTraversal.MWalk c s s)
instance Data.String.IsString (Data.Greskell.GTraversal.ByComparator s)
instance Data.Greskell.GTraversal.ProjectionLike (Data.Greskell.GTraversal.ByProjection s e)
instance Data.String.IsString (Data.Greskell.GTraversal.ByProjection s e)
instance Data.Greskell.GTraversal.ProjectionLike (Data.Greskell.GTraversal.Walk Data.Greskell.GTraversal.Filter s e)
instance Data.Greskell.GTraversal.ProjectionLike (Data.Greskell.GTraversal.GTraversal Data.Greskell.GTraversal.Filter s e)
instance Data.Greskell.GTraversal.ProjectionLike (Data.Greskell.Greskell.Greskell (Data.Greskell.GTraversal.GraphTraversal Data.Greskell.GTraversal.Filter s e))
instance Data.Greskell.GTraversal.ProjectionLike (Data.Greskell.GTraversal.Walk Data.Greskell.GTraversal.Transform s e)
instance Data.Greskell.GTraversal.ProjectionLike (Data.Greskell.GTraversal.GTraversal Data.Greskell.GTraversal.Transform s e)
instance Data.Greskell.GTraversal.ProjectionLike (Data.Greskell.Greskell.Greskell (Data.Greskell.GTraversal.GraphTraversal Data.Greskell.GTraversal.Transform s e))
instance Data.Greskell.GTraversal.ProjectionLike (Data.Greskell.Graph.Key s e)
instance Data.Greskell.GTraversal.ProjectionLike (Data.Greskell.Greskell.Greskell (Data.Greskell.Graph.T s e))
instance Data.Greskell.GTraversal.ProjectionLike (Data.Greskell.Greskell.Greskell (s -> e))
instance Data.Greskell.Greskell.ToGreskell Data.Greskell.GTraversal.RepeatLabel
instance Data.Greskell.GTraversal.WalkType p => Data.Greskell.GTraversal.Split Data.Greskell.GTraversal.Filter p
instance Data.Greskell.GTraversal.WalkType p => Data.Greskell.GTraversal.Split Data.Greskell.GTraversal.Transform p
instance Data.Greskell.GTraversal.Split Data.Greskell.GTraversal.SideEffect Data.Greskell.GTraversal.SideEffect
instance Data.Greskell.GTraversal.ToGTraversal Data.Greskell.GTraversal.GTraversal
instance Data.Greskell.GTraversal.ToGTraversal Data.Greskell.GTraversal.Walk
instance Data.Greskell.GTraversal.WalkType c => Data.Greskell.Greskell.ToGreskell (Data.Greskell.GTraversal.Walk c s e)
instance Data.Greskell.GTraversal.WalkType c => Data.Greskell.GTraversal.Lift Data.Greskell.GTraversal.Filter c
instance Data.Greskell.GTraversal.Lift Data.Greskell.GTraversal.Transform Data.Greskell.GTraversal.Transform
instance Data.Greskell.GTraversal.Lift Data.Greskell.GTraversal.Transform Data.Greskell.GTraversal.SideEffect
instance Data.Greskell.GTraversal.Lift Data.Greskell.GTraversal.SideEffect Data.Greskell.GTraversal.SideEffect
instance Data.Greskell.GTraversal.WalkType Data.Greskell.GTraversal.SideEffect
instance Data.Greskell.GTraversal.WalkType Data.Greskell.GTraversal.Transform
instance Data.Greskell.GTraversal.WalkType Data.Greskell.GTraversal.Filter
instance Data.Greskell.GTraversal.WalkType c => Control.Category.Category (Data.Greskell.GTraversal.Walk c)
instance Data.Greskell.GTraversal.WalkType c => GHC.Base.Semigroup (Data.Greskell.GTraversal.Walk c s s)
instance Data.Greskell.GTraversal.WalkType c => GHC.Base.Monoid (Data.Greskell.GTraversal.Walk c s s)
instance GHC.Base.Functor (Data.Greskell.GTraversal.Walk c s)
instance Data.Bifunctor.Bifunctor (Data.Greskell.GTraversal.Walk c)
instance GHC.Base.Functor (Data.Greskell.GTraversal.GTraversal c s)
instance Data.Bifunctor.Bifunctor (Data.Greskell.GTraversal.GTraversal c)
instance Data.Greskell.Greskell.ToGreskell (Data.Greskell.GTraversal.GTraversal c s e)
instance Data.Greskell.AsIterator.AsIterator (Data.Greskell.GTraversal.GraphTraversal c s e)
instance GHC.Base.Functor (Data.Greskell.GTraversal.GraphTraversal c s)
instance Data.Bifunctor.Bifunctor (Data.Greskell.GTraversal.GraphTraversal c)
-- | This module is experimental. It may have breaking changes in
-- future.
--
-- This module has Gremlin traversals defined in GTraversal
-- generalized on the walk type. It may save you from calling
-- liftWalk manually.
module Data.Greskell.GTraversal.Gen
-- | GraphTraversal class object of TinkerPop. It takes data
-- s from upstream and emits data e to downstream. Type
-- c is called "walk type", a marker to describe the effect of
-- the traversal.
--
-- GTraversal is NOT a Category. Because a
-- GraphTraversal object keeps some context data, the starting
-- (left-most) GraphTraversal object controls most of the
-- behavior of entire composition of traversals and steps. This violates
-- Category law.
newtype GTraversal c s e
GTraversal :: Greskell (GraphTraversal c s e) -> GTraversal c s e
[unGTraversal] :: GTraversal c s e -> Greskell (GraphTraversal c s e)
-- | Phantom type for GraphTraversal class. In greskell, we
-- usually use GTraversal instead of Greskell
-- GraphTraversal.
data GraphTraversal c s e
-- | Types that can convert to GTraversal.
class ToGTraversal g
toGTraversal :: (ToGTraversal g, WalkType c) => g c s e -> GTraversal c s e
-- | Lift WalkType from to to. Use this for type
-- matching.
liftWalk :: (ToGTraversal g, WalkType from, WalkType to, Lift from to) => g from s e -> g to s e
-- | Unsafely cast the start type s1 into s2.
--
-- It is recommended that s2 is coercible to s1 in
-- terms of FromGraphSON. That is, if s2 can parse a
-- GValue, s1 should also be able to parse that
-- GValue.
unsafeCastStart :: (ToGTraversal g, WalkType c) => g c s1 e -> g c s2 e
-- | Unsafely cast the end type e1 into e2. See
-- unsafeCastStart.
unsafeCastEnd :: (ToGTraversal g, WalkType c) => g c s e1 -> g c s e2
-- | A chain of one or more Gremlin steps. Like GTraversal, type
-- s is the input, type e is the output, and type
-- c is a marker to describe the step.
--
-- Walk represents a chain of method calls such as
-- .has(x).outE(). Because this is not a Gremlin (Groovy)
-- expression, we use bare Walk, not Greskell Walk.
--
-- Walk is a Category. You can use functions from
-- Control.Category to compose Walks. This is equivalent to
-- making a chain of method calls in Gremlin.
--
-- Walk is not an Eq, because it's difficult to define true
-- equality between Gremlin method calls. If we define it naively, it
-- might have conflict with Category law.
data Walk c s e
-- | GraphTraversalSource class object of TinkerPop. It is a
-- factory object of GraphTraversals.
data GraphTraversalSource
-- | Class of phantom type markers to describe the effect of the
-- walk/traversals.
class WalkType t
-- | WalkType for filtering steps.
--
-- A filtering step is a step that does filtering only. It takes input
-- and emits some of them without any modification, reordering, traversal
-- actions, or side-effects. Filtering decision must be solely based on
-- each element.
--
-- A Walk w is Filter type iff:
--
-- -- (gSideEffect w == gIdentity) AND (gFilter w == w) ---- -- If Walks w1 and w2 are Filter type, -- then -- --
-- gAnd [w1, w2] == w1 >>> w2 == w2 >>> w1 --data Filter -- | WalkType for steps without any side-effects. This includes -- transformations, reordring, injections and graph traversal actions. -- -- A Walk w is Transform type iff: -- --
-- gSideEffect w == gIdentity ---- -- Obviously, every Filter type Walks are also -- Transform type. data Transform -- | WalkType for steps that may have side-effects. -- -- A side-effect here means manipulation of the "sideEffect" in Gremlin -- context (i.e. the stash of data kept in a Traversal object), as well -- as interaction with the world outside the Traversal object. -- -- For example, the following steps (in Gremlin) all have side-effects. -- --
-- .addE('label')
-- .aggregate('x')
-- .sideEffect(System.out.&println)
-- .map { some_variable += 1 }
--
data SideEffect
-- | Relation of WalkTypes where one includes the other.
-- from can be lifted to to, because to is
-- more powerful than from.
class Lift from to
-- | Relation of WalkTypes where the child walk c is split
-- from the parent walk p.
--
-- When splitting, transformation effect done in the child walk is rolled
-- back (canceled) in the parent walk.
class Split c p
-- | Create GraphTraversalSource from a varible name in Gremlin
source :: Text -> Greskell GraphTraversalSource
sV :: (Vertex v, WalkType c, Lift Transform c) => [Greskell (ElementID v)] -> Greskell GraphTraversalSource -> GTraversal c () v
sV' :: (WalkType c, Lift Transform c) => [Greskell (ElementID AVertex)] -> Greskell GraphTraversalSource -> GTraversal c () AVertex
sE :: (Edge e, WalkType c, Lift Transform c) => [Greskell (ElementID e)] -> Greskell GraphTraversalSource -> GTraversal c () e
sE' :: (WalkType c, Lift Transform c) => [Greskell (ElementID AEdge)] -> Greskell GraphTraversalSource -> GTraversal c () AEdge
sAddV :: (Vertex v, WalkType c, Lift SideEffect c) => Greskell Text -> Greskell GraphTraversalSource -> GTraversal c () v
sAddV' :: (WalkType c, Lift SideEffect c) => Greskell Text -> Greskell GraphTraversalSource -> GTraversal c () AVertex
-- | Apply the Walk to the GTraversal. In Gremlin, this means
-- calling a chain of methods on the Traversal object.
(&.) :: GTraversal c a b -> Walk c b d -> GTraversal c a d
infixl 1 &.
-- | Same as &. with arguments flipped.
($.) :: Walk c b d -> GTraversal c a b -> GTraversal c a d
infixr 0 $.
-- | Similar to <$>, but for $..
(<$.>) :: Functor f => Walk c b d -> f (GTraversal c a b) -> f (GTraversal c a d)
infixr 0 <$.>
-- | Similar to <*>, but for $..
(<*.>) :: Applicative f => f (Walk c b d) -> f (GTraversal c a b) -> f (GTraversal c a d)
infixr 0 <*.>
-- | .iterate method on GraphTraversal.
--
-- gIterate is not a Walk because it's usually used to
-- terminate the method chain of Gremlin steps. The returned
-- GTraversal outputs nothing, thus its end type is ().
gIterate :: WalkType c => GTraversal c s e -> GTraversal c s ()
-- | Unsafely create GTraversal from the given raw Gremlin script.
unsafeGTraversal :: Text -> GTraversal c s e
-- | Unsafely create a Walk that represents a single method call on
-- a GraphTraversal.
unsafeWalk :: WalkType c => Text -> [Text] -> Walk c s e
-- | Optionally modulate the main Walk with some modulating
-- Walks.
modulateWith :: WalkType c => Walk c s e -> [Walk c e e] -> Walk c s e
-- | .identity step.
gIdentity :: WalkType c => Walk c s s
-- | .filter step that takes a traversal.
gFilter :: (ToGTraversal g, WalkType c, WalkType p, Split c p) => g c s e -> Walk p s s
-- | .cyclicPath step.
gCyclicPath :: WalkType c => Walk c a a
-- | .simplePath step.
gSimplePath :: WalkType c => Walk c a a
-- | .is step of simple equality.
gIs :: WalkType c => Greskell v -> Walk c v v
-- | .is step with predicate P.
gIsP :: WalkType c => Greskell (P v) -> Walk c v v
-- | .has step with one argument.
gHas1 :: (WalkType c, Element s) => Key s v -> Walk c s s
-- | .has step with two arguments.
gHas2 :: (WalkType c, Element s) => Key s v -> Greskell v -> Walk c s s
-- | .has step with two arguments and P type.
gHas2P :: (WalkType c, Element s) => Key s v -> Greskell (P v) -> Walk c s s
-- | .hasLabel step.
gHasLabel :: (Element s, WalkType c) => Greskell Text -> Walk c s s
-- | .hasLabel step with P type. Supported since TinkerPop
-- 3.2.7.
gHasLabelP :: (Element s, WalkType c) => Greskell (P Text) -> Walk c s s
-- | .hasId step.
gHasId :: (Element s, WalkType c) => Greskell (ElementID s) -> Walk c s s
-- | .hasId step with P type. Supported since TinkerPop
-- 3.2.7.
gHasIdP :: (Element s, WalkType c) => Greskell (P (ElementID s)) -> Walk c s s
-- | .hasKey step. The input type should be a VertexProperty.
gHasKey :: (Element (p v), Property p, WalkType c) => Greskell Text -> Walk c (p v) (p v)
-- | .hasKey step with P type. Supported since TinkerPop
-- 3.2.7.
gHasKeyP :: (Element (p v), Property p, WalkType c) => Greskell (P Text) -> Walk c (p v) (p v)
-- | .hasValue step. The input type should be a VertexProperty.
gHasValue :: (Element (p v), Property p, WalkType c) => Greskell v -> Walk c (p v) (p v)
-- | .hasValue step with P type. Supported since TinkerPop
-- 3.2.7.
gHasValueP :: (Element (p v), Property p, WalkType c) => Greskell (P v) -> Walk c (p v) (p v)
-- | .and step.
gAnd :: (ToGTraversal g, WalkType c, WalkType p, Split c p) => [g c s e] -> Walk p s s
-- | .or step.
gOr :: (ToGTraversal g, WalkType c, WalkType p, Split c p) => [g c s e] -> Walk p s s
-- | .not step.
gNot :: (ToGTraversal g, WalkType c, WalkType p, Split c p) => g c s e -> Walk p s s
-- | .where step with P argument only.
--
-- If the ByProjection argument is Nothing, comparison is
-- performed on the type a. You have to ensure that the
-- comparator included in the LabeledP argument can handle the
-- type a. Usually this means the type a should
-- implement Java's Comparable interface (this is true for most
-- Java classes).
--
-- If the ByProjection argument is given, comparison is performed
-- on the projected values of type b. So, the type b
-- should implement Java's Comparable interface.
gWhereP1 :: WalkType c => Greskell (LabeledP a) -> Maybe (ByProjection a b) -> Walk c a a
-- | .where step with the starting label and P arguments.
-- See also gWhereP1.
gWhereP2 :: WalkType c => AsLabel a -> Greskell (LabeledP a) -> Maybe (ByProjection a b) -> Walk c x x
gOrder :: (WalkType c, Lift Transform c) => [ByComparator s] -> Walk c s s
gRange :: (WalkType c, Lift Transform c) => Greskell Int -> Greskell Int -> Walk c s s
gLimit :: (WalkType c, Lift Transform c) => Greskell Int -> Walk c s s
gTail :: (WalkType c, Lift Transform c) => Greskell Int -> Walk c s s
gSkip :: (WalkType c, Lift Transform c) => Greskell Int -> Walk c s s
-- | .repeat step.
gRepeat :: (ToGTraversal g, WalkType c) => Maybe RepeatLabel -> Maybe (RepeatPos, RepeatUntil c s) -> Maybe (RepeatPos, RepeatEmit c s) -> g c s s -> Walk c s s
-- | .times modulator before the .repeat step. It always
-- returns Just.
gTimes :: Greskell Int -> Maybe (RepeatPos, RepeatUntil c s)
-- | .until modulator before the .repeat step. It always
-- returns Just.
gUntilHead :: (ToGTraversal g, WalkType c, WalkType cc, Split cc c) => g cc s e -> Maybe (RepeatPos, RepeatUntil c s)
-- | .until modulator after the .repeat step. It always
-- returns Just.
gUntilTail :: (ToGTraversal g, WalkType c, WalkType cc, Split cc c) => g cc s e -> Maybe (RepeatPos, RepeatUntil c s)
-- | .emit modulator without argument before the .repeat
-- step. It always returns Just.
gEmitHead :: Maybe (RepeatPos, RepeatEmit c s)
-- | .emit modulator without argument after the .repeat
-- step. It always returns Just.
gEmitTail :: Maybe (RepeatPos, RepeatEmit c s)
-- | .emit modulator with a sub-traversal argument before the
-- .repeat step. It always returns Just.
gEmitHeadT :: (ToGTraversal g, WalkType c, WalkType cc, Split cc c) => g cc s e -> Maybe (RepeatPos, RepeatEmit c s)
-- | .emit modulator with a sub-traversal argument after the
-- .repeat step. It always returns Just.
gEmitTailT :: (ToGTraversal g, WalkType c, WalkType cc, Split cc c) => g cc s e -> Maybe (RepeatPos, RepeatEmit c s)
gLoops :: (WalkType c, Lift Transform c) => Maybe RepeatLabel -> Walk c s Int
-- | .until or .times modulator step.
--
-- Type c is the WalkType of the parent .repeat
-- step. Type s is the start (and end) type of the
-- .repeat step.
data RepeatUntil c s
-- | .times modulator.
[RepeatTimes] :: Greskell Int -> RepeatUntil c s
-- | .until modulator with a sub-traversal as the predicate to
-- decide if the repetition should stop.
[RepeatUntilT] :: (WalkType cc, WalkType c, Split cc c) => GTraversal cc s e -> RepeatUntil c s
-- | .emit modulator step.
--
-- Type c is the WalkType of the parent .repeat
-- step. Type s is the start (and end) type of the
-- .repeat step.
data RepeatEmit c s
-- | .emit modulator without argument. It always emits the input
-- traverser of type s.
[RepeatEmit] :: RepeatEmit c s
-- | .emit modulator with a sub-traversal as the predicate to
-- decide if it emits the traverser.
[RepeatEmitT] :: (WalkType cc, WalkType c, Split cc c) => GTraversal cc s e -> RepeatEmit c s
-- | Position of a step modulator relative to .repeat step.
data RepeatPos
-- | Modulator before the .repeat step.
RepeatHead :: RepeatPos
-- | Modulator after the .repeat step.
RepeatTail :: RepeatPos
-- | A label that points to a loop created by .repeat step. It can
-- be used by .loops step to specify the loop.
newtype RepeatLabel
RepeatLabel :: Text -> RepeatLabel
[unRepeatLabel] :: RepeatLabel -> Text
-- | .local step.
gLocal :: (ToGTraversal g, WalkType c) => g c s e -> Walk c s e
-- | .union step.
gUnion :: (ToGTraversal g, WalkType c) => [g c s e] -> Walk c s e
-- | .coalesce step.
--
-- Like gFlatMap, gCoalesce always modifies path history.
gCoalesce :: (ToGTraversal g, Split cc c, Lift Transform c, WalkType c, WalkType cc) => [g cc s e] -> Walk c s e
-- | .choose step with if-then-else style.
gChoose3 :: (ToGTraversal g, Split cc c, WalkType cc, WalkType c) => g cc s ep -> g c s e -> g c s e -> Walk c s e
-- | .barrier step.
gBarrier :: WalkType c => Maybe (Greskell Int) -> Walk c s s
gDedup :: (WalkType c, Lift Transform c) => Maybe (ByProjection s e) -> Walk c s s
gDedupN :: (WalkType c, Lift Transform c) => AsLabel a -> [AsLabel a] -> Maybe (ByProjection a e) -> Walk c s s
-- | .flatMap step.
--
-- .flatMap step is at least as powerful as Transform,
-- even if the child walk is Filter type. This is because
-- .flatMap step always modifies the path of the Traverser.
gFlatMap :: (Lift Transform c, Split cc c, ToGTraversal g, WalkType c, WalkType cc) => g cc s e -> Walk c s e
gV :: (Vertex v, WalkType c, Lift Transform c) => [Greskell (ElementID v)] -> Walk c s v
gV' :: (WalkType c, Lift Transform c) => [Greskell (ElementID AVertex)] -> Walk c s AVertex
gConstant :: (WalkType c, Lift Transform c) => Greskell a -> Walk c s a
gProject :: (WalkType c, Lift Transform c) => LabeledByProjection s -> [LabeledByProjection s] -> Walk c s (PMap Single GValue)
gAs :: (WalkType c, Lift Transform c) => AsLabel a -> Walk c a a
gValues :: (Element s, WalkType c, Lift Transform c) => [Key s e] -> Walk c s e
gProperties :: (Element s, Property p, ElementProperty s ~ p, WalkType c, Lift Transform c) => [Key s v] -> Walk c s (p v)
gId :: (Element s, WalkType c, Lift Transform c) => Walk c s (ElementID s)
gLabel :: (Element s, WalkType c, Lift Transform c) => Walk c s Text
gValueMap :: (Element s, WalkType c, Lift Transform c) => Keys s -> Walk c s (PMap (ElementPropertyContainer s) GValue)
gElementMap :: (Element s, WalkType c, Lift Transform c) => Keys s -> Walk c s (PMap Single GValue)
gSelect1 :: (WalkType c, Lift Transform c) => AsLabel a -> Walk c s a
gSelectN :: (WalkType c, Lift Transform c) => AsLabel a -> AsLabel b -> [AsLabel c] -> Walk c s (SelectedMap GValue)
gSelectBy1 :: (WalkType c, Lift Transform c) => AsLabel a -> ByProjection a b -> Walk c s b
gSelectByN :: (WalkType c, Lift Transform c) => AsLabel a -> AsLabel a -> [AsLabel a] -> ByProjection a b -> Walk c s (SelectedMap b)
gUnfold :: (AsIterator a, WalkType c, Lift Transform c) => Walk c a (IteratorItem a)
gPath :: (WalkType c, Lift Transform c) => Walk c s (Path GValue)
gPathBy :: (WalkType c, Lift Transform c) => ByProjection a b -> [ByProjection a b] -> Walk c s (Path b)
gFold :: (WalkType c, Lift Transform c) => Walk c a [a]
gCount :: (WalkType c, Lift Transform c) => Walk c a Int
gOut :: (Vertex v1, Vertex v2, WalkType c, Lift Transform c) => [Greskell Text] -> Walk c v1 v2
gOut' :: (Vertex v, WalkType c, Lift Transform c) => [Greskell Text] -> Walk c v AVertex
gOutE :: (Vertex v, Edge e, WalkType c, Lift Transform c) => [Greskell Text] -> Walk c v e
gOutE' :: (Vertex v, WalkType c, Lift Transform c) => [Greskell Text] -> Walk c v AEdge
gOutV :: (Edge e, Vertex v, WalkType c, Lift Transform c) => Walk c e v
gOutV' :: (Edge e, WalkType c, Lift Transform c) => Walk c e AVertex
gIn :: (Vertex v1, Vertex v2, WalkType c, Lift Transform c) => [Greskell Text] -> Walk c v1 v2
gIn' :: (Vertex v, WalkType c, Lift Transform c) => [Greskell Text] -> Walk c v AVertex
gInE :: (Vertex v, Edge e, WalkType c, Lift Transform c) => [Greskell Text] -> Walk c v e
gInE' :: (Vertex v, WalkType c, Lift Transform c) => [Greskell Text] -> Walk c v AEdge
gInV :: (Edge e, Vertex v, WalkType c, Lift Transform c) => Walk c e v
gInV' :: (Edge e, WalkType c, Lift Transform c) => Walk c e AVertex
gMatch :: (WalkType c, Lift Transform c) => Logic MatchPattern -> Walk c a MatchResult
-- | A pattern for .match step.
data MatchPattern
-- | A pattern with the starting .as label followed by traversal
-- steps.
[MatchPattern] :: AsLabel a -> Walk Transform a b -> MatchPattern
-- | A convenient function to make a MatchPattern wrapped by
-- Leaf.
mPattern :: (WalkType c, Lift c Transform) => AsLabel a -> Walk c a b -> Logic MatchPattern
-- | Result of .match step.
data MatchResult
-- | .sideEffect step that takes a traversal.
gSideEffect :: (ToGTraversal g, WalkType c, WalkType p, Split c p) => g c s e -> Walk p s s
gAddV :: (Vertex v, WalkType c, Lift SideEffect c) => Greskell Text -> Walk c a v
gAddV' :: (WalkType c, Lift SideEffect c) => Greskell Text -> Walk c a AVertex
gAddE :: (Vertex vs, Vertex ve, Edge e, WalkType c, Lift SideEffect c) => Greskell Text -> AddAnchor vs ve -> Walk c vs e
gAddE' :: (WalkType c, Lift SideEffect c) => Greskell Text -> AddAnchor AVertex AVertex -> Walk c AVertex AEdge
-- | Vertex anchor for gAddE. It corresponds to .from or
-- .to step following an .addE step.
--
-- Type s is the input Vertex for the .addE step. Type
-- e is the type of the anchor Vertex that the AddAnchor
-- yields. So, .addE step creates an edge between s and
-- e.
data AddAnchor s e
gFrom :: (ToGTraversal g, WalkType c, Lift c Transform) => g c s e -> AddAnchor s e
gTo :: (ToGTraversal g, WalkType c, Lift c Transform) => g c s e -> AddAnchor s e
gDrop :: (Element e, WalkType c, Lift SideEffect c) => Walk c e e
gDropP :: (Property p, WalkType c, Lift SideEffect c) => Walk c (p a) (p a)
gProperty :: (Element e, WalkType c, Lift SideEffect c) => Key e v -> Greskell v -> Walk c e e
gPropertyV :: (Vertex e, vp ~ ElementProperty e, Property vp, Element (vp v), WalkType c, Lift SideEffect c) => Maybe (Greskell Cardinality) -> Key e v -> Greskell v -> [KeyValue (vp v)] -> Walk c e e
-- | Projection from type s to type e used in
-- .by step. You can also use gBy to construct
-- ByProjection.
data ByProjection s e
[ByProjection] :: (ProjectionLike p, ToGreskell p) => p -> ByProjection (ProjectionLikeStart p) (ProjectionLikeEnd p)
-- | Data types that mean a projection from one type to another.
class ProjectionLike p where {
-- | The start type of the projection.
type ProjectionLikeStart p;
-- | The end type of the projection.
type ProjectionLikeEnd p;
}
-- | Comparison of type s used in .by step. You can also
-- use gBy1 and gBy2 to construct ByComparator.
data ByComparator s
-- | Type s is projected to type e, and compared by the
-- natural comparator of type e.
[ByComparatorProj] :: ByProjection s e -> ByComparator s
-- | Type s is compared by the Comparator comp.
[ByComparatorComp] :: Comparator comp => Greskell comp -> ByComparator (CompareArg comp)
-- | Type s is projected to type CompareArg comp, and
-- compared by the Comparator comp.
[ByComparatorProjComp] :: Comparator comp => ByProjection s (CompareArg comp) -> Greskell comp -> ByComparator s
-- | A ByProjection associated with an AsLabel. You can
-- construct it by gByL.
data LabeledByProjection s
[LabeledByProjection] :: AsLabel a -> ByProjection s a -> LabeledByProjection s
-- | .by step with 1 argument, used for projection.
gBy :: (ProjectionLike p, ToGreskell p) => p -> ByProjection (ProjectionLikeStart p) (ProjectionLikeEnd p)
-- | .by step with 1 argument, used for comparison.
gBy1 :: (ProjectionLike p, ToGreskell p) => p -> ByComparator (ProjectionLikeStart p)
-- | .by step with 2 arguments, used for comparison.
gBy2 :: (ProjectionLike p, ToGreskell p, Comparator comp, ProjectionLikeEnd p ~ CompareArg comp) => p -> Greskell comp -> ByComparator (ProjectionLikeStart p)
-- | .by step associated with an AsLabel.
gByL :: (ProjectionLike p, ToGreskell p) => AsLabel (ProjectionLikeEnd p) -> p -> LabeledByProjection (ProjectionLikeStart p)
module Data.Greskell.Binder
-- | A Monad that manages binding variables and labels to values.
data Binder a
-- | Binding between Gremlin variable names and JSON values.
type Binding = Object
-- | Create a new Gremlin variable bound to the given value.
--
-- The value v is kept in the monadic context. The returned
-- Greskell is a Gremlin variable pointing to the v. The
-- Gremlin variable is guaranteed to be unique in the current monadic
-- context.
newBind :: ToJSON v => v -> Binder (Greskell v)
-- | Create a new AsLabel.
--
-- The returned AsLabel is guaranteed to be unique in the current
-- monadic context.
newAsLabel :: Binder (AsLabel a)
-- | Execute the given Binder monad to obtain Binding.
runBinder :: Binder a -> (a, Binding)
instance GHC.Show.Show Data.Greskell.Binder.BinderS
instance GHC.Classes.Eq Data.Greskell.Binder.BinderS
instance GHC.Base.Monad Data.Greskell.Binder.Binder
instance GHC.Base.Functor Data.Greskell.Binder.Binder
instance GHC.Base.Applicative Data.Greskell.Binder.Binder
-- | Extra utility functions implemented by Greskell.
module Data.Greskell.Extra
-- | Lookup the value and parse it into a.
lookupAs :: (PMapKey k, NonEmptyLike c, PMapValue k ~ a, FromGraphSON a) => k -> PMap c GValue -> Either PMapLookupException a
-- | Similar to lookupAs, but this function converts a null
-- result into Nothing.
--
-- A null result is either (1) the key k is not found
-- in the map, or (2) the key is found, but the value is null.
lookupAs' :: (PMapKey k, NonEmptyLike c, PMapValue k ~ Maybe a, FromGraphSON a) => k -> PMap c GValue -> Either PMapLookupException (Maybe a)
-- | Look up the values and parse them into a.
lookupListAs :: (PMapKey k, NonEmptyLike c, PMapValue k ~ a, FromGraphSON a) => k -> PMap c GValue -> Either PMapLookupException (NonEmpty a)
-- | 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 nulls are included
-- in the values, they are obtained as Nothing.
lookupListAs' :: (PMapKey k, NonEmptyLike c, PMapValue k ~ Maybe a, FromGraphSON a) => k -> PMap c GValue -> Either PMapLookupException [Maybe a]
-- | Convert the lookup result into a MonadFail. It fails with the
-- description returned by pMapDecribeError.
pMapToFail :: MonadFail m => Either PMapLookupException a -> m a
-- | Make a series of .property steps to write the given key-value
-- pairs as properties. Use <=:> and <=?> to
-- make a KeyValue within Binder.
writeKeyValues :: Element e => [KeyValue e] -> Walk SideEffect e e
-- | Like =:, but this one takes a real value, binds it into a
-- Greskell value and returns KeyValue.
(<=:>) :: ToJSON b => Key a b -> b -> Binder (KeyValue a)
-- | 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.
(<=?>) :: ToJSON b => Key a (Maybe b) -> Maybe b -> Binder (KeyValue a)
-- | Make a series of .property steps to write the given key-value
-- pairs as properties.
writePropertyKeyValues :: (ToJSON v, Element e) => [(Text, v)] -> Binder (Walk SideEffect e e)
-- | Make a series of .property steps to write all properties in
-- the given PMap.
writePMapProperties :: (Foldable c, ToJSON v, Element e) => PMap c v -> Binder (Walk SideEffect e e)
-- | The result Walk emits the input elements as-is when there is at
-- least one input element. If there is no input element, it runs the
-- body traversal once and outputs its result.
--
-- You can use this function to implement "upsert" a vertex (i.e. add a
-- vertex if not exist).
--
-- See also: https://stackoverflow.com/questions/46027444/
gWhenEmptyInput :: (ToGTraversal g, Split cc c, Lift Transform cc, Lift Transform c, WalkType c, WalkType cc) => g cc [s] s -> Walk c s s
-- | Examples of using this module. See the source. The fst of the
-- output is the testee, while the snd is the expectation.
examples :: [(String, String)]
-- | Data.Greskell is a Haskell support to use the Gremlin graph query
-- language. For more information, see project README.
--
-- This module re-exports most modules from greskell and greskell-core
-- packages. The following modules are excluded from re-export:
--
--
-- .addE('label')
-- .aggregate('x')
-- .sideEffect(System.out.&println)
-- .map { some_variable += 1 }
--
data SideEffect
-- | WalkType for steps without any side-effects. This includes
-- transformations, reordring, injections and graph traversal actions.
--
-- A Walk w is Transform type iff:
--
-- -- gSideEffect w == gIdentity ---- -- Obviously, every Filter type Walks are also -- Transform type. data Transform -- | WalkType for filtering steps. -- -- A filtering step is a step that does filtering only. It takes input -- and emits some of them without any modification, reordering, traversal -- actions, or side-effects. Filtering decision must be solely based on -- each element. -- -- A Walk w is Filter type iff: -- --
-- (gSideEffect w == gIdentity) AND (gFilter w == w) ---- -- If Walks w1 and w2 are Filter type, -- then -- --
-- gAnd [w1, w2] == w1 >>> w2 == w2 >>> w1 --data Filter -- | Class of phantom type markers to describe the effect of the -- walk/traversals. class WalkType t -- | Only for tests. showWalkType :: WalkType t => Proxy t -> String -- | A chain of one or more Gremlin steps. Like GTraversal, type -- s is the input, type e is the output, and type -- c is a marker to describe the step. -- -- Walk represents a chain of method calls such as -- .has(x).outE(). Because this is not a Gremlin (Groovy) -- expression, we use bare Walk, not Greskell Walk. -- -- Walk is a Category. You can use functions from -- Control.Category to compose Walks. This is equivalent to -- making a chain of method calls in Gremlin. -- -- Walk is not an Eq, because it's difficult to define true -- equality between Gremlin method calls. If we define it naively, it -- might have conflict with Category law. data Walk c s e -- | Types that can convert to GTraversal. class ToGTraversal g toGTraversal :: (ToGTraversal g, WalkType c) => g c s e -> GTraversal c s e -- | Lift WalkType from to to. Use this for type -- matching. liftWalk :: (ToGTraversal g, WalkType from, WalkType to, Lift from to) => g from s e -> g to s e -- | Unsafely cast the start type s1 into s2. -- -- It is recommended that s2 is coercible to s1 in -- terms of FromGraphSON. That is, if s2 can parse a -- GValue, s1 should also be able to parse that -- GValue. unsafeCastStart :: (ToGTraversal g, WalkType c) => g c s1 e -> g c s2 e -- | Unsafely cast the end type e1 into e2. See -- unsafeCastStart. unsafeCastEnd :: (ToGTraversal g, WalkType c) => g c s e1 -> g c s e2 -- | Phantom type for GraphTraversal class. In greskell, we -- usually use GTraversal instead of Greskell -- GraphTraversal. data GraphTraversal c s e -- | GraphTraversal class object of TinkerPop. It takes data -- s from upstream and emits data e to downstream. Type -- c is called "walk type", a marker to describe the effect of -- the traversal. -- -- GTraversal is NOT a Category. Because a -- GraphTraversal object keeps some context data, the starting -- (left-most) GraphTraversal object controls most of the -- behavior of entire composition of traversals and steps. This violates -- Category law. newtype GTraversal c s e GTraversal :: Greskell (GraphTraversal c s e) -> GTraversal c s e [unGTraversal] :: GTraversal c s e -> Greskell (GraphTraversal c s e) -- | Create GraphTraversalSource from a varible name in Gremlin source :: Text -> Greskell GraphTraversalSource -- | .V() method on GraphTraversalSource. sV :: Vertex v => [Greskell (ElementID v)] -> Greskell GraphTraversalSource -> GTraversal Transform () v -- | Monomorphic version of sV. sV' :: [Greskell (ElementID AVertex)] -> Greskell GraphTraversalSource -> GTraversal Transform () AVertex -- | .E() method on GraphTraversalSource. sE :: Edge e => [Greskell (ElementID e)] -> Greskell GraphTraversalSource -> GTraversal Transform () e -- | Monomorphic version of sE. sE' :: [Greskell (ElementID AEdge)] -> Greskell GraphTraversalSource -> GTraversal Transform () AEdge -- | .addV() method on GraphTraversalSource. sAddV :: Vertex v => Greskell Text -> Greskell GraphTraversalSource -> GTraversal SideEffect () v -- | Monomorphic version of sAddV. sAddV' :: Greskell Text -> Greskell GraphTraversalSource -> GTraversal SideEffect () AVertex -- | Unsafely create GTraversal from the given raw Gremlin script. unsafeGTraversal :: Text -> GTraversal c s e -- | Apply the Walk to the GTraversal. In Gremlin, this means -- calling a chain of methods on the Traversal object. (&.) :: GTraversal c a b -> Walk c b d -> GTraversal c a d infixl 1 &. -- | Same as &. with arguments flipped. ($.) :: Walk c b d -> GTraversal c a b -> GTraversal c a d infixr 0 $. -- | Similar to <$>, but for $.. (<$.>) :: Functor f => Walk c b d -> f (GTraversal c a b) -> f (GTraversal c a d) infixr 0 <$.> -- | Similar to <*>, but for $.. (<*.>) :: Applicative f => f (Walk c b d) -> f (GTraversal c a b) -> f (GTraversal c a d) infixr 0 <*.> -- | .iterate method on GraphTraversal. -- -- gIterate is not a Walk because it's usually used to -- terminate the method chain of Gremlin steps. The returned -- GTraversal outputs nothing, thus its end type is (). gIterate :: WalkType c => GTraversal c s e -> GTraversal c s () -- | Unsafely create a Walk that represents a single method call on -- a GraphTraversal. unsafeWalk :: WalkType c => Text -> [Text] -> Walk c s e -- | Optionally modulate the main Walk with some modulating -- Walks. modulateWith :: WalkType c => Walk c s e -> [Walk c e e] -> Walk c s e -- | .identity step. gIdentity :: WalkType c => Walk c s s -- | Monomorphic version of gIdentity. gIdentity' :: Walk Filter s s -- | .filter step that takes a traversal. gFilter :: (ToGTraversal g, WalkType c, WalkType p, Split c p) => g c s e -> Walk p s s -- | .cyclicPath step. gCyclicPath :: WalkType c => Walk c a a -- | Monomorphic version of gCyclicPath. gCyclicPath' :: Walk Filter a a -- | .simplePath step. gSimplePath :: WalkType c => Walk c a a -- | Monomorphic version of gSimplePath. gSimplePath' :: Walk Filter a a -- | .where step with P argument only. -- -- If the ByProjection argument is Nothing, comparison is -- performed on the type a. You have to ensure that the -- comparator included in the LabeledP argument can handle the -- type a. Usually this means the type a should -- implement Java's Comparable interface (this is true for most -- Java classes). -- -- If the ByProjection argument is given, comparison is performed -- on the projected values of type b. So, the type b -- should implement Java's Comparable interface. gWhereP1 :: WalkType c => Greskell (LabeledP a) -> Maybe (ByProjection a b) -> Walk c a a -- | Monomorphic version of gWhereP1. gWhereP1' :: Greskell (LabeledP a) -> Maybe (ByProjection a b) -> Walk Filter a a -- | .where step with the starting label and P arguments. -- See also gWhereP1. gWhereP2 :: WalkType c => AsLabel a -> Greskell (LabeledP a) -> Maybe (ByProjection a b) -> Walk c x x -- | Monomorphic version of gWhereP2. gWhereP2' :: AsLabel a -> Greskell (LabeledP a) -> Maybe (ByProjection a b) -> Walk Filter x x -- | A convenient function to make a MatchPattern wrapped by -- Leaf. mPattern :: (WalkType c, Lift c Transform) => AsLabel a -> Walk c a b -> Logic MatchPattern -- | .match step. -- -- If the top-level Logic of the argument is And, the -- patterns are directly passed to the .match step arguments. -- -- The result of .match step, MatchResult, is an opaque -- type. Basically you should not use it. Instead, you should use -- gSelectN etc to access the path history labels inside the -- MatchPattern. -- -- See also: -- https://groups.google.com/g/gremlin-users/c/HVtldzV0Xk8 gMatch :: Logic MatchPattern -> Walk Transform a MatchResult -- | .is step of simple equality. gIs :: WalkType c => Greskell v -> Walk c v v -- | Monomorphic version of gIs. gIs' :: Greskell v -> Walk Filter v v -- | .is step with predicate P. gIsP :: WalkType c => Greskell (P v) -> Walk c v v -- | Monomorphic version of gIsP. gIsP' :: Greskell (P v) -> Walk Filter v v -- | .has step with one argument. gHas1 :: (WalkType c, Element s) => Key s v -> Walk c s s -- | Monomorphic version of gHas1. gHas1' :: Element s => Key s v -> Walk Filter s s -- | .has step with two arguments. gHas2 :: (WalkType c, Element s) => Key s v -> Greskell v -> Walk c s s -- | Monomorphic verson of gHas2. gHas2' :: Element s => Key s v -> Greskell v -> Walk Filter s s -- | .has step with two arguments and P type. gHas2P :: (WalkType c, Element s) => Key s v -> Greskell (P v) -> Walk c s s -- | Monomorphic version of gHas2P. gHas2P' :: Element s => Key s v -> Greskell (P v) -> Walk Filter s s -- | .hasLabel step. gHasLabel :: (Element s, WalkType c) => Greskell Text -> Walk c s s -- | Monomorphic version of gHasLabel. gHasLabel' :: Element s => Greskell Text -> Walk Filter s s -- | .hasLabel step with P type. Supported since TinkerPop -- 3.2.7. gHasLabelP :: (Element s, WalkType c) => Greskell (P Text) -> Walk c s s -- | Monomorphic version of gHasLabelP. gHasLabelP' :: Element s => Greskell (P Text) -> Walk Filter s s -- | .hasId step. gHasId :: (Element s, WalkType c) => Greskell (ElementID s) -> Walk c s s -- | Monomorphic version of gHasId. gHasId' :: Element s => Greskell (ElementID s) -> Walk Filter s s -- | .hasId step with P type. Supported since TinkerPop -- 3.2.7. gHasIdP :: (Element s, WalkType c) => Greskell (P (ElementID s)) -> Walk c s s -- | Monomorphic version of gHasIdP. gHasIdP' :: Element s => Greskell (P (ElementID s)) -> Walk Filter s s -- | .hasKey step. The input type should be a VertexProperty. gHasKey :: (Element (p v), Property p, WalkType c) => Greskell Text -> Walk c (p v) (p v) -- | Monomorphic version of gHasKey. gHasKey' :: (Element (p v), Property p) => Greskell Text -> Walk Filter (p v) (p v) -- | .hasKey step with P type. Supported since TinkerPop -- 3.2.7. gHasKeyP :: (Element (p v), Property p, WalkType c) => Greskell (P Text) -> Walk c (p v) (p v) -- | Monomorphic version of gHasKeyP. gHasKeyP' :: (Element (p v), Property p) => Greskell (P Text) -> Walk Filter (p v) (p v) -- | .hasValue step. The input type should be a VertexProperty. gHasValue :: (Element (p v), Property p, WalkType c) => Greskell v -> Walk c (p v) (p v) -- | Monomorphic version of gHasValue. gHasValue' :: (Element (p v), Property p) => Greskell v -> Walk Filter (p v) (p v) -- | .hasValue step with P type. Supported since TinkerPop -- 3.2.7. gHasValueP :: (Element (p v), Property p, WalkType c) => Greskell (P v) -> Walk c (p v) (p v) -- | Monomorphic version of gHasValueP. gHasValueP' :: (Element (p v), Property p) => Greskell (P v) -> Walk Filter (p v) (p v) -- | .and step. gAnd :: (ToGTraversal g, WalkType c, WalkType p, Split c p) => [g c s e] -> Walk p s s -- | .or step. gOr :: (ToGTraversal g, WalkType c, WalkType p, Split c p) => [g c s e] -> Walk p s s -- | .not step. gNot :: (ToGTraversal g, WalkType c, WalkType p, Split c p) => g c s e -> Walk p s s -- | .range step. This step is not a Filter, because the -- filtering decision by this step is based on position of each element, -- not the element itself. This violates Filter law. gRange :: Greskell Int -> Greskell Int -> Walk Transform s s -- | .limit step. gLimit :: Greskell Int -> Walk Transform s s -- | .tail step. gTail :: Greskell Int -> Walk Transform s s -- | .skip step. gSkip :: Greskell Int -> Walk Transform s s -- | .repeat step. gRepeat :: (ToGTraversal g, WalkType c) => Maybe RepeatLabel -> Maybe (RepeatPos, RepeatUntil c s) -> Maybe (RepeatPos, RepeatEmit c s) -> g c s s -> Walk c s s -- | .times modulator before the .repeat step. It always -- returns Just. gTimes :: Greskell Int -> Maybe (RepeatPos, RepeatUntil c s) -- | .until modulator before the .repeat step. It always -- returns Just. gUntilHead :: (ToGTraversal g, WalkType c, WalkType cc, Split cc c) => g cc s e -> Maybe (RepeatPos, RepeatUntil c s) -- | .until modulator after the .repeat step. It always -- returns Just. gUntilTail :: (ToGTraversal g, WalkType c, WalkType cc, Split cc c) => g cc s e -> Maybe (RepeatPos, RepeatUntil c s) -- | .emit modulator without argument before the .repeat -- step. It always returns Just. gEmitHead :: Maybe (RepeatPos, RepeatEmit c s) -- | .emit modulator without argument after the .repeat -- step. It always returns Just. gEmitTail :: Maybe (RepeatPos, RepeatEmit c s) -- | .emit modulator with a sub-traversal argument before the -- .repeat step. It always returns Just. gEmitHeadT :: (ToGTraversal g, WalkType c, WalkType cc, Split cc c) => g cc s e -> Maybe (RepeatPos, RepeatEmit c s) -- | .emit modulator with a sub-traversal argument after the -- .repeat step. It always returns Just. gEmitTailT :: (ToGTraversal g, WalkType c, WalkType cc, Split cc c) => g cc s e -> Maybe (RepeatPos, RepeatEmit c s) -- | .loops step. gLoops :: Maybe RepeatLabel -> Walk Transform s Int -- | .local step. gLocal :: (ToGTraversal g, WalkType c) => g c s e -> Walk c s e -- | .union step. gUnion :: (ToGTraversal g, WalkType c) => [g c s e] -> Walk c s e -- | .coalesce step. -- -- Like gFlatMap, gCoalesce always modifies path history. gCoalesce :: (ToGTraversal g, Split cc c, Lift Transform c, WalkType c, WalkType cc) => [g cc s e] -> Walk c s e -- | .choose step with if-then-else style. gChoose3 :: (ToGTraversal g, Split cc c, WalkType cc, WalkType c) => g cc s ep -> g c s e -> g c s e -> Walk c s e -- | .barrier step. gBarrier :: WalkType c => Maybe (Greskell Int) -> Walk c s s -- | .dedup step without argument. -- -- .dedup step is Transform because the filtering -- decision depends on the sequence (order) of input elements. gDedup :: Maybe (ByProjection s e) -> Walk Transform s s -- | .dedup step with at least one argument. The tuple specified -- by the AsLabels is used as the criterion of deduplication. gDedupN :: AsLabel a -> [AsLabel a] -> Maybe (ByProjection a e) -> Walk Transform s s -- | .by step with 1 argument, used for projection. gBy :: (ProjectionLike p, ToGreskell p) => p -> ByProjection (ProjectionLikeStart p) (ProjectionLikeEnd p) -- | .by step with 1 argument, used for comparison. gBy1 :: (ProjectionLike p, ToGreskell p) => p -> ByComparator (ProjectionLikeStart p) -- | .by step with 2 arguments, used for comparison. gBy2 :: (ProjectionLike p, ToGreskell p, Comparator comp, ProjectionLikeEnd p ~ CompareArg comp) => p -> Greskell comp -> ByComparator (ProjectionLikeStart p) -- | .order step. -- -- ByComparator is an IsString, meaning projection by the -- given key. gOrder :: [ByComparator s] -> Walk Transform s s -- | .by step associated with an AsLabel. gByL :: (ProjectionLike p, ToGreskell p) => AsLabel (ProjectionLikeEnd p) -> p -> LabeledByProjection (ProjectionLikeStart p) -- | .flatMap step. -- -- .flatMap step is at least as powerful as Transform, -- even if the child walk is Filter type. This is because -- .flatMap step always modifies the path of the Traverser. gFlatMap :: (Lift Transform c, Split cc c, ToGTraversal g, WalkType c, WalkType cc) => g cc s e -> Walk c s e -- | Monomorphic version of gFlatMap. gFlatMap' :: ToGTraversal g => g Transform s e -> Walk Transform s e -- | .V step. -- -- For each input item, .V step emits vertices selected by the -- argument (or all vertices if the empty list is passed.) gV :: Vertex v => [Greskell (ElementID v)] -> Walk Transform s v -- | Monomorphic version of gV. gV' :: [Greskell (ElementID AVertex)] -> Walk Transform s AVertex -- | .constant step. gConstant :: Greskell a -> Walk Transform s a -- | .unfold step. -- -- Note that we use AsIterator here because basically the -- .unfold step does the same thing as -- IteratorUtils.asIterator function in Tinkerpop. However, -- Tinkerpop's implementation of .unfold step doesn't -- necessarily use asIterator, so there may be some corner cases -- where asIterator and .unfold step behave -- differently. gUnfold :: AsIterator a => Walk Transform a (IteratorItem a) -- | .as step. -- -- .as step is Transform because it adds the label to the -- traverser. gAs :: AsLabel a -> Walk Transform a a -- | .values step. gValues :: Element s => [Key s e] -> Walk Transform s e -- | .properties step. gProperties :: (Element s, Property p, ElementProperty s ~ p) => [Key s v] -> Walk Transform s (p v) -- | .id step. gId :: Element s => Walk Transform s (ElementID s) -- | .label step. gLabel :: Element s => Walk Transform s Text -- | .valueMap step. gValueMap :: Element s => Keys s -> Walk Transform s (PMap (ElementPropertyContainer s) GValue) -- | .elementMap step. gElementMap :: Element s => Keys s -> Walk Transform s (PMap Single GValue) -- | .select step with one argument. gSelect1 :: AsLabel a -> Walk Transform s a -- | .select step with more than one arguments. gSelectN :: AsLabel a -> AsLabel b -> [AsLabel c] -> Walk Transform s (SelectedMap GValue) -- | .select step with one argument followed by .by step. gSelectBy1 :: AsLabel a -> ByProjection a b -> Walk Transform s b -- | .select step with more than one arguments followed by -- .by step. gSelectByN :: AsLabel a -> AsLabel a -> [AsLabel a] -> ByProjection a b -> Walk Transform s (SelectedMap b) -- | .project step. gProject :: LabeledByProjection s -> [LabeledByProjection s] -> Walk Transform s (PMap Single GValue) -- | .path step without modulation. gPath :: Walk Transform s (Path GValue) -- | .path step with one or more .by modulations. gPathBy :: ByProjection a b -> [ByProjection a b] -> Walk Transform s (Path b) -- | .fold step. gFold :: Walk Transform a [a] -- | .count step. gCount :: Walk Transform a Int -- | .out step gOut :: (Vertex v1, Vertex v2) => [Greskell Text] -> Walk Transform v1 v2 -- | Monomorphic version of gOut. gOut' :: Vertex v => [Greskell Text] -> Walk Transform v AVertex -- | .outE step gOutE :: (Vertex v, Edge e) => [Greskell Text] -> Walk Transform v e -- | Monomorphic version of gOutE. gOutE' :: Vertex v => [Greskell Text] -> Walk Transform v AEdge -- | .outV step. gOutV :: (Edge e, Vertex v) => Walk Transform e v -- | Monomorphic version of gOutV. gOutV' :: Edge e => Walk Transform e AVertex -- | .in step gIn :: (Vertex v1, Vertex v2) => [Greskell Text] -> Walk Transform v1 v2 -- | Monomorphic version of gIn. gIn' :: Vertex v => [Greskell Text] -> Walk Transform v AVertex -- | .inE step. gInE :: (Vertex v, Edge e) => [Greskell Text] -> Walk Transform v e -- | Monomorphic version of gInE. gInE' :: Vertex v => [Greskell Text] -> Walk Transform v AEdge -- | .inV step. gInV :: (Edge e, Vertex v) => Walk Transform e v -- | Monomorphic version of gInV. gInV' :: Edge e => Walk Transform e AVertex -- | .sideEffect step that takes a traversal. gSideEffect :: (ToGTraversal g, WalkType c, WalkType p, Split c p) => g c s e -> Walk p s s -- | Monomorphic version of gSideEffect. The result walk is always -- SideEffect type. gSideEffect' :: (ToGTraversal g, WalkType c, Split c SideEffect) => g c s e -> Walk SideEffect s s -- | .addV step with a label. gAddV :: Vertex v => Greskell Text -> Walk SideEffect a v -- | Monomorphic version of gAddV. gAddV' :: Greskell Text -> Walk SideEffect a AVertex -- | .drop step on Element. gDrop :: Element e => Walk SideEffect e e -- | .drop step on Property. gDropP :: Property p => Walk SideEffect (p a) (p a) -- | Simple .property step. It adds a value to the property. gProperty :: Element e => Key e v -> Greskell v -> Walk SideEffect e e -- | .property step for Vertex. gPropertyV :: (Vertex e, vp ~ ElementProperty e, Property vp, Element (vp v)) => Maybe (Greskell Cardinality) -> Key e v -> Greskell v -> [KeyValue (vp v)] -> Walk SideEffect e e -- | .from step with a traversal. gFrom :: ToGTraversal g => g Transform s e -> AddAnchor s e -- | .to step with a traversal. gTo :: ToGTraversal g => g Transform s e -> AddAnchor s e -- | .addE step. Supported since TinkerPop 3.1.0. gAddE :: (Vertex vs, Vertex ve, Edge e) => Greskell Text -> AddAnchor vs ve -> Walk SideEffect vs e -- | Monomorphic version of gAddE. gAddE' :: Greskell Text -> AddAnchor AVertex AVertex -> Walk SideEffect AVertex AEdge -- | org.apache.tinkerpop.gremlin.process.traversal.Order enum. data Order a -- | Type for anonymous class of Comparator interface. newtype ComparatorA a ComparatorA :: (a -> a -> Int) -> ComparatorA a [unComparatorA] :: ComparatorA a -> a -> a -> Int -- | java.util.Comparator interface. -- -- Comparator compares two data of type CompareArg -- c. class Comparator c where { type CompareArg c; } -- | .compare method. cCompare :: Comparator c => Greskell c -> Greskell (CompareArg c) -> Greskell (CompareArg c) -> Greskell Int -- | .reversed method. cReversed :: Comparator c => Greskell c -> Greskell c -- | .thenComparing method. cThenComparing :: Comparator c => Greskell c -> Greskell c -> Greskell c -- | Type that is compatible with P. You can construct a value of -- type Greskell p using values of PParameter p. -- -- Note that the type of constuctor arguments (i.e. GreskellReturn -- (PParameter p)) should implement Java's Comparable -- interface. This is true for most types, so greskell doesn't have any -- explicit constraint about it. class (ToGreskell (PParameter p)) => PLike p where { type PParameter p; } -- | org.apache.tinkerpop.gremlin.process.traversal.P class. -- -- P a keeps data of type a and compares it with data -- of type a given as the Predicate argument. data P a -- | Type for anonymous class of Predicate interface. newtype PredicateA a PredicateA :: (a -> Bool) -> PredicateA a [unPredicateA] :: PredicateA a -> a -> Bool -- | java.util.function.Predicate interface. -- -- A Predicate p is a function that takes -- PredicateArg p and returns Bool. class Predicate p where { type PredicateArg p; } -- | .and method. pAnd :: Predicate p => Greskell p -> Greskell p -> Greskell p -- | .or method. pOr :: Predicate p => Greskell p -> Greskell p -> Greskell p -- | .test method. pTest :: Predicate p => Greskell p -> Greskell (PredicateArg p) -> Greskell Bool -- | .nagate method. pNegate :: Predicate p => Greskell p -> Greskell p -- | P.not static method. pNot :: PLike p => Greskell p -> Greskell p -- | P.eq static method. pEq :: PLike p => PParameter p -> Greskell p -- | P.neq static method. pNeq :: PLike p => PParameter p -> Greskell p -- | P.lt static method. pLt :: PLike p => PParameter p -> Greskell p -- | P.lte static method. pLte :: PLike p => PParameter p -> Greskell p -- | P.gt static method. pGt :: PLike p => PParameter p -> Greskell p -- | P.gte static method. pGte :: PLike p => PParameter p -> Greskell p -- | P.inside static method. pInside :: PLike p => PParameter p -> PParameter p -> Greskell p -- | P.outside static method. pOutside :: PLike p => PParameter p -> PParameter p -> Greskell p -- | P.between static method. pBetween :: PLike p => PParameter p -> PParameter p -> Greskell p -- | P.within static method. pWithin :: PLike p => [PParameter p] -> Greskell p -- | P.without static method. pWithout :: PLike p => [PParameter p] -> Greskell p -- | desc order. oDesc :: Greskell (Order a) -- | asc order. oAsc :: Greskell (Order a) -- | decr order. -- -- Note that decr was removed in TinkerPop 3.5.0. Use -- oDesc instead. oDecr :: Greskell (Order a) -- | incr order. -- -- Note that incr was removed in TinkerPop 3.5.0. Use -- oAsc instead. oIncr :: Greskell (Order a) -- | shuffle order. oShuffle :: Greskell (Order a) -- | An entry in a Path. data PathEntry a PathEntry :: HashSet (AsLabel a) -> a -> PathEntry a [peLabels] :: PathEntry a -> HashSet (AsLabel a) [peObject] :: PathEntry a -> a -- | org.apache.tinkerpop.gremlin.process.traversal.Path -- interface. newtype Path a Path :: [PathEntry a] -> Path a [unPath] :: Path a -> [PathEntry a] -- | General vertex property type you can use for VertexProperty. -- -- If you are not sure about the type v, just use GValue. data AVertexProperty v AVertexProperty :: ElementID (AVertexProperty v) -> Text -> v -> AVertexProperty v -- | ID of this vertex property. [avpId] :: AVertexProperty v -> ElementID (AVertexProperty v) -- | Label and key of this vertex property. [avpLabel] :: AVertexProperty v -> Text -- | Value of this vertex property. [avpValue] :: AVertexProperty v -> v -- | General simple property type you can use for Property class. -- -- If you are not sure about the type v, just use GValue. data AProperty v AProperty :: Text -> v -> AProperty v [apKey] :: AProperty v -> Text [apValue] :: AProperty v -> v -- | General edge type you can use for Edge class. data AEdge AEdge :: ElementID AEdge -> Text -> AEdge -- | ID of this edge. [aeId] :: AEdge -> ElementID AEdge -- | Label of this edge. [aeLabel] :: AEdge -> Text -- | General vertex type you can use for Vertex class. data AVertex AVertex :: ElementID AVertex -> Text -> AVertex -- | ID of this vertex [avId] :: AVertex -> ElementID AVertex -- | Label of this vertex [avLabel] :: AVertex -> Text -- | Heterogeneous list of Keys. It keeps the parent type -- a, but discards the value type b. data Keys a -- | Empty Keys. [KeysNil] :: Keys a -- | Add a Key to Keys. [KeysCons] :: Key a b -> Keys a -> Keys a -- | Pair of Key and its value. Mainly used for writing properties -- into the database. -- -- Type a is the type of Element that keeps the -- KeyValue pair. It drops the type of the value, so that you can -- construct a heterogeneous list of key-value pairs for a given -- Element. data KeyValue a -- | Key and value [KeyValue] :: Key a b -> Greskell b -> KeyValue a -- | Key without value [KeyNoValue] :: Key a b -> KeyValue a -- | A property key accessing value b in an Element a. In -- Gremlin, it's just a String type. -- -- Since greskell-1.0.0.0, Key is newtype of Text. Before -- that, it was newtype of Greskell Text. newtype Key a b Key :: Text -> Key a b [unKey] :: Key a b -> Text -- | -- org.apache.tinkerpop.gremlin.structure.VertexProperty.Cardinality -- enum. data Cardinality -- | org.apache.tinkerpop.gremlin.structure.T enum. -- -- T is a token to get data b from an Element a. data T a b -- | org.apache.tinkerpop.gremlin.structure.Property interface in -- a TinkerPop graph. class Property p -- | Get key of this property. propertyKey :: Property p => p v -> Text -- | Get value of this property. propertyValue :: Property p => p v -> v -- | org.apache.tinkerpop.gremlin.structure.Edge interface in a -- TinkerPop graph. class (Element e) => Edge e -- | org.apache.tinkerpop.gremlin.structure.Vertex interface in a -- TinkerPop graph. class (Element v) => Vertex v -- | org.apache.tinkerpop.gremlin.structure.Element interface in a -- TinkerPop graph. -- -- Since greskell-1.0.0.0, ElementData is a super-class of -- Element. class ElementData e => Element e where { -- | Property type of the Element. It should be of Property -- class. type ElementProperty e :: Type -> Type; -- | Container type of the properties of the Element. It should be -- of NonEmptyLike class. type ElementPropertyContainer e :: Type -> Type; } -- | Types that keep reference to TinkerPop graph Elements. class ElementData e -- | ID of this Element. elementId :: ElementData e => e -> ElementID e -- | Label of this Element. elementLabel :: ElementData e => e -> Text -- | ID of a graph element e (vertex, edge and vertex property). -- -- Although the internal of ElementID is exposed, you should treat -- it as an opaque value. That's because it depends on graph -- implementation. newtype ElementID e ElementID :: GValue -> ElementID e [unElementID] :: ElementID e -> GValue -- | Unsafely cast the phantom type of ElementID. unsafeCastElementID :: ElementID a -> ElementID b -- | T.id token. tId :: Element a => Greskell (T a (ElementID a)) -- | T.key token. tKey :: (Element (p v), Property p) => Greskell (T (p v) Text) -- | T.label token. tLabel :: Element a => Greskell (T a Text) -- | T.value token. tValue :: (Element (p v), Property p) => Greskell (T (p v) v) -- | list Cardinality. cList :: Greskell Cardinality -- | set Cardinality. cSet :: Greskell Cardinality -- | single Cardinality. cSingle :: Greskell Cardinality -- | Create a Key a text. key :: Text -> Key a b -- | Unsafely cast the type signature of the Key. unsafeCastKey :: Key a1 b1 -> Key a2 b2 -- | Constructor operator of KeyValue. (=:) :: Key a b -> Greskell b -> KeyValue a -- | Keys with a single Key. singletonKeys :: Key a b -> Keys a -- | Convert Keys to a list of Gremlin scripts. toGremlinKeys :: Keys a -> [Text] -- | Prepend a Key to Keys. (-:) :: Key a b -> Keys a -> Keys a infixr 5 -: -- | Convert a Path into PMap. -- -- In the result PMap, the keys are the labels in the Path, -- and the values are the objects associated with the labels. The values -- are stored in the same order in the Path. Objects without any -- label are discarded. pathToPMap :: Path a -> PMap Multi a -- | Make a PathEntry. makePathEntry :: [AsLabel a] -> a -> PathEntry a -- | A JSON parser. N.B. This might not fit your usual understanding of -- "parser". Instead you might like to think of Parser as a "parse -- result", i.e. a parser to which the input has already been applied. data Parser a -- | Implementation of parseJSON based on parseGraphSON. The -- input Value is first converted to GValue, and it's -- parsed to the output type. parseJSONViaGValue :: FromGraphSON a => Value -> Parser a -- | Like Aeson's .:, but for FromGraphSON. (.:) :: FromGraphSON a => KeyMap GValue -> Key -> Parser a -- | Parse GValue into FromGraphSON. parseEither :: FromGraphSON a => GValue -> Either String a -- | Extract GArray from the given GValue, parse the items in -- the array, and gather them by fromList. -- -- Useful to implement FromGraphSON instances for IsList -- types. parseUnwrapList :: (IsList a, i ~ Item a, FromGraphSON i) => GValue -> Parser a -- | Unwrap the given GValue with unwrapAll, and just parse -- the result with parseJSON. -- -- Useful to implement FromGraphSON instances for scalar types. parseUnwrapAll :: FromJSON a => GValue -> Parser a -- | Types that can be constructed from GValue. This is analogous to -- FromJSON class. -- -- Instances of basic types are implemented based on the following rule. -- --