Maintainer | Toshio Ito <debug.ito@gmail.com> |
---|---|
Safe Haskell | None |
Language | Haskell2010 |
Synopsis
- data PMap c v
- lookup :: (PMapKey k, NonEmptyLike c) => k -> PMap c v -> Maybe v
- lookupM :: (PMapKey k, NonEmptyLike c, MonadThrow m) => k -> PMap c v -> m v
- lookupAs :: (PMapKey k, NonEmptyLike c, PMapValue k ~ a, FromGraphSON a) => k -> PMap c GValue -> Either PMapLookupException a
- lookupAs' :: (PMapKey k, NonEmptyLike c, PMapValue k ~ Maybe a, FromGraphSON a) => k -> PMap c GValue -> Either PMapLookupException (Maybe a)
- lookupAsM :: (PMapKey k, NonEmptyLike c, PMapValue k ~ a, FromGraphSON a, MonadThrow m) => k -> PMap c GValue -> m a
- lookupList :: (PMapKey k, NonEmptyLike c) => k -> PMap c v -> [v]
- lookupListAs :: (PMapKey k, NonEmptyLike c, PMapValue k ~ a, FromGraphSON a) => k -> PMap c GValue -> Either PMapLookupException (NonEmpty a)
- lookupListAs' :: (PMapKey k, NonEmptyLike c, PMapValue k ~ Maybe a, FromGraphSON a) => k -> PMap c GValue -> Either PMapLookupException [Maybe a]
- pMapInsert :: NonEmptyLike c => Text -> v -> PMap c v -> PMap c v
- pMapDelete :: Text -> PMap c v -> PMap c v
- pMapLookup :: NonEmptyLike c => Text -> PMap c v -> [v]
- pMapToList :: Foldable c => PMap c v -> [(Text, v)]
- pMapFromList :: NonEmptyLike c => [(Text, v)] -> PMap c v
- type Single = First
- data Multi a
- class PMapKey k where
- data PMapLookupException
- pMapDecribeError :: PMapLookupException -> String
- pMapToThrow :: MonadThrow m => Either PMapLookupException a -> m a
- pMapToFail :: MonadFail m => Either PMapLookupException a -> m a
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.
Since: 1.0.0.0
Instances
Functor c => Functor (PMap c) Source # | |
Foldable c => Foldable (PMap c) Source # | |
Defined in Data.Greskell.PMap 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 # elem :: Eq a => a -> PMap c a -> Bool # maximum :: Ord a => PMap c a -> a # minimum :: Ord a => PMap c a -> a # | |
Traversable c => Traversable (PMap c) Source # | |
Eq (c v) => Eq (PMap c v) Source # | |
Show (c v) => Show (PMap c v) Source # | |
NonEmptyLike c => Semigroup (PMap c v) Source # | Make a union of the two |
NonEmptyLike c => Monoid (PMap c v) Source # | |
AsIterator (PMap c v) Source # | |
Defined in Data.Greskell.PMap type IteratorItem (PMap c v) :: Type # | |
FromGraphSON (c v) => FromGraphSON (PMap c v) Source # | |
Defined in Data.Greskell.PMap parseGraphSON :: GValue -> Parser (PMap c v) # | |
GraphSONTyped (PMap c v) Source # | |
Defined in Data.Greskell.PMap gsonTypeFor :: PMap c v -> Text # | |
type IteratorItem (PMap c v) Source # | |
Defined in Data.Greskell.PMap |
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 #
lookupAsM :: (PMapKey k, NonEmptyLike c, PMapValue k ~ a, FromGraphSON a, MonadThrow m) => k -> PMap c GValue -> m a Source #
MonadThrow
version of lookupAs
.
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 null
s 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.
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.
pMapFromList :: NonEmptyLike c => [(Text, v)] -> PMap c v Source #
Make a PMap
from list of entries.
Cardinality
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
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 # | |
Foldable Multi Source # | |
Defined in Data.Greskell.PMap 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 # elem :: Eq a => a -> Multi a -> Bool # maximum :: Ord a => Multi a -> a # minimum :: Ord a => Multi a -> a # | |
Traversable Multi Source # | |
NonEmptyLike Multi Source # | |
Eq a => Eq (Multi a) Source # | |
Ord a => Ord (Multi a) Source # | |
Show a => Show (Multi a) Source # | |
Semigroup (Multi a) Source # | |
FromGraphSON a => FromGraphSON (Multi a) Source # | |
Defined in Data.Greskell.PMap parseGraphSON :: GValue -> Parser (Multi a) # |
PMapKey
class PMapKey k where Source #
A typed key for PMap
.
Since: 1.0.0.0
Errors
data PMapLookupException Source #
PMapNoSuchKey Text | The |
PMapParseError Text String | Failed to parse the value into the type that the |
Instances
Eq PMapLookupException Source # | |
Defined in Data.Greskell.PMap (==) :: PMapLookupException -> PMapLookupException -> Bool # (/=) :: PMapLookupException -> PMapLookupException -> Bool # | |
Ord PMapLookupException Source # | |
Defined in Data.Greskell.PMap compare :: PMapLookupException -> PMapLookupException -> Ordering # (<) :: PMapLookupException -> PMapLookupException -> Bool # (<=) :: PMapLookupException -> PMapLookupException -> Bool # (>) :: PMapLookupException -> PMapLookupException -> Bool # (>=) :: PMapLookupException -> PMapLookupException -> Bool # max :: PMapLookupException -> PMapLookupException -> PMapLookupException # min :: PMapLookupException -> PMapLookupException -> PMapLookupException # | |
Show PMapLookupException Source # | |
Defined in Data.Greskell.PMap showsPrec :: Int -> PMapLookupException -> ShowS # show :: PMapLookupException -> String # showList :: [PMapLookupException] -> ShowS # | |
Exception PMapLookupException Source # | |
Defined in Data.Greskell.PMap |
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
.