greskell-1.0.1.0: Haskell binding for Gremlin graph query language

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

Data.Greskell.PMap

Contents

Description

This module defines PMap, a map with Text keys and cardinality options.

Since: 1.0.0.0

Synopsis

PMap

data PMap c v Source #

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.

Since: 1.0.0.0

Instances
Functor c => Functor (PMap c) Source # 
Instance details

Defined in Data.Greskell.PMap

Methods

fmap :: (a -> b) -> PMap c a -> PMap c b #

(<$) :: a -> PMap c b -> PMap c a #

Foldable c => Foldable (PMap c) Source # 
Instance details

Defined in Data.Greskell.PMap

Methods

fold :: Monoid m => PMap c m -> m #

foldMap :: Monoid m => (a -> m) -> PMap c a -> m #

foldr :: (a -> b -> b) -> b -> PMap c a -> b #

foldr' :: (a -> b -> b) -> b -> PMap c a -> b #

foldl :: (b -> a -> b) -> b -> PMap c a -> b #

foldl' :: (b -> a -> b) -> b -> PMap c a -> b #

foldr1 :: (a -> a -> a) -> PMap c a -> a #

foldl1 :: (a -> a -> a) -> PMap c a -> a #

toList :: PMap c a -> [a] #

null :: PMap c a -> Bool #

length :: PMap c a -> Int #

elem :: Eq a => a -> PMap c a -> Bool #

maximum :: Ord a => PMap c a -> a #

minimum :: Ord a => PMap c a -> a #

sum :: Num a => PMap c a -> a #

product :: Num a => PMap c a -> a #

Traversable c => Traversable (PMap c) Source # 
Instance details

Defined in Data.Greskell.PMap

Methods

traverse :: Applicative f => (a -> f b) -> PMap c a -> f (PMap c b) #

sequenceA :: Applicative f => PMap c (f a) -> f (PMap c a) #

mapM :: Monad m => (a -> m b) -> PMap c a -> m (PMap c b) #

sequence :: Monad m => PMap c (m a) -> m (PMap c a) #

Eq (c v) => Eq (PMap c v) Source # 
Instance details

Defined in Data.Greskell.PMap

Methods

(==) :: PMap c v -> PMap c v -> Bool #

(/=) :: PMap c v -> PMap c v -> Bool #

Show (c v) => Show (PMap c v) Source # 
Instance details

Defined in Data.Greskell.PMap

Methods

showsPrec :: Int -> PMap c v -> ShowS #

show :: PMap c v -> String #

showList :: [PMap c v] -> ShowS #

NonEmptyLike c => Semigroup (PMap c v) Source #

Make a union of the two PMaps. If the two PMaps share some keys, those values are merged by append method from NonEmptyLike.

Instance details

Defined in Data.Greskell.PMap

Methods

(<>) :: PMap c v -> PMap c v -> PMap c v #

sconcat :: NonEmpty (PMap c v) -> PMap c v #

stimes :: Integral b => b -> PMap c v -> PMap c v #

NonEmptyLike c => Monoid (PMap c v) Source # 
Instance details

Defined in Data.Greskell.PMap

Methods

mempty :: PMap c v #

mappend :: PMap c v -> PMap c v -> PMap c v #

mconcat :: [PMap c v] -> PMap c v #

AsIterator (PMap c v) Source # 
Instance details

Defined in Data.Greskell.PMap

Associated Types

type IteratorItem (PMap c v) :: Type #

FromGraphSON (c v) => FromGraphSON (PMap c v) Source # 
Instance details

Defined in Data.Greskell.PMap

Methods

parseGraphSON :: GValue -> Parser (PMap c v) #

GraphSONTyped (PMap c v) Source # 
Instance details

Defined in Data.Greskell.PMap

Methods

gsonTypeFor :: PMap c v -> Text #

type IteratorItem (PMap c v) Source # 
Instance details

Defined in Data.Greskell.PMap

type IteratorItem (PMap c v) = GMapEntry Text (c v)

Single lookup

lookup :: (PMapKey k, NonEmptyLike c) => k -> PMap c v -> Maybe v Source #

Lookup the first value for the key from PMap.

lookupM :: (PMapKey k, NonEmptyLike c, MonadThrow m) => k -> PMap c v -> m v Source #

MonadThrow version of lookup. If there is no value for the key, it throws PMapNoSuchKey.

lookupAs :: (PMapKey k, NonEmptyLike c, PMapValue k ~ a, FromGraphSON a) => k -> PMap c GValue -> Either PMapLookupException a Source #

Lookup the value and parse it into a.

lookupAs' :: (PMapKey k, NonEmptyLike c, PMapValue k ~ Maybe a, FromGraphSON a) => k -> PMap c GValue -> Either PMapLookupException (Maybe a) Source #

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.

List lookup

lookupList :: (PMapKey k, NonEmptyLike c) => k -> PMap c v -> [v] Source #

Lookup all items for the key. If there is no item for the key, it returns an empty list.

lookupListAs :: (PMapKey k, NonEmptyLike c, PMapValue k ~ a, FromGraphSON a) => k -> PMap c GValue -> Either PMapLookupException (NonEmpty a) Source #

Look up the values and parse them into a.

lookupListAs' :: (PMapKey k, NonEmptyLike c, PMapValue k ~ Maybe a, FromGraphSON a) => k -> PMap c GValue -> Either PMapLookupException [Maybe a] Source #

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.

Others

pMapInsert :: NonEmptyLike c => Text -> v -> PMap c v -> PMap c v Source #

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.

pMapDelete :: Text -> PMap c v -> PMap c v Source #

Delete a key and all values associated with it.

pMapLookup :: NonEmptyLike c => Text -> PMap c v -> [v] Source #

Lookup all items for the key (low-level function). If there is no item for the key, it returns an empty list.

pMapToList :: Foldable c => PMap c v -> [(Text, v)] Source #

List up all entries.

pMapFromList :: NonEmptyLike c => [(Text, v)] -> PMap c v Source #

Make a PMap from list of entries.

Cardinality

type Single = First Source #

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.

Since: 1.0.0.0

data Multi a Source #

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.

Since: 1.0.0.0

Instances
Functor Multi Source # 
Instance details

Defined in Data.Greskell.PMap

Methods

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

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

Foldable Multi Source # 
Instance details

Defined in Data.Greskell.PMap

Methods

fold :: Monoid m => Multi m -> m #

foldMap :: Monoid m => (a -> m) -> Multi a -> m #

foldr :: (a -> b -> b) -> b -> Multi a -> b #

foldr' :: (a -> b -> b) -> b -> Multi a -> b #

foldl :: (b -> a -> b) -> b -> Multi a -> b #

foldl' :: (b -> a -> b) -> b -> Multi a -> b #

foldr1 :: (a -> a -> a) -> Multi a -> a #

foldl1 :: (a -> a -> a) -> Multi a -> a #

toList :: Multi a -> [a] #

null :: Multi a -> Bool #

length :: Multi a -> Int #

elem :: Eq a => a -> Multi a -> Bool #

maximum :: Ord a => Multi a -> a #

minimum :: Ord a => Multi a -> a #

sum :: Num a => Multi a -> a #

product :: Num a => Multi a -> a #

Traversable Multi Source # 
Instance details

Defined in Data.Greskell.PMap

Methods

traverse :: Applicative f => (a -> f b) -> Multi a -> f (Multi b) #

sequenceA :: Applicative f => Multi (f a) -> f (Multi a) #

mapM :: Monad m => (a -> m b) -> Multi a -> m (Multi b) #

sequence :: Monad m => Multi (m a) -> m (Multi a) #

NonEmptyLike Multi Source # 
Instance details

Defined in Data.Greskell.PMap

Methods

singleton :: a -> Multi a Source #

append :: Multi a -> Multi a -> Multi a Source #

toNonEmpty :: Multi a -> NonEmpty a Source #

Eq a => Eq (Multi a) Source # 
Instance details

Defined in Data.Greskell.PMap

Methods

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

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

Ord a => Ord (Multi a) Source # 
Instance details

Defined in Data.Greskell.PMap

Methods

compare :: Multi a -> Multi a -> Ordering #

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

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

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

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

max :: Multi a -> Multi a -> Multi a #

min :: Multi a -> Multi a -> Multi a #

Show a => Show (Multi a) Source # 
Instance details

Defined in Data.Greskell.PMap

Methods

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

show :: Multi a -> String #

showList :: [Multi a] -> ShowS #

Semigroup (Multi a) Source # 
Instance details

Defined in Data.Greskell.PMap

Methods

(<>) :: Multi a -> Multi a -> Multi a #

sconcat :: NonEmpty (Multi a) -> Multi a #

stimes :: Integral b => b -> Multi a -> Multi a #

FromGraphSON a => FromGraphSON (Multi a) Source # 
Instance details

Defined in Data.Greskell.PMap

Methods

parseGraphSON :: GValue -> Parser (Multi a) #

PMapKey

class PMapKey k where Source #

A typed key for PMap.

Since: 1.0.0.0

Associated Types

type PMapValue k :: * Source #

Type of the value associated with the key.

Methods

keyText :: k -> Text Source #

Text representation of the key.

Instances
PMapKey Text Source #

For simple Text, the GValue is returned without being parsed.

Instance details

Defined in Data.Greskell.PMap

Associated Types

type PMapValue Text :: Type Source #

Methods

keyText :: Text -> Text Source #

PMapKey (AsLabel a) Source #

Since: 1.0.0.0

Instance details

Defined in Data.Greskell.AsLabel

Associated Types

type PMapValue (AsLabel a) :: Type Source #

Methods

keyText :: AsLabel a -> Text Source #

PMapKey (Key a b) Source #

Since: 1.0.0.0

Instance details

Defined in Data.Greskell.Graph

Associated Types

type PMapValue (Key a b) :: Type Source #

Methods

keyText :: Key a b -> Text Source #

Errors

data PMapLookupException Source #

An Exception raised when looking up values from PMap.

Since: 1.0.0.0

Constructors

PMapNoSuchKey Text

The PMap doesn't have the given key.

PMapParseError Text String

Failed to parse the value into the type that the PMapKey indicates. The Text is the key, and the String is the error message.

pMapDecribeError :: PMapLookupException -> String Source #

Make a human-readable description on PMapLookupException.

pMapToThrow :: MonadThrow m => Either PMapLookupException a -> m a Source #

Convert the lookup result into a MonadThrow. It throws PMapLookupException.

pMapToFail :: MonadFail m => Either PMapLookupException a -> m a Source #

Convert the lookup result into a MonadFail. It fails with the description returned by pMapDecribeError.