| Maintainer | Toshio Ito <[email protected]> |
|---|---|
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
Data.Greskell.GraphSON
Description
Synopsis
- data GraphSON v = GraphSON {}
- class GraphSONTyped a where
- gsonTypeFor :: a -> Text
- nonTypedGraphSON :: v -> GraphSON v
- typedGraphSON :: GraphSONTyped v => v -> GraphSON v
- typedGraphSON' :: Text -> v -> GraphSON v
- parseTypedGraphSON :: (GraphSONTyped v, FromJSON v) => Value -> Parser (GraphSON v)
- data GValue
- data GValueBody
- nonTypedGValue :: GValueBody -> GValue
- typedGValue' :: Text -> GValueBody -> GValue
- class FromGraphSON a where
- parseGraphSON :: GValue -> Parser a
- data Parser a
- parseEither :: FromGraphSON a => GValue -> Either String a
- parseUnwrapAll :: FromJSON a => GValue -> Parser a
- parseUnwrapList :: (IsList a, i ~ Item a, FromGraphSON i) => GValue -> Parser a
- (.:) :: FromGraphSON a => KeyMap GValue -> Key -> Parser a
- parseJSONViaGValue :: FromGraphSON a => Value -> Parser a
- examples :: [(String, String)]
GraphSON
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.
Constructors
| GraphSON | |
Instances
| Foldable GraphSON Source # | |
Defined in Data.Greskell.GraphSON.Core Methods fold :: Monoid m => GraphSON m -> m # foldMap :: Monoid m => (a -> m) -> GraphSON a -> m # foldMap' :: Monoid m => (a -> m) -> GraphSON a -> m # foldr :: (a -> b -> b) -> b -> GraphSON a -> b # foldr' :: (a -> b -> b) -> b -> GraphSON a -> b # foldl :: (b -> a -> b) -> b -> GraphSON a -> b # foldl' :: (b -> a -> b) -> b -> GraphSON a -> b # foldr1 :: (a -> a -> a) -> GraphSON a -> a # foldl1 :: (a -> a -> a) -> GraphSON a -> a # elem :: Eq a => a -> GraphSON a -> Bool # maximum :: Ord a => GraphSON a -> a # minimum :: Ord a => GraphSON a -> a # | |
| Traversable GraphSON Source # | |
Defined in Data.Greskell.GraphSON.Core | |
| Functor GraphSON Source # | |
| FromJSON v => FromJSON (GraphSON v) Source # | If the given |
Defined in Data.Greskell.GraphSON.Core | |
| ToJSON v => ToJSON (GraphSON v) Source # | If |
| Generic (GraphSON v) Source # | |
| Show v => Show (GraphSON v) Source # | |
| Eq v => Eq (GraphSON v) Source # | |
| Ord v => Ord (GraphSON v) Source # | |
Defined in Data.Greskell.GraphSON.Core | |
| Hashable v => Hashable (GraphSON v) Source # | Since: 0.1.2.0 |
Defined in Data.Greskell.GraphSON.Core | |
| type Rep (GraphSON v) Source # | |
Defined in Data.Greskell.GraphSON.Core type Rep (GraphSON v) = D1 ('MetaData "GraphSON" "Data.Greskell.GraphSON.Core" "greskell-core-1.0.0.2-6nHI8OdnlPRAe9DfPDE8v6" 'False) (C1 ('MetaCons "GraphSON" 'PrefixI 'True) (S1 ('MetaSel ('Just "gsonType") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe Text)) :*: S1 ('MetaSel ('Just "gsonValue") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 v))) | |
class GraphSONTyped a where Source #
Types that have an intrinsic type ID for gsonType field.
Instances
constructors
typedGraphSON :: GraphSONTyped v => v -> GraphSON v Source #
Create a GraphSON with its type ID.
parser support
parseTypedGraphSON :: (GraphSONTyped v, FromJSON v) => Value -> Parser (GraphSON v) Source #
Parse GraphSON v, but it checks gsonType. If gsonType is
Nothing or it's not equal to gsonTypeFor, the Parser fails.
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.
Since: 0.1.2.0
Instances
| FromJSON GValue Source # | Parse |
Defined in Data.Greskell.GraphSON.GValue | |
| ToJSON GValue Source # | Reconstruct |
| Generic GValue Source # | |
| Show GValue Source # | |
| Eq GValue Source # | |
| FromGraphSON GValue Source # | |
Defined in Data.Greskell.GraphSON | |
| Hashable GValue Source # | |
Defined in Data.Greskell.GraphSON.GValue | |
| type Rep GValue Source # | |
Defined in Data.Greskell.GraphSON.GValue type Rep GValue = D1 ('MetaData "GValue" "Data.Greskell.GraphSON.GValue" "greskell-core-1.0.0.2-6nHI8OdnlPRAe9DfPDE8v6" 'True) (C1 ('MetaCons "GValue" 'PrefixI 'True) (S1 ('MetaSel ('Just "unGValue") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (GraphSON GValueBody)))) | |
data GValueBody Source #
Constructors
| GObject !(KeyMap GValue) | |
| GArray !(Vector GValue) | |
| GString !Text | |
| GNumber !Scientific | |
| GBool !Bool | |
| GNull |
Instances
constructors
nonTypedGValue :: GValueBody -> GValue Source #
Create a GValue without "@type" field.
Since: 0.1.2.0
Arguments
| :: Text | "@type" field. |
| -> GValueBody | |
| -> GValue |
Create a GValue with the given "@type" field.
Since: 0.1.2.0
FromGraphSON
class FromGraphSON a where Source #
Types that can be constructed from GValue. This is analogous to
FromJSON class.
Instances of basic types are implemented based on the following rule.
- Simple scalar types (e.g.
IntandText): useparseUnwrapAll. - List-like types (e.g.
[],VectorandSet): useparseUnwrapList. - Map-like types (e.g.
HashMapandMap): parse intoGMapfirst, then unwrap theGMapwrapper. That way, all versions of GraphSON formats are handled properly. - Trivial wrapper types (e.g.
Identity): just parse the item inside. - Other types: see the individual instance documentation.
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.
Since: 0.1.2.0
Methods
parseGraphSON :: GValue -> Parser a Source #
Instances
parser support
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.
Instances
| MonadFail Parser | |
Defined in Data.Aeson.Types.Internal | |
| MonadFix Parser | Since: aeson-2.1.0.0 |
Defined in Data.Aeson.Types.Internal | |
| Alternative Parser | |
| Applicative Parser | |
| Functor Parser | |
| Monad Parser | |
| MonadPlus Parser | |
| Monoid (Parser a) | |
| Semigroup (Parser a) | |
parseEither :: FromGraphSON a => GValue -> Either String a Source #
Parse GValue into FromGraphSON.
Since: 0.1.2.0
parseUnwrapAll :: FromJSON a => GValue -> Parser a Source #
Unwrap the given GValue with unwrapAll, and just parse the
result with parseJSON.
Useful to implement FromGraphSON instances for scalar types.
Since: 0.1.2.0
parseUnwrapList :: (IsList a, i ~ Item a, FromGraphSON i) => GValue -> Parser a Source #
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.
Since: 0.1.2.0
(.:) :: FromGraphSON a => KeyMap GValue -> Key -> Parser a Source #
Like Aeson's .:, but for FromGraphSON.
Since: 1.0.0.0
parseJSONViaGValue :: FromGraphSON a => Value -> Parser a Source #
Implementation of parseJSON based on parseGraphSON. The input
Value is first converted to GValue, and it's parsed to the
output type.
Since: 0.1.2.0