-- 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 1.0.0.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 family 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 -- | P.not static method. -- --
-- >>> toGremlin $ pNot $ pEq $ number 10 -- "P.not(P.eq(10.0))" --pNot :: Greskell (P a) -> Greskell (P a) -- | P.eq static method. -- --
-- >>> toGremlin $ pEq $ string "hoge" -- "P.eq(\"hoge\")" --pEq :: Greskell a -> Greskell (P a) -- | P.neq static method. pNeq :: Greskell a -> Greskell (P a) -- | P.lt static method. pLt :: Greskell a -> Greskell (P a) -- | P.lte static method. pLte :: Greskell a -> Greskell (P a) -- | P.gt static method. pGt :: Greskell a -> Greskell (P a) -- | P.gte static method. pGte :: Greskell a -> Greskell (P a) -- | P.inside static method. -- --
-- >>> toGremlin $ pInside (number 10) (number 20) -- "P.inside(10.0,20.0)" --pInside :: Greskell a -> Greskell a -> Greskell (P a) -- | P.outside static method. pOutside :: Greskell a -> Greskell a -> Greskell (P a) -- | P.between static method. pBetween :: Greskell a -> Greskell a -> Greskell (P a) -- | P.within static method. -- --
-- >>> toGremlin $ pWithin (["foo", "bar", "hoge"] :: [Greskell String]) -- "P.within(\"foo\",\"bar\",\"hoge\")" --pWithin :: [Greskell a] -> Greskell (P a) -- | P.without static method. pWithout :: [Greskell a] -> Greskell (P a) -- | java.util.Comparator interface. -- -- Comparator compares two data of type CompareArg -- c. class Comparator c where { type family CompareArg c; } -- | .compare method. cCompare :: Comparator c => Greskell c -> Greskell (CompareArg c) -> Greskell (CompareArg c) -> Greskell Int -- | .reverse 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 -- | decr order. -- --
-- >>> toGremlin oDecr -- "Order.decr" --oDecr :: Greskell (Order a) -- | incr order. oIncr :: Greskell (Order a) -- | shuffle order. oShuffle :: Greskell (Order a) 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.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) 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 family PMapValue k :: *; } -- | 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 GHC.Classes.Ord Data.Greskell.PMap.PMapLookupException instance GHC.Classes.Eq Data.Greskell.PMap.PMapLookupException instance GHC.Show.Show Data.Greskell.PMap.PMapLookupException instance Data.Greskell.GraphSON.FromGraphSON a => Data.Greskell.GraphSON.FromGraphSON (Data.Greskell.PMap.Multi a) instance Data.Greskell.NonEmptyLike.NonEmptyLike Data.Greskell.PMap.Multi instance Data.Traversable.Traversable Data.Greskell.PMap.Multi instance Data.Foldable.Foldable Data.Greskell.PMap.Multi instance GHC.Base.Semigroup (Data.Greskell.PMap.Multi a) instance GHC.Base.Functor Data.Greskell.PMap.Multi instance GHC.Classes.Ord a => GHC.Classes.Ord (Data.Greskell.PMap.Multi a) instance GHC.Classes.Eq a => GHC.Classes.Eq (Data.Greskell.PMap.Multi a) instance GHC.Show.Show a => GHC.Show.Show (Data.Greskell.PMap.Multi a) instance Data.Traversable.Traversable c => Data.Traversable.Traversable (Data.Greskell.PMap.PMap c) instance Data.Foldable.Foldable c => Data.Foldable.Foldable (Data.Greskell.PMap.PMap c) instance GHC.Base.Functor c => GHC.Base.Functor (Data.Greskell.PMap.PMap c) instance GHC.Classes.Eq (c v) => GHC.Classes.Eq (Data.Greskell.PMap.PMap c v) instance GHC.Show.Show (c v) => GHC.Show.Show (Data.Greskell.PMap.PMap c v) 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) -- | 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 family ElementProperty e :: * -> *; -- | Container type of the properties of the Element. It should be -- of NonEmptyLike class. type family ElementPropertyContainer e :: * -> *; } -- | 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). newtype ElementID e ElementID :: GValue -> ElementID e -- | Although it's exposed, it is recommended NOT to rely on the internal -- of ElementID. That's because it depends on graph -- implementation. [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. -- --
-- >>> toGremlin cList -- "list" --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. -- --
-- >>> toGremlin ("age" :: Key AVertex Int)
-- "\"age\""
--
-- >>> toGremlin (key "created_at" :: Key AEdge Text)
-- "\"created_at\""
--
-- >>> keyText ("name" :: Key AVertex Text)
-- "name"
--
--
-- 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
-- | Prepend a Key to Keys.
(-:) :: Key a b -> Keys a -> Keys a
infixr 5 -:
-- | 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
instance GHC.Classes.Eq v => GHC.Classes.Eq (Data.Greskell.Graph.AVertexProperty v)
instance GHC.Show.Show v => GHC.Show.Show (Data.Greskell.Graph.AVertexProperty 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.AProperty v)
instance GHC.Classes.Eq Data.Greskell.Graph.AEdge
instance GHC.Show.Show Data.Greskell.Graph.AEdge
instance GHC.Classes.Eq Data.Greskell.Graph.AVertex
instance GHC.Show.Show Data.Greskell.Graph.AVertex
instance GHC.Classes.Eq (Data.Greskell.Graph.Key a b)
instance GHC.Show.Show (Data.Greskell.Graph.Key a b)
instance Data.Hashable.Class.Hashable (Data.Greskell.Graph.ElementID e)
instance Data.Greskell.GraphSON.FromGraphSON (Data.Greskell.Graph.ElementID e)
instance Data.Aeson.Types.FromJSON.FromJSON (Data.Greskell.Graph.ElementID e)
instance Data.Aeson.Types.ToJSON.ToJSON (Data.Greskell.Graph.ElementID e)
instance GHC.Generics.Generic (Data.Greskell.Graph.ElementID e)
instance GHC.Classes.Eq (Data.Greskell.Graph.ElementID e)
instance GHC.Show.Show (Data.Greskell.Graph.ElementID e)
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.
-- | Deprecated: Use PMap instead
module Data.Greskell.Graph.PropertyMap
-- | Common basic operations supported by maps of properties.
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 Data.Traversable.Traversable p => Data.Traversable.Traversable (Data.Greskell.Graph.PropertyMap.PropertyMapList p)
instance Data.Foldable.Foldable p => Data.Foldable.Foldable (Data.Greskell.Graph.PropertyMap.PropertyMapList p)
instance GHC.Base.Functor p => GHC.Base.Functor (Data.Greskell.Graph.PropertyMap.PropertyMapList p)
instance GHC.Base.Monoid (Data.Greskell.Graph.PropertyMap.PropertyMapList p v)
instance GHC.Base.Semigroup (Data.Greskell.Graph.PropertyMap.PropertyMapList p v)
instance GHC.Classes.Eq (p v) => GHC.Classes.Eq (Data.Greskell.Graph.PropertyMap.PropertyMapList p v)
instance GHC.Show.Show (p v) => GHC.Show.Show (Data.Greskell.Graph.PropertyMap.PropertyMapList p v)
instance Data.Traversable.Traversable p => Data.Traversable.Traversable (Data.Greskell.Graph.PropertyMap.PropertyMapSingle p)
instance Data.Foldable.Foldable p => Data.Foldable.Foldable (Data.Greskell.Graph.PropertyMap.PropertyMapSingle p)
instance GHC.Base.Functor p => GHC.Base.Functor (Data.Greskell.Graph.PropertyMap.PropertyMapSingle p)
instance GHC.Base.Monoid (Data.Greskell.Graph.PropertyMap.PropertyMapSingle p v)
instance GHC.Base.Semigroup (Data.Greskell.Graph.PropertyMap.PropertyMapSingle p v)
instance GHC.Classes.Eq (p v) => GHC.Classes.Eq (Data.Greskell.Graph.PropertyMap.PropertyMapSingle p v)
instance GHC.Show.Show (p v) => GHC.Show.Show (Data.Greskell.Graph.PropertyMap.PropertyMapSingle p v)
instance GHC.Classes.Eq (t (p v)) => GHC.Classes.Eq (Data.Greskell.Graph.PropertyMap.PropertyMapGeneric t p v)
instance GHC.Show.Show (t (p v)) => GHC.Show.Show (Data.Greskell.Graph.PropertyMap.PropertyMapGeneric t 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)
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
-- | 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
instance GHC.Classes.Ord (Data.Greskell.AsLabel.AsLabel a)
instance GHC.Classes.Eq (Data.Greskell.AsLabel.AsLabel a)
instance GHC.Show.Show (Data.Greskell.AsLabel.AsLabel 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 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
--
-- -- >>> toGremlin $ source "g" -- "g" --source :: Text -> Greskell GraphTraversalSource -- | .V() method on GraphTraversalSource. sV :: Vertex v => [Greskell (ElementID v)] -> Greskell GraphTraversalSource -> GTraversal Transform () v -- | Monomorphic version of sV. -- --
-- >>> toGremlin (source "g" & sV' (map (fmap ElementID . gvalueInt) ([1,2,3] :: [Int]))) -- "g.V(1,2,3)" --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. -- --
-- >>> toGremlin (source "g" & sE' (map (fmap ElementID . gvalueInt) ([1] :: [Int]))) -- "g.E(1)" --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. -- --
-- >>> toGremlin (source "g" & sAddV' "person") -- "g.addV(\"person\")" --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. -- --
-- >>> toGremlin (source "g" & sV' [] &. gValues ["age"]) -- "g.V().values(\"age\")" --(&.) :: GTraversal c a b -> Walk c b d -> GTraversal c a d infixl 1 &. -- | Same as &. with arguments flipped. -- --
-- >>> toGremlin (gValues ["age"] $. sV' [] $ source "g") -- "g.V().values(\"age\")" --($.) :: 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 <*.> -- | Unsafely create GTraversal from the given raw Gremlin script. -- --
-- >>> toGremlin $ unsafeGTraversal "g.V().count()" -- "g.V().count()" --unsafeGTraversal :: Text -> GTraversal c s e -- | Unsafely create a Walk that represents a single method call on -- a GraphTraversal. -- --
-- >>> toGremlin (source "g" & sV' [] &. unsafeWalk "valueMap" ["'foo'", "'bar'"])
-- "g.V().valueMap('foo','bar')"
--
unsafeWalk :: WalkType c => Text -> [Text] -> Walk c s e
-- | Optionally modulate the main Walk with some modulating
-- Walks.
--
--
-- >>> toGremlin (source "g" & sV' [] &. modulateWith (unsafeWalk "path" []) [unsafeWalk "by" ["'name'"], unsafeWalk "by" ["'age'"]])
-- "g.V().path().by('name').by('age')"
--
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.
--
-- -- >>> toGremlin (source "g" & sV' [] &. gFilter (gOut' ["knows"])) -- "g.V().filter(__.out(\"knows\"))" --gFilter :: (ToGTraversal g, WalkType c, WalkType p, Split c p) => g c s e -> Walk p s s -- | .has step with one argument. -- --
-- >>> toGremlin (source "g" & sV' [] &. gHas1 "age") -- "g.V().has(\"age\")" --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. -- --
-- >>> toGremlin (source "g" & sV' [] &. gHas2 "age" (31 :: Greskell Int)) -- "g.V().has(\"age\",31)" --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. -- --
-- >>> toGremlin (source "g" & sV' [] &. gHas2P "age" (pBetween (30 :: Greskell Int) 40)) -- "g.V().has(\"age\",P.between(30,40))" --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. -- --
-- >>> toGremlin (source "g" & sV' [] &. gHasLabel "person") -- "g.V().hasLabel(\"person\")" --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. -- --
-- >>> toGremlin (source "g" & sV' [] &. gHasLabelP (pEq "person")) -- "g.V().hasLabel(P.eq(\"person\"))" --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. -- --
-- >>> toGremlin (source "g" & sV' [] &. gHasId (fmap ElementID $ gvalueInt $ (7 :: Int))) -- "g.V().hasId(7)" --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. -- --
-- >>> toGremlin (source "g" & sV' [] &. gHasIdP (pLte $ fmap ElementID $ gvalueInt (100 :: Int))) -- "g.V().hasId(P.lte(100))" --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. -- --
-- >>> toGremlin (source "g" & sV' [] &. gProperties [] &. gHasKey "age") -- "g.V().properties().hasKey(\"age\")" --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. -- --
-- >>> toGremlin (source "g" & sV' [] &. gProperties ["age"] &. gHasValue (32 :: Greskell Int)) -- "g.V().properties(\"age\").hasValue(32)" --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. -- --
-- >>> toGremlin (source "g" & sV' [] &. gProperties ["age"] &. gHasValueP (pBetween (30 :: Greskell Int) 40)) -- "g.V().properties(\"age\").hasValue(P.between(30,40))" --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. -- --
-- >>> toGremlin (source "g" & sV' [] &. gAnd [gOut' ["knows"], gHas1 "age"]) -- "g.V().and(__.out(\"knows\"),__.has(\"age\"))" --gAnd :: (ToGTraversal g, WalkType c, WalkType p, Split c p) => [g c s e] -> Walk p s s -- | .or step. -- --
-- >>> toGremlin (source "g" & sV' [] &. gOr [gOut' ["knows"], gHas1 "age"]) -- "g.V().or(__.out(\"knows\"),__.has(\"age\"))" --gOr :: (ToGTraversal g, WalkType c, WalkType p, Split c p) => [g c s e] -> Walk p s s -- | .not step. -- --
-- >>> toGremlin (source "g" & sV' [] &. gNot (gOut' ["knows"])) -- "g.V().not(__.out(\"knows\"))" --gNot :: (ToGTraversal g, WalkType c, WalkType p, Split c p) => g c s e -> Walk p s s -- | .order step. -- --
-- >>> let key_age = ("age" :: Key AVertex Int)
--
-- >>> toGremlin (source "g" & sV' [] &. gOrder [gBy1 key_age])
-- "g.V().order().by(\"age\")"
--
-- >>> toGremlin (source "g" & sV' [] &. gOrder [gBy2 key_age oDecr, gBy1 tId])
-- "g.V().order().by(\"age\",Order.decr).by(T.id)"
--
-- >>> toGremlin (source "g" & sV' [] &. gOrder [gBy2 (gOut' ["knows"] >>> gCount) oIncr, gBy2 tId oIncr])
-- "g.V().order().by(__.out(\"knows\").count(),Order.incr).by(T.id,Order.incr)"
--
--
-- ByComparator is an IsString, meaning projection by the
-- given key.
--
-- -- >>> toGremlin (source "g" & sV' [] &. gOrder ["age"]) -- "g.V().order().by(\"age\")" --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. -- --
-- >>> toGremlin (source "g" & sV' [] &. gRange 0 100) -- "g.V().range(0,100)" --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 -- | .flatMap step. -- -- .flatMap step is a Transform step even if the child -- walk is Filter type. This is because .flatMap step -- always modifies the path of the Traverser. -- --
-- >>> toGremlin (source "g" & sV' [] &. gFlatMap (gOut' ["knows"] >>> gOut' ["created"])) -- "g.V().flatMap(__.out(\"knows\").out(\"created\"))" --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 -- | .as step. -- -- .as step is Transform because it adds the label to the -- traverser. gAs :: AsLabel a -> Walk Transform a a -- | .values step. -- --
-- >>> toGremlin (source "g" & sV' [] &. gValues ["name", "age"]) -- "g.V().values(\"name\",\"age\")" --gValues :: Element s => [Key s e] -> Walk Transform s e -- | .properties step. -- --
-- >>> toGremlin (source "g" & sV' [] &. gProperties ["age"]) -- "g.V().properties(\"age\")" --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. -- --
-- >>> toGremlin (source "g" & sV' [] &. gValueMap KeysNil)
-- "g.V().valueMap()"
--
-- >>> toGremlin (source "g" & sV' [] &. gValueMap ("name" -: "age" -: KeysNil))
-- "g.V().valueMap(\"name\",\"age\")"
--
gValueMap :: Element s => Keys s -> Walk Transform s (PMap (ElementPropertyContainer s) 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.
--
--
-- >>> let name_label = ("a" :: AsLabel Text)
--
-- >>> let name_key = ("name" :: Key AVertex Text)
--
-- >>> let count_label = ("b" :: AsLabel Int)
--
-- >>> toGremlin (source "g" & sV' [] &. gProject (gByL name_label name_key) [gByL count_label (gOut' [] >>> gCount), gByL "c" tId])
-- "g.V().project(\"a\",\"b\",\"c\").by(\"name\").by(__.out().count()).by(T.id)"
--
gProject :: LabeledByProjection s -> [LabeledByProjection s] -> Walk Transform s (PMap Single GValue)
-- | .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.
--
-- -- >>> toGremlin (source "g" & sV' [fmap ElementID $ gvalueInt (8 :: Int)] &. gOut' ["knows"]) -- "g.V(8).out(\"knows\")" --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. -- --
-- >>> toGremlin (source "g" & sV' [] & liftWalk &. gHas2 "name" "marko" &. gSideEffect' (gAddV' "toshio")) -- "g.V().has(\"name\",\"marko\").sideEffect(__.addV(\"toshio\"))" --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. -- --
-- >>> let key_name = "name" :: Key AVertex Text -- -- >>> toGremlin (source "g" & sV' [] & liftWalk &. gAddE' "knows" (gFrom $ gV' [] >>> gHas2 key_name "marko")) -- "g.V().addE(\"knows\").from(__.V().has(\"name\",\"marko\"))" -- -- >>> toGremlin (source "g" & sV' [] &. gHas2 key_name "marko" & liftWalk &. gAddE' "knows" (gTo $ gV' [])) -- "g.V().has(\"name\",\"marko\").addE(\"knows\").to(__.V())" --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. -- --
-- >>> toGremlin (source "g" & sV' [] &. gHas2 "name" "marko" & liftWalk &. gDrop) -- "g.V().has(\"name\",\"marko\").drop()" --gDrop :: Element e => Walk SideEffect e e -- | .drop step on Property. -- --
-- >>> toGremlin (source "g" & sE' [] &. gProperties ["weight"] & liftWalk &. gDropP) -- "g.E().properties(\"weight\").drop()" --gDropP :: Property p => Walk SideEffect (p a) (p a) -- | Simple .property step. It adds a value to the property. -- --
-- >>> toGremlin (source "g" & sV' [] & liftWalk &. gProperty "age" (20 :: Greskell Int)) -- "g.V().property(\"age\",20)" --gProperty :: Element e => Key e v -> Greskell v -> Walk SideEffect e e -- | .property step for Vertex. -- --
-- >>> let key_location = "location" :: Key AVertex Text -- -- >>> let key_since = "since" :: Key (AVertexProperty Text) Text -- -- >>> let key_score = "score" :: Key (AVertexProperty Text) Int -- -- >>> toGremlin (source "g" & sV' [] & liftWalk &. gPropertyV (Just cList) key_location "New York" [key_since =: "2012-09-23", key_score =: 8]) -- "g.V().property(list,\"location\",\"New York\",\"since\",\"2012-09-23\",\"score\",8)" --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 family ProjectionLikeStart p; -- | The end type of the projection. type family 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) instance GHC.Show.Show Data.Greskell.GTraversal.GraphTraversalSource instance GHC.Show.Show (Data.Greskell.GTraversal.Walk c s e) instance GHC.Show.Show (Data.Greskell.GTraversal.GTraversal c s e) instance GHC.Show.Show (Data.Greskell.GTraversal.GraphTraversal c s e) 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.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) module Data.Greskell.Binder -- | A Monad that manages binding variables and labels to values. -- --
-- >>> let binder = (,) <$> newBind (10 :: Int) <*> newBind "hoge"
--
-- >>> let ((var_int, var_str), binding) = runBinder binder
--
-- >>> toGremlin var_int
-- "__v0"
--
-- >>> toGremlin var_str
-- "__v1"
--
-- >>> sortBy (comparing fst) $ HashMap.toList binding
-- [("__v0",Number 10.0),("__v1",String "hoge")]
--
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.Base.Monad Data.Greskell.Binder.Binder
instance GHC.Base.Applicative Data.Greskell.Binder.Binder
instance GHC.Base.Functor Data.Greskell.Binder.Binder
instance GHC.Classes.Eq Data.Greskell.Binder.BinderS
instance GHC.Show.Show Data.Greskell.Binder.BinderS
-- | 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.
--
--
-- >>> let keyAge = ("age" :: Key AVertex Int)
--
-- >>> let keyName = ("name" :: Key AVertex Text)
--
-- >>> let (walk, binding) = runBinder $ writeKeyValues <$> sequence [keyAge <=:> 21, keyName <=:> "Josh"]
--
-- >>> toGremlin walk
-- "__.property(\"age\",__v0).property(\"name\",__v1).identity()"
--
-- >>> sortBy (comparing fst) $ HashMap.toList binding
-- [("__v0",Number 21.0),("__v1",String "Josh")]
--
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.
--
--
-- >>> let keyNName = ("nickname" :: Key AVertex (Maybe Text))
--
-- >>> let keyCompany = ("company" :: Key AVertex (Maybe Text))
--
-- >>> let (walk, binding) = runBinder $ writeKeyValues <$> sequence [keyNName <=?> Nothing, keyCompany <=?> Just "foobar.com"]
--
-- >>> toGremlin walk
-- "__.property(\"company\",__v0).identity()"
--
-- >>> sortBy (comparing fst) $ HashMap.toList binding
-- [("__v0",String "foobar.com")]
--
(<=?>) :: 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.
--
--
-- >>> let binder = (writePropertyKeyValues [("age", (21 :: Int))] :: Binder (Walk SideEffect AVertex AVertex))
--
-- >>> let (walk, binding) = runBinder binder
--
-- >>> toGremlin walk
-- "__.property(\"age\",__v0).identity()"
--
-- >>> sortBy (comparing fst) $ HashMap.toList binding
-- [("__v0",Number 21.0)]
--
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)
-- | 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:
--
--