Maintainer | Toshio Ito <[email protected]> |
---|---|
Safe Haskell | None |
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 # | |||||
Defined in Data.Greskell.GraphSON.Core Associated Types
| |||||
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.6-1yr8dCJYYSrACSC2iDXKAN" '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
data GValueBody Source #
Constructors
GObject !(KeyMap GValue) | |
GArray !(Vector GValue) | |
GString !Text | |
GNumber !Scientific | |
GBool !Bool | |
GNull |
Instances
ToJSON GValueBody Source # | |||||
Defined in Data.Greskell.GraphSON.GValue Methods toJSON :: GValueBody -> Value # toEncoding :: GValueBody -> Encoding # toJSONList :: [GValueBody] -> Value # toEncodingList :: [GValueBody] -> Encoding # omitField :: GValueBody -> Bool # | |||||
Generic GValueBody Source # | |||||
Defined in Data.Greskell.GraphSON.GValue Associated Types
| |||||
Show GValueBody Source # | |||||
Defined in Data.Greskell.GraphSON.GValue Methods showsPrec :: Int -> GValueBody -> ShowS # show :: GValueBody -> String # showList :: [GValueBody] -> ShowS # | |||||
Eq GValueBody Source # | |||||
Defined in Data.Greskell.GraphSON.GValue | |||||
Hashable GValueBody Source # | |||||
Defined in Data.Greskell.GraphSON.GValue | |||||
type Rep GValueBody Source # | |||||
Defined in Data.Greskell.GraphSON.GValue type Rep GValueBody = D1 ('MetaData "GValueBody" "Data.Greskell.GraphSON.GValue" "greskell-core-1.0.0.6-1yr8dCJYYSrACSC2iDXKAN" 'False) ((C1 ('MetaCons "GObject" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (KeyMap GValue))) :+: (C1 ('MetaCons "GArray" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Vector GValue))) :+: C1 ('MetaCons "GString" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Text)))) :+: (C1 ('MetaCons "GNumber" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Scientific)) :+: (C1 ('MetaCons "GBool" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Bool)) :+: C1 ('MetaCons "GNull" 'PrefixI 'False) (U1 :: Type -> Type)))) |
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.
Int
andText
): useparseUnwrapAll
. - List-like types (e.g.
[]
,Vector
andSet
): useparseUnwrapList
. - Map-like types (e.g.
HashMap
andMap
): parse intoGMap
first, then unwrap theGMap
wrapper. 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 String
in greskell
is an error in most cases. To prevent you from using String
,
Char
(and thus String
) don't have FromGraphSON
instances.
Since: 0.1.2.0
Methods
parseGraphSON :: GValue -> Parser a Source #
Instances
FromGraphSON Key Source # | First convert to Since: 1.0.0.0 |
Defined in Data.Greskell.GraphSON | |
FromGraphSON Value Source # | Call |
Defined in Data.Greskell.GraphSON | |
FromGraphSON All Source # | Since: 0.1.3.0 |
Defined in Data.Greskell.GraphSON | |
FromGraphSON Any Source # | Since: 0.1.3.0 |
Defined in Data.Greskell.GraphSON | |
FromGraphSON Int16 Source # | |
Defined in Data.Greskell.GraphSON | |
FromGraphSON Int32 Source # | |
Defined in Data.Greskell.GraphSON | |
FromGraphSON Int64 Source # | |
Defined in Data.Greskell.GraphSON | |
FromGraphSON Int8 Source # | |
Defined in Data.Greskell.GraphSON | |
FromGraphSON Word16 Source # | |
Defined in Data.Greskell.GraphSON | |
FromGraphSON Word32 Source # | |
Defined in Data.Greskell.GraphSON | |
FromGraphSON Word64 Source # | |
Defined in Data.Greskell.GraphSON | |
FromGraphSON Word8 Source # | |
Defined in Data.Greskell.GraphSON | |
FromGraphSON IntSet Source # | |
Defined in Data.Greskell.GraphSON | |
FromGraphSON GValue Source # | |
Defined in Data.Greskell.GraphSON | |
FromGraphSON Scientific Source # | |
Defined in Data.Greskell.GraphSON Methods parseGraphSON :: GValue -> Parser Scientific Source # | |
FromGraphSON Text Source # | |
Defined in Data.Greskell.GraphSON | |
FromGraphSON Text Source # | |
Defined in Data.Greskell.GraphSON | |
FromGraphSON UUID Source # | |
Defined in Data.Greskell.GraphSON | |
FromGraphSON Integer Source # | |
Defined in Data.Greskell.GraphSON | |
FromGraphSON Natural Source # | |
Defined in Data.Greskell.GraphSON | |
FromGraphSON () Source # | For any input |
Defined in Data.Greskell.GraphSON Methods parseGraphSON :: GValue -> Parser () Source # | |
FromGraphSON Bool Source # | |
Defined in Data.Greskell.GraphSON | |
FromGraphSON Double Source # | |
Defined in Data.Greskell.GraphSON | |
FromGraphSON Float Source # | |
Defined in Data.Greskell.GraphSON | |
FromGraphSON Int Source # | |
Defined in Data.Greskell.GraphSON | |
FromGraphSON Word Source # | |
Defined in Data.Greskell.GraphSON | |
FromGraphSON v => FromGraphSON (KeyMap v) Source # | First convert to Since: 1.0.0.0 |
Defined in Data.Greskell.GraphSON | |
FromGraphSON a => FromGraphSON (Identity a) Source # | Since: 0.1.3.0 |
Defined in Data.Greskell.GraphSON | |
FromGraphSON a => FromGraphSON (First a) Source # | Since: 0.1.3.0 |
Defined in Data.Greskell.GraphSON | |
FromGraphSON a => FromGraphSON (Last a) Source # | Since: 0.1.3.0 |
Defined in Data.Greskell.GraphSON | |
FromGraphSON a => FromGraphSON (First a) Source # | Since: 0.1.3.0 |
Defined in Data.Greskell.GraphSON | |
FromGraphSON a => FromGraphSON (Last a) Source # | Since: 0.1.3.0 |
Defined in Data.Greskell.GraphSON | |
FromGraphSON a => FromGraphSON (Max a) Source # | Since: 0.1.3.0 |
Defined in Data.Greskell.GraphSON | |
FromGraphSON a => FromGraphSON (Min a) Source # | Since: 0.1.3.0 |
Defined in Data.Greskell.GraphSON | |
FromGraphSON a => FromGraphSON (WrappedMonoid a) Source # | Since: 0.1.3.0 |
Defined in Data.Greskell.GraphSON Methods parseGraphSON :: GValue -> Parser (WrappedMonoid a) Source # | |
FromGraphSON a => FromGraphSON (Dual a) Source # | Since: 0.1.3.0 |
Defined in Data.Greskell.GraphSON | |
FromGraphSON a => FromGraphSON (Product a) Source # | Since: 0.1.3.0 |
Defined in Data.Greskell.GraphSON | |
FromGraphSON a => FromGraphSON (Sum a) Source # | Since: 0.1.3.0 |
Defined in Data.Greskell.GraphSON | |
FromGraphSON a => FromGraphSON (NonEmpty a) Source # | Since: 0.1.3.0 |
Defined in Data.Greskell.GraphSON | |
(FromJSON a, Integral a) => FromGraphSON (Ratio a) Source # | |
Defined in Data.Greskell.GraphSON | |
FromGraphSON v => FromGraphSON (IntMap v) Source # | |
Defined in Data.Greskell.GraphSON | |
FromGraphSON a => FromGraphSON (Seq a) Source # | |
Defined in Data.Greskell.GraphSON | |
(FromGraphSON a, Ord a) => FromGraphSON (Set a) Source # | |
Defined in Data.Greskell.GraphSON | |
(FromGraphSON a, Eq a, Hashable a) => FromGraphSON (HashSet a) Source # | |
Defined in Data.Greskell.GraphSON | |
FromGraphSON a => FromGraphSON (Vector a) Source # | |
Defined in Data.Greskell.GraphSON Methods parseGraphSON :: GValue -> Parser (Vector a) Source # | |
FromGraphSON a => FromGraphSON (Maybe a) Source # | |
Defined in Data.Greskell.GraphSON | |
FromGraphSON a => FromGraphSON [a] Source # | |
Defined in Data.Greskell.GraphSON Methods parseGraphSON :: GValue -> Parser [a] Source # | |
(FromGraphSON a, FromGraphSON b) => FromGraphSON (Either a b) Source # | |
Defined in Data.Greskell.GraphSON | |
(FromGraphSON v, Ord k, FromJSONKey k, FromGraphSON k) => FromGraphSON (Map k v) Source # | |
Defined in Data.Greskell.GraphSON | |
(FromGraphSON k, FromGraphSON v, FromJSONKey k) => FromGraphSON (GMapEntry k v) Source # | Use |
Defined in Data.Greskell.GraphSON | |
(FromGraphSON v, Eq k, Hashable k, FromJSONKey k, FromGraphSON k) => FromGraphSON (HashMap k v) Source # | |
Defined in Data.Greskell.GraphSON | |
(FromGraphSON k, FromGraphSON v, IsList (c k v), Item (c k v) ~ (k, v)) => FromGraphSON (FlattenedMap c k v) Source # | Use |
Defined in Data.Greskell.GraphSON Methods parseGraphSON :: GValue -> Parser (FlattenedMap c k v) Source # | |
(FromGraphSON k, FromGraphSON v, IsList (c k v), Item (c k v) ~ (k, v), Traversable (c k), FromJSON (c k GValue)) => FromGraphSON (GMap c k v) Source # | Use |
Defined in Data.Greskell.GraphSON |
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