| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Data.PackStream.Ps
Description
Core PackStream AST: the Ps type and the PackStream type class for
converting between Haskell types and PackStream values.
Specification: https://neo4j.com/docs/bolt/current/packstream/
Synopsis
- type Tag = Word8
- data Ps
- structFromDict :: Tag -> HashMap Text Ps -> Ps
- structureSingleton :: Tag -> Ps -> Ps
- class PackStream a where
- (.:) :: PackStream a => Ps -> Text -> Result a
- (.=) :: PackStream a => Text -> a -> (Ps, Ps)
- getPs :: Get Ps
- putPs :: Ps -> Put
- typeMismatch :: Text -> Ps -> Result a
- withNull :: Text -> Result a -> Ps -> Result a
- withBoolean :: Text -> (Bool -> Result a) -> Ps -> Result a
- withInteger :: Text -> (PSInteger -> Result a) -> Ps -> Result a
- withFloat :: Text -> (Double -> Result a) -> Ps -> Result a
- withBytes :: Text -> (ByteString -> Result a) -> Ps -> Result a
- withString :: Text -> (Text -> Result a) -> Ps -> Result a
- withList :: Text -> (Vector Ps -> Result a) -> Ps -> Result a
- withDictionary :: Text -> (HashMap Text Ps -> Result a) -> Ps -> Result a
Core types
A PackStream value. This is the intermediate AST used for serialization.
Constructors
| PsNull | missing or empty value |
| PsBoolean !Bool | true or false |
| PsInteger !PSInteger | signed 64-bit integer |
| PsFloat !Double | 64-bit floating point number |
| PsBytes !ByteString | byte array |
| PsString !Text | unicode text, UTF-8 |
| PsList !(Vector Ps) | ordered collection of values |
| PsDictionary !(HashMap Text Ps) | collection of key-value entries (no order guaranteed) |
| PsStructure !Tag !(Vector Ps) | composite value with a type signature fields being a Vector is a bit wasteful, but the spec demands it in practice there is always just 1 field, which is a dictionary Control messages all use dictionaries: https://neo4j.com/docs/bolt/current/bolt/message/#messages Datatypes all use dictionaries: https://neo4j.com/docs/bolt/current/bolt/structure-semantics/ |
structFromDict :: Tag -> HashMap Text Ps -> Ps Source #
Build a structure with a single dictionary field.
PackStream class
class PackStream a where Source #
Class for converting between PackStream Pss and native Haskell types.
Methods
Instances
Operators
(.:) :: PackStream a => Ps -> Text -> Result a Source #
Look up a key in a PsDictionary and decode the value.
(.=) :: PackStream a => Text -> a -> (Ps, Ps) Source #
Build a key-value pair for constructing a PsDictionary.
Accessors
Type matching
typeMismatch :: Text -> Ps -> Result a Source #
Report a type mismatch error for the expected type and actual Ps value.
withBoolean :: Text -> (Bool -> Result a) -> Ps -> Result a Source #
Match a PsBoolean, or report a type mismatch.
withInteger :: Text -> (PSInteger -> Result a) -> Ps -> Result a Source #
Match a PsInteger, or report a type mismatch.
withFloat :: Text -> (Double -> Result a) -> Ps -> Result a Source #
Match a PsFloat, or report a type mismatch.
withBytes :: Text -> (ByteString -> Result a) -> Ps -> Result a Source #
Match a PsBytes, or report a type mismatch.
withString :: Text -> (Text -> Result a) -> Ps -> Result a Source #
Match a PsString, or report a type mismatch.