- Fix
maybe
/oneOf
combination not properly detecting Nothing branch.
-
CborItem
's variantCborInt
has been split in two variants:CborInt32
for ints that fits in an int32.CborInt64
for larger integers.
This change comes mainly as a fix to
Cbor.Decode.any
which would otherwise choke on integers in the range[2^53+1; 2^64-1]
which is generally unsafe to manipulate in JavaScript (and by extension, Elm). Instead, we now represent large ints as two smallers 32-bit values when decoding.
-
New primitive
fold
, as an alternative for decoding record out of order.fold : Decoder k -> (k -> Decoder (state -> state)) -> state -> Decoder state
record
,fields
andfield
are now properly working with out-of-order records. The API is identical, but the internal implementation has been fixed to support that case.
-
New primitive
associativeList
associativeList : Decoder k -> Decoder v -> Decoder (List ( k, v ))
-
New primitives
keep
andignore
to manually decode a data-structure.keep : Decoder a -> Decoder (a -> b) -> Decoder b ignore : Decoder ignore -> Decoder keep -> Decoder keep
- New data-type
Sign
to represent signed big integer values.
-
New primitive
oneOf
to alternatively try decoders:oneOf : List (Decoder a) -> Decoder a
-
New primitive
bigInt
:bigint : Decoder (Sign, Bytes)
N/A
N/A
-
New primitive
optionalElem
for decoding tuples of variable length.optionalElem : Decoder field -> Decoder (Step Never (Maybe field -> steps)) -> Decoder (Step Never steps)
fail
no longer fails eagerly, but at a later stage when needed. This fixes the use of partial decoder in conjunction withmaybe
.
N/A
CborItem.CborTag
now necessarily carries another taggedCborItem
.
-
New primitive
traverse
:traverse : (a -> Decoder b) -> List a -> Decoder (List b)
-
New primitive
indefiniteList
:indefiniteList : (a -> Encoder) -> List a -> Encoder
-
New primitive
optionalElem
:optionalElem : (elem -> Encoder) -> (tuple -> Maybe elem) -> Step Never tuple -> Step Never tuple
- Reviewed internal implementation of Cbor.Decode to, in particular, fix an
issue with
Cbor.Decode.andThen
sometimes decoding more bytes than expected and causing decoder to fail prematurely.
-
New primitives for decoding tuples:
tuple : steps -> (Step Never steps -> Decoder (Step Never tuple)) -> Decoder tuple elems : Step Never steps -> Decoder (Step Never steps) elem : Decoder field -> Decoder (Step Never (field -> steps)) -> Decoder (Step Never steps)
-
New primitives for decoding records:
record : Decoder k -> steps -> (Step k steps -> Decoder (Step k record)) -> Decoder record fields : Step k steps -> Decoder (Step k steps) field : k -> Decoder field -> Decoder (Step k (field -> steps)) -> Decoder (Step k steps) optionalField : k -> Decoder field -> Decoder (Step k (Maybe field -> steps)) -> Decoder (Step k steps)
-
New primitives for manually decoding definite & indefinite structures:
length : Decoder Int size : Decoder Int beginBytes : Decoder () beginDict : Decoder () beginList : Decoder () beginString : Decoder () break : Decoder ()
-
New helpers for combining decoders:
ignoreThen : Decoder a -> Decoder ignored -> Decoder a thenIgnore : Decoder ignored -> Decoder a -> Decoder a
-
New primitives for encoding tuples:
tuple : (Step Never tuple -> Step Never tuple) -> tuple -> Encoder elems : Step Never tuple -> Step Never tuple elem : (elem -> Encoder) -> (tuple -> elem) -> Step Never tuple -> Step Never tuple
-
New primitives for encoding records:
record : (k -> Encoder) -> (Step k record -> Step k record) -> record -> Encoder fields : Step k record -> Step k record field : k -> (field -> Encoder) -> (record -> field) -> Step k record -> Step k record optionalField : k -> (field -> Encoder) -> (record -> Maybe field) -> Step k record -> Step k record
-
New primitives for manually encoding definite structures:
size : Int -> Encoder length : Int -> Encoder
-
New helper for optionally encoding values:
maybe : (a -> Encoder) -> Maybe a -> Encoder
- Changed
record
as described in the previous section.
- Renamed
beginStrings
intobeginString
. - Renamed
pair
intokeyValue
. - Renamed
keyValueMap
intoassociativeList
.
- Removed
array
, made obsolete by the new (more flexible) additions.
- New module
Cbor
exposing a genericCborItem
sum-type.
-
New primitives added (see #1):
keyValueMap : Decoder k -> Decoder v -> Decoder (List ( k, v )) array : Decoder a -> Decoder a record : Decoder a -> Decoder a any : Decoder CborItem raw : Decoder Bytes
-
New primitives added:
keyValueMap : (k -> Encoder) -> (v -> Encoder) -> List ( k, v ) -> Encoder undefined : Encoder any : CborItem -> Encoder raw : Bytes -> Encoder
N/A
N/A
- Initial RFC-7049 implementation
- Provide unit & fuzz tests
- Initial README with example usage
N/A
N/A