Safe Haskell | None |
---|---|
Language | Haskell2010 |
Types for and operations on backend data.
Synopsis
- data BackendData p m h = BackendData {
- bdJSON :: Value
- bdGVal :: GVal (Run p m h)
- bdRaw :: RawBytes
- bdMeta :: BackendMeta
- bdChildren :: HashMap Text (BackendData p m h)
- bdVerification :: Verification
- data BackendMeta = BackendMeta {}
- data BackendSource = BackendSource {}
- data Verification
- data RawBytes = RawBytes {
- rbLength :: IO Integer
- rbGetRange :: Integer -> Integer -> IO LByteString
- toBackendData :: (ToJSON a, ToGVal (Run p m h) a) => BackendSource -> a -> BackendData p m h
- data Items a
- = NotFound
- | SingleItem a
- | MultiItem [a]
- reduceItems :: FetchMode -> [a] -> Items a
- addBackendDataChildren :: HashMap Text (BackendData p m h) -> BackendData p m h -> BackendData p m h
- rawToLBS :: RawBytes -> IO LByteString
- rawFromLBS :: LByteString -> RawBytes
- serializeBackendSource :: BackendSource -> IO SerializableBackendSource
- deserializeBackendSource :: SerializableBackendSource -> BackendSource
Documentation
data BackendData p m h Source #
A parsed record from a query result.
BackendData | |
|
Instances
ToJSON (BackendData p m h) Source # | |
Defined in Web.Sprinkles.Backends.Data toJSON :: BackendData p m h -> Value # toEncoding :: BackendData p m h -> Encoding # toJSONList :: [BackendData p m h] -> Value # toEncodingList :: [BackendData p m h] -> Encoding # | |
MonadIO m => ToGVal (Run p m h) (BackendData p m h) Source # | |
Defined in Web.Sprinkles.Backends.Data toGVal :: BackendData p m h -> GVal (Run p m h) # |
data BackendMeta Source #
Metadata for a backend query result.
Instances
data BackendSource Source #
A raw (unparsed) record from a query result.
Instances
Generic BackendSource Source # | |
Defined in Web.Sprinkles.Backends.Data type Rep BackendSource :: * -> * # from :: BackendSource -> Rep BackendSource x # to :: Rep BackendSource x -> BackendSource # | |
type Rep BackendSource Source # | |
Defined in Web.Sprinkles.Backends.Data type Rep BackendSource = D1 (MetaData "BackendSource" "Web.Sprinkles.Backends.Data" "sprinkles-0.6.0.0-EffGjOzp9OR7TO7a15Us7S" False) (C1 (MetaCons "BackendSource" PrefixI True) (S1 (MetaSel (Just "bsMeta") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 BackendMeta) :*: (S1 (MetaSel (Just "bsSource") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 RawBytes) :*: S1 (MetaSel (Just "bsVerification") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Verification)))) |
data Verification Source #
Instances
RawBytes | |
|
toBackendData :: (ToJSON a, ToGVal (Run p m h) a) => BackendSource -> a -> BackendData p m h Source #
Wrap a parsed backend value in a BackendData
structure. The original
raw BackendSource
value is needed alongside the parsed value, because the
resulting structure contains both the BackendMeta
and the raw (unparsed)
data from it.
The shapes of data that can be returned from a backend query.
NotFound | Nothing was found |
SingleItem a | A single item was requested, and this is it |
MultiItem [a] | Multiple items were requested, here they are |
Instances
Functor Items Source # | |
Foldable Items Source # | |
Defined in Web.Sprinkles.Backends.Data fold :: Monoid m => Items m -> m # foldMap :: Monoid m => (a -> m) -> Items a -> m # foldr :: (a -> b -> b) -> b -> Items a -> b # foldr' :: (a -> b -> b) -> b -> Items a -> b # foldl :: (b -> a -> b) -> b -> Items a -> b # foldl' :: (b -> a -> b) -> b -> Items a -> b # foldr1 :: (a -> a -> a) -> Items a -> a # foldl1 :: (a -> a -> a) -> Items a -> a # elem :: Eq a => a -> Items a -> Bool # maximum :: Ord a => Items a -> a # minimum :: Ord a => Items a -> a # | |
ToGVal m a => ToGVal m (Items a) Source # | |
Defined in Web.Sprinkles.Backends.Data | |
ToJSON a => ToJSON (Items a) Source # | |
Defined in Web.Sprinkles.Backends.Data |
reduceItems :: FetchMode -> [a] -> Items a Source #
Transform a raw list of results into an Items
value. This allows us
later to distinguish between Nothing Found vs. Empty List, and between
Single Item Requested And Found vs. Many Items Requested, One Found. This
is needed such that when a single item is requested, it gets converted to
GVal
and JSON as a scalar, while when we request many items and receive
one, it becomes a singleton list.
addBackendDataChildren :: HashMap Text (BackendData p m h) -> BackendData p m h -> BackendData p m h Source #
rawFromLBS :: LByteString -> RawBytes Source #
serializeBackendSource :: BackendSource -> IO SerializableBackendSource Source #
deserializeBackendSource :: SerializableBackendSource -> BackendSource Source #