| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Ecluse.Core.Registry.Json.Shape
Description
Retained-value shapes for the token walk, and the reader that builds each value once. A shape
reads what the matching Ecluse.Core.Registry.JsonStream combinator reads, and interns keys and
strings by the bytes the lexer read unless its mode keeps them as read. A Build says what the
reader builds: aeson's tree, or the packed form a full read writes.
Synopsis
- data Shape
- data Members
- namedMembers :: [(Text, Shape)] -> Members
- everyMember :: Shape -> Members
- knownMembers :: [Text] -> Shape -> Members
- data Mode
- data MemberKey
- class Walk r => Build b r where
- type Built b
- type Fields b
- type Items b
- sharedString :: b -> Entry -> (Built b -> r) -> r
- ownString :: b -> Name -> (Built b -> r) -> r
- integer :: b -> Int -> (Built b -> r) -> r
- whole :: b -> Value -> (Built b -> r) -> r
- emptyContainer :: b -> (Built b -> r) -> r
- openObject :: b -> (Fields b -> r) -> r
- beginMember :: b -> MemberKey -> Fields b -> (Bool -> r) -> r
- addMember :: b -> MemberKey -> Built b -> Fields b -> (Fields b -> r) -> r
- dropValue :: b -> Built b -> r -> r
- closeObject :: b -> Fields b -> (Built b -> r) -> r
- openArray :: b -> (Items b -> r) -> r
- addItem :: b -> Built b -> Items b -> (Items b -> r) -> r
- closeArray :: b -> Int -> Items b -> (Built b -> r) -> r
- data Trees = Trees
- readShape :: Build b r => b -> Shape -> Mode -> InternTable -> Element -> TokenResult -> (Built b -> InternTable -> TokenResult -> r) -> r
Documentation
What to retain of one value. Each budget is the structural depth left, and a value read with none left is skipped and fails the read.
Constructors
| Scalar !Int | A scalar as read, or an empty array for a container. |
| Generic !Int | The whole value. |
| ObjectWith !Int Members Shape | An object's members, or the fallback shape for any other value. |
| ArrayWith !Int Shape Shape | An array's items, or the fallback shape for any other value. |
| StringOr !Int Shape | A string, or the other shape for any other value. |
| ObjectOr Value Members | An object's members, or the given value for any other value. |
| Checked !Int Shape | The shape, charged against a budget of its own. |
namedMembers :: [(Text, Shape)] -> Members Source #
Retain only the named members. The first entry for a name wins.
everyMember :: Shape -> Members Source #
Retain every member with one shape.
knownMembers :: [Text] -> Shape -> Members Source #
Retain every member with one shape, sharing the key of each listed name.
Whether a value's keys and strings go through the document's table or keep their own copies.
A member's key: the table's entry, or a key with its own copy.
class Walk r => Build b r where Source #
What a read builds, one value at a time, each step handing its result to a continuation. An object's members arrive in source order, and a repeated key's value is read and then dropped.
Associated Types
A finished value.
An object being read.
An array being read.
Methods
sharedString :: b -> Entry -> (Built b -> r) -> r Source #
A string the document's table shares.
ownString :: b -> Name -> (Built b -> r) -> r Source #
A string with a copy of its own.
integer :: b -> Int -> (Built b -> r) -> r Source #
An integer the lexer read whole.
whole :: b -> Value -> (Built b -> r) -> r Source #
A number, boolean, null or fallback value, taken whole.
emptyContainer :: b -> (Built b -> r) -> r Source #
The empty array a scalar shape keeps for a container it skips.
openObject :: b -> (Fields b -> r) -> r Source #
An object begins.
beginMember :: b -> MemberKey -> Fields b -> (Bool -> r) -> r Source #
A member under the key begins, and whether the object already holds the key.
addMember :: b -> MemberKey -> Built b -> Fields b -> (Fields b -> r) -> r Source #
The member begun last ends with its value.
dropValue :: b -> Built b -> r -> r Source #
Forget the member begun last, whose key the object already holds.
closeObject :: b -> Fields b -> (Built b -> r) -> r Source #
Finish an object.
openArray :: b -> (Items b -> r) -> r Source #
An array begins.
addItem :: b -> Built b -> Items b -> (Items b -> r) -> r Source #
An item of the array ends.
closeArray :: b -> Int -> Items b -> (Built b -> r) -> r Source #
Finish an array of the given item count.
Instances
Build aeson's tree.
Constructors
| Trees |
Instances
| Walk r => Build Trees r Source # | |||||||||||||
Defined in Ecluse.Core.Registry.Json.Shape Associated Types
Methods sharedString :: Trees -> Entry -> (Built Trees -> r) -> r Source # ownString :: Trees -> Name -> (Built Trees -> r) -> r Source # integer :: Trees -> Int -> (Built Trees -> r) -> r Source # whole :: Trees -> Value -> (Built Trees -> r) -> r Source # emptyContainer :: Trees -> (Built Trees -> r) -> r Source # openObject :: Trees -> (Fields Trees -> r) -> r Source # beginMember :: Trees -> MemberKey -> Fields Trees -> (Bool -> r) -> r Source # addMember :: Trees -> MemberKey -> Built Trees -> Fields Trees -> (Fields Trees -> r) -> r Source # dropValue :: Trees -> Built Trees -> r -> r Source # closeObject :: Trees -> Fields Trees -> (Built Trees -> r) -> r Source # openArray :: Trees -> (Items Trees -> r) -> r Source # addItem :: Trees -> Built Trees -> Items Trees -> (Items Trees -> r) -> r Source # closeArray :: Trees -> Int -> Items Trees -> (Built Trees -> r) -> r Source # | |||||||||||||
| type Built Trees Source # | |||||||||||||
Defined in Ecluse.Core.Registry.Json.Shape | |||||||||||||
| type Fields Trees Source # | |||||||||||||
Defined in Ecluse.Core.Registry.Json.Shape | |||||||||||||
| type Items Trees Source # | |||||||||||||
Defined in Ecluse.Core.Registry.Json.Shape | |||||||||||||
readShape :: Build b r => b -> Shape -> Mode -> InternTable -> Element -> TokenResult -> (Built b -> InternTable -> TokenResult -> r) -> r Source #
Read the value starting at the element and build it once.