diff --git a/crates/compiler/builtins/roc/Encode.roc b/crates/compiler/builtins/roc/Encode.roc index b63ad2f35ba..a426a5fe78a 100644 --- a/crates/compiler/builtins/roc/Encode.roc +++ b/crates/compiler/builtins/roc/Encode.roc @@ -45,31 +45,31 @@ import Num exposing [ ] import Bool exposing [Bool] -Encoder fmt := List U8, fmt -> List U8 where fmt implements EncoderFormatting +Encoder state fmt := state, fmt -> state where fmt implements EncoderFormatting Encoding implements - toEncoder : val -> Encoder fmt where val implements Encoding, fmt implements EncoderFormatting + toEncoder : val -> Encoder state fmt where val implements Encoding, fmt implements EncoderFormatting EncoderFormatting implements - u8 : U8 -> Encoder fmt where fmt implements EncoderFormatting - u16 : U16 -> Encoder fmt where fmt implements EncoderFormatting - u32 : U32 -> Encoder fmt where fmt implements EncoderFormatting - u64 : U64 -> Encoder fmt where fmt implements EncoderFormatting - u128 : U128 -> Encoder fmt where fmt implements EncoderFormatting - i8 : I8 -> Encoder fmt where fmt implements EncoderFormatting - i16 : I16 -> Encoder fmt where fmt implements EncoderFormatting - i32 : I32 -> Encoder fmt where fmt implements EncoderFormatting - i64 : I64 -> Encoder fmt where fmt implements EncoderFormatting - i128 : I128 -> Encoder fmt where fmt implements EncoderFormatting - f32 : F32 -> Encoder fmt where fmt implements EncoderFormatting - f64 : F64 -> Encoder fmt where fmt implements EncoderFormatting - dec : Dec -> Encoder fmt where fmt implements EncoderFormatting - bool : Bool -> Encoder fmt where fmt implements EncoderFormatting - string : Str -> Encoder fmt where fmt implements EncoderFormatting - list : List elem, (elem -> Encoder fmt) -> Encoder fmt where fmt implements EncoderFormatting - record : List { key : Str, value : Encoder fmt } -> Encoder fmt where fmt implements EncoderFormatting - tuple : List (Encoder fmt) -> Encoder fmt where fmt implements EncoderFormatting - tag : Str, List (Encoder fmt) -> Encoder fmt where fmt implements EncoderFormatting + u8 : U8 -> Encoder state fmt where fmt implements EncoderFormatting + u16 : U16 -> Encoder state fmt where fmt implements EncoderFormatting + u32 : U32 -> Encoder state fmt where fmt implements EncoderFormatting + u64 : U64 -> Encoder state fmt where fmt implements EncoderFormatting + u128 : U128 -> Encoder state fmt where fmt implements EncoderFormatting + i8 : I8 -> Encoder state fmt where fmt implements EncoderFormatting + i16 : I16 -> Encoder state fmt where fmt implements EncoderFormatting + i32 : I32 -> Encoder state fmt where fmt implements EncoderFormatting + i64 : I64 -> Encoder state fmt where fmt implements EncoderFormatting + i128 : I128 -> Encoder state fmt where fmt implements EncoderFormatting + f32 : F32 -> Encoder state fmt where fmt implements EncoderFormatting + f64 : F64 -> Encoder state fmt where fmt implements EncoderFormatting + dec : Dec -> Encoder state fmt where fmt implements EncoderFormatting + bool : Bool -> Encoder state fmt where fmt implements EncoderFormatting + string : Str -> Encoder state fmt where fmt implements EncoderFormatting + list : List elem, (elem -> Encoder state fmt) -> Encoder state fmt where fmt implements EncoderFormatting + record : List { key : Str, value : Encoder state fmt } -> Encoder state fmt where fmt implements EncoderFormatting + tuple : List (Encoder state fmt) -> Encoder state fmt where fmt implements EncoderFormatting + tag : Str, List (Encoder state fmt) -> Encoder state fmt where fmt implements EncoderFormatting ## Creates a custom encoder from a given function. ## @@ -83,10 +83,10 @@ EncoderFormatting implements ## ## actual == expected ## ``` -custom : (List U8, fmt -> List U8) -> Encoder fmt where fmt implements EncoderFormatting +custom : (state, fmt -> state) -> Encoder state fmt where fmt implements EncoderFormatting custom = \encoder -> @Encoder encoder -appendWith : List U8, Encoder fmt, fmt -> List U8 where fmt implements EncoderFormatting +appendWith : state, Encoder state fmt, fmt -> state where fmt implements EncoderFormatting appendWith = \lst, @Encoder doEncoding, fmt -> doEncoding lst fmt ## Appends the encoded representation of a value to an existing list of bytes. @@ -98,7 +98,7 @@ appendWith = \lst, @Encoder doEncoding, fmt -> doEncoding lst fmt ## ## actual == expected ## ``` -append : List U8, val, fmt -> List U8 where val implements Encoding, fmt implements EncoderFormatting +append : state, val, fmt -> state where val implements Encoding, fmt implements EncoderFormatting append = \lst, val, fmt -> appendWith lst (toEncoder val) fmt ## Encodes a value to a list of bytes (`List U8`) according to the specified format.