More progress

This commit is contained in:
Sam Mohr 2025-01-05 05:16:47 -08:00
parent b56fbd38e1
commit 0edbf16d55
No known key found for this signature in database
GPG key ID: EA41D161A3C1BC99
79 changed files with 1351 additions and 1419 deletions

View file

@ -39,7 +39,7 @@ encodeF32 = \_n -> encodeNothing
encodeF64 = \_n -> encodeNothing
encodeDec = \_n -> encodeNothing
encodeBool = \_b -> encodeNothing
encodeString = \str -> Encode.custom \bytes, @OnlyStrEncoder {} -> List.concat bytes (Str.toUtf8 str)
encodeString = \str -> Encode.custom \bytes, @OnlyStrEncoder {} -> List.concat bytes (Str.to_utf8 str)
encodeList : List elem, (elem -> Encoder OnlyStrEncoder) -> Encoder OnlyStrEncoder
encodeList = \_lst, _encodeElem -> encodeNothing
encodeRecord : List {key: Str, value: Encoder OnlyStrEncoder} -> Encoder OnlyStrEncoder
@ -50,15 +50,15 @@ encodeTag : Str, List (Encoder OnlyStrEncoder) -> Encoder OnlyStrEncoder
encodeTag = \_name, _payload -> encodeNothing
HelloWorld := {} implements [Encoding {toEncoder}]
HelloWorld := {} implements [Encoding {to_encoder}]
toEncoder = \@HelloWorld {} ->
to_encoder = \@HelloWorld {} ->
Encode.custom \bytes, fmt ->
bytes
|> Encode.appendWith (Encode.string "Hello, World!\n") fmt
|> Encode.append_with (Encode.string "Hello, World!\n") fmt
f =
when Str.fromUtf8 (Encode.toBytes (@HelloWorld {}) (@OnlyStrEncoder {})) is
when Str.from_utf8 (Encode.to_bytes (@HelloWorld {}) (@OnlyStrEncoder {})) is
Ok s -> s
_ -> "<bad>"