greskell-core-0.1.0.0: Haskell binding for Gremlin graph query language - core data types and tools

MaintainerToshio Ito <debug.ito@gmail.com>
Safe HaskellNone
LanguageHaskell2010

Data.Greskell.Greskell

Contents

Description

 

Synopsis

Type

data Greskell a Source #

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.

Instances

Functor Greskell Source #

Unsafely convert the phantom type.

Methods

fmap :: (a -> b) -> Greskell a -> Greskell b #

(<$) :: a -> Greskell b -> Greskell a #

Eq (Greskell a) Source # 

Methods

(==) :: Greskell a -> Greskell a -> Bool #

(/=) :: Greskell a -> Greskell a -> Bool #

Fractional a => Fractional (Greskell a) Source #

Floating-point number literals and numeric operation in Gremlin

Num a => Num (Greskell a) Source #

Integer literals and numeric operation in Gremlin

Ord (Greskell a) Source # 

Methods

compare :: Greskell a -> Greskell a -> Ordering #

(<) :: Greskell a -> Greskell a -> Bool #

(<=) :: Greskell a -> Greskell a -> Bool #

(>) :: Greskell a -> Greskell a -> Bool #

(>=) :: Greskell a -> Greskell a -> Bool #

max :: Greskell a -> Greskell a -> Greskell a #

min :: Greskell a -> Greskell a -> Greskell a #

Show (Greskell a) Source # 

Methods

showsPrec :: Int -> Greskell a -> ShowS #

show :: Greskell a -> String #

showList :: [Greskell a] -> ShowS #

IsString a => IsString (Greskell a) Source #

Same as string except for the input and output type.

Methods

fromString :: String -> Greskell a #

IsString a => Monoid (Greskell a) Source #

Monoidal operations on Greskell assumes String operations in Gremlin. mempty is the empty String, and mappend is String concatenation.

Methods

mempty :: Greskell a #

mappend :: Greskell a -> Greskell a -> Greskell a #

mconcat :: [Greskell a] -> Greskell a #

ToGreskell (Greskell a) Source #

It's just id.

Associated Types

type GreskellReturn (Greskell a) :: * Source #

type GreskellReturn (Greskell a) Source # 

class ToGreskell a where Source #

Something that can convert to Greskell.

Minimal complete definition

toGreskell

Associated Types

type GreskellReturn a Source #

type of return value by Greskell.

Instances

ToGreskell (Greskell a) Source #

It's just id.

Associated Types

type GreskellReturn (Greskell a) :: * Source #

Conversions

toGremlin :: ToGreskell a => a -> Text Source #

Create a readable Gremlin script from Greskell.

toGremlinLazy :: ToGreskell a => a -> Text Source #

Same as toGremlin except that this returns lazy Text.

Literals

Functions to create literals in Gremlin script. Use fromInteger to create integer literals. Use fromRational or number to create floating-point data literals.

string :: Text -> Greskell Text Source #

Create a String literal in Gremlin script. The content is automatically escaped.

>>> toGremlin $ string "foo bar"
"\"foo bar\""
>>> toGremlin $ string "escape newline\n escape dollar $"
"\"escape newline\\n escape dollar \\$\""

true :: Greskell Bool Source #

Boolean true literal.

>>> toGremlin true
"true"

false :: Greskell Bool Source #

Boolean false literal.

>>> toGremlin false
"false"

list :: [Greskell a] -> Greskell [a] Source #

List literal.

>>> toGremlin $ list ([100, 200, 300] :: [Greskell Int])
"[100,200,300]"

single :: Greskell a -> Greskell [a] Source #

Make a list with a single object. Useful to prevent the Gremlin Server from automatically iterating the result object.

>>> toGremlin $ single ("hoge" :: Greskell String)
"[\"hoge\"]"

number :: Scientific -> Greskell Scientific Source #

Arbitrary precision number literal, like "123e8".

>>> toGremlin $ number 123e8
"1.23e10"

value :: Value -> Greskell Value Source #

Aeson Value literal.

>>> toGremlin $ value Aeson.Null
"null"
>>> toGremlin $ value $ Aeson.toJSON $ ([10, 20, 30] :: [Int])
"[10.0,20.0,30.0]"
>>> toGremlin $ value $ Aeson.Object mempty
"[:]"

Unsafe constructors

unsafeGreskell Source #

Arguments

:: Text

Gremlin script

-> Greskell a 

Unsafely create a Greskell of arbitrary type. The given Gremlin script is printed as-is.

>>> toGremlin $ unsafeGreskell "x + 100"
"x + 100"

unsafeGreskellLazy Source #

Arguments

:: Text

Gremlin script

-> Greskell a 

Same as unsafeGreskell, but it takes lazy Text.

unsafeFunCall Source #

Arguments

:: Text

function name

-> [Text]

arguments

-> Greskell a

return value of the function call

Unsafely create a Greskell that calls the given function with the given arguments.

>>> toGremlin $ unsafeFunCall "add" ["10", "20"]
"add(10,20)"

unsafeMethodCall Source #

Arguments

:: Greskell a

target object

-> Text

method name

-> [Text]

arguments

-> Greskell b

return value of the method call

Unsafely create a Greskell that calls the given object method call with the given target and arguments.

>>> toGremlin $ unsafeMethodCall ("foobar" :: Greskell String) "length" []
"(\"foobar\").length()"