-- 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 -- -- -- -- Typeclasses about boolean/logic operations -- -- -- -- Trees that contain heterogeneous values -- -- module Data.Greskell.Logic -- | A general-purpose logic tree structure. Only the leaf nodes have -- values of type a. The tree is lazy both in value and spine -- (structure). data Logic a -- | Leaf node with value Leaf :: a -> Logic a -- | "and" logic operator And :: Logic a -> [Logic a] -> Logic a -- | "or" logic operator Or :: Logic a -> [Logic a] -> Logic a -- | "not" logic operator Not :: Logic a -> Logic a -- | Run the logic tree of Bool values to get the result. runBool :: Logic Bool -> Bool instance GHC.Show.Show a => GHC.Show.Show (Data.Greskell.Logic.Logic a) instance GHC.Classes.Ord a => GHC.Classes.Ord (Data.Greskell.Logic.Logic a) instance GHC.Generics.Generic (Data.Greskell.Logic.Logic a) instance GHC.Classes.Eq a => GHC.Classes.Eq (Data.Greskell.Logic.Logic a) instance GHC.Base.Functor Data.Greskell.Logic.Logic instance GHC.Base.Applicative Data.Greskell.Logic.Logic instance GHC.Base.Monad Data.Greskell.Logic.Logic instance Data.Foldable.Foldable Data.Greskell.Logic.Logic instance Data.Traversable.Traversable Data.Greskell.Logic.Logic module Data.Greskell.NonEmptyLike -- | Non-empty containers. Its cardinality is one or more. class Foldable t => NonEmptyLike t -- | Make a container with a single value. singleton :: NonEmptyLike t => a -> t a -- | Append two containers. append :: NonEmptyLike t => t a -> t a -> t a -- | Convert the container to NonEmpty list. toNonEmpty :: NonEmptyLike t => t a -> NonEmpty a instance Data.Greskell.NonEmptyLike.NonEmptyLike GHC.Base.NonEmpty instance Data.Greskell.NonEmptyLike.NonEmptyLike Data.Semigroup.First instance Data.Greskell.NonEmptyLike.NonEmptyLike Data.Semigroup.Last -- | This module defines PMap, a map with Text keys and -- cardinality options. module Data.Greskell.PMap -- | A property map, which has text keys and v values. c -- specifies the cardinality of each item, and should be an instance of -- NonEmptyLike. -- -- You can look up values from PMap using key types of -- PMapKey class. data PMap c v -- | Lookup the first value for the key from PMap. lookup :: (PMapKey k, NonEmptyLike c) => k -> PMap c v -> Maybe v -- | MonadThrow version of lookup. If there is no value for -- the key, it throws PMapNoSuchKey. lookupM :: (PMapKey k, NonEmptyLike c, MonadThrow m) => k -> PMap c v -> m v -- | 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) -- | MonadThrow version of lookupAs. lookupAsM :: (PMapKey k, NonEmptyLike c, PMapValue k ~ a, FromGraphSON a, MonadThrow m) => k -> PMap c GValue -> m a -- | Lookup all items for the key. If there is no item for the key, it -- returns an empty list. lookupList :: (PMapKey k, NonEmptyLike c) => k -> PMap c v -> [v] -- | 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] -- | Insert a key-value pair to PMap. If it already has some items -- for that key, append method of the NonEmptyLike type -- c determines its behavior. pMapInsert :: NonEmptyLike c => Text -> v -> PMap c v -> PMap c v -- | Delete a key and all values associated with it. pMapDelete :: Text -> PMap c v -> PMap c v -- | Lookup all items for the key (low-level function). If there is no item -- for the key, it returns an empty list. pMapLookup :: NonEmptyLike c => Text -> PMap c v -> [v] -- | List up all entries. pMapToList :: Foldable c => PMap c v -> [(Text, v)] -- | Make a PMap from list of entries. pMapFromList :: NonEmptyLike c => [(Text, v)] -> PMap c v -- | The single cardinality for PMap. pMapInsert method -- replaces the old value. <> on PMap prefers the -- items from the left PMap. pMapFromList prefers the first -- item for each key. type Single = First -- | The "one or more" cardinality for PMap. pMapInsert -- method prepends the new value at the head. <> on -- PMap appends the right items to the tail of the left items. -- pMapFromList preserves the order of the items for each key. data Multi a -- | A typed key for PMap. class PMapKey k where { -- | Type of the value associated with the key. type PMapValue k :: Type; } -- | Text representation of the key. keyText :: PMapKey k => k -> Text -- | An Exception raised when looking up values from PMap. data PMapLookupException -- | The PMap doesn't have the given key. PMapNoSuchKey :: Text -> PMapLookupException -- | Failed to parse the value into the type that the PMapKey -- indicates. The Text is the key, and the String is the -- error message. PMapParseError :: Text -> String -> PMapLookupException -- | Make a human-readable description on PMapLookupException. pMapDecribeError :: PMapLookupException -> String -- | Convert the lookup result into a MonadThrow. It throws -- PMapLookupException. pMapToThrow :: MonadThrow m => Either PMapLookupException a -> m a -- | Convert the lookup result into a MonadFail. It fails with the -- description returned by pMapDecribeError. pMapToFail :: MonadFail m => Either PMapLookupException a -> m a instance Data.Traversable.Traversable c => Data.Traversable.Traversable (Data.Greskell.PMap.PMap c) instance GHC.Show.Show (c v) => GHC.Show.Show (Data.Greskell.PMap.PMap c v) instance GHC.Base.Functor c => GHC.Base.Functor (Data.Greskell.PMap.PMap c) instance Data.Foldable.Foldable c => Data.Foldable.Foldable (Data.Greskell.PMap.PMap c) instance GHC.Classes.Eq (c v) => GHC.Classes.Eq (Data.Greskell.PMap.PMap c v) instance Data.Traversable.Traversable Data.Greskell.PMap.Multi instance GHC.Show.Show a => GHC.Show.Show (Data.Greskell.PMap.Multi a) instance GHC.Base.Semigroup (Data.Greskell.PMap.Multi a) instance GHC.Classes.Ord a => GHC.Classes.Ord (Data.Greskell.PMap.Multi a) instance Data.Greskell.NonEmptyLike.NonEmptyLike Data.Greskell.PMap.Multi instance GHC.Base.Functor Data.Greskell.PMap.Multi instance Data.Greskell.GraphSON.FromGraphSON a => Data.Greskell.GraphSON.FromGraphSON (Data.Greskell.PMap.Multi a) instance Data.Foldable.Foldable Data.Greskell.PMap.Multi instance GHC.Classes.Eq a => GHC.Classes.Eq (Data.Greskell.PMap.Multi a) instance GHC.Show.Show Data.Greskell.PMap.PMapLookupException instance GHC.Classes.Ord Data.Greskell.PMap.PMapLookupException instance GHC.Classes.Eq Data.Greskell.PMap.PMapLookupException instance GHC.Exception.Type.Exception Data.Greskell.PMap.PMapLookupException instance Data.Greskell.PMap.PMapKey Data.Text.Internal.Text instance Data.Greskell.GraphSON.GraphSONTyped.GraphSONTyped (Data.Greskell.PMap.PMap c v) instance Data.Greskell.GraphSON.FromGraphSON (c v) => Data.Greskell.GraphSON.FromGraphSON (Data.Greskell.PMap.PMap c v) instance Data.Greskell.NonEmptyLike.NonEmptyLike c => GHC.Base.Semigroup (Data.Greskell.PMap.PMap c v) instance Data.Greskell.NonEmptyLike.NonEmptyLike c => GHC.Base.Monoid (Data.Greskell.PMap.PMap c v) instance Data.Greskell.AsIterator.AsIterator (Data.Greskell.PMap.PMap c v) module Data.Greskell.AsLabel -- | AsLabel a represents a label string used in -- .as step pointing to the data of type a. newtype AsLabel a AsLabel :: Text -> AsLabel a [unAsLabel] :: AsLabel a -> Text -- | A map keyed with AsLabel. Obtained from .select step, -- for example. type SelectedMap = PMap Single -- | Unsafely cast the phantom type of the AsLabel. unsafeCastAsLabel :: AsLabel a -> AsLabel b -- | Lookup the first value for the key from PMap. lookup :: (PMapKey k, NonEmptyLike c) => k -> PMap c v -> Maybe v -- | MonadThrow version of lookup. If there is no value for -- the key, it throws PMapNoSuchKey. lookupM :: (PMapKey k, NonEmptyLike c, MonadThrow m) => k -> PMap c v -> m v -- | 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 -- | MonadThrow version of lookupAs. lookupAsM :: (PMapKey k, NonEmptyLike c, PMapValue k ~ a, FromGraphSON a, MonadThrow m) => k -> PMap c GValue -> m a -- | An Exception raised when looking up values from PMap. data PMapLookupException -- | The PMap doesn't have the given key. PMapNoSuchKey :: Text -> PMapLookupException -- | Failed to parse the value into the type that the PMapKey -- indicates. The Text is the key, and the String is the -- error message. PMapParseError :: Text -> String -> PMapLookupException -- | LabeledP is just like P, a Haskell representation of -- TinkerPop's P class. Unlike P, however, -- LabeledP keeps a label (AsLabel) inside. It is used in -- .where step. data LabeledP a instance GHC.Show.Show (Data.Greskell.AsLabel.AsLabel a) instance GHC.Classes.Ord (Data.Greskell.AsLabel.AsLabel a) instance Data.Hashable.Class.Hashable (Data.Greskell.AsLabel.AsLabel a) instance GHC.Classes.Eq (Data.Greskell.AsLabel.AsLabel a) instance Data.Greskell.Gremlin.PLike (Data.Greskell.AsLabel.LabeledP a) instance Data.String.IsString (Data.Greskell.AsLabel.AsLabel a) instance Data.Greskell.Greskell.ToGreskell (Data.Greskell.AsLabel.AsLabel a) instance GHC.Base.Functor Data.Greskell.AsLabel.AsLabel instance Data.Greskell.PMap.PMapKey (Data.Greskell.AsLabel.AsLabel a) -- | This module defines types and functions about TinkerPop graph -- structure API. module Data.Greskell.Graph -- | 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 -- | org.apache.tinkerpop.gremlin.structure.Vertex interface in a -- TinkerPop graph. class (Element v) => Vertex v -- | org.apache.tinkerpop.gremlin.structure.Edge interface in a -- TinkerPop graph. class (Element e) => Edge e -- | 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.T enum. -- -- T is a token to get data b from an Element a. data T a 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) -- | -- org.apache.tinkerpop.gremlin.structure.VertexProperty.Cardinality -- enum. data Cardinality -- | list Cardinality. cList :: Greskell Cardinality -- | set Cardinality. cSet :: Greskell Cardinality -- | single Cardinality. cSingle :: Greskell Cardinality -- | 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 -- | 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 -- | 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 -- | Constructor operator of KeyValue. (=:) :: Key a b -> Greskell b -> KeyValue a -- | 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 -- | 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 -: -- | org.apache.tinkerpop.gremlin.process.traversal.Path -- interface. newtype Path a Path :: [PathEntry a] -> Path a [unPath] :: Path a -> [PathEntry 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 -- | 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 -- | 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 -- | 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 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 -- | 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.Aeson.Types.ToJSON.ToJSON (Data.Greskell.Graph.ElementID e) instance GHC.Show.Show (Data.Greskell.Graph.ElementID e) instance Data.Hashable.Class.Hashable (Data.Greskell.Graph.ElementID e) instance GHC.Generics.Generic (Data.Greskell.Graph.ElementID e) instance Data.Aeson.Types.FromJSON.FromJSON (Data.Greskell.Graph.ElementID e) instance Data.Greskell.GraphSON.FromGraphSON (Data.Greskell.Graph.ElementID e) instance GHC.Classes.Eq (Data.Greskell.Graph.ElementID e) instance GHC.Show.Show (Data.Greskell.Graph.Key a b) instance GHC.Classes.Eq (Data.Greskell.Graph.Key a b) instance GHC.Show.Show Data.Greskell.Graph.AVertex instance GHC.Classes.Eq Data.Greskell.Graph.AVertex instance GHC.Show.Show Data.Greskell.Graph.AEdge instance GHC.Classes.Eq Data.Greskell.Graph.AEdge instance GHC.Show.Show v => GHC.Show.Show (Data.Greskell.Graph.AProperty v) instance GHC.Classes.Ord v => GHC.Classes.Ord (Data.Greskell.Graph.AProperty v) instance GHC.Classes.Eq v => GHC.Classes.Eq (Data.Greskell.Graph.AProperty v) instance GHC.Show.Show v => GHC.Show.Show (Data.Greskell.Graph.AVertexProperty v) instance GHC.Classes.Eq v => GHC.Classes.Eq (Data.Greskell.Graph.AVertexProperty v) instance GHC.Show.Show a => GHC.Show.Show (Data.Greskell.Graph.PathEntry a) instance GHC.Classes.Ord a => GHC.Classes.Ord (Data.Greskell.Graph.PathEntry a) instance GHC.Classes.Eq a => GHC.Classes.Eq (Data.Greskell.Graph.PathEntry a) instance Data.Traversable.Traversable Data.Greskell.Graph.Path instance GHC.Show.Show a => GHC.Show.Show (Data.Greskell.Graph.Path a) instance GHC.Base.Semigroup (Data.Greskell.Graph.Path a) instance GHC.Classes.Ord a => GHC.Classes.Ord (Data.Greskell.Graph.Path a) instance GHC.Base.Monoid (Data.Greskell.Graph.Path a) instance GHC.Base.Functor Data.Greskell.Graph.Path instance Data.Foldable.Foldable Data.Greskell.Graph.Path instance GHC.Classes.Eq a => GHC.Classes.Eq (Data.Greskell.Graph.Path a) instance Data.Greskell.GraphSON.GraphSONTyped.GraphSONTyped (Data.Greskell.Graph.Path a) instance Data.Greskell.AsIterator.AsIterator (Data.Greskell.Graph.Path a) instance Data.Greskell.GraphSON.FromGraphSON a => Data.Aeson.Types.FromJSON.FromJSON (Data.Greskell.Graph.Path a) instance Data.Greskell.GraphSON.FromGraphSON a => Data.Greskell.GraphSON.FromGraphSON (Data.Greskell.Graph.Path a) instance GHC.Base.Functor Data.Greskell.Graph.PathEntry instance Data.Foldable.Foldable Data.Greskell.Graph.PathEntry instance Data.Traversable.Traversable Data.Greskell.Graph.PathEntry instance Data.Greskell.Graph.Element Data.Greskell.Graph.AVertex instance Data.Greskell.GraphSON.FromGraphSON v => Data.Aeson.Types.FromJSON.FromJSON (Data.Greskell.Graph.AVertexProperty v) instance Data.Greskell.GraphSON.FromGraphSON v => Data.Greskell.GraphSON.FromGraphSON (Data.Greskell.Graph.AVertexProperty v) instance Data.Greskell.GraphSON.GraphSONTyped.GraphSONTyped (Data.Greskell.Graph.AVertexProperty v) instance Data.Greskell.Graph.ElementData (Data.Greskell.Graph.AVertexProperty v) instance Data.Greskell.Graph.Element (Data.Greskell.Graph.AVertexProperty v) instance Data.Greskell.Graph.Property Data.Greskell.Graph.AVertexProperty instance GHC.Base.Functor Data.Greskell.Graph.AVertexProperty instance Data.Foldable.Foldable Data.Greskell.Graph.AVertexProperty instance Data.Traversable.Traversable Data.Greskell.Graph.AVertexProperty instance Data.Greskell.Graph.Element Data.Greskell.Graph.AEdge instance Data.Greskell.GraphSON.FromGraphSON v => Data.Aeson.Types.FromJSON.FromJSON (Data.Greskell.Graph.AProperty v) instance Data.Greskell.GraphSON.FromGraphSON v => Data.Greskell.GraphSON.FromGraphSON (Data.Greskell.Graph.AProperty v) instance Data.Greskell.Graph.Property Data.Greskell.Graph.AProperty instance Data.Greskell.GraphSON.GraphSONTyped.GraphSONTyped (Data.Greskell.Graph.AProperty v) instance GHC.Base.Functor Data.Greskell.Graph.AProperty instance Data.Foldable.Foldable Data.Greskell.Graph.AProperty instance Data.Traversable.Traversable Data.Greskell.Graph.AProperty instance Data.Greskell.Graph.ElementData Data.Greskell.Graph.AEdge instance Data.Greskell.Graph.Edge Data.Greskell.Graph.AEdge instance Data.Greskell.GraphSON.GraphSONTyped.GraphSONTyped Data.Greskell.Graph.AEdge instance Data.Aeson.Types.FromJSON.FromJSON Data.Greskell.Graph.AEdge instance Data.Greskell.GraphSON.FromGraphSON Data.Greskell.Graph.AEdge instance Data.Greskell.Graph.ElementData Data.Greskell.Graph.AVertex instance Data.Greskell.Graph.Vertex Data.Greskell.Graph.AVertex instance Data.Greskell.GraphSON.GraphSONTyped.GraphSONTyped Data.Greskell.Graph.AVertex instance Data.Aeson.Types.FromJSON.FromJSON Data.Greskell.Graph.AVertex instance Data.Greskell.GraphSON.FromGraphSON Data.Greskell.Graph.AVertex instance GHC.Base.Semigroup (Data.Greskell.Graph.Keys a) instance GHC.Base.Monoid (Data.Greskell.Graph.Keys a) instance GHC.Base.Functor (Data.Greskell.Graph.Key a) instance Data.String.IsString (Data.Greskell.Graph.Key a b) instance Data.Greskell.Greskell.ToGreskell (Data.Greskell.Graph.Key a b) instance Data.Greskell.PMap.PMapKey (Data.Greskell.Graph.Key a b) instance Data.Greskell.GraphSON.GraphSONTyped.GraphSONTyped (Data.Greskell.Graph.T a b) instance GHC.Base.Functor Data.Greskell.Graph.ElementID -- | PropertyMap was used in greskell prior than 1.0.0.0, but is now -- deprecated. Use Data.Greskell.PMap instead. module Data.Greskell.Graph.PropertyMap -- | Common basic operations supported by maps of properties. -- | Deprecated: PropertyMap and its instances are deprecated. Use PMap -- instead. class PropertyMap m -- | Look up a property associated with the given key. lookupOne :: PropertyMap m => Text -> m p v -> Maybe (p v) -- | Look up all properties associated with the given key. lookupList :: PropertyMap m => Text -> m p v -> [p v] -- | Put a property into the map. putProperty :: (PropertyMap m, Property p) => p v -> m p v -> m p v -- | Remove all properties associated with the given key. removeProperty :: PropertyMap m => Text -> m p v -> m p v -- | Return all properties in the map. allProperties :: PropertyMap m => m p v -> [p v] -- | A PropertyMap that has a single value per key. -- -- putProperty replaces the old property by the given property. -- -- <> returns the union of the two given property maps. If -- the two property maps share some same keys, the value from the left -- map wins. data PropertyMapSingle p v -- | A PropertyMap that can keep more than one values per key. -- -- lookupOne returns the first property associated with the given -- key. -- -- putProperty prepends the given property to the property list. -- -- <> returns the union of the two given property maps. If -- the two property maps share some same keys, those property lists are -- concatenated. data PropertyMapList p v -- | Lookup a property value from a PropertyMap by key. lookupOneValue :: (PropertyMap m, Property p) => Text -> m p v -> Maybe v -- | Lookup a list of property values from a PropertyMap by key. lookupListValues :: (PropertyMap m, Property p) => Text -> m p v -> [v] -- | Lookup a property GValue by the given key, and parse it. -- -- In version 0.1.1.0 and before, this function took an argument m p -- (GraphSON Value). This has changed, because property types for -- AVertex etc have changed. parseOneValue :: (PropertyMap m, Property p, FromGraphSON v) => Text -> m p GValue -> Parser v -- | Lookup a list of property values from a PropertyMap by the -- given key, and parse them. -- -- In version 0.1.1.0 and before, this function took an argument m p -- (GraphSON Value). This has changed, because property types for -- AVertex etc have changed. parseListValues :: (PropertyMap m, Property p, FromGraphSON v) => Text -> m p GValue -> Parser [v] -- | Like parseListValues, but this function fails when there -- is no property with the given key. -- -- In version 0.1.1.0 and before, this function took an argument m p -- (GraphSON Value). This has changed, because property types for -- AVertex etc have changed. parseNonEmptyValues :: (PropertyMap m, Property p, FromGraphSON v) => Text -> m p GValue -> Parser (NonEmpty v) -- | Create a PropertyMap from list of Propertys. fromProperties :: (PropertyMap m, Property p, Monoid (m p v)) => [p v] -> m p v -- | This typeclass is for internal use. -- -- GraphSON parser with a property key given from outside. class FromGraphSONWithKey a -- | 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 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 instance GHC.Show.Show (t (p v)) => GHC.Show.Show (Data.Greskell.Graph.PropertyMap.PropertyMapGeneric t p v) instance GHC.Classes.Eq (t (p v)) => GHC.Classes.Eq (Data.Greskell.Graph.PropertyMap.PropertyMapGeneric t p v) instance Data.Traversable.Traversable p => Data.Traversable.Traversable (Data.Greskell.Graph.PropertyMap.PropertyMapSingle p) instance GHC.Show.Show (p v) => GHC.Show.Show (Data.Greskell.Graph.PropertyMap.PropertyMapSingle p v) instance GHC.Base.Semigroup (Data.Greskell.Graph.PropertyMap.PropertyMapSingle p v) instance GHC.Base.Monoid (Data.Greskell.Graph.PropertyMap.PropertyMapSingle p v) instance GHC.Base.Functor p => GHC.Base.Functor (Data.Greskell.Graph.PropertyMap.PropertyMapSingle p) instance Data.Foldable.Foldable p => Data.Foldable.Foldable (Data.Greskell.Graph.PropertyMap.PropertyMapSingle p) instance GHC.Classes.Eq (p v) => GHC.Classes.Eq (Data.Greskell.Graph.PropertyMap.PropertyMapSingle p v) instance Data.Traversable.Traversable p => Data.Traversable.Traversable (Data.Greskell.Graph.PropertyMap.PropertyMapList p) instance GHC.Show.Show (p v) => GHC.Show.Show (Data.Greskell.Graph.PropertyMap.PropertyMapList p v) instance GHC.Base.Semigroup (Data.Greskell.Graph.PropertyMap.PropertyMapList p v) instance GHC.Base.Monoid (Data.Greskell.Graph.PropertyMap.PropertyMapList p v) instance GHC.Base.Functor p => GHC.Base.Functor (Data.Greskell.Graph.PropertyMap.PropertyMapList p) instance Data.Foldable.Foldable p => Data.Foldable.Foldable (Data.Greskell.Graph.PropertyMap.PropertyMapList p) instance GHC.Classes.Eq (p v) => GHC.Classes.Eq (Data.Greskell.Graph.PropertyMap.PropertyMapList p v) instance (Data.Greskell.Graph.Property p, Data.Greskell.GraphSON.GraphSONTyped.GraphSONTyped (p v), Data.Greskell.GraphSON.FromGraphSON (p v), Data.Greskell.Graph.PropertyMap.FromGraphSONWithKey (p v)) => Data.Aeson.Types.FromJSON.FromJSON (Data.Greskell.Graph.PropertyMap.PropertyMapSingle p v) instance (Data.Greskell.Graph.Property p, Data.Greskell.GraphSON.GraphSONTyped.GraphSONTyped (p v), Data.Greskell.GraphSON.FromGraphSON (p v), Data.Greskell.Graph.PropertyMap.FromGraphSONWithKey (p v)) => Data.Greskell.GraphSON.FromGraphSON (Data.Greskell.Graph.PropertyMap.PropertyMapSingle p v) instance (Data.Greskell.Graph.Property p, Data.Greskell.GraphSON.GraphSONTyped.GraphSONTyped (p v), Data.Greskell.GraphSON.FromGraphSON (p v), Data.Greskell.Graph.PropertyMap.FromGraphSONWithKey (p v)) => Data.Aeson.Types.FromJSON.FromJSON (Data.Greskell.Graph.PropertyMap.PropertyMapList p v) instance (Data.Greskell.Graph.Property p, Data.Greskell.GraphSON.GraphSONTyped.GraphSONTyped (p v), Data.Greskell.GraphSON.FromGraphSON (p v), Data.Greskell.Graph.PropertyMap.FromGraphSONWithKey (p v)) => Data.Greskell.GraphSON.FromGraphSON (Data.Greskell.Graph.PropertyMap.PropertyMapList p v) instance Data.Greskell.GraphSON.FromGraphSON v => Data.Greskell.Graph.PropertyMap.FromGraphSONWithKey (Data.Greskell.Graph.AProperty v) instance Data.Greskell.GraphSON.FromGraphSON v => Data.Greskell.Graph.PropertyMap.FromGraphSONWithKey (Data.Greskell.Graph.AVertexProperty v) instance Data.Greskell.Graph.PropertyMap.PropertyMap Data.Greskell.Graph.PropertyMap.PropertyMapList instance Data.Greskell.Graph.PropertyMap.PropertyMap Data.Greskell.Graph.PropertyMap.PropertyMapSingle instance GHC.Base.Semigroup (t (p v)) => GHC.Base.Semigroup (Data.Greskell.Graph.PropertyMap.PropertyMapGeneric t p v) instance GHC.Base.Semigroup (t (p v)) => GHC.Base.Monoid (Data.Greskell.Graph.PropertyMap.PropertyMapGeneric t p v) instance (GHC.Base.Functor t, GHC.Base.Functor p) => GHC.Base.Functor (Data.Greskell.Graph.PropertyMap.PropertyMapGeneric t p) instance (Data.Foldable.Foldable t, Data.Foldable.Foldable p) => Data.Foldable.Foldable (Data.Greskell.Graph.PropertyMap.PropertyMapGeneric t p) instance (Data.Traversable.Traversable t, Data.Traversable.Traversable p) => Data.Traversable.Traversable (Data.Greskell.Graph.PropertyMap.PropertyMapGeneric t p) -- | This module defines GTraversal, greskell counterpart of -- GraphTraversal class object, and a DSL of composing graph -- traversal steps. module Data.Greskell.GTraversal -- | 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 -- | .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: -- -- module Data.Greskell -- | Unsafely create a Greskell that calls the given object method -- call with the given target and arguments. unsafeMethodCall :: Greskell a -> Text -> [Text] -> Greskell b -- | Unsafely create a Greskell that calls the given function with -- the given arguments. unsafeFunCall :: Text -> [Text] -> Greskell a -- | Same as toGremlin except that this returns lazy Text. toGremlinLazy :: ToGreskell a => a -> Text -- | Create a readable Gremlin script from Greskell. toGremlin :: ToGreskell a => a -> Text -- | Integer literal as GValue type. gvalueInt :: Integral a => a -> Greskell GValue -- | Value literal as GValue type. gvalue :: Value -> Greskell GValue -- | Integer literal as Value type. valueInt :: Integral a => a -> Greskell Value -- | Aeson Value literal. -- -- Note that Number does not distinguish integers from -- floating-point numbers, so value function may format an integer -- as a floating-point number. To ensure formatting as integers, use -- valueInt. value :: Value -> Greskell Value -- | Arbitrary precision number literal, like "123e8". number :: Scientific -> Greskell Scientific -- | Make a list with a single object. Useful to prevent the Gremlin Server -- from automatically iterating the result object. single :: Greskell a -> Greskell [a] -- | List literal. list :: [Greskell a] -> Greskell [a] -- | Boolean false literal. false :: Greskell Bool -- | Boolean true literal. true :: Greskell Bool -- | Create a String literal in Gremlin script. The content is -- automatically escaped. string :: Text -> Greskell Text -- | Same as unsafeGreskell, but it takes lazy Text. unsafeGreskellLazy :: Text -> Greskell a -- | Unsafely create a Greskell of arbitrary type. The given Gremlin -- script is printed as-is. unsafeGreskell :: Text -> Greskell a -- | Gremlin expression of type a. -- -- Greskell is essentially just a piece of Gremlin script with a -- phantom type. The type a represents the type of data that the -- script is supposed to evaluate to. -- -- Eq and Ord instances compare Gremlin scripts, NOT the -- values they evaluate to. data Greskell a -- | type of return value by Greskell. type family GreskellReturn a -- | Something that can convert to Greskell. class ToGreskell a where { -- | type of return value by Greskell. type family GreskellReturn a; } toGreskell :: ToGreskell a => a -> Greskell (GreskellReturn a) -- | 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 -- | A ByProjection associated with an AsLabel. You can -- construct it by gByL. data LabeledByProjection s [LabeledByProjection] :: AsLabel a -> ByProjection s a -> LabeledByProjection s -- | 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 -- | 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; } -- | .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 -- | .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 -- | 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 -- | 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 -- | Result of .match step. data MatchResult -- | GraphTraversalSource class object of TinkerPop. It is a -- factory object of GraphTraversals. data GraphTraversalSource -- | 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 -- | Only for tests. showSplit :: Split c p => Proxy c -> Proxy p -> String -- | 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 -- | Only for tests. showLift :: Lift from to => Proxy from -> Proxy to -> String -- | 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 -- | 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. -- -- -- -- Note that Char does not have FromGraphSON instance. This -- is intentional. As stated in the document of AsIterator, using -- Value in greskell is an error in most cases. To prevent you -- from using Value, Char (and thus Value) don't -- have FromGraphSON instances. class FromGraphSON a parseGraphSON :: FromGraphSON a => GValue -> Parser a -- | Create a GValue with the given "@type" field. typedGValue' :: Text -> GValueBody -> GValue -- | Create a GValue without "@type" field. nonTypedGValue :: GValueBody -> GValue -- | An Aeson Value wrapped in GraphSON wrapper type. -- Basically this type is the Haskell representaiton of a -- GraphSON-encoded document. -- -- This type is used to parse GraphSON documents. See also -- FromGraphSON class. data GValue -- | GValue without the top-level GraphSON wrapper. data GValueBody GObject :: !KeyMap GValue -> GValueBody GArray :: !Vector GValue -> GValueBody GString :: !Text -> GValueBody GNumber :: !Scientific -> GValueBody GBool :: !Bool -> GValueBody GNull :: GValueBody -- | Parse GraphSON v, but it checks gsonType. If -- gsonType is Nothing or it's not equal to -- gsonTypeFor, the Parser fails. parseTypedGraphSON :: (GraphSONTyped v, FromJSON v) => Value -> Parser (GraphSON v) -- | Create a GraphSON with the given type ID. typedGraphSON' :: Text -> v -> GraphSON v -- | Create a GraphSON with its type ID. typedGraphSON :: GraphSONTyped v => v -> GraphSON v -- | Create a GraphSON without gsonType. nonTypedGraphSON :: v -> GraphSON v -- | Wrapper for "typed JSON object" introduced in GraphSON version 2. See -- http://tinkerpop.apache.org/docs/current/dev/io/#graphson -- -- This data type is useful for encoding/decoding GraphSON text. -- -- Note that encoding of the "g:Map" type is inconsistent between -- GraphSON v1 and v2, v3. To handle the encoding, use -- Data.Greskell.GMap. data GraphSON v GraphSON :: Maybe Text -> v -> GraphSON v -- | Type ID, corresponding to @type field. [gsonType] :: GraphSON v -> Maybe Text -- | Value, correspoding to @value field. [gsonValue] :: GraphSON v -> v -- | Types that have an intrinsic type ID for gsonType field. class GraphSONTyped a -- | Type ID for gsonType. gsonTypeFor :: GraphSONTyped a => a -> Text -- | Deconstruct GMap into a list of GMapEntrys. toList :: forall (c :: Type -> Type -> Type) k v. (IsList (c k v), Item (c k v) ~ (k, v)) => GMap c k v -> [GMapEntry k v] -- | Create GMap that has the single GMapEntry. singleton :: forall (c :: Type -> Type -> Type) k v. (IsList (c k v), Item (c k v) ~ (k, v)) => GMapEntry k v -> GMap c k v -- | Get the key-value pair from GMapEntry. unGMapEntry :: GMapEntry k v -> (k, v) -- | General parser for GMapEntry. parseToGMapEntry :: FromJSONKey k => (s -> Parser k) -> (s -> Parser v) -> Either (KeyMap s) (Vector s) -> Parser (GMapEntry k v) -- | Get the map implementation from GMap. unGMap :: GMap c k v -> c k v -- | General parser for GMap. parseToGMap :: (IsList (c k v), Item (c k v) ~ (k, v)) => (s -> Parser k) -> (s -> Parser v) -> (KeyMap s -> Parser (c k v)) -> Either (KeyMap s) (Vector s) -> Parser (GMap c k v) -- | General parser for FlattenedMap. parseToFlattenedMap :: forall (c :: Type -> Type -> Type) k v s. (IsList (c k v), Item (c k v) ~ (k, v)) => (s -> Parser k) -> (s -> Parser v) -> Vector s -> Parser (FlattenedMap c k v) -- | JSON encoding of a map as an array of flattened key-value pairs. -- -- ToJSON instance of this type encodes the internal map as an -- array of keys and values. FromJSON instance of this type parses -- that flattened map. -- -- newtype FlattenedMap (c :: Type -> Type -> Type) k v FlattenedMap :: c k v -> FlattenedMap (c :: Type -> Type -> Type) k v [unFlattenedMap] :: FlattenedMap (c :: Type -> Type -> Type) k v -> c k v -- | Haskell representation of g:Map type. -- -- GraphSON v1 and v2 encode Java Map type as a JSON Object, -- while GraphSON v3 encodes it as an array of flattened keys and values -- (like FlattenedMap.) GMap type handles both encoding -- schemes. -- -- data GMap (c :: Type -> Type -> Type) k v GMap :: !Bool -> !c k v -> GMap (c :: Type -> Type -> Type) k v -- | If True, the map is encoded as an array. If False, it's -- encoded as a JSON Object. [gmapFlat] :: GMap (c :: Type -> Type -> Type) k v -> !Bool -- | Map implementation. [gmapValue] :: GMap (c :: Type -> Type -> Type) k v -> !c k v -- | Haskell representation of Map.Entry type. -- -- Basically GraphSON encodes Java's Map.Entry type as if it -- were a Map with a single entry. Thus its encoded form is -- either a JSON object or a flattened key-values, as explained in -- GMap. -- -- In old versions of TinkerPop, Map.Entry is encoded as a JSON -- object with "key" and "value" fields. FromJSON instance of -- GMapEntry supports this format as well, but ToJSON -- instance doesn't support it. data GMapEntry k v GMapEntry :: !Bool -> !k -> !v -> GMapEntry k v [gmapEntryFlat] :: GMapEntry k v -> !Bool [gmapEntryKey] :: GMapEntry k v -> !k [gmapEntryValue] :: GMapEntry k v -> !v