From 0f289ed712c833a3cf0410d56dcfb663382e6ab5 Mon Sep 17 00:00:00 2001 From: Bryce Miller Date: Fri, 19 May 2023 21:13:33 -0400 Subject: [PATCH 001/176] add word10 fn --- crates/compiler/parse/src/parser.rs | 42 +++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/crates/compiler/parse/src/parser.rs b/crates/compiler/parse/src/parser.rs index 385dea9f40..ec6b618606 100644 --- a/crates/compiler/parse/src/parser.rs +++ b/crates/compiler/parse/src/parser.rs @@ -1608,6 +1608,48 @@ where } } +pub fn word10<'a, ToError, E>( + word_1: u8, + word_2: u8, + word_3: u8, + word_4: u8, + word_5: u8, + word_6: u8, + word_7: u8, + word_8: u8, + word_9: u8, + word_10: u8, + to_error: ToError, +) -> impl Parser<'a, (), E> +where + ToError: Fn(Position) -> E, + E: 'a, +{ + debug_assert_ne!(word_1, b'\n'); + debug_assert_ne!(word_2, b'\n'); + debug_assert_ne!(word_3, b'\n'); + debug_assert_ne!(word_4, b'\n'); + debug_assert_ne!(word_5, b'\n'); + debug_assert_ne!(word_6, b'\n'); + debug_assert_ne!(word_7, b'\n'); + debug_assert_ne!(word_8, b'\n'); + debug_assert_ne!(word_9, b'\n'); + debug_assert_ne!(word_10, b'\n'); + + let needle = [ + word_1, word_2, word_3, word_4, word_5, word_6, word_7, word_8, word_9, word_10, + ]; + + move |_arena: &'a Bump, state: State<'a>, _min_indent: u32| { + if state.bytes().starts_with(&needle) { + let state = state.advance(10); + Ok((MadeProgress, (), state)) + } else { + Err((NoProgress, to_error(state.pos()))) + } + } +} + #[macro_export] macro_rules! word1_check_indent { ($word:expr, $word_problem:expr, $min_indent:expr, $indent_problem:expr) => { From b1d592ec377b6c7208cf92a6e1e544365d161aa5 Mon Sep 17 00:00:00 2001 From: Bryce Miller Date: Sat, 20 May 2023 07:15:30 -0400 Subject: [PATCH 002/176] has clause -> implements clause --- crates/compiler/builtins/roc/Bool.roc | 4 +- crates/compiler/builtins/roc/Decode.roc | 48 ++++++++--------- crates/compiler/builtins/roc/Dict.roc | 54 ++++++++++---------- crates/compiler/builtins/roc/Encode.roc | 50 +++++++++--------- crates/compiler/builtins/roc/Hash.roc | 30 +++++------ crates/compiler/builtins/roc/List.roc | 10 ++-- crates/compiler/builtins/roc/Set.roc | 30 +++++------ crates/compiler/parse/src/type_annotation.rs | 44 ++++++++++------ 8 files changed, 142 insertions(+), 128 deletions(-) diff --git a/crates/compiler/builtins/roc/Bool.roc b/crates/compiler/builtins/roc/Bool.roc index d16e8b2494..3b425e9bf1 100644 --- a/crates/compiler/builtins/roc/Bool.roc +++ b/crates/compiler/builtins/roc/Bool.roc @@ -30,7 +30,7 @@ Eq has ## for more detail. ## 5. Functions cannot be compared for structural equality, therefore Roc ## cannot derive `isEq` for types that contain functions. - isEq : a, a -> Bool | a has Eq + isEq : a, a -> Bool | a implements Eq ## Represents the boolean true and false using an opaque type. ## `Bool` implements the `Eq` ability. @@ -116,7 +116,7 @@ not : Bool -> Bool ## expect (Bool.false != Bool.false) == Bool.false ## expect "Apples" != "Oranges" ## ``` -isNotEq : a, a -> Bool | a has Eq +isNotEq : a, a -> Bool | a implements Eq isNotEq = \a, b -> structuralNotEq a b # INTERNAL COMPILER USE ONLY: used to lower calls to `isEq` to structural diff --git a/crates/compiler/builtins/roc/Decode.roc b/crates/compiler/builtins/roc/Decode.roc index 3f42aa6b62..850b71de30 100644 --- a/crates/compiler/builtins/roc/Decode.roc +++ b/crates/compiler/builtins/roc/Decode.roc @@ -73,30 +73,30 @@ DecodeResult val : { result : Result val DecodeError, rest : List U8 } ## Decodes a `List U8` of utf-8 bytes where `val` is the type of the decoded ## value, and `fmt` is a [Decoder] which implements the [DecoderFormatting] ## ability -Decoder val fmt := List U8, fmt -> DecodeResult val | fmt has DecoderFormatting +Decoder val fmt := List U8, fmt -> DecodeResult val | fmt implements DecoderFormatting ## Definition of the [Decoding] ability Decoding has - decoder : Decoder val fmt | val has Decoding, fmt has DecoderFormatting + decoder : Decoder val fmt | val implements Decoding, fmt implements DecoderFormatting ## Definition of the [DecoderFormatting] ability DecoderFormatting has - u8 : Decoder U8 fmt | fmt has DecoderFormatting - u16 : Decoder U16 fmt | fmt has DecoderFormatting - u32 : Decoder U32 fmt | fmt has DecoderFormatting - u64 : Decoder U64 fmt | fmt has DecoderFormatting - u128 : Decoder U128 fmt | fmt has DecoderFormatting - i8 : Decoder I8 fmt | fmt has DecoderFormatting - i16 : Decoder I16 fmt | fmt has DecoderFormatting - i32 : Decoder I32 fmt | fmt has DecoderFormatting - i64 : Decoder I64 fmt | fmt has DecoderFormatting - i128 : Decoder I128 fmt | fmt has DecoderFormatting - f32 : Decoder F32 fmt | fmt has DecoderFormatting - f64 : Decoder F64 fmt | fmt has DecoderFormatting - dec : Decoder Dec fmt | fmt has DecoderFormatting - bool : Decoder Bool fmt | fmt has DecoderFormatting - string : Decoder Str fmt | fmt has DecoderFormatting - list : Decoder elem fmt -> Decoder (List elem) fmt | fmt has DecoderFormatting + u8 : Decoder U8 fmt | fmt implements DecoderFormatting + u16 : Decoder U16 fmt | fmt implements DecoderFormatting + u32 : Decoder U32 fmt | fmt implements DecoderFormatting + u64 : Decoder U64 fmt | fmt implements DecoderFormatting + u128 : Decoder U128 fmt | fmt implements DecoderFormatting + i8 : Decoder I8 fmt | fmt implements DecoderFormatting + i16 : Decoder I16 fmt | fmt implements DecoderFormatting + i32 : Decoder I32 fmt | fmt implements DecoderFormatting + i64 : Decoder I64 fmt | fmt implements DecoderFormatting + i128 : Decoder I128 fmt | fmt implements DecoderFormatting + f32 : Decoder F32 fmt | fmt implements DecoderFormatting + f64 : Decoder F64 fmt | fmt implements DecoderFormatting + dec : Decoder Dec fmt | fmt implements DecoderFormatting + bool : Decoder Bool fmt | fmt implements DecoderFormatting + string : Decoder Str fmt | fmt implements DecoderFormatting + list : Decoder elem fmt -> Decoder (List elem) fmt | fmt implements DecoderFormatting ## `record state stepField finalizer` decodes a record field-by-field. ## @@ -104,7 +104,7 @@ DecoderFormatting has ## `Skip` if the field is not a part of the decoded record. ## ## `finalizer` should produce the record value from the decoded `state`. - record : state, (state, Str -> [Keep (Decoder state fmt), Skip]), (state -> Result val DecodeError) -> Decoder val fmt | fmt has DecoderFormatting + record : state, (state, Str -> [Keep (Decoder state fmt), Skip]), (state -> Result val DecodeError) -> Decoder val fmt | fmt implements DecoderFormatting ## `tuple state stepElem finalizer` decodes a tuple element-by-element. ## @@ -113,7 +113,7 @@ DecoderFormatting has ## index passed to `stepElem` is 0-indexed. ## ## `finalizer` should produce the tuple value from the decoded `state`. - tuple : state, (state, Nat -> [Next (Decoder state fmt), TooLong]), (state -> Result val DecodeError) -> Decoder val fmt | fmt has DecoderFormatting + tuple : state, (state, Nat -> [Next (Decoder state fmt), TooLong]), (state -> Result val DecodeError) -> Decoder val fmt | fmt implements DecoderFormatting ## Build a custom [Decoder] function. For example the implementation of ## `decodeBool` could be defined as follows; @@ -125,11 +125,11 @@ DecoderFormatting has ## ['t', 'r', 'u', 'e', ..] -> { result: Ok Bool.true, rest: List.drop bytes 4 } ## _ -> { result: Err TooShort, rest: bytes } ## ``` -custom : (List U8, fmt -> DecodeResult val) -> Decoder val fmt | fmt has DecoderFormatting +custom : (List U8, fmt -> DecodeResult val) -> Decoder val fmt | fmt implements DecoderFormatting custom = \decode -> @Decoder decode ## Decode a `List U8` utf-8 bytes using a specific [Decoder] function -decodeWith : List U8, Decoder val fmt, fmt -> DecodeResult val | fmt has DecoderFormatting +decodeWith : List U8, Decoder val fmt, fmt -> DecodeResult val | fmt implements DecoderFormatting decodeWith = \bytes, @Decoder decode, fmt -> decode bytes fmt ## Decode a `List U8` utf-8 bytes and return a [DecodeResult](#DecodeResult) @@ -141,7 +141,7 @@ decodeWith = \bytes, @Decoder decode, fmt -> decode bytes fmt ## ## actual.result == expected ## ``` -fromBytesPartial : List U8, fmt -> DecodeResult val | val has Decoding, fmt has DecoderFormatting +fromBytesPartial : List U8, fmt -> DecodeResult val | val implements Decoding, fmt implements DecoderFormatting fromBytesPartial = \bytes, fmt -> decodeWith bytes decoder fmt ## Decode a `List U8` utf-8 bytes and return a [Result] with no leftover bytes @@ -155,7 +155,7 @@ fromBytesPartial = \bytes, fmt -> decodeWith bytes decoder fmt ## ## actual == expected ## ``` -fromBytes : List U8, fmt -> Result val [Leftover (List U8)]DecodeError | val has Decoding, fmt has DecoderFormatting +fromBytes : List U8, fmt -> Result val [Leftover (List U8)]DecodeError | val implements Decoding, fmt implements DecoderFormatting fromBytes = \bytes, fmt -> when fromBytesPartial bytes fmt is { result, rest } -> diff --git a/crates/compiler/builtins/roc/Dict.roc b/crates/compiler/builtins/roc/Dict.roc index 0db8f601ca..57d5091c80 100644 --- a/crates/compiler/builtins/roc/Dict.roc +++ b/crates/compiler/builtins/roc/Dict.roc @@ -97,13 +97,13 @@ Dict k v := { dataIndices : List Nat, data : List (T k v), size : Nat, -} | k has Hash & Eq +} | k implements Hash & Eq ## Return an empty dictionary. ## ``` ## emptyDict = Dict.empty {} ## ``` -empty : {} -> Dict k v | k has Hash & Eq +empty : {} -> Dict k v | k implements Hash & Eq empty = \{} -> @Dict { metadata: List.repeat emptySlot 8, @@ -120,7 +120,7 @@ empty = \{} -> ## ## capacityOfDict = Dict.capacity foodDict ## ``` -capacity : Dict k v -> Nat | k has Hash & Eq +capacity : Dict k v -> Nat | k implements Hash & Eq capacity = \@Dict { dataIndices } -> cap = List.len dataIndices @@ -129,7 +129,7 @@ capacity = \@Dict { dataIndices } -> ## Return a dictionary with space allocated for a number of entries. This ## may provide a performance optimisation if you know how many entries will be ## inserted. -withCapacity : Nat -> Dict k v | k has Hash & Eq +withCapacity : Nat -> Dict k v | k implements Hash & Eq withCapacity = \_ -> # TODO: power of 2 * 8 and actual implementation empty {} @@ -140,7 +140,7 @@ withCapacity = \_ -> ## Dict.single "A" "B" ## |> Bool.isEq (Dict.insert (Dict.empty {}) "A" "B") ## ``` -single : k, v -> Dict k v | k has Hash & Eq +single : k, v -> Dict k v | k implements Hash & Eq single = \k, v -> insert (empty {}) k v @@ -153,7 +153,7 @@ single = \k, v -> ## |> Dict.insert 4 "Four" ## |> Bool.isEq (Dict.fromList [T 1 "One", T 2 "Two", T 3 "Three", T 4 "Four"]) ## ``` -fromList : List (T k v) -> Dict k v | k has Hash & Eq +fromList : List (T k v) -> Dict k v | k implements Hash & Eq fromList = \data -> # TODO: make this efficient. Should just set data and then set all indicies in the hashmap. List.walk data (empty {}) (\dict, T k v -> insert dict k v) @@ -168,7 +168,7 @@ fromList = \data -> ## |> Dict.len ## |> Bool.isEq 3 ## ``` -len : Dict k v -> Nat | k has Hash & Eq +len : Dict k v -> Nat | k implements Hash & Eq len = \@Dict { size } -> size @@ -184,7 +184,7 @@ len = \@Dict { size } -> ## ## expect Dict.len clearSongs == 0 ## ``` -clear : Dict k v -> Dict k v | k has Hash & Eq +clear : Dict k v -> Dict k v | k implements Hash & Eq clear = \@Dict { metadata, dataIndices, data } -> cap = List.len dataIndices @@ -212,7 +212,7 @@ clear = \@Dict { metadata, dataIndices, data } -> ## |> Dict.walk 0 (\count, _, qty -> count + qty) ## |> Bool.isEq 36 ## ``` -walk : Dict k v, state, (state, k, v -> state) -> state | k has Hash & Eq +walk : Dict k v, state, (state, k, v -> state) -> state | k implements Hash & Eq walk = \@Dict { data }, initialState, transform -> List.walk data initialState (\state, T k v -> transform state k v) @@ -244,7 +244,7 @@ walk = \@Dict { data }, initialState, transform -> ## ## expect someoneIsAnAdult == Bool.true ## ``` -walkUntil : Dict k v, state, (state, k, v -> [Continue state, Break state]) -> state | k has Hash & Eq +walkUntil : Dict k v, state, (state, k, v -> [Continue state, Break state]) -> state | k implements Hash & Eq walkUntil = \@Dict { data }, initialState, transform -> List.walkUntil data initialState (\state, T k v -> transform state k v) @@ -259,7 +259,7 @@ walkUntil = \@Dict { data }, initialState, transform -> ## expect Dict.get dictionary 1 == Ok "Apple" ## expect Dict.get dictionary 2000 == Err KeyNotFound ## ``` -get : Dict k v, k -> Result v [KeyNotFound] | k has Hash & Eq +get : Dict k v, k -> Result v [KeyNotFound] | k implements Hash & Eq get = \@Dict { metadata, dataIndices, data }, key -> hashKey = createLowLevelHasher {} @@ -287,7 +287,7 @@ get = \@Dict { metadata, dataIndices, data }, key -> ## |> Dict.contains 1234 ## |> Bool.isEq Bool.true ## ``` -contains : Dict k v, k -> Bool | k has Hash & Eq +contains : Dict k v, k -> Bool | k implements Hash & Eq contains = \@Dict { metadata, dataIndices, data }, key -> hashKey = createLowLevelHasher {} @@ -312,7 +312,7 @@ contains = \@Dict { metadata, dataIndices, data }, key -> ## |> Dict.get "Apples" ## |> Bool.isEq (Ok 12) ## ``` -insert : Dict k v, k, v -> Dict k v | k has Hash & Eq +insert : Dict k v, k, v -> Dict k v | k implements Hash & Eq insert = \@Dict { metadata, dataIndices, data, size }, key, value -> hashKey = createLowLevelHasher {} @@ -358,7 +358,7 @@ insert = \@Dict { metadata, dataIndices, data, size }, key, value -> ## |> Dict.len ## |> Bool.isEq 0 ## ``` -remove : Dict k v, k -> Dict k v | k has Hash & Eq +remove : Dict k v, k -> Dict k v | k implements Hash & Eq remove = \@Dict { metadata, dataIndices, data, size }, key -> # TODO: change this from swap remove to tombstone and test is performance is still good. hashKey = @@ -402,7 +402,7 @@ remove = \@Dict { metadata, dataIndices, data, size }, key -> ## expect Dict.update (Dict.single "a" Bool.false) "a" alterValue == Dict.single "a" Bool.true ## expect Dict.update (Dict.single "a" Bool.true) "a" alterValue == Dict.empty {} ## ``` -update : Dict k v, k, ([Present v, Missing] -> [Present v, Missing]) -> Dict k v | k has Hash & Eq +update : Dict k v, k, ([Present v, Missing] -> [Present v, Missing]) -> Dict k v | k implements Hash & Eq update = \dict, key, alter -> # TODO: look into optimizing by merging substeps and reducing lookups. possibleValue = @@ -425,7 +425,7 @@ update = \dict, key, alter -> ## |> Dict.toList ## |> Bool.isEq [T 1 "One", T 2 "Two", T 3 "Three", T 4 "Four"] ## ``` -toList : Dict k v -> List (T k v) | k has Hash & Eq +toList : Dict k v -> List (T k v) | k implements Hash & Eq toList = \@Dict { data } -> data @@ -440,7 +440,7 @@ toList = \@Dict { data } -> ## |> Dict.keys ## |> Bool.isEq [1,2,3,4] ## ``` -keys : Dict k v -> List k | k has Hash & Eq +keys : Dict k v -> List k | k implements Hash & Eq keys = \@Dict { data } -> List.map data (\T k _ -> k) @@ -455,7 +455,7 @@ keys = \@Dict { data } -> ## |> Dict.values ## |> Bool.isEq ["One","Two","Three","Four"] ## ``` -values : Dict k v -> List v | k has Hash & Eq +values : Dict k v -> List v | k implements Hash & Eq values = \@Dict { data } -> List.map data (\T _ v -> v) @@ -483,7 +483,7 @@ values = \@Dict { data } -> ## expect ## Dict.insertAll first second == expected ## ``` -insertAll : Dict k v, Dict k v -> Dict k v | k has Hash & Eq +insertAll : Dict k v, Dict k v -> Dict k v | k implements Hash & Eq insertAll = \xs, ys -> walk ys xs insert @@ -505,7 +505,7 @@ insertAll = \xs, ys -> ## ## expect Dict.keepShared first second == first ## ``` -keepShared : Dict k v, Dict k v -> Dict k v | k has Hash & Eq +keepShared : Dict k v, Dict k v -> Dict k v | k implements Hash & Eq keepShared = \xs, ys -> walk xs @@ -537,11 +537,11 @@ keepShared = \xs, ys -> ## ## expect Dict.removeAll first second == expected ## ``` -removeAll : Dict k v, Dict k v -> Dict k v | k has Hash & Eq +removeAll : Dict k v, Dict k v -> Dict k v | k implements Hash & Eq removeAll = \xs, ys -> walk ys xs (\state, k, _ -> remove state k) -swapAndUpdateDataIndex : Dict k v, Nat, Nat -> Dict k v | k has Hash & Eq +swapAndUpdateDataIndex : Dict k v, Nat, Nat -> Dict k v | k implements Hash & Eq swapAndUpdateDataIndex = \@Dict { metadata, dataIndices, data, size }, removedIndex, lastIndex -> (T key _) = listGetUnsafe data lastIndex hashKey = @@ -605,7 +605,7 @@ nextEmptyOrDeletedHelper = \metadata, probe, offset -> # TODO: investigate if this needs to be split into more specific helper functions. # There is a chance that returning specific sub-info like the value would be faster. -findIndexHelper : List I8, List Nat, List (T k v), I8, k, Probe, Nat -> Result Nat [NotFound] | k has Hash & Eq +findIndexHelper : List I8, List Nat, List (T k v), I8, k, Probe, Nat -> Result Nat [NotFound] | k implements Hash & Eq findIndexHelper = \metadata, dataIndices, data, h2Key, key, probe, offset -> # For finding a value, we must search past all deleted element tombstones. index = Num.addWrap (mul8 probe.slotIndex) offset @@ -637,7 +637,7 @@ findIndexHelper = \metadata, dataIndices, data, h2Key, key, probe, offset -> # This is how we grow the container. # If we aren't to the load factor yet, just ignore this. # The container must have an updated size including any elements about to be inserted. -maybeRehash : Dict k v -> Dict k v | k has Hash & Eq +maybeRehash : Dict k v -> Dict k v | k implements Hash & Eq maybeRehash = \@Dict { metadata, dataIndices, data, size } -> cap = List.len dataIndices maxLoadCap = @@ -650,7 +650,7 @@ maybeRehash = \@Dict { metadata, dataIndices, data, size } -> @Dict { metadata, dataIndices, data, size } # TODO: switch rehash to iterate data and eventually clear out tombstones as well. -rehash : Dict k v -> Dict k v | k has Hash & Eq +rehash : Dict k v -> Dict k v | k implements Hash & Eq rehash = \@Dict { metadata, dataIndices, data, size } -> newLen = 2 * List.len dataIndices newDict = @@ -663,7 +663,7 @@ rehash = \@Dict { metadata, dataIndices, data, size } -> rehashHelper newDict metadata dataIndices data 0 -rehashHelper : Dict k v, List I8, List Nat, List (T k v), Nat -> Dict k v | k has Hash & Eq +rehashHelper : Dict k v, List I8, List Nat, List (T k v), Nat -> Dict k v | k implements Hash & Eq rehashHelper = \dict, oldMetadata, oldDataIndices, oldData, index -> when List.get oldMetadata index is Ok md -> @@ -684,7 +684,7 @@ rehashHelper = \dict, oldMetadata, oldDataIndices, oldData, index -> # Walked entire list, complete now. dict -insertForRehash : Dict k v, k, Nat -> Dict k v | k has Hash & Eq +insertForRehash : Dict k v, k, Nat -> Dict k v | k implements Hash & Eq insertForRehash = \@Dict { metadata, dataIndices, data, size }, key, dataIndex -> hashKey = createLowLevelHasher {} diff --git a/crates/compiler/builtins/roc/Encode.roc b/crates/compiler/builtins/roc/Encode.roc index 2ac900e3e7..26ba2f77cc 100644 --- a/crates/compiler/builtins/roc/Encode.roc +++ b/crates/compiler/builtins/roc/Encode.roc @@ -47,40 +47,40 @@ interface Encode Bool.{ Bool }, ] -Encoder fmt := List U8, fmt -> List U8 | fmt has EncoderFormatting +Encoder fmt := List U8, fmt -> List U8 | fmt implements EncoderFormatting Encoding has - toEncoder : val -> Encoder fmt | val has Encoding, fmt has EncoderFormatting + toEncoder : val -> Encoder fmt | val implements Encoding, fmt implements EncoderFormatting EncoderFormatting has - u8 : U8 -> Encoder fmt | fmt has EncoderFormatting - u16 : U16 -> Encoder fmt | fmt has EncoderFormatting - u32 : U32 -> Encoder fmt | fmt has EncoderFormatting - u64 : U64 -> Encoder fmt | fmt has EncoderFormatting - u128 : U128 -> Encoder fmt | fmt has EncoderFormatting - i8 : I8 -> Encoder fmt | fmt has EncoderFormatting - i16 : I16 -> Encoder fmt | fmt has EncoderFormatting - i32 : I32 -> Encoder fmt | fmt has EncoderFormatting - i64 : I64 -> Encoder fmt | fmt has EncoderFormatting - i128 : I128 -> Encoder fmt | fmt has EncoderFormatting - f32 : F32 -> Encoder fmt | fmt has EncoderFormatting - f64 : F64 -> Encoder fmt | fmt has EncoderFormatting - dec : Dec -> Encoder fmt | fmt has EncoderFormatting - bool : Bool -> Encoder fmt | fmt has EncoderFormatting - string : Str -> Encoder fmt | fmt has EncoderFormatting - list : List elem, (elem -> Encoder fmt) -> Encoder fmt | fmt has EncoderFormatting - record : List { key : Str, value : Encoder fmt } -> Encoder fmt | fmt has EncoderFormatting - tuple : List (Encoder fmt) -> Encoder fmt | fmt has EncoderFormatting - tag : Str, List (Encoder fmt) -> Encoder fmt | fmt has EncoderFormatting + u8 : U8 -> Encoder fmt | fmt implements EncoderFormatting + u16 : U16 -> Encoder fmt | fmt implements EncoderFormatting + u32 : U32 -> Encoder fmt | fmt implements EncoderFormatting + u64 : U64 -> Encoder fmt | fmt implements EncoderFormatting + u128 : U128 -> Encoder fmt | fmt implements EncoderFormatting + i8 : I8 -> Encoder fmt | fmt implements EncoderFormatting + i16 : I16 -> Encoder fmt | fmt implements EncoderFormatting + i32 : I32 -> Encoder fmt | fmt implements EncoderFormatting + i64 : I64 -> Encoder fmt | fmt implements EncoderFormatting + i128 : I128 -> Encoder fmt | fmt implements EncoderFormatting + f32 : F32 -> Encoder fmt | fmt implements EncoderFormatting + f64 : F64 -> Encoder fmt | fmt implements EncoderFormatting + dec : Dec -> Encoder fmt | fmt implements EncoderFormatting + bool : Bool -> Encoder fmt | fmt implements EncoderFormatting + string : Str -> Encoder fmt | fmt implements EncoderFormatting + list : List elem, (elem -> Encoder fmt) -> Encoder fmt | fmt implements EncoderFormatting + record : List { key : Str, value : Encoder fmt } -> Encoder fmt | fmt implements EncoderFormatting + tuple : List (Encoder fmt) -> Encoder fmt | fmt implements EncoderFormatting + tag : Str, List (Encoder fmt) -> Encoder fmt | fmt implements EncoderFormatting -custom : (List U8, fmt -> List U8) -> Encoder fmt | fmt has EncoderFormatting +custom : (List U8, fmt -> List U8) -> Encoder fmt | fmt implements EncoderFormatting custom = \encoder -> @Encoder encoder -appendWith : List U8, Encoder fmt, fmt -> List U8 | fmt has EncoderFormatting +appendWith : List U8, Encoder fmt, fmt -> List U8 | fmt implements EncoderFormatting appendWith = \lst, @Encoder doEncoding, fmt -> doEncoding lst fmt -append : List U8, val, fmt -> List U8 | val has Encoding, fmt has EncoderFormatting +append : List U8, val, fmt -> List U8 | val implements Encoding, fmt implements EncoderFormatting append = \lst, val, fmt -> appendWith lst (toEncoder val) fmt -toBytes : val, fmt -> List U8 | val has Encoding, fmt has EncoderFormatting +toBytes : val, fmt -> List U8 | val implements Encoding, fmt implements EncoderFormatting toBytes = \val, fmt -> appendWith [] (toEncoder val) fmt diff --git a/crates/compiler/builtins/roc/Hash.roc b/crates/compiler/builtins/roc/Hash.roc index caed5814c8..da6b9dda1c 100644 --- a/crates/compiler/builtins/roc/Hash.roc +++ b/crates/compiler/builtins/roc/Hash.roc @@ -32,7 +32,7 @@ Hash has ## Hashes a value into a [Hasher]. ## Note that [hash] does not produce a hash value itself; the hasher must be ## [complete]d in order to extract the hash value. - hash : hasher, a -> hasher | a has Hash, hasher has Hasher + hash : hasher, a -> hasher | a implements Hash, hasher implements Hasher ## Describes a hashing algorithm that is fed bytes and produces an integer hash. ## @@ -41,26 +41,26 @@ Hash has ## cryptographically-secure hashing. Hasher has ## Adds a list of bytes to the hasher. - addBytes : a, List U8 -> a | a has Hasher + addBytes : a, List U8 -> a | a implements Hasher ## Adds a single U8 to the hasher. - addU8 : a, U8 -> a | a has Hasher + addU8 : a, U8 -> a | a implements Hasher ## Adds a single U16 to the hasher. - addU16 : a, U16 -> a | a has Hasher + addU16 : a, U16 -> a | a implements Hasher ## Adds a single U32 to the hasher. - addU32 : a, U32 -> a | a has Hasher + addU32 : a, U32 -> a | a implements Hasher ## Adds a single U64 to the hasher. - addU64 : a, U64 -> a | a has Hasher + addU64 : a, U64 -> a | a implements Hasher ## Adds a single U128 to the hasher. - addU128 : a, U128 -> a | a has Hasher + addU128 : a, U128 -> a | a implements Hasher ## Completes the hasher, extracting a hash value from its ## accumulated hash state. - complete : a -> U64 | a has Hasher + complete : a -> U64 | a implements Hasher ## Adds a string into a [Hasher] by hashing its UTF-8 bytes. hashStrBytes = \hasher, s -> @@ -72,33 +72,33 @@ hashList = \hasher, lst -> hash accumHasher elem ## Adds a single [Bool] to a hasher. -hashBool : a, Bool -> a | a has Hasher +hashBool : a, Bool -> a | a implements Hasher hashBool = \hasher, b -> asU8 = if b then 1 else 0 addU8 hasher asU8 ## Adds a single I8 to a hasher. -hashI8 : a, I8 -> a | a has Hasher +hashI8 : a, I8 -> a | a implements Hasher hashI8 = \hasher, n -> addU8 hasher (Num.toU8 n) ## Adds a single I16 to a hasher. -hashI16 : a, I16 -> a | a has Hasher +hashI16 : a, I16 -> a | a implements Hasher hashI16 = \hasher, n -> addU16 hasher (Num.toU16 n) ## Adds a single I32 to a hasher. -hashI32 : a, I32 -> a | a has Hasher +hashI32 : a, I32 -> a | a implements Hasher hashI32 = \hasher, n -> addU32 hasher (Num.toU32 n) ## Adds a single I64 to a hasher. -hashI64 : a, I64 -> a | a has Hasher +hashI64 : a, I64 -> a | a implements Hasher hashI64 = \hasher, n -> addU64 hasher (Num.toU64 n) ## Adds a single I128 to a hasher. -hashI128 : a, I128 -> a | a has Hasher +hashI128 : a, I128 -> a | a implements Hasher hashI128 = \hasher, n -> addU128 hasher (Num.toU128 n) ## Adds a single Nat to a hasher. -hashNat : a, Nat -> a | a has Hasher +hashNat : a, Nat -> a | a implements Hasher hashNat = \hasher, n -> isPlatform32bit = x : Nat diff --git a/crates/compiler/builtins/roc/List.roc b/crates/compiler/builtins/roc/List.roc index 9d13209614..299b348760 100644 --- a/crates/compiler/builtins/roc/List.roc +++ b/crates/compiler/builtins/roc/List.roc @@ -362,7 +362,7 @@ join = \lists -> List.walk lists (List.withCapacity totalLength) (\state, list -> List.concat state list) -contains : List a, a -> Bool | a has Eq +contains : List a, a -> Bool | a implements Eq contains = \list, needle -> List.any list (\x -> x == needle) @@ -1036,7 +1036,7 @@ intersperse = \list, sep -> ## is considered to "start with" an empty list. ## ## If the first list is empty, this only returns `Bool.true` if the second list is empty. -startsWith : List elem, List elem -> Bool | elem has Eq +startsWith : List elem, List elem -> Bool | elem implements Eq startsWith = \list, prefix -> # TODO once we have seamless slices, verify that this wouldn't # have better performance with a function like List.compareSublists @@ -1048,7 +1048,7 @@ startsWith = \list, prefix -> ## is considered to "end with" an empty list. ## ## If the first list is empty, this only returns `Bool.true` if the second list is empty. -endsWith : List elem, List elem -> Bool | elem has Eq +endsWith : List elem, List elem -> Bool | elem implements Eq endsWith = \list, suffix -> # TODO once we have seamless slices, verify that this wouldn't # have better performance with a function like List.compareSublists @@ -1078,7 +1078,7 @@ split = \elements, userSplitIndex -> ## ``` ## List.splitFirst [Foo, Z, Bar, Z, Baz] Z == Ok { before: [Foo], after: [Bar, Z, Baz] } ## ``` -splitFirst : List elem, elem -> Result { before : List elem, after : List elem } [NotFound] | elem has Eq +splitFirst : List elem, elem -> Result { before : List elem, after : List elem } [NotFound] | elem implements Eq splitFirst = \list, delimiter -> when List.findFirstIndex list (\elem -> elem == delimiter) is Ok index -> @@ -1094,7 +1094,7 @@ splitFirst = \list, delimiter -> ## ``` ## List.splitLast [Foo, Z, Bar, Z, Baz] Z == Ok { before: [Foo, Z, Bar], after: [Baz] } ## ``` -splitLast : List elem, elem -> Result { before : List elem, after : List elem } [NotFound] | elem has Eq +splitLast : List elem, elem -> Result { before : List elem, after : List elem } [NotFound] | elem implements Eq splitLast = \list, delimiter -> when List.findLastIndex list (\elem -> elem == delimiter) is Ok index -> diff --git a/crates/compiler/builtins/roc/Set.roc b/crates/compiler/builtins/roc/Set.roc index ba6a09069b..c13570c895 100644 --- a/crates/compiler/builtins/roc/Set.roc +++ b/crates/compiler/builtins/roc/Set.roc @@ -25,7 +25,7 @@ interface Set # We should have this line above the next has. # It causes the formatter to fail currently. -# | k has Hash & Eq +# | k implements Hash & Eq ## Provides a [set](https://en.wikipedia.org/wiki/Set_(abstract_data_type)) ## type which stores a collection of unique values, without any ordering Set k := Dict.Dict k {} @@ -35,7 +35,7 @@ Set k := Dict.Dict k {} }, ] -isEq : Set k, Set k -> Bool | k has Hash & Eq +isEq : Set k, Set k -> Bool | k implements Hash & Eq isEq = \xs, ys -> if len xs != len ys then Bool.false @@ -53,7 +53,7 @@ isEq = \xs, ys -> ## ## expect countValues == 0 ## ``` -empty : {} -> Set k | k has Hash & Eq +empty : {} -> Set k | k implements Hash & Eq empty = \{} -> @Set (Dict.empty {}) ## Creates a new `Set` with a single value. @@ -63,7 +63,7 @@ empty = \{} -> @Set (Dict.empty {}) ## ## expect countValues == 1 ## ``` -single : k -> Set k | k has Hash & Eq +single : k -> Set k | k implements Hash & Eq single = \key -> Dict.single key {} |> @Set @@ -79,7 +79,7 @@ single = \key -> ## ## expect countValues == 3 ## ``` -insert : Set k, k -> Set k | k has Hash & Eq +insert : Set k, k -> Set k | k implements Hash & Eq insert = \@Set dict, key -> Dict.insert dict key {} |> @Set @@ -112,7 +112,7 @@ expect ## ## expect countValues == 3 ## ``` -len : Set k -> Nat | k has Hash & Eq +len : Set k -> Nat | k implements Hash & Eq len = \@Set dict -> Dict.len dict @@ -142,7 +142,7 @@ expect ## expect has10 == Bool.false ## expect has20 == Bool.true ## ``` -remove : Set k, k -> Set k | k has Hash & Eq +remove : Set k, k -> Set k | k implements Hash & Eq remove = \@Set dict, key -> Dict.remove dict key |> @Set @@ -161,7 +161,7 @@ remove = \@Set dict, key -> ## expect hasApple == Bool.true ## expect hasBanana == Bool.false ## ``` -contains : Set k, k -> Bool | k has Hash & Eq +contains : Set k, k -> Bool | k implements Hash & Eq contains = \@Set dict, key -> Dict.contains dict key @@ -174,7 +174,7 @@ contains = \@Set dict, key -> ## ## expect Set.toList numbers == values ## ``` -toList : Set k -> List k | k has Hash & Eq +toList : Set k -> List k | k implements Hash & Eq toList = \@Set dict -> Dict.keys dict @@ -188,7 +188,7 @@ toList = \@Set dict -> ## ## expect Set.fromList [Pear, Apple, Banana] == values ## ``` -fromList : List k -> Set k | k has Hash & Eq +fromList : List k -> Set k | k implements Hash & Eq fromList = \list -> initial = @Set (Dict.withCapacity (List.len list)) @@ -204,7 +204,7 @@ fromList = \list -> ## ## expect Set.union set1 set2 == Set.fromList [Left, Right] ## ``` -union : Set k, Set k -> Set k | k has Hash & Eq +union : Set k, Set k -> Set k | k implements Hash & Eq union = \@Set dict1, @Set dict2 -> Dict.insertAll dict1 dict2 |> @Set @@ -217,7 +217,7 @@ union = \@Set dict1, @Set dict2 -> ## ## expect Set.intersection set1 set2 == Set.single Left ## ``` -intersection : Set k, Set k -> Set k | k has Hash & Eq +intersection : Set k, Set k -> Set k | k implements Hash & Eq intersection = \@Set dict1, @Set dict2 -> Dict.keepShared dict1 dict2 |> @Set @@ -231,7 +231,7 @@ intersection = \@Set dict1, @Set dict2 -> ## ## expect Set.difference first second == Set.fromList [Up, Down] ## ``` -difference : Set k, Set k -> Set k | k has Hash & Eq +difference : Set k, Set k -> Set k | k implements Hash & Eq difference = \@Set dict1, @Set dict2 -> Dict.removeAll dict1 dict2 |> @Set @@ -254,7 +254,7 @@ difference = \@Set dict1, @Set dict2 -> ## ## expect result == 2 ## ``` -walk : Set k, state, (state, k -> state) -> state | k has Hash & Eq +walk : Set k, state, (state, k -> state) -> state | k implements Hash & Eq walk = \@Set dict, state, step -> Dict.walk dict state (\s, k, _ -> step s k) @@ -273,7 +273,7 @@ walk = \@Set dict, state, step -> ## ## expect result == FoundTheAnswer ## ``` -walkUntil : Set k, state, (state, k -> [Continue state, Break state]) -> state | k has Hash & Eq +walkUntil : Set k, state, (state, k -> [Continue state, Break state]) -> state | k implements Hash & Eq walkUntil = \@Set dict, state, step -> Dict.walkUntil dict state (\s, k, _ -> step s k) diff --git a/crates/compiler/parse/src/type_annotation.rs b/crates/compiler/parse/src/type_annotation.rs index e2fe0e78d5..c244996f5e 100644 --- a/crates/compiler/parse/src/type_annotation.rs +++ b/crates/compiler/parse/src/type_annotation.rs @@ -12,8 +12,8 @@ use crate::parser::{ absolute_column_min_indent, increment_min_indent, then, ERecord, ETypeAbilityImpl, }; use crate::parser::{ - allocated, backtrackable, fail, optional, specialize, specialize_ref, word1, word2, word3, - EType, ETypeApply, ETypeInParens, ETypeInlineAlias, ETypeRecord, ETypeTagUnion, Parser, + allocated, backtrackable, fail, optional, specialize, specialize_ref, word1, word10, word2, + word3, EType, ETypeApply, ETypeInParens, ETypeInlineAlias, ETypeRecord, ETypeTagUnion, Parser, Progress::{self, *}, }; use crate::state::State; @@ -444,9 +444,9 @@ fn ability_chain<'a>() -> impl Parser<'a, Vec<'a, Loc>>, ETyp ) } -fn has_clause<'a>() -> impl Parser<'a, Loc>, EType<'a>> { +fn implements_clause<'a>() -> impl Parser<'a, Loc>, EType<'a>> { map!( - // Suppose we are trying to parse "a has Hash" + // Suppose we are trying to parse "a implements Hash" and!( space0_around_ee( // Parse "a", with appropriate spaces @@ -458,8 +458,20 @@ fn has_clause<'a>() -> impl Parser<'a, Loc>, EType<'a>> { EType::TIndentEnd ), skip_first!( - // Parse "has"; we don't care about this keyword - word3(b'h', b'a', b's', EType::THasClause), + // Parse "implements"; we don't care about this keyword + word10( + b'i', + b'm', + b'p', + b'l', + b'e', + b'm', + b'e', + b'n', + b't', + b's', + EType::THasClause + ), // Parse "Hash & ..."; this may be qualified from another module like "Hash.Hash" absolute_column_min_indent(ability_chain()) ) @@ -470,18 +482,18 @@ fn has_clause<'a>() -> impl Parser<'a, Loc>, EType<'a>> { &abilities.last().unwrap().region, ); let region = Region::span_across(&var.region, &abilities_region); - let has_clause = HasClause { + let implements_clause = HasClause { var, abilities: abilities.into_bump_slice(), }; - Loc::at(region, has_clause) + Loc::at(region, implements_clause) } ) } -/// Parse a chain of `has` clauses, e.g. " | a has Hash, b has Eq". +/// Parse a chain of `implements` clauses, e.g. " | a implements Hash, b implements Eq". /// Returns the clauses and spaces before the starting "|", if there were any. -fn has_clause_chain<'a>( +fn implements_clause_chain<'a>( ) -> impl Parser<'a, (&'a [CommentOrNewline<'a>], &'a [Loc>]), EType<'a>> { move |arena, state: State<'a>, min_indent: u32| { let (_, (spaces_before, ()), state) = @@ -489,11 +501,13 @@ fn has_clause_chain<'a>( .parse(arena, state, min_indent)?; // Parse the first clause (there must be one), then the rest - let (_, first_clause, state) = has_clause().parse(arena, state, min_indent)?; + let (_, first_clause, state) = implements_clause().parse(arena, state, min_indent)?; - let (_, mut clauses, state) = - zero_or_more!(skip_first!(word1(b',', EType::THasClause), has_clause())) - .parse(arena, state, min_indent)?; + let (_, mut clauses, state) = zero_or_more!(skip_first!( + word1(b',', EType::THasClause), + implements_clause() + )) + .parse(arena, state, min_indent)?; // Usually the number of clauses shouldn't be too large, so this is okay clauses.insert(0, first_clause); @@ -642,7 +656,7 @@ fn expression<'a>( // Finally, try to parse a where clause if there is one. // The where clause must be at least as deep as where the type annotation started. - match has_clause_chain().parse(arena, state.clone(), min_indent) { + match implements_clause_chain().parse(arena, state.clone(), min_indent) { Ok((where_progress, (spaces_before, has_chain), state)) => { let region = Region::span_across(&annot.region, &has_chain.last().unwrap().region); let type_annot = if !spaces_before.is_empty() { From d2fed03cb1816ceeb134b354f5ff93aedcba7bd2 Mon Sep 17 00:00:00 2001 From: Bryce Miller Date: Sat, 20 May 2023 08:04:26 -0400 Subject: [PATCH 003/176] has [abilities] -> implements [abilities] --- crates/compiler/parse/src/type_annotation.rs | 26 ++++++++++++++------ 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/crates/compiler/parse/src/type_annotation.rs b/crates/compiler/parse/src/type_annotation.rs index c244996f5e..0c587fb9c9 100644 --- a/crates/compiler/parse/src/type_annotation.rs +++ b/crates/compiler/parse/src/type_annotation.rs @@ -13,7 +13,7 @@ use crate::parser::{ }; use crate::parser::{ allocated, backtrackable, fail, optional, specialize, specialize_ref, word1, word10, word2, - word3, EType, ETypeApply, ETypeInParens, ETypeInlineAlias, ETypeRecord, ETypeTagUnion, Parser, + EType, ETypeApply, ETypeInParens, ETypeInlineAlias, ETypeRecord, ETypeTagUnion, Parser, Progress::{self, *}, }; use crate::state::State; @@ -520,17 +520,29 @@ fn implements_clause_chain<'a>( } } -/// Parse a has-abilities clause, e.g. `has [Eq, Hash]`. -pub fn has_abilities<'a>() -> impl Parser<'a, Loc>, EType<'a>> { +/// Parse a implements-abilities clause, e.g. `implements [Eq, Hash]`. +pub fn implements_abilities<'a>() -> impl Parser<'a, Loc>, EType<'a>> { increment_min_indent(skip_first!( - // Parse "has"; we don't care about this keyword - word3(b'h', b'a', b's', EType::THasClause), + // Parse "implements"; we don't care about this keyword + word10( + b'i', + b'm', + b'p', + b'l', + b'e', + b'm', + b'e', + b'n', + b't', + b's', + EType::THasClause + ), // Parse "Hash"; this may be qualified from another module like "Hash.Hash" space0_before_e( loc!(map!( collection_trailing_sep_e!( word1(b'[', EType::TStart), - loc!(parse_has_ability()), + loc!(parse_implements_ability()), word1(b',', EType::TEnd), word1(b']', EType::TEnd), HasAbility::SpaceBefore @@ -542,7 +554,7 @@ pub fn has_abilities<'a>() -> impl Parser<'a, Loc>, EType<'a>> )) } -fn parse_has_ability<'a>() -> impl Parser<'a, HasAbility<'a>, EType<'a>> { +fn parse_implements_ability<'a>() -> impl Parser<'a, HasAbility<'a>, EType<'a>> { increment_min_indent(record!(HasAbility::HasAbility { ability: loc!(specialize(EType::TApply, concrete_type())), impls: optional(backtrackable(space0_before_e( From 64c34a5c6d3404986a2f1b91d75ce7c71a7ad11c Mon Sep 17 00:00:00 2001 From: Bryce Miller Date: Sat, 20 May 2023 08:12:20 -0400 Subject: [PATCH 004/176] ast::Has -> ast::Implements --- crates/compiler/fmt/src/spaces.rs | 10 +++++----- crates/compiler/parse/src/ast.rs | 24 ++++++++++++------------ crates/compiler/parse/src/expr.rs | 13 +++++++------ crates/compiler/parse/src/pattern.rs | 10 +++++++--- 4 files changed, 31 insertions(+), 26 deletions(-) diff --git a/crates/compiler/fmt/src/spaces.rs b/crates/compiler/fmt/src/spaces.rs index 5408814c09..eba9b22e6c 100644 --- a/crates/compiler/fmt/src/spaces.rs +++ b/crates/compiler/fmt/src/spaces.rs @@ -3,9 +3,9 @@ use bumpalo::Bump; use roc_module::called_via::{BinOp, UnaryOp}; use roc_parse::{ ast::{ - AbilityMember, AssignedField, Collection, CommentOrNewline, Defs, Expr, Has, HasAbilities, - HasAbility, HasClause, HasImpls, Header, Module, Pattern, RecordBuilderField, Spaced, - Spaces, StrLiteral, StrSegment, Tag, TypeAnnotation, TypeDef, TypeHeader, ValueDef, + AbilityMember, AssignedField, Collection, CommentOrNewline, Defs, Expr, HasAbilities, + HasAbility, HasClause, HasImpls, Header, Implements, Module, Pattern, RecordBuilderField, + Spaced, Spaces, StrLiteral, StrSegment, Tag, TypeAnnotation, TypeDef, TypeHeader, ValueDef, WhenBranch, }, header::{ @@ -569,9 +569,9 @@ impl<'a> RemoveSpaces<'a> for ValueDef<'a> { } } -impl<'a> RemoveSpaces<'a> for Has<'a> { +impl<'a> RemoveSpaces<'a> for Implements<'a> { fn remove_spaces(&self, _arena: &'a Bump) -> Self { - Has::Has + Implements::Implements } } diff --git a/crates/compiler/parse/src/ast.rs b/crates/compiler/parse/src/ast.rs index c0d35d67c0..424f8bc9d7 100644 --- a/crates/compiler/parse/src/ast.rs +++ b/crates/compiler/parse/src/ast.rs @@ -357,12 +357,12 @@ impl<'a> TypeHeader<'a> { } } -/// The `has` keyword associated with ability definitions. +/// The `implements` keyword associated with ability definitions. #[derive(Debug, Clone, Copy, PartialEq)] -pub enum Has<'a> { - Has, - SpaceBefore(&'a Has<'a>, &'a [CommentOrNewline<'a>]), - SpaceAfter(&'a Has<'a>, &'a [CommentOrNewline<'a>]), +pub enum Implements<'a> { + Implements, + SpaceBefore(&'a Implements<'a>, &'a [CommentOrNewline<'a>]), + SpaceAfter(&'a Implements<'a>, &'a [CommentOrNewline<'a>]), } /// An ability demand is a value defining the ability; for example `hash : a -> U64 | a has Hash` @@ -402,7 +402,7 @@ pub enum TypeDef<'a> { /// hash : a -> U64 | a has Hash Ability { header: TypeHeader<'a>, - loc_has: Loc>, + loc_has: Loc>, members: &'a [AbilityMember<'a>], }, } @@ -1245,12 +1245,12 @@ impl<'a> Spaceable<'a> for Tag<'a> { } } -impl<'a> Spaceable<'a> for Has<'a> { +impl<'a> Spaceable<'a> for Implements<'a> { fn before(&'a self, spaces: &'a [CommentOrNewline<'a>]) -> Self { - Has::SpaceBefore(self, spaces) + Implements::SpaceBefore(self, spaces) } fn after(&'a self, spaces: &'a [CommentOrNewline<'a>]) -> Self { - Has::SpaceAfter(self, spaces) + Implements::SpaceAfter(self, spaces) } } @@ -1698,11 +1698,11 @@ impl<'a> Malformed for AbilityMember<'a> { } } -impl<'a> Malformed for Has<'a> { +impl<'a> Malformed for Implements<'a> { fn is_malformed(&self) -> bool { match self { - Has::Has => false, - Has::SpaceBefore(has, _) | Has::SpaceAfter(has, _) => has.is_malformed(), + Implements::Implements => false, + Implements::SpaceBefore(has, _) | Implements::SpaceAfter(has, _) => has.is_malformed(), } } } diff --git a/crates/compiler/parse/src/expr.rs b/crates/compiler/parse/src/expr.rs index e77bd8a216..62a2159050 100644 --- a/crates/compiler/parse/src/expr.rs +++ b/crates/compiler/parse/src/expr.rs @@ -1,6 +1,7 @@ use crate::ast::{ - AssignedField, Collection, CommentOrNewline, Defs, Expr, ExtractSpaces, Has, HasAbilities, - Pattern, RecordBuilderField, Spaceable, Spaces, TypeAnnotation, TypeDef, TypeHeader, ValueDef, + AssignedField, Collection, CommentOrNewline, Defs, Expr, ExtractSpaces, HasAbilities, + Implements, Pattern, RecordBuilderField, Spaceable, Spaces, TypeAnnotation, TypeDef, + TypeHeader, ValueDef, }; use crate::blankspace::{ space0_after_e, space0_around_e_no_after_indent_check, space0_around_ee, space0_before_e, @@ -1075,7 +1076,7 @@ fn opaque_signature_with_space_before<'a>( ), optional(backtrackable(specialize( EExpr::Type, - space0_before_e(type_annotation::has_abilities(), EType::TIndentStart,), + space0_before_e(type_annotation::implements_abilities(), EType::TIndentStart,), ))) ) } @@ -1363,7 +1364,7 @@ fn finish_parsing_ability_def_help<'a>( start_column: u32, name: Loc<&'a str>, args: &'a [Loc>], - loc_has: Loc>, + loc_has: Loc>, arena: &'a Bump, state: State<'a>, ) -> ParseResult<'a, (TypeDef<'a>, Region), EExpr<'a>> { @@ -1664,10 +1665,10 @@ fn parse_expr_end<'a>( // Attach any spaces to the `has` keyword let has = if !expr_state.spaces_after.is_empty() { arena - .alloc(Has::Has) + .alloc(Implements::Implements) .with_spaces_before(expr_state.spaces_after, has.region) } else { - Loc::at(has.region, Has::Has) + Loc::at(has.region, Implements::Implements) }; let args = arguments.into_bump_slice(); diff --git a/crates/compiler/parse/src/pattern.rs b/crates/compiler/parse/src/pattern.rs index 0854eb04be..b35dac7e5d 100644 --- a/crates/compiler/parse/src/pattern.rs +++ b/crates/compiler/parse/src/pattern.rs @@ -1,4 +1,4 @@ -use crate::ast::{Has, Pattern, PatternAs, Spaceable}; +use crate::ast::{Implements, Pattern, PatternAs, Spaceable}; use crate::blankspace::{space0_e, spaces, spaces_before}; use crate::ident::{lowercase_ident, parse_ident, Accessor, Ident}; use crate::keyword; @@ -154,12 +154,16 @@ fn loc_tag_pattern_arg<'a>( } } -pub fn loc_has_parser<'a>() -> impl Parser<'a, Loc>, EPattern<'a>> { +pub fn loc_has_parser<'a>() -> impl Parser<'a, Loc>, EPattern<'a>> { then( loc_tag_pattern_arg(false), |_arena, state, progress, pattern| { if matches!(pattern.value, Pattern::Identifier("has")) { - Ok((progress, Loc::at(pattern.region, Has::Has), state)) + Ok(( + progress, + Loc::at(pattern.region, Implements::Implements), + state, + )) } else { Err((progress, EPattern::End(state.pos()))) } From ebbdae6c284110c0e9c1ab21d1da4ab48c5938a5 Mon Sep 17 00:00:00 2001 From: Bryce Miller Date: Sat, 20 May 2023 08:20:44 -0400 Subject: [PATCH 005/176] ast::HasClause -> ast::ImplementsClause --- crates/compiler/can/src/annotation.rs | 4 ++-- crates/compiler/fmt/src/annotation.rs | 6 +++--- crates/compiler/fmt/src/spaces.rs | 10 +++++----- crates/compiler/load_internal/src/docs.rs | 2 +- crates/compiler/parse/src/ast.rs | 6 +++--- crates/compiler/parse/src/type_annotation.rs | 10 +++++----- 6 files changed, 19 insertions(+), 19 deletions(-) diff --git a/crates/compiler/can/src/annotation.rs b/crates/compiler/can/src/annotation.rs index e80033c1e3..85d4501cf1 100644 --- a/crates/compiler/can/src/annotation.rs +++ b/crates/compiler/can/src/annotation.rs @@ -1064,13 +1064,13 @@ fn canonicalize_has_clause( scope: &mut Scope, var_store: &mut VarStore, introduced_variables: &mut IntroducedVariables, - clause: &Loc>, + clause: &Loc>, pending_abilities_in_scope: &PendingAbilitiesInScope, references: &mut VecSet, ) -> Result<(), Type> { let Loc { region, - value: roc_parse::ast::HasClause { var, abilities }, + value: roc_parse::ast::ImplementsClause { var, abilities }, } = clause; let region = *region; diff --git a/crates/compiler/fmt/src/annotation.rs b/crates/compiler/fmt/src/annotation.rs index 8f7614af34..d2a6142b33 100644 --- a/crates/compiler/fmt/src/annotation.rs +++ b/crates/compiler/fmt/src/annotation.rs @@ -4,8 +4,8 @@ use crate::{ Buf, }; use roc_parse::ast::{ - AssignedField, Collection, Expr, ExtractSpaces, HasAbilities, HasAbility, HasClause, HasImpls, - RecordBuilderField, Tag, TypeAnnotation, TypeHeader, + AssignedField, Collection, Expr, ExtractSpaces, HasAbilities, HasAbility, HasImpls, + ImplementsClause, RecordBuilderField, Tag, TypeAnnotation, TypeHeader, }; use roc_parse::ident::UppercaseIdent; use roc_region::all::Loc; @@ -645,7 +645,7 @@ impl<'a> Formattable for Tag<'a> { } } -impl<'a> Formattable for HasClause<'a> { +impl<'a> Formattable for ImplementsClause<'a> { fn is_multiline(&self) -> bool { // No, always put abilities in a "has" clause on one line false diff --git a/crates/compiler/fmt/src/spaces.rs b/crates/compiler/fmt/src/spaces.rs index eba9b22e6c..35cfce7fa3 100644 --- a/crates/compiler/fmt/src/spaces.rs +++ b/crates/compiler/fmt/src/spaces.rs @@ -4,9 +4,9 @@ use roc_module::called_via::{BinOp, UnaryOp}; use roc_parse::{ ast::{ AbilityMember, AssignedField, Collection, CommentOrNewline, Defs, Expr, HasAbilities, - HasAbility, HasClause, HasImpls, Header, Implements, Module, Pattern, RecordBuilderField, - Spaced, Spaces, StrLiteral, StrSegment, Tag, TypeAnnotation, TypeDef, TypeHeader, ValueDef, - WhenBranch, + HasAbility, HasImpls, Header, Implements, ImplementsClause, Module, Pattern, + RecordBuilderField, Spaced, Spaces, StrLiteral, StrSegment, Tag, TypeAnnotation, TypeDef, + TypeHeader, ValueDef, WhenBranch, }, header::{ AppHeader, ExposedName, HostedHeader, ImportsEntry, InterfaceHeader, KeywordItem, @@ -862,9 +862,9 @@ impl<'a> RemoveSpaces<'a> for TypeAnnotation<'a> { } } -impl<'a> RemoveSpaces<'a> for HasClause<'a> { +impl<'a> RemoveSpaces<'a> for ImplementsClause<'a> { fn remove_spaces(&self, arena: &'a Bump) -> Self { - HasClause { + ImplementsClause { var: self.var.remove_spaces(arena), abilities: self.abilities.remove_spaces(arena), } diff --git a/crates/compiler/load_internal/src/docs.rs b/crates/compiler/load_internal/src/docs.rs index 27dee8c8a0..f74667f936 100644 --- a/crates/compiler/load_internal/src/docs.rs +++ b/crates/compiler/load_internal/src/docs.rs @@ -553,7 +553,7 @@ fn ability_member_type_to_docs( let has_clauses = has_clauses .iter() .map(|hc| { - let ast::HasClause { var, abilities } = hc.value; + let ast::ImplementsClause { var, abilities } = hc.value; ( var.value.extract_spaces().item.to_string(), abilities diff --git a/crates/compiler/parse/src/ast.rs b/crates/compiler/parse/src/ast.rs index 424f8bc9d7..c6084e6b53 100644 --- a/crates/compiler/parse/src/ast.rs +++ b/crates/compiler/parse/src/ast.rs @@ -538,7 +538,7 @@ impl<'a> Defs<'a> { pub type AbilityName<'a> = Loc>; #[derive(Debug, Copy, Clone, PartialEq)] -pub struct HasClause<'a> { +pub struct ImplementsClause<'a> { pub var: Loc>, pub abilities: &'a [AbilityName<'a>], } @@ -642,7 +642,7 @@ pub enum TypeAnnotation<'a> { Wildcard, /// A "where" clause demanding abilities designated by a `|`, e.g. `a -> U64 | a has Hash` - Where(&'a Loc>, &'a [Loc>]), + Where(&'a Loc>, &'a [Loc>]), // We preserve this for the formatter; canonicalization ignores it. SpaceBefore(&'a TypeAnnotation<'a>, &'a [CommentOrNewline<'a>]), @@ -1823,7 +1823,7 @@ impl<'a> Malformed for Tag<'a> { } } -impl<'a> Malformed for HasClause<'a> { +impl<'a> Malformed for ImplementsClause<'a> { fn is_malformed(&self) -> bool { self.abilities.iter().any(|ability| ability.is_malformed()) } diff --git a/crates/compiler/parse/src/type_annotation.rs b/crates/compiler/parse/src/type_annotation.rs index 0c587fb9c9..26cc88da8d 100644 --- a/crates/compiler/parse/src/type_annotation.rs +++ b/crates/compiler/parse/src/type_annotation.rs @@ -1,6 +1,6 @@ use crate::ast::{ - AssignedField, CommentOrNewline, Expr, HasAbilities, HasAbility, HasClause, HasImpls, Pattern, - Spaceable, Spaced, Tag, TypeAnnotation, TypeHeader, + AssignedField, CommentOrNewline, Expr, HasAbilities, HasAbility, HasImpls, ImplementsClause, + Pattern, Spaceable, Spaced, Tag, TypeAnnotation, TypeHeader, }; use crate::blankspace::{ space0_around_ee, space0_before_e, space0_before_optional_after, space0_e, @@ -444,7 +444,7 @@ fn ability_chain<'a>() -> impl Parser<'a, Vec<'a, Loc>>, ETyp ) } -fn implements_clause<'a>() -> impl Parser<'a, Loc>, EType<'a>> { +fn implements_clause<'a>() -> impl Parser<'a, Loc>, EType<'a>> { map!( // Suppose we are trying to parse "a implements Hash" and!( @@ -482,7 +482,7 @@ fn implements_clause<'a>() -> impl Parser<'a, Loc>, EType<'a>> { &abilities.last().unwrap().region, ); let region = Region::span_across(&var.region, &abilities_region); - let implements_clause = HasClause { + let implements_clause = ImplementsClause { var, abilities: abilities.into_bump_slice(), }; @@ -494,7 +494,7 @@ fn implements_clause<'a>() -> impl Parser<'a, Loc>, EType<'a>> { /// Parse a chain of `implements` clauses, e.g. " | a implements Hash, b implements Eq". /// Returns the clauses and spaces before the starting "|", if there were any. fn implements_clause_chain<'a>( -) -> impl Parser<'a, (&'a [CommentOrNewline<'a>], &'a [Loc>]), EType<'a>> { +) -> impl Parser<'a, (&'a [CommentOrNewline<'a>], &'a [Loc>]), EType<'a>> { move |arena, state: State<'a>, min_indent: u32| { let (_, (spaces_before, ()), state) = and!(space0_e(EType::TIndentStart), word1(b'|', EType::TWhereBar)) From 413ccb24ad27714a57511777a80c0b8388b98b06 Mon Sep 17 00:00:00 2001 From: Bryce Miller Date: Sat, 20 May 2023 08:24:02 -0400 Subject: [PATCH 006/176] ast::HasImpls -> ast::AbilityImpls --- crates/compiler/fmt/src/annotation.rs | 14 +++--- crates/compiler/fmt/src/spaces.rs | 12 +++-- crates/compiler/parse/src/ast.rs | 48 ++++++++++---------- crates/compiler/parse/src/type_annotation.rs | 6 +-- 4 files changed, 42 insertions(+), 38 deletions(-) diff --git a/crates/compiler/fmt/src/annotation.rs b/crates/compiler/fmt/src/annotation.rs index d2a6142b33..762d2bb1f4 100644 --- a/crates/compiler/fmt/src/annotation.rs +++ b/crates/compiler/fmt/src/annotation.rs @@ -4,7 +4,7 @@ use crate::{ Buf, }; use roc_parse::ast::{ - AssignedField, Collection, Expr, ExtractSpaces, HasAbilities, HasAbility, HasImpls, + AbilityImpls, AssignedField, Collection, Expr, ExtractSpaces, HasAbilities, HasAbility, ImplementsClause, RecordBuilderField, Tag, TypeAnnotation, TypeHeader, }; use roc_parse::ident::UppercaseIdent; @@ -668,30 +668,30 @@ impl<'a> Formattable for ImplementsClause<'a> { } } -impl<'a> Formattable for HasImpls<'a> { +impl<'a> Formattable for AbilityImpls<'a> { fn is_multiline(&self) -> bool { match self { - HasImpls::SpaceBefore(_, _) | HasImpls::SpaceAfter(_, _) => true, - HasImpls::HasImpls(impls) => is_collection_multiline(impls), + AbilityImpls::SpaceBefore(_, _) | AbilityImpls::SpaceAfter(_, _) => true, + AbilityImpls::AbilityImpls(impls) => is_collection_multiline(impls), } } fn format_with_options(&self, buf: &mut Buf, parens: Parens, newlines: Newlines, indent: u16) { match self { - HasImpls::HasImpls(impls) => { + AbilityImpls::AbilityImpls(impls) => { if newlines == Newlines::Yes { buf.newline(); buf.indent(indent); } fmt_collection(buf, indent, Braces::Curly, *impls, Newlines::No); } - HasImpls::SpaceBefore(impls, spaces) => { + AbilityImpls::SpaceBefore(impls, spaces) => { buf.newline(); buf.indent(indent); fmt_comments_only(buf, spaces.iter(), NewlineAt::Bottom, indent); impls.format_with_options(buf, parens, Newlines::No, indent); } - HasImpls::SpaceAfter(impls, spaces) => { + AbilityImpls::SpaceAfter(impls, spaces) => { impls.format_with_options(buf, parens, newlines, indent); fmt_comments_only(buf, spaces.iter(), NewlineAt::Bottom, indent); } diff --git a/crates/compiler/fmt/src/spaces.rs b/crates/compiler/fmt/src/spaces.rs index 35cfce7fa3..f4516dbe82 100644 --- a/crates/compiler/fmt/src/spaces.rs +++ b/crates/compiler/fmt/src/spaces.rs @@ -3,8 +3,8 @@ use bumpalo::Bump; use roc_module::called_via::{BinOp, UnaryOp}; use roc_parse::{ ast::{ - AbilityMember, AssignedField, Collection, CommentOrNewline, Defs, Expr, HasAbilities, - HasAbility, HasImpls, Header, Implements, ImplementsClause, Module, Pattern, + AbilityImpls, AbilityMember, AssignedField, Collection, CommentOrNewline, Defs, Expr, + HasAbilities, HasAbility, Header, Implements, ImplementsClause, Module, Pattern, RecordBuilderField, Spaced, Spaces, StrLiteral, StrSegment, Tag, TypeAnnotation, TypeDef, TypeHeader, ValueDef, WhenBranch, }, @@ -885,11 +885,13 @@ impl<'a> RemoveSpaces<'a> for Tag<'a> { } } -impl<'a> RemoveSpaces<'a> for HasImpls<'a> { +impl<'a> RemoveSpaces<'a> for AbilityImpls<'a> { fn remove_spaces(&self, arena: &'a Bump) -> Self { match *self { - HasImpls::HasImpls(impls) => HasImpls::HasImpls(impls.remove_spaces(arena)), - HasImpls::SpaceBefore(has, _) | HasImpls::SpaceAfter(has, _) => { + AbilityImpls::AbilityImpls(impls) => { + AbilityImpls::AbilityImpls(impls.remove_spaces(arena)) + } + AbilityImpls::SpaceBefore(has, _) | AbilityImpls::SpaceAfter(has, _) => { has.remove_spaces(arena) } } diff --git a/crates/compiler/parse/src/ast.rs b/crates/compiler/parse/src/ast.rs index c6084e6b53..7fab0f0150 100644 --- a/crates/compiler/parse/src/ast.rs +++ b/crates/compiler/parse/src/ast.rs @@ -544,13 +544,13 @@ pub struct ImplementsClause<'a> { } #[derive(Debug, Copy, Clone, PartialEq)] -pub enum HasImpls<'a> { +pub enum AbilityImpls<'a> { // `{ eq: myEq }` - HasImpls(Collection<'a, Loc>>>), + AbilityImpls(Collection<'a, Loc>>>), // We preserve this for the formatter; canonicalization ignores it. - SpaceBefore(&'a HasImpls<'a>, &'a [CommentOrNewline<'a>]), - SpaceAfter(&'a HasImpls<'a>, &'a [CommentOrNewline<'a>]), + SpaceBefore(&'a AbilityImpls<'a>, &'a [CommentOrNewline<'a>]), + SpaceAfter(&'a AbilityImpls<'a>, &'a [CommentOrNewline<'a>]), } /// `Eq` or `Eq { eq: myEq }` @@ -559,7 +559,7 @@ pub enum HasAbility<'a> { HasAbility { /// Should be a zero-argument `Apply` or an error; we'll check this in canonicalization ability: Loc>, - impls: Option>>, + impls: Option>>, }, // We preserve this for the formatter; canonicalization ignores it. @@ -1254,12 +1254,12 @@ impl<'a> Spaceable<'a> for Implements<'a> { } } -impl<'a> Spaceable<'a> for HasImpls<'a> { +impl<'a> Spaceable<'a> for AbilityImpls<'a> { fn before(&'a self, spaces: &'a [CommentOrNewline<'a>]) -> Self { - HasImpls::SpaceBefore(self, spaces) + AbilityImpls::SpaceBefore(self, spaces) } fn after(&'a self, spaces: &'a [CommentOrNewline<'a>]) -> Self { - HasImpls::SpaceAfter(self, spaces) + AbilityImpls::SpaceAfter(self, spaces) } } @@ -1422,43 +1422,43 @@ impl<'a, T: Copy> ExtractSpaces<'a> for Spaced<'a, T> { } } -impl<'a> ExtractSpaces<'a> for HasImpls<'a> { +impl<'a> ExtractSpaces<'a> for AbilityImpls<'a> { type Item = Collection<'a, Loc>>>; fn extract_spaces(&self) -> Spaces<'a, Self::Item> { match self { - HasImpls::HasImpls(inner) => Spaces { + AbilityImpls::AbilityImpls(inner) => Spaces { before: &[], item: *inner, after: &[], }, - HasImpls::SpaceBefore(item, before) => match item { - HasImpls::HasImpls(inner) => Spaces { + AbilityImpls::SpaceBefore(item, before) => match item { + AbilityImpls::AbilityImpls(inner) => Spaces { before, item: *inner, after: &[], }, - HasImpls::SpaceBefore(_, _) => todo!(), - HasImpls::SpaceAfter(HasImpls::HasImpls(inner), after) => Spaces { + AbilityImpls::SpaceBefore(_, _) => todo!(), + AbilityImpls::SpaceAfter(AbilityImpls::AbilityImpls(inner), after) => Spaces { before, item: *inner, after, }, - HasImpls::SpaceAfter(_, _) => todo!(), + AbilityImpls::SpaceAfter(_, _) => todo!(), }, - HasImpls::SpaceAfter(item, after) => match item { - HasImpls::HasImpls(inner) => Spaces { + AbilityImpls::SpaceAfter(item, after) => match item { + AbilityImpls::AbilityImpls(inner) => Spaces { before: &[], item: *inner, after, }, - HasImpls::SpaceBefore(HasImpls::HasImpls(inner), before) => Spaces { + AbilityImpls::SpaceBefore(AbilityImpls::AbilityImpls(inner), before) => Spaces { before, item: *inner, after, }, - HasImpls::SpaceBefore(_, _) => todo!(), - HasImpls::SpaceAfter(_, _) => todo!(), + AbilityImpls::SpaceBefore(_, _) => todo!(), + AbilityImpls::SpaceAfter(_, _) => todo!(), }, } } @@ -1729,11 +1729,13 @@ impl<'a> Malformed for HasAbilities<'a> { } } -impl<'a> Malformed for HasImpls<'a> { +impl<'a> Malformed for AbilityImpls<'a> { fn is_malformed(&self) -> bool { match self { - HasImpls::HasImpls(impls) => impls.iter().any(|ability| ability.is_malformed()), - HasImpls::SpaceBefore(has, _) | HasImpls::SpaceAfter(has, _) => has.is_malformed(), + AbilityImpls::AbilityImpls(impls) => impls.iter().any(|ability| ability.is_malformed()), + AbilityImpls::SpaceBefore(has, _) | AbilityImpls::SpaceAfter(has, _) => { + has.is_malformed() + } } } } diff --git a/crates/compiler/parse/src/type_annotation.rs b/crates/compiler/parse/src/type_annotation.rs index 26cc88da8d..43fb96c357 100644 --- a/crates/compiler/parse/src/type_annotation.rs +++ b/crates/compiler/parse/src/type_annotation.rs @@ -1,6 +1,6 @@ use crate::ast::{ - AssignedField, CommentOrNewline, Expr, HasAbilities, HasAbility, HasImpls, ImplementsClause, - Pattern, Spaceable, Spaced, Tag, TypeAnnotation, TypeHeader, + AbilityImpls, AssignedField, CommentOrNewline, Expr, HasAbilities, HasAbility, + ImplementsClause, Pattern, Spaceable, Spaced, Tag, TypeAnnotation, TypeHeader, }; use crate::blankspace::{ space0_around_ee, space0_before_e, space0_before_optional_after, space0_e, @@ -569,7 +569,7 @@ fn parse_implements_ability<'a>() -> impl Parser<'a, HasAbility<'a>, EType<'a>> AssignedField::SpaceBefore ) ), - HasImpls::HasImpls + AbilityImpls::AbilityImpls )), EType::TIndentEnd ))) From 9eb2180a0f4e0dabdd89d5318408e8f565bd7563 Mon Sep 17 00:00:00 2001 From: Bryce Miller Date: Sat, 20 May 2023 08:27:42 -0400 Subject: [PATCH 007/176] ast::HasAbility -> ast::ImplementsAbility --- crates/compiler/can/src/def.rs | 2 +- crates/compiler/fmt/src/annotation.rs | 14 +++++----- crates/compiler/fmt/src/spaces.rs | 16 ++++++----- crates/compiler/parse/src/ast.rs | 28 +++++++++++--------- crates/compiler/parse/src/type_annotation.rs | 8 +++--- 5 files changed, 36 insertions(+), 32 deletions(-) diff --git a/crates/compiler/can/src/def.rs b/crates/compiler/can/src/def.rs index 79c05a5871..14bd8086c9 100644 --- a/crates/compiler/can/src/def.rs +++ b/crates/compiler/can/src/def.rs @@ -695,7 +695,7 @@ fn canonicalize_opaque<'a>( for has_ability in has_abilities.items { let region = has_ability.region; let (ability, opt_impls) = match has_ability.value.extract_spaces().item { - ast::HasAbility::HasAbility { ability, impls } => (ability, impls), + ast::ImplementsAbility::ImplementsAbility { ability, impls } => (ability, impls), _ => internal_error!("spaces not extracted"), }; diff --git a/crates/compiler/fmt/src/annotation.rs b/crates/compiler/fmt/src/annotation.rs index 762d2bb1f4..f66ede894d 100644 --- a/crates/compiler/fmt/src/annotation.rs +++ b/crates/compiler/fmt/src/annotation.rs @@ -4,7 +4,7 @@ use crate::{ Buf, }; use roc_parse::ast::{ - AbilityImpls, AssignedField, Collection, Expr, ExtractSpaces, HasAbilities, HasAbility, + AbilityImpls, AssignedField, Collection, Expr, ExtractSpaces, HasAbilities, ImplementsAbility, ImplementsClause, RecordBuilderField, Tag, TypeAnnotation, TypeHeader, }; use roc_parse::ident::UppercaseIdent; @@ -699,11 +699,11 @@ impl<'a> Formattable for AbilityImpls<'a> { } } -impl<'a> Formattable for HasAbility<'a> { +impl<'a> Formattable for ImplementsAbility<'a> { fn is_multiline(&self) -> bool { match self { - HasAbility::SpaceAfter(..) | HasAbility::SpaceBefore(..) => true, - HasAbility::HasAbility { ability, impls } => { + ImplementsAbility::SpaceAfter(..) | ImplementsAbility::SpaceBefore(..) => true, + ImplementsAbility::ImplementsAbility { ability, impls } => { ability.is_multiline() || impls.map(|i| i.is_multiline()).unwrap_or(false) } } @@ -711,7 +711,7 @@ impl<'a> Formattable for HasAbility<'a> { fn format_with_options(&self, buf: &mut Buf, parens: Parens, newlines: Newlines, indent: u16) { match self { - HasAbility::HasAbility { ability, impls } => { + ImplementsAbility::ImplementsAbility { ability, impls } => { if newlines == Newlines::Yes { buf.newline(); buf.indent(indent); @@ -722,13 +722,13 @@ impl<'a> Formattable for HasAbility<'a> { impls.format_with_options(buf, parens, newlines, indent); } } - HasAbility::SpaceBefore(ab, spaces) => { + ImplementsAbility::SpaceBefore(ab, spaces) => { buf.newline(); buf.indent(indent); fmt_comments_only(buf, spaces.iter(), NewlineAt::Bottom, indent); ab.format_with_options(buf, parens, Newlines::No, indent) } - HasAbility::SpaceAfter(ab, spaces) => { + ImplementsAbility::SpaceAfter(ab, spaces) => { ab.format_with_options(buf, parens, newlines, indent); fmt_comments_only(buf, spaces.iter(), NewlineAt::Bottom, indent); } diff --git a/crates/compiler/fmt/src/spaces.rs b/crates/compiler/fmt/src/spaces.rs index f4516dbe82..ed2d79adc4 100644 --- a/crates/compiler/fmt/src/spaces.rs +++ b/crates/compiler/fmt/src/spaces.rs @@ -4,7 +4,7 @@ use roc_module::called_via::{BinOp, UnaryOp}; use roc_parse::{ ast::{ AbilityImpls, AbilityMember, AssignedField, Collection, CommentOrNewline, Defs, Expr, - HasAbilities, HasAbility, Header, Implements, ImplementsClause, Module, Pattern, + HasAbilities, Header, Implements, ImplementsAbility, ImplementsClause, Module, Pattern, RecordBuilderField, Spaced, Spaces, StrLiteral, StrSegment, Tag, TypeAnnotation, TypeDef, TypeHeader, ValueDef, WhenBranch, }, @@ -898,14 +898,16 @@ impl<'a> RemoveSpaces<'a> for AbilityImpls<'a> { } } -impl<'a> RemoveSpaces<'a> for HasAbility<'a> { +impl<'a> RemoveSpaces<'a> for ImplementsAbility<'a> { fn remove_spaces(&self, arena: &'a Bump) -> Self { match *self { - HasAbility::HasAbility { ability, impls } => HasAbility::HasAbility { - ability: ability.remove_spaces(arena), - impls: impls.remove_spaces(arena), - }, - HasAbility::SpaceBefore(has, _) | HasAbility::SpaceAfter(has, _) => { + ImplementsAbility::ImplementsAbility { ability, impls } => { + ImplementsAbility::ImplementsAbility { + ability: ability.remove_spaces(arena), + impls: impls.remove_spaces(arena), + } + } + ImplementsAbility::SpaceBefore(has, _) | ImplementsAbility::SpaceAfter(has, _) => { has.remove_spaces(arena) } } diff --git a/crates/compiler/parse/src/ast.rs b/crates/compiler/parse/src/ast.rs index 7fab0f0150..b995297a46 100644 --- a/crates/compiler/parse/src/ast.rs +++ b/crates/compiler/parse/src/ast.rs @@ -555,22 +555,22 @@ pub enum AbilityImpls<'a> { /// `Eq` or `Eq { eq: myEq }` #[derive(Debug, Copy, Clone, PartialEq)] -pub enum HasAbility<'a> { - HasAbility { +pub enum ImplementsAbility<'a> { + ImplementsAbility { /// Should be a zero-argument `Apply` or an error; we'll check this in canonicalization ability: Loc>, impls: Option>>, }, // We preserve this for the formatter; canonicalization ignores it. - SpaceBefore(&'a HasAbility<'a>, &'a [CommentOrNewline<'a>]), - SpaceAfter(&'a HasAbility<'a>, &'a [CommentOrNewline<'a>]), + SpaceBefore(&'a ImplementsAbility<'a>, &'a [CommentOrNewline<'a>]), + SpaceAfter(&'a ImplementsAbility<'a>, &'a [CommentOrNewline<'a>]), } #[derive(Debug, Copy, Clone, PartialEq)] pub enum HasAbilities<'a> { /// `has [Eq { eq: myEq }, Hash]` - Has(Collection<'a, Loc>>), + Has(Collection<'a, Loc>>), // We preserve this for the formatter; canonicalization ignores it. SpaceBefore(&'a HasAbilities<'a>, &'a [CommentOrNewline<'a>]), @@ -578,7 +578,7 @@ pub enum HasAbilities<'a> { } impl HasAbilities<'_> { - pub fn collection(&self) -> &Collection> { + pub fn collection(&self) -> &Collection> { let mut it = self; loop { match it { @@ -1263,12 +1263,12 @@ impl<'a> Spaceable<'a> for AbilityImpls<'a> { } } -impl<'a> Spaceable<'a> for HasAbility<'a> { +impl<'a> Spaceable<'a> for ImplementsAbility<'a> { fn before(&'a self, spaces: &'a [CommentOrNewline<'a>]) -> Self { - HasAbility::SpaceBefore(self, spaces) + ImplementsAbility::SpaceBefore(self, spaces) } fn after(&'a self, spaces: &'a [CommentOrNewline<'a>]) -> Self { - HasAbility::SpaceAfter(self, spaces) + ImplementsAbility::SpaceAfter(self, spaces) } } @@ -1368,7 +1368,7 @@ impl_extract_spaces!(Pattern); impl_extract_spaces!(Tag); impl_extract_spaces!(AssignedField); impl_extract_spaces!(TypeAnnotation); -impl_extract_spaces!(HasAbility); +impl_extract_spaces!(ImplementsAbility); impl<'a, T: Copy> ExtractSpaces<'a> for Spaced<'a, T> { type Item = T; @@ -1707,13 +1707,15 @@ impl<'a> Malformed for Implements<'a> { } } -impl<'a> Malformed for HasAbility<'a> { +impl<'a> Malformed for ImplementsAbility<'a> { fn is_malformed(&self) -> bool { match self { - HasAbility::HasAbility { ability, impls } => { + ImplementsAbility::ImplementsAbility { ability, impls } => { ability.is_malformed() || impls.iter().any(|impl_| impl_.is_malformed()) } - HasAbility::SpaceBefore(has, _) | HasAbility::SpaceAfter(has, _) => has.is_malformed(), + ImplementsAbility::SpaceBefore(has, _) | ImplementsAbility::SpaceAfter(has, _) => { + has.is_malformed() + } } } } diff --git a/crates/compiler/parse/src/type_annotation.rs b/crates/compiler/parse/src/type_annotation.rs index 43fb96c357..0c4fad8901 100644 --- a/crates/compiler/parse/src/type_annotation.rs +++ b/crates/compiler/parse/src/type_annotation.rs @@ -1,5 +1,5 @@ use crate::ast::{ - AbilityImpls, AssignedField, CommentOrNewline, Expr, HasAbilities, HasAbility, + AbilityImpls, AssignedField, CommentOrNewline, Expr, HasAbilities, ImplementsAbility, ImplementsClause, Pattern, Spaceable, Spaced, Tag, TypeAnnotation, TypeHeader, }; use crate::blankspace::{ @@ -545,7 +545,7 @@ pub fn implements_abilities<'a>() -> impl Parser<'a, Loc>, ETyp loc!(parse_implements_ability()), word1(b',', EType::TEnd), word1(b']', EType::TEnd), - HasAbility::SpaceBefore + ImplementsAbility::SpaceBefore ), HasAbilities::Has )), @@ -554,8 +554,8 @@ pub fn implements_abilities<'a>() -> impl Parser<'a, Loc>, ETyp )) } -fn parse_implements_ability<'a>() -> impl Parser<'a, HasAbility<'a>, EType<'a>> { - increment_min_indent(record!(HasAbility::HasAbility { +fn parse_implements_ability<'a>() -> impl Parser<'a, ImplementsAbility<'a>, EType<'a>> { + increment_min_indent(record!(ImplementsAbility::ImplementsAbility { ability: loc!(specialize(EType::TApply, concrete_type())), impls: optional(backtrackable(space0_before_e( loc!(map!( From 4b90948fcfc4cdbd3a4306b21aeae2c22796cacf Mon Sep 17 00:00:00 2001 From: Bryce Miller Date: Sat, 20 May 2023 19:13:01 -0400 Subject: [PATCH 008/176] ast::HasAbilities -> ast::ImplementsAbilities --- crates/compiler/can/src/def.rs | 8 +++---- crates/compiler/fmt/src/annotation.rs | 16 ++++++------- crates/compiler/fmt/src/spaces.rs | 15 ++++++------ crates/compiler/parse/src/ast.rs | 24 +++++++++++--------- crates/compiler/parse/src/expr.rs | 14 ++++++++---- crates/compiler/parse/src/type_annotation.rs | 6 ++--- 6 files changed, 46 insertions(+), 37 deletions(-) diff --git a/crates/compiler/can/src/def.rs b/crates/compiler/can/src/def.rs index 14bd8086c9..140da5955e 100644 --- a/crates/compiler/can/src/def.rs +++ b/crates/compiler/can/src/def.rs @@ -174,7 +174,7 @@ enum PendingTypeDef<'a> { name: Loc, vars: Vec>, ann: &'a Loc>, - derived: Option<&'a Loc>>, + derived: Option<&'a Loc>>, }, Ability { @@ -672,7 +672,7 @@ fn canonicalize_opaque<'a>( name_str: &'a str, ann: &'a Loc>, vars: &[Loc], - has_abilities: Option<&'a Loc>>, + has_abilities: Option<&'a Loc>>, ) -> Result, ()> { let alias = canonicalize_alias( env, @@ -1182,7 +1182,7 @@ fn canonicalize_type_defs<'a>( Loc, Vec>, &'a Loc>, - Option<&'a Loc>>, + Option<&'a Loc>>, ), Ability(Loc, Vec>), } @@ -2492,7 +2492,7 @@ fn to_pending_alias_or_opaque<'a>( name: &'a Loc<&'a str>, vars: &'a [Loc>], ann: &'a Loc>, - opt_derived: Option<&'a Loc>>, + opt_derived: Option<&'a Loc>>, kind: AliasKind, ) -> PendingTypeDef<'a> { let region = Region::span_across(&name.region, &ann.region); diff --git a/crates/compiler/fmt/src/annotation.rs b/crates/compiler/fmt/src/annotation.rs index f66ede894d..8909b3345d 100644 --- a/crates/compiler/fmt/src/annotation.rs +++ b/crates/compiler/fmt/src/annotation.rs @@ -4,8 +4,8 @@ use crate::{ Buf, }; use roc_parse::ast::{ - AbilityImpls, AssignedField, Collection, Expr, ExtractSpaces, HasAbilities, ImplementsAbility, - ImplementsClause, RecordBuilderField, Tag, TypeAnnotation, TypeHeader, + AbilityImpls, AssignedField, Collection, Expr, ExtractSpaces, ImplementsAbilities, + ImplementsAbility, ImplementsClause, RecordBuilderField, Tag, TypeAnnotation, TypeHeader, }; use roc_parse::ident::UppercaseIdent; use roc_region::all::Loc; @@ -736,17 +736,17 @@ impl<'a> Formattable for ImplementsAbility<'a> { } } -impl<'a> Formattable for HasAbilities<'a> { +impl<'a> Formattable for ImplementsAbilities<'a> { fn is_multiline(&self) -> bool { match self { - HasAbilities::SpaceAfter(..) | HasAbilities::SpaceBefore(..) => true, - HasAbilities::Has(has_abilities) => is_collection_multiline(has_abilities), + ImplementsAbilities::SpaceAfter(..) | ImplementsAbilities::SpaceBefore(..) => true, + ImplementsAbilities::Has(has_abilities) => is_collection_multiline(has_abilities), } } fn format_with_options(&self, buf: &mut Buf, parens: Parens, newlines: Newlines, indent: u16) { match self { - HasAbilities::Has(has_abilities) => { + ImplementsAbilities::Has(has_abilities) => { if newlines == Newlines::Yes { buf.newline(); buf.indent(indent); @@ -755,13 +755,13 @@ impl<'a> Formattable for HasAbilities<'a> { buf.spaces(1); fmt_collection(buf, indent, Braces::Square, *has_abilities, Newlines::No); } - HasAbilities::SpaceBefore(has_abilities, spaces) => { + ImplementsAbilities::SpaceBefore(has_abilities, spaces) => { buf.newline(); buf.indent(indent); fmt_comments_only(buf, spaces.iter(), NewlineAt::Bottom, indent); has_abilities.format_with_options(buf, parens, Newlines::No, indent) } - HasAbilities::SpaceAfter(has_abilities, spaces) => { + ImplementsAbilities::SpaceAfter(has_abilities, spaces) => { has_abilities.format_with_options(buf, parens, newlines, indent); fmt_comments_only(buf, spaces.iter(), NewlineAt::Bottom, indent); } diff --git a/crates/compiler/fmt/src/spaces.rs b/crates/compiler/fmt/src/spaces.rs index ed2d79adc4..ad94739c72 100644 --- a/crates/compiler/fmt/src/spaces.rs +++ b/crates/compiler/fmt/src/spaces.rs @@ -4,9 +4,9 @@ use roc_module::called_via::{BinOp, UnaryOp}; use roc_parse::{ ast::{ AbilityImpls, AbilityMember, AssignedField, Collection, CommentOrNewline, Defs, Expr, - HasAbilities, Header, Implements, ImplementsAbility, ImplementsClause, Module, Pattern, - RecordBuilderField, Spaced, Spaces, StrLiteral, StrSegment, Tag, TypeAnnotation, TypeDef, - TypeHeader, ValueDef, WhenBranch, + Header, Implements, ImplementsAbilities, ImplementsAbility, ImplementsClause, Module, + Pattern, RecordBuilderField, Spaced, Spaces, StrLiteral, StrSegment, Tag, TypeAnnotation, + TypeDef, TypeHeader, ValueDef, WhenBranch, }, header::{ AppHeader, ExposedName, HostedHeader, ImportsEntry, InterfaceHeader, KeywordItem, @@ -914,13 +914,14 @@ impl<'a> RemoveSpaces<'a> for ImplementsAbility<'a> { } } -impl<'a> RemoveSpaces<'a> for HasAbilities<'a> { +impl<'a> RemoveSpaces<'a> for ImplementsAbilities<'a> { fn remove_spaces(&self, arena: &'a Bump) -> Self { match *self { - HasAbilities::Has(derived) => HasAbilities::Has(derived.remove_spaces(arena)), - HasAbilities::SpaceBefore(derived, _) | HasAbilities::SpaceAfter(derived, _) => { - derived.remove_spaces(arena) + ImplementsAbilities::Has(derived) => { + ImplementsAbilities::Has(derived.remove_spaces(arena)) } + ImplementsAbilities::SpaceBefore(derived, _) + | ImplementsAbilities::SpaceAfter(derived, _) => derived.remove_spaces(arena), } } } diff --git a/crates/compiler/parse/src/ast.rs b/crates/compiler/parse/src/ast.rs index b995297a46..fbde09ecb6 100644 --- a/crates/compiler/parse/src/ast.rs +++ b/crates/compiler/parse/src/ast.rs @@ -394,7 +394,7 @@ pub enum TypeDef<'a> { Opaque { header: TypeHeader<'a>, typ: Loc>, - derived: Option>>, + derived: Option>>, }, /// An ability definition. E.g. @@ -568,16 +568,16 @@ pub enum ImplementsAbility<'a> { } #[derive(Debug, Copy, Clone, PartialEq)] -pub enum HasAbilities<'a> { +pub enum ImplementsAbilities<'a> { /// `has [Eq { eq: myEq }, Hash]` Has(Collection<'a, Loc>>), // We preserve this for the formatter; canonicalization ignores it. - SpaceBefore(&'a HasAbilities<'a>, &'a [CommentOrNewline<'a>]), - SpaceAfter(&'a HasAbilities<'a>, &'a [CommentOrNewline<'a>]), + SpaceBefore(&'a ImplementsAbilities<'a>, &'a [CommentOrNewline<'a>]), + SpaceAfter(&'a ImplementsAbilities<'a>, &'a [CommentOrNewline<'a>]), } -impl HasAbilities<'_> { +impl ImplementsAbilities<'_> { pub fn collection(&self) -> &Collection> { let mut it = self; loop { @@ -1272,12 +1272,12 @@ impl<'a> Spaceable<'a> for ImplementsAbility<'a> { } } -impl<'a> Spaceable<'a> for HasAbilities<'a> { +impl<'a> Spaceable<'a> for ImplementsAbilities<'a> { fn before(&'a self, spaces: &'a [CommentOrNewline<'a>]) -> Self { - HasAbilities::SpaceBefore(self, spaces) + ImplementsAbilities::SpaceBefore(self, spaces) } fn after(&'a self, spaces: &'a [CommentOrNewline<'a>]) -> Self { - HasAbilities::SpaceAfter(self, spaces) + ImplementsAbilities::SpaceAfter(self, spaces) } } @@ -1720,11 +1720,13 @@ impl<'a> Malformed for ImplementsAbility<'a> { } } -impl<'a> Malformed for HasAbilities<'a> { +impl<'a> Malformed for ImplementsAbilities<'a> { fn is_malformed(&self) -> bool { match self { - HasAbilities::Has(abilities) => abilities.iter().any(|ability| ability.is_malformed()), - HasAbilities::SpaceBefore(has, _) | HasAbilities::SpaceAfter(has, _) => { + ImplementsAbilities::Has(abilities) => { + abilities.iter().any(|ability| ability.is_malformed()) + } + ImplementsAbilities::SpaceBefore(has, _) | ImplementsAbilities::SpaceAfter(has, _) => { has.is_malformed() } } diff --git a/crates/compiler/parse/src/expr.rs b/crates/compiler/parse/src/expr.rs index 62a2159050..5cfc998311 100644 --- a/crates/compiler/parse/src/expr.rs +++ b/crates/compiler/parse/src/expr.rs @@ -1,6 +1,6 @@ use crate::ast::{ - AssignedField, Collection, CommentOrNewline, Defs, Expr, ExtractSpaces, HasAbilities, - Implements, Pattern, RecordBuilderField, Spaceable, Spaces, TypeAnnotation, TypeDef, + AssignedField, Collection, CommentOrNewline, Defs, Expr, ExtractSpaces, Implements, + ImplementsAbilities, Pattern, RecordBuilderField, Spaceable, Spaces, TypeAnnotation, TypeDef, TypeHeader, ValueDef, }; use crate::blankspace::{ @@ -1064,8 +1064,14 @@ fn alias_signature_with_space_before<'a>() -> impl Parser<'a, Loc( -) -> impl Parser<'a, (Loc>, Option>>), EExpr<'a>> { +fn opaque_signature_with_space_before<'a>() -> impl Parser< + 'a, + ( + Loc>, + Option>>, + ), + EExpr<'a>, +> { and!( specialize( EExpr::Type, diff --git a/crates/compiler/parse/src/type_annotation.rs b/crates/compiler/parse/src/type_annotation.rs index 0c4fad8901..78e03c03b2 100644 --- a/crates/compiler/parse/src/type_annotation.rs +++ b/crates/compiler/parse/src/type_annotation.rs @@ -1,5 +1,5 @@ use crate::ast::{ - AbilityImpls, AssignedField, CommentOrNewline, Expr, HasAbilities, ImplementsAbility, + AbilityImpls, AssignedField, CommentOrNewline, Expr, ImplementsAbilities, ImplementsAbility, ImplementsClause, Pattern, Spaceable, Spaced, Tag, TypeAnnotation, TypeHeader, }; use crate::blankspace::{ @@ -521,7 +521,7 @@ fn implements_clause_chain<'a>( } /// Parse a implements-abilities clause, e.g. `implements [Eq, Hash]`. -pub fn implements_abilities<'a>() -> impl Parser<'a, Loc>, EType<'a>> { +pub fn implements_abilities<'a>() -> impl Parser<'a, Loc>, EType<'a>> { increment_min_indent(skip_first!( // Parse "implements"; we don't care about this keyword word10( @@ -547,7 +547,7 @@ pub fn implements_abilities<'a>() -> impl Parser<'a, Loc>, ETyp word1(b']', EType::TEnd), ImplementsAbility::SpaceBefore ), - HasAbilities::Has + ImplementsAbilities::Has )), EType::TIndentEnd, ) From 10d92bf0f38a87ddfebd00854a8485ae0287efbb Mon Sep 17 00:00:00 2001 From: Bryce Miller Date: Sat, 20 May 2023 19:16:13 -0400 Subject: [PATCH 009/176] ast::ImplementsAbilities::Has -> ast::ImplementsAbilities::Implements --- crates/compiler/fmt/src/annotation.rs | 6 ++++-- crates/compiler/fmt/src/spaces.rs | 4 ++-- crates/compiler/parse/src/ast.rs | 6 +++--- crates/compiler/parse/src/type_annotation.rs | 2 +- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/crates/compiler/fmt/src/annotation.rs b/crates/compiler/fmt/src/annotation.rs index 8909b3345d..78ae3eb5d5 100644 --- a/crates/compiler/fmt/src/annotation.rs +++ b/crates/compiler/fmt/src/annotation.rs @@ -740,13 +740,15 @@ impl<'a> Formattable for ImplementsAbilities<'a> { fn is_multiline(&self) -> bool { match self { ImplementsAbilities::SpaceAfter(..) | ImplementsAbilities::SpaceBefore(..) => true, - ImplementsAbilities::Has(has_abilities) => is_collection_multiline(has_abilities), + ImplementsAbilities::Implements(has_abilities) => { + is_collection_multiline(has_abilities) + } } } fn format_with_options(&self, buf: &mut Buf, parens: Parens, newlines: Newlines, indent: u16) { match self { - ImplementsAbilities::Has(has_abilities) => { + ImplementsAbilities::Implements(has_abilities) => { if newlines == Newlines::Yes { buf.newline(); buf.indent(indent); diff --git a/crates/compiler/fmt/src/spaces.rs b/crates/compiler/fmt/src/spaces.rs index ad94739c72..450963fe9d 100644 --- a/crates/compiler/fmt/src/spaces.rs +++ b/crates/compiler/fmt/src/spaces.rs @@ -917,8 +917,8 @@ impl<'a> RemoveSpaces<'a> for ImplementsAbility<'a> { impl<'a> RemoveSpaces<'a> for ImplementsAbilities<'a> { fn remove_spaces(&self, arena: &'a Bump) -> Self { match *self { - ImplementsAbilities::Has(derived) => { - ImplementsAbilities::Has(derived.remove_spaces(arena)) + ImplementsAbilities::Implements(derived) => { + ImplementsAbilities::Implements(derived.remove_spaces(arena)) } ImplementsAbilities::SpaceBefore(derived, _) | ImplementsAbilities::SpaceAfter(derived, _) => derived.remove_spaces(arena), diff --git a/crates/compiler/parse/src/ast.rs b/crates/compiler/parse/src/ast.rs index fbde09ecb6..c58dedbfdb 100644 --- a/crates/compiler/parse/src/ast.rs +++ b/crates/compiler/parse/src/ast.rs @@ -570,7 +570,7 @@ pub enum ImplementsAbility<'a> { #[derive(Debug, Copy, Clone, PartialEq)] pub enum ImplementsAbilities<'a> { /// `has [Eq { eq: myEq }, Hash]` - Has(Collection<'a, Loc>>), + Implements(Collection<'a, Loc>>), // We preserve this for the formatter; canonicalization ignores it. SpaceBefore(&'a ImplementsAbilities<'a>, &'a [CommentOrNewline<'a>]), @@ -585,7 +585,7 @@ impl ImplementsAbilities<'_> { Self::SpaceBefore(inner, _) | Self::SpaceAfter(inner, _) => { it = inner; } - Self::Has(collection) => return collection, + Self::Implements(collection) => return collection, } } } @@ -1723,7 +1723,7 @@ impl<'a> Malformed for ImplementsAbility<'a> { impl<'a> Malformed for ImplementsAbilities<'a> { fn is_malformed(&self) -> bool { match self { - ImplementsAbilities::Has(abilities) => { + ImplementsAbilities::Implements(abilities) => { abilities.iter().any(|ability| ability.is_malformed()) } ImplementsAbilities::SpaceBefore(has, _) | ImplementsAbilities::SpaceAfter(has, _) => { diff --git a/crates/compiler/parse/src/type_annotation.rs b/crates/compiler/parse/src/type_annotation.rs index 78e03c03b2..92ec2404c1 100644 --- a/crates/compiler/parse/src/type_annotation.rs +++ b/crates/compiler/parse/src/type_annotation.rs @@ -547,7 +547,7 @@ pub fn implements_abilities<'a>() -> impl Parser<'a, Loc word1(b']', EType::TEnd), ImplementsAbility::SpaceBefore ), - ImplementsAbilities::Has + ImplementsAbilities::Implements )), EType::TIndentEnd, ) From d700a6a6e6d5d57f3745deab9713b915f564a99f Mon Sep 17 00:00:00 2001 From: Bryce Miller Date: Sat, 20 May 2023 19:19:11 -0400 Subject: [PATCH 010/176] has -> implements in comments --- crates/compiler/parse/src/ast.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/compiler/parse/src/ast.rs b/crates/compiler/parse/src/ast.rs index c58dedbfdb..855441d39c 100644 --- a/crates/compiler/parse/src/ast.rs +++ b/crates/compiler/parse/src/ast.rs @@ -365,7 +365,7 @@ pub enum Implements<'a> { SpaceAfter(&'a Implements<'a>, &'a [CommentOrNewline<'a>]), } -/// An ability demand is a value defining the ability; for example `hash : a -> U64 | a has Hash` +/// An ability demand is a value defining the ability; for example `hash : a -> U64 | a implements Hash` /// for a `Hash` ability. #[derive(Debug, Clone, Copy, PartialEq)] pub struct AbilityMember<'a> { @@ -398,8 +398,8 @@ pub enum TypeDef<'a> { }, /// An ability definition. E.g. - /// Hash has - /// hash : a -> U64 | a has Hash + /// Hash implements + /// hash : a -> U64 | a implements Hash Ability { header: TypeHeader<'a>, loc_has: Loc>, @@ -569,7 +569,7 @@ pub enum ImplementsAbility<'a> { #[derive(Debug, Copy, Clone, PartialEq)] pub enum ImplementsAbilities<'a> { - /// `has [Eq { eq: myEq }, Hash]` + /// `implements [Eq { eq: myEq }, Hash]` Implements(Collection<'a, Loc>>), // We preserve this for the formatter; canonicalization ignores it. @@ -641,7 +641,7 @@ pub enum TypeAnnotation<'a> { /// The `*` type variable, e.g. in (List *) Wildcard, - /// A "where" clause demanding abilities designated by a `|`, e.g. `a -> U64 | a has Hash` + /// A "where" clause demanding abilities designated by a `|`, e.g. `a -> U64 | a implements Hash` Where(&'a Loc>, &'a [Loc>]), // We preserve this for the formatter; canonicalization ignores it. From 46cb45f71736a5ba699fd641976474035d077797 Mon Sep 17 00:00:00 2001 From: Bryce Miller Date: Sat, 20 May 2023 19:24:08 -0400 Subject: [PATCH 011/176] loc_has -> loc_implements --- crates/compiler/can/src/def.rs | 2 +- crates/compiler/fmt/src/def.rs | 2 +- crates/compiler/fmt/src/spaces.rs | 4 ++-- crates/compiler/parse/src/ast.rs | 4 ++-- crates/compiler/parse/src/expr.rs | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/crates/compiler/can/src/def.rs b/crates/compiler/can/src/def.rs index 140da5955e..e4dee03468 100644 --- a/crates/compiler/can/src/def.rs +++ b/crates/compiler/can/src/def.rs @@ -2611,7 +2611,7 @@ fn to_pending_type_def<'a>( Ability { header: TypeHeader { name, vars }, members, - loc_has: _, + loc_implements: _, } => { let name = match scope .introduce_without_shadow_symbol(&Ident::from(name.value), name.region) diff --git a/crates/compiler/fmt/src/def.rs b/crates/compiler/fmt/src/def.rs index bb5268bcc2..b2066f5ffe 100644 --- a/crates/compiler/fmt/src/def.rs +++ b/crates/compiler/fmt/src/def.rs @@ -123,7 +123,7 @@ impl<'a> Formattable for TypeDef<'a> { } Ability { header: TypeHeader { name, vars }, - loc_has: _, + loc_implements: _, members, } => { buf.indent(indent); diff --git a/crates/compiler/fmt/src/spaces.rs b/crates/compiler/fmt/src/spaces.rs index 450963fe9d..98ae35ca10 100644 --- a/crates/compiler/fmt/src/spaces.rs +++ b/crates/compiler/fmt/src/spaces.rs @@ -507,14 +507,14 @@ impl<'a> RemoveSpaces<'a> for TypeDef<'a> { }, Ability { header: TypeHeader { name, vars }, - loc_has, + loc_implements: loc_has, members, } => Ability { header: TypeHeader { name: name.remove_spaces(arena), vars: vars.remove_spaces(arena), }, - loc_has: loc_has.remove_spaces(arena), + loc_implements: loc_has.remove_spaces(arena), members: members.remove_spaces(arena), }, } diff --git a/crates/compiler/parse/src/ast.rs b/crates/compiler/parse/src/ast.rs index 855441d39c..88e6db4210 100644 --- a/crates/compiler/parse/src/ast.rs +++ b/crates/compiler/parse/src/ast.rs @@ -402,7 +402,7 @@ pub enum TypeDef<'a> { /// hash : a -> U64 | a implements Hash Ability { header: TypeHeader<'a>, - loc_has: Loc>, + loc_implements: Loc>, members: &'a [AbilityMember<'a>], }, } @@ -1681,7 +1681,7 @@ impl<'a> Malformed for TypeDef<'a> { } => header.is_malformed() || typ.is_malformed() || derived.is_malformed(), TypeDef::Ability { header, - loc_has, + loc_implements: loc_has, members, } => { header.is_malformed() diff --git a/crates/compiler/parse/src/expr.rs b/crates/compiler/parse/src/expr.rs index 5cfc998311..7e5cf1a527 100644 --- a/crates/compiler/parse/src/expr.rs +++ b/crates/compiler/parse/src/expr.rs @@ -1408,7 +1408,7 @@ fn finish_parsing_ability_def_help<'a>( let def_region = Region::span_across(&name.region, &demands.last().unwrap().typ.region); let type_def = TypeDef::Ability { header: TypeHeader { name, vars: args }, - loc_has, + loc_implements: loc_has, members: demands.into_bump_slice(), }; From 44d33965089ed047901d3f1333802f108a960052 Mon Sep 17 00:00:00 2001 From: Bryce Miller Date: Sat, 20 May 2023 19:47:17 -0400 Subject: [PATCH 012/176] builtin opaque type abilites has -> implements --- crates/compiler/builtins/roc/Bool.roc | 2 +- crates/compiler/builtins/roc/Dict.roc | 4 ++-- crates/compiler/builtins/roc/Json.roc | 2 +- crates/compiler/builtins/roc/Set.roc | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/crates/compiler/builtins/roc/Bool.roc b/crates/compiler/builtins/roc/Bool.roc index 3b425e9bf1..1dbaef1228 100644 --- a/crates/compiler/builtins/roc/Bool.roc +++ b/crates/compiler/builtins/roc/Bool.roc @@ -34,7 +34,7 @@ Eq has ## Represents the boolean true and false using an opaque type. ## `Bool` implements the `Eq` ability. -Bool := [True, False] has [Eq { isEq: boolIsEq }] +Bool := [True, False] implements [Eq { isEq: boolIsEq }] boolIsEq = \@Bool b1, @Bool b2 -> structuralEq b1 b2 diff --git a/crates/compiler/builtins/roc/Dict.roc b/crates/compiler/builtins/roc/Dict.roc index 57d5091c80..ea25f7df78 100644 --- a/crates/compiler/builtins/roc/Dict.roc +++ b/crates/compiler/builtins/roc/Dict.roc @@ -92,7 +92,7 @@ Dict k v := { # TODO: As an optimization, we can make all of these lists in one allocation # TODO: Grow data with the rest of the hashmap. This will require creating a list of garbage data. # TODO: Change remove to use tombstones. Store the tombstones in a bitmap. - # TODO: define Eq and Hash that are unordered. Only if value has hash/eq? + # TODO: define Eq and Hash that are unordered. Only if value implements hash/eq? metadata : List I8, dataIndices : List Nat, data : List (T k v), @@ -888,7 +888,7 @@ expect # TODO: wyhash is slow for large keys, use something like cityhash if the keys are too long. # TODO: Add a builtin to distinguish big endian systems and change loading orders. # TODO: Switch out Wymum on systems with slow 128bit multiplication. -LowLevelHasher := { originalSeed : U64, state : U64 } has [ +LowLevelHasher := { originalSeed : U64, state : U64 } implements [ Hasher { addBytes, addU8, diff --git a/crates/compiler/builtins/roc/Json.roc b/crates/compiler/builtins/roc/Json.roc index 3cb81ce4bc..c36b655dfc 100644 --- a/crates/compiler/builtins/roc/Json.roc +++ b/crates/compiler/builtins/roc/Json.roc @@ -79,7 +79,7 @@ interface Json ## An opaque type with the `EncoderFormatting` and ## `DecoderFormatting` abilities. Json := { fieldNameMapping : FieldNameMapping } - has [ + implements [ EncoderFormatting { u8: encodeU8, u16: encodeU16, diff --git a/crates/compiler/builtins/roc/Set.roc b/crates/compiler/builtins/roc/Set.roc index c13570c895..a0f1a8854b 100644 --- a/crates/compiler/builtins/roc/Set.roc +++ b/crates/compiler/builtins/roc/Set.roc @@ -28,8 +28,8 @@ interface Set # | k implements Hash & Eq ## Provides a [set](https://en.wikipedia.org/wiki/Set_(abstract_data_type)) ## type which stores a collection of unique values, without any ordering -Set k := Dict.Dict k {} - has [ +Set k := Dict.Dict k {} | k implements Hash & Eq + implements [ Eq { isEq, }, From e04f09231c3fda6fa60ea3422053da5f717d1352 Mon Sep 17 00:00:00 2001 From: Bryce Miller Date: Sat, 20 May 2023 21:05:34 -0400 Subject: [PATCH 013/176] has -> implements in error messages --- crates/reporting/src/error/canonicalize.rs | 44 +++++++++++----------- crates/reporting/src/error/type.rs | 18 +++++---- 2 files changed, 33 insertions(+), 29 deletions(-) diff --git a/crates/reporting/src/error/canonicalize.rs b/crates/reporting/src/error/canonicalize.rs index 30f9e58aae..70ef2e0dc5 100644 --- a/crates/reporting/src/error/canonicalize.rs +++ b/crates/reporting/src/error/canonicalize.rs @@ -42,9 +42,9 @@ const OPAQUE_NOT_APPLIED: &str = "OPAQUE TYPE NOT APPLIED"; const OPAQUE_OVER_APPLIED: &str = "OPAQUE TYPE APPLIED TO TOO MANY ARGS"; const INVALID_EXTENSION_TYPE: &str = "INVALID_EXTENSION_TYPE"; const ABILITY_HAS_TYPE_VARIABLES: &str = "ABILITY HAS TYPE VARIABLES"; -const HAS_CLAUSE_IS_NOT_AN_ABILITY: &str = "HAS CLAUSE IS NOT AN ABILITY"; -const ILLEGAL_HAS_CLAUSE: &str = "ILLEGAL HAS CLAUSE"; -const ABILITY_MEMBER_MISSING_HAS_CLAUSE: &str = "ABILITY MEMBER MISSING HAS CLAUSE"; +const IMPLEMENTS_CLAUSE_IS_NOT_AN_ABILITY: &str = "IMPLEMENTS CLAUSE IS NOT AN ABILITY"; +const ILLEGAL_IMPLEMENTS_CLAUSE: &str = "ILLEGAL IMPLEMENTS CLAUSE"; +const ABILITY_MEMBER_MISSING_IMPLEMENTS_CLAUSE: &str = "ABILITY MEMBER MISSING IMPLEMENTS CLAUSE"; const ABILITY_MEMBER_BINDS_MULTIPLE_VARIABLES: &str = "ABILITY MEMBER BINDS MULTIPLE VARIABLES"; const ABILITY_NOT_ON_TOPLEVEL: &str = "ABILITY NOT ON TOP-LEVEL"; const SPECIALIZATION_NOT_ON_TOPLEVEL: &str = "SPECIALIZATION NOT ON TOP-LEVEL"; @@ -652,28 +652,30 @@ pub fn can_problem<'b>( region: clause_region, } => { doc = alloc.stack([ - alloc.reflow(r#"The type referenced in this "has" clause is not an ability:"#), + alloc.reflow( + r#"The type referenced in this "implements" clause is not an ability:"#, + ), alloc.region(lines.convert_region(clause_region)), ]); - title = HAS_CLAUSE_IS_NOT_AN_ABILITY.to_string(); + title = IMPLEMENTS_CLAUSE_IS_NOT_AN_ABILITY.to_string(); } Problem::IllegalHasClause { region } => { doc = alloc.stack([ alloc.concat([ - alloc.reflow("A "), - alloc.keyword("has"), + alloc.reflow("An "), + alloc.keyword("implements"), alloc.reflow(" clause is not allowed here:"), ]), alloc.region(lines.convert_region(region)), alloc.concat([ - alloc.keyword("has"), + alloc.keyword("implements"), alloc.reflow( " clauses can only be specified on the top-level type annotations.", ), ]), ]); - title = ILLEGAL_HAS_CLAUSE.to_string(); + title = ILLEGAL_IMPLEMENTS_CLAUSE.to_string(); } Problem::DuplicateHasAbility { ability, region } => { @@ -685,8 +687,8 @@ pub fn can_problem<'b>( ]), alloc.region(lines.convert_region(region)), alloc.concat([ - alloc.reflow("Abilities only need to bound to a type variable once in a "), - alloc.keyword("has"), + alloc.reflow("Abilities only need to bound to a type variable once in an "), + alloc.keyword("implements"), alloc.reflow(" clause!"), ]), ]); @@ -702,29 +704,29 @@ pub fn can_problem<'b>( alloc.concat([ alloc.reflow("The definition of the ability member "), alloc.symbol_unqualified(member), - alloc.reflow(" does not include a "), - alloc.keyword("has"), + alloc.reflow(" does not include an "), + alloc.keyword("implements"), alloc.reflow(" clause binding a type variable to the ability "), alloc.symbol_unqualified(ability), alloc.reflow(":"), ]), alloc.region(lines.convert_region(region)), alloc.concat([ - alloc.reflow("Ability members must include a "), - alloc.keyword("has"), + alloc.reflow("Ability members must include an "), + alloc.keyword("implements"), alloc.reflow(" clause binding a type variable to an ability, like"), ]), alloc.type_block(alloc.concat([ alloc.type_variable("a".into()), alloc.space(), - alloc.keyword("has"), + alloc.keyword("implements"), alloc.space(), alloc.symbol_unqualified(ability), ])), alloc.concat([alloc .reflow("Otherwise, the function does not need to be part of the ability!")]), ]); - title = ABILITY_MEMBER_MISSING_HAS_CLAUSE.to_string(); + title = ABILITY_MEMBER_MISSING_IMPLEMENTS_CLAUSE.to_string(); } Problem::AbilityMemberMultipleBoundVars { @@ -778,13 +780,13 @@ pub fn can_problem<'b>( ), alloc .hint("") - .append(alloc.reflow("Perhaps you meant to include a ")) - .append(alloc.keyword("has")) + .append(alloc.reflow("Perhaps you meant to include an ")) + .append(alloc.keyword("implements")) .append(alloc.reflow(" annotation, like")), alloc.type_block(alloc.concat([ alloc.type_variable(suggested_var_name), alloc.space(), - alloc.keyword("has"), + alloc.keyword("implements"), alloc.space(), alloc.symbol_unqualified(ability), ])), @@ -851,7 +853,7 @@ pub fn can_problem<'b>( let hint = if ability.is_builtin() { alloc.hint("").append( alloc.reflow("if you want this implementation to be derived, don't include a record of implementations. For example,") - .append(alloc.type_block(alloc.concat([alloc.type_str("has ["), alloc.symbol_unqualified(ability), alloc.type_str("]")]))) + .append(alloc.type_block(alloc.concat([alloc.type_str("implements ["), alloc.symbol_unqualified(ability), alloc.type_str("]")]))) .append(alloc.reflow(" will attempt to derive ").append(alloc.symbol_unqualified(ability)))) } else { alloc.nil() diff --git a/crates/reporting/src/error/type.rs b/crates/reporting/src/error/type.rs index ea2b56d9d8..c039a2770a 100644 --- a/crates/reporting/src/error/type.rs +++ b/crates/reporting/src/error/type.rs @@ -373,7 +373,7 @@ fn underivable_hint<'b>( alloc.concat([ alloc.reflow(" or "), alloc.inline_type_block(alloc.concat([ - alloc.keyword("has"), + alloc.keyword("implements"), alloc.space(), alloc.symbol_qualified(ability), ])), @@ -400,13 +400,13 @@ fn underivable_hint<'b>( alloc.reflow("This type variable is not bound to "), alloc.symbol_unqualified(ability), alloc.reflow(". Consider adding a "), - alloc.keyword("has"), + alloc.keyword("implements"), alloc.reflow(" clause to bind the type variable, like "), alloc.inline_type_block(alloc.concat([ alloc.string("| ".to_string()), alloc.type_variable(v.clone()), alloc.space(), - alloc.keyword("has"), + alloc.keyword("implements"), alloc.space(), alloc.symbol_qualified(ability), ])), @@ -2758,7 +2758,7 @@ fn type_with_able_vars<'b>( doc.push(alloc.string(if i == 0 { " | " } else { ", " }.to_string())); doc.push(alloc.type_variable(var)); doc.push(alloc.space()); - doc.push(alloc.keyword("has")); + doc.push(alloc.keyword("implements")); for (i, ability) in abilities.into_sorted_iter().enumerate() { if i > 0 { @@ -4468,7 +4468,7 @@ fn type_problem_to_pretty<'b>( .note("") .append(alloc.reflow("The type variable ")) .append(alloc.type_variable(name.clone())) - .append(alloc.reflow(" says it can take on any value that has the ")) + .append(alloc.reflow(" says it can take on any value that implements the ")) .append(list_abilities(alloc, &abilities)) .append(alloc.reflow(".")), alloc.concat([ @@ -4509,11 +4509,13 @@ fn type_problem_to_pretty<'b>( alloc .note("") .append(type_var_doc) - .append(alloc.reflow(" can take on any value that has only the ")) + .append( + alloc.reflow(" can take on any value that implements only the "), + ) .append(list_abilities(alloc, &abilities)) .append(alloc.reflow(".")), alloc.concat([ - alloc.reflow("But, I see that it's also used as if it has the "), + alloc.reflow("But, I see that it's also used as if it implements the "), list_abilities(alloc, &extra_abilities), alloc.reflow(". Can you use "), alloc.type_variable(name.clone()), @@ -4530,7 +4532,7 @@ fn type_problem_to_pretty<'b>( alloc.reflow("it") }, alloc.reflow(" to the "), - alloc.keyword("has"), + alloc.keyword("implements"), alloc.reflow(" clause of "), alloc.type_variable(name), alloc.reflow("."), From 17c733ec81ecd359d37c3abb86e71e0a58323e45 Mon Sep 17 00:00:00 2001 From: Bryce Miller Date: Sat, 20 May 2023 21:12:26 -0400 Subject: [PATCH 014/176] has -> implements in roc_problem::can::Problem --- crates/compiler/can/src/annotation.rs | 8 +++---- crates/compiler/can/src/def.rs | 4 ++-- crates/compiler/problem/src/can.rs | 28 +++++++++++----------- crates/reporting/src/error/canonicalize.rs | 10 ++++---- 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/crates/compiler/can/src/annotation.rs b/crates/compiler/can/src/annotation.rs index 85d4501cf1..63e9b8ef34 100644 --- a/crates/compiler/can/src/annotation.rs +++ b/crates/compiler/can/src/annotation.rs @@ -1041,7 +1041,7 @@ fn can_annotation_help( debug_assert!(!clauses.is_empty()); // Has clauses are allowed only on the top level of a signature, which we handle elsewhere. - env.problem(roc_problem::can::Problem::IllegalHasClause { + env.problem(roc_problem::can::Problem::IllegalImplementsClause { region: Region::across_all(clauses.iter().map(|clause| &clause.region)), }); @@ -1096,13 +1096,13 @@ fn canonicalize_has_clause( // or an ability that was imported from elsewhere && !scope.abilities_store.is_ability(symbol) { - env.problem(roc_problem::can::Problem::HasClauseIsNotAbility { region }); + env.problem(roc_problem::can::Problem::ImplementsClauseIsNotAbility { region }); return Err(Type::Error); } symbol } _ => { - env.problem(roc_problem::can::Problem::HasClauseIsNotAbility { region }); + env.problem(roc_problem::can::Problem::ImplementsClauseIsNotAbility { region }); return Err(Type::Error); } }; @@ -1111,7 +1111,7 @@ fn canonicalize_has_clause( let already_seen = can_abilities.insert(ability); if already_seen { - env.problem(roc_problem::can::Problem::DuplicateHasAbility { ability, region }); + env.problem(roc_problem::can::Problem::DuplicateImplementsAbility { ability, region }); } } diff --git a/crates/compiler/can/src/def.rs b/crates/compiler/can/src/def.rs index e4dee03468..41d4800cfb 100644 --- a/crates/compiler/can/src/def.rs +++ b/crates/compiler/can/src/def.rs @@ -1388,7 +1388,7 @@ fn resolve_abilities( [] => { // There are no variables bound to the parent ability - then this member doesn't // need to be a part of the ability. - env.problem(Problem::AbilityMemberMissingHasClause { + env.problem(Problem::AbilityMemberMissingImplementsClause { member: member_sym, ability, region: member_name_region, @@ -1411,7 +1411,7 @@ fn resolve_abilities( env.problem(Problem::AbilityMemberMultipleBoundVars { member: member_sym, ability, - span_has_clauses, + span_implements_clauses: span_has_clauses, bound_var_names, }); // Pretend the member isn't a part of the ability diff --git a/crates/compiler/problem/src/can.rs b/crates/compiler/problem/src/can.rs index a81784b239..2136f7314f 100644 --- a/crates/compiler/problem/src/can.rs +++ b/crates/compiler/problem/src/can.rs @@ -117,17 +117,17 @@ pub enum Problem { name: Symbol, variables_region: Region, }, - HasClauseIsNotAbility { + ImplementsClauseIsNotAbility { region: Region, }, - IllegalHasClause { + IllegalImplementsClause { region: Region, }, - DuplicateHasAbility { + DuplicateImplementsAbility { ability: Symbol, region: Region, }, - AbilityMemberMissingHasClause { + AbilityMemberMissingImplementsClause { member: Symbol, ability: Symbol, region: Region, @@ -135,7 +135,7 @@ pub enum Problem { AbilityMemberMultipleBoundVars { member: Symbol, ability: Symbol, - span_has_clauses: Region, + span_implements_clauses: Region, bound_var_names: Vec, }, AbilityNotOnToplevel { @@ -245,10 +245,10 @@ impl Problem { Problem::NestedDatatype { .. } => RuntimeError, Problem::InvalidExtensionType { .. } => RuntimeError, Problem::AbilityHasTypeVariables { .. } => RuntimeError, - Problem::HasClauseIsNotAbility { .. } => RuntimeError, - Problem::IllegalHasClause { .. } => RuntimeError, - Problem::DuplicateHasAbility { .. } => Warning, - Problem::AbilityMemberMissingHasClause { .. } => RuntimeError, + Problem::ImplementsClauseIsNotAbility { .. } => RuntimeError, + Problem::IllegalImplementsClause { .. } => RuntimeError, + Problem::DuplicateImplementsAbility { .. } => Warning, + Problem::AbilityMemberMissingImplementsClause { .. } => RuntimeError, Problem::AbilityMemberMultipleBoundVars { .. } => RuntimeError, Problem::AbilityNotOnToplevel { .. } => RuntimeError, // Ideally, could be compiled Problem::AbilityUsedAsType(_, _, _) => RuntimeError, @@ -375,12 +375,12 @@ impl Problem { variables_region: region, .. } - | Problem::HasClauseIsNotAbility { region } - | Problem::IllegalHasClause { region } - | Problem::DuplicateHasAbility { region, .. } - | Problem::AbilityMemberMissingHasClause { region, .. } + | Problem::ImplementsClauseIsNotAbility { region } + | Problem::IllegalImplementsClause { region } + | Problem::DuplicateImplementsAbility { region, .. } + | Problem::AbilityMemberMissingImplementsClause { region, .. } | Problem::AbilityMemberMultipleBoundVars { - span_has_clauses: region, + span_implements_clauses: region, .. } | Problem::AbilityNotOnToplevel { region } diff --git a/crates/reporting/src/error/canonicalize.rs b/crates/reporting/src/error/canonicalize.rs index 70ef2e0dc5..a3332a06f2 100644 --- a/crates/reporting/src/error/canonicalize.rs +++ b/crates/reporting/src/error/canonicalize.rs @@ -648,7 +648,7 @@ pub fn can_problem<'b>( title = ABILITY_HAS_TYPE_VARIABLES.to_string(); } - Problem::HasClauseIsNotAbility { + Problem::ImplementsClauseIsNotAbility { region: clause_region, } => { doc = alloc.stack([ @@ -660,7 +660,7 @@ pub fn can_problem<'b>( title = IMPLEMENTS_CLAUSE_IS_NOT_AN_ABILITY.to_string(); } - Problem::IllegalHasClause { region } => { + Problem::IllegalImplementsClause { region } => { doc = alloc.stack([ alloc.concat([ alloc.reflow("An "), @@ -678,7 +678,7 @@ pub fn can_problem<'b>( title = ILLEGAL_IMPLEMENTS_CLAUSE.to_string(); } - Problem::DuplicateHasAbility { ability, region } => { + Problem::DuplicateImplementsAbility { ability, region } => { doc = alloc.stack([ alloc.concat([ alloc.reflow("I already saw that this type variable is bound to the "), @@ -695,7 +695,7 @@ pub fn can_problem<'b>( title = "DUPLICATE BOUND ABILITY".to_string(); } - Problem::AbilityMemberMissingHasClause { + Problem::AbilityMemberMissingImplementsClause { member, ability, region, @@ -732,7 +732,7 @@ pub fn can_problem<'b>( Problem::AbilityMemberMultipleBoundVars { member, ability, - span_has_clauses, + span_implements_clauses: span_has_clauses, mut bound_var_names, } => { doc = alloc.stack([ From 43e6cf6f907934c7958690f8bde2db73a5872091 Mon Sep 17 00:00:00 2001 From: Bryce Miller Date: Sat, 20 May 2023 21:36:55 -0400 Subject: [PATCH 015/176] Fix typo --- crates/reporting/src/error/type.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/reporting/src/error/type.rs b/crates/reporting/src/error/type.rs index c039a2770a..9647b0208b 100644 --- a/crates/reporting/src/error/type.rs +++ b/crates/reporting/src/error/type.rs @@ -399,7 +399,7 @@ fn underivable_hint<'b>( Some(alloc.tip().append(alloc.concat([ alloc.reflow("This type variable is not bound to "), alloc.symbol_unqualified(ability), - alloc.reflow(". Consider adding a "), + alloc.reflow(". Consider adding an "), alloc.keyword("implements"), alloc.reflow(" clause to bind the type variable, like "), alloc.inline_type_block(alloc.concat([ From 95516d585afcafdaae7a7757f6401ab28bdd1a4f Mon Sep 17 00:00:00 2001 From: Bryce Miller Date: Sun, 21 May 2023 19:03:53 -0400 Subject: [PATCH 016/176] Update formatter `has` -> `implements` --- crates/compiler/fmt/src/annotation.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/compiler/fmt/src/annotation.rs b/crates/compiler/fmt/src/annotation.rs index 78ae3eb5d5..7b6c969dad 100644 --- a/crates/compiler/fmt/src/annotation.rs +++ b/crates/compiler/fmt/src/annotation.rs @@ -654,7 +654,7 @@ impl<'a> Formattable for ImplementsClause<'a> { fn format_with_options(&self, buf: &mut Buf, parens: Parens, newlines: Newlines, indent: u16) { buf.push_str(self.var.value.extract_spaces().item); buf.spaces(1); - buf.push_str("has"); + buf.push_str("implements"); buf.spaces(1); for (i, ab) in self.abilities.iter().enumerate() { @@ -753,7 +753,7 @@ impl<'a> Formattable for ImplementsAbilities<'a> { buf.newline(); buf.indent(indent); } - buf.push_str("has"); + buf.push_str("implements"); buf.spaces(1); fmt_collection(buf, indent, Braces::Square, *has_abilities, Newlines::No); } From 8191c49ab02d9e7e0fe155cde1fda1b675710c92 Mon Sep 17 00:00:00 2001 From: Bryce Miller Date: Sun, 21 May 2023 19:52:49 -0400 Subject: [PATCH 017/176] `has` -> `implements` in reporting tests --- crates/reporting/tests/test_reporting.rs | 317 ++++++++++++----------- 1 file changed, 159 insertions(+), 158 deletions(-) diff --git a/crates/reporting/tests/test_reporting.rs b/crates/reporting/tests/test_reporting.rs index 9096c1bf1b..098e7a7b20 100644 --- a/crates/reporting/tests/test_reporting.rs +++ b/crates/reporting/tests/test_reporting.rs @@ -6488,7 +6488,7 @@ In roc, functions are always written as a lambda, like{} inference_var_conflict_in_rigid_links, indoc!( r#" - f : a -> (_ -> b) | a has Eq + f : a -> (_ -> b) | a implements Eq f = \x -> \y -> if x == y then x else y f "# @@ -6499,17 +6499,17 @@ In roc, functions are always written as a lambda, like{} Something is off with the body of the `f` definition: - 4│ f : a -> (_ -> b) | a has Eq + 4│ f : a -> (_ -> b) | a implements Eq 5│ f = \x -> \y -> if x == y then x else y ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ The body is an anonymous function of type: - a -> a | a has Eq, a has Eq + a -> a | a implements Eq, a implements Eq But the type annotation on `f` says it should be: - a -> b | a has Eq + a -> b | a implements Eq Tip: Your type annotation uses `b` and `a` as separate type variables. Your code seems to be saying they are the same though. Maybe they @@ -8206,8 +8206,8 @@ In roc, functions are always written as a lambda, like{} ability_first_demand_not_indented_enough, indoc!( r#" - MEq has - eq : a, a -> U64 | a has MEq + MEq implements + eq : a, a -> U64 | a implements MEq 1 "# @@ -8218,8 +8218,8 @@ In roc, functions are always written as a lambda, like{} I was partway through parsing an ability definition, but I got stuck here: - 4│ MEq has - 5│ eq : a, a -> U64 | a has MEq + 4│ MEq implements + 5│ eq : a, a -> U64 | a implements MEq ^ I suspect this line is not indented enough (by 1 spaces) @@ -8230,9 +8230,9 @@ In roc, functions are always written as a lambda, like{} ability_demands_not_indented_with_first, indoc!( r#" - MEq has - eq : a, a -> U64 | a has MEq - neq : a, a -> U64 | a has MEq + MEq implements + eq : a, a -> U64 | a implements MEq + neq : a, a -> U64 | a implements MEq 1 "# @@ -8243,8 +8243,8 @@ In roc, functions are always written as a lambda, like{} I was partway through parsing an ability definition, but I got stuck here: - 5│ eq : a, a -> U64 | a has MEq - 6│ neq : a, a -> U64 | a has MEq + 5│ eq : a, a -> U64 | a implements MEq + 6│ neq : a, a -> U64 | a implements MEq ^ I suspect this line is indented too much (by 4 spaces)"# @@ -8254,8 +8254,8 @@ In roc, functions are always written as a lambda, like{} ability_demand_value_has_args, indoc!( r#" - MEq has - eq b c : a, a -> U64 | a has MEq + MEq implements + eq b c : a, a -> U64 | a implements MEq 1 "# @@ -8266,8 +8266,8 @@ In roc, functions are always written as a lambda, like{} I was partway through parsing an ability definition, but I got stuck here: - 4│ MEq has - 5│ eq b c : a, a -> U64 | a has MEq + 4│ MEq implements + 5│ eq b c : a, a -> U64 | a implements MEq ^ I was expecting to see a : annotating the signature of this value @@ -8278,7 +8278,7 @@ In roc, functions are always written as a lambda, like{} ability_non_signature_expression, indoc!( r#" - MEq has + MEq implememts 123 1 @@ -8290,7 +8290,7 @@ In roc, functions are always written as a lambda, like{} I was partway through parsing an ability definition, but I got stuck here: - 4│ MEq has + 4│ MEq implements 5│ 123 ^ @@ -8416,8 +8416,8 @@ In roc, functions are always written as a lambda, like{} r#" app "test" provides [] to "./platform" - MHash a b c has - hash : a -> U64 | a has MHash + MHash a b c implements + hash : a -> U64 | a implements MHash "# ), @r###" @@ -8425,7 +8425,7 @@ In roc, functions are always written as a lambda, like{} The definition of the `MHash` ability includes type variables: - 3│ MHash a b c has + 3│ MHash a b c implements ^^^^^ Abilities cannot depend on type variables, but their member values @@ -8435,7 +8435,7 @@ In roc, functions are always written as a lambda, like{} `MHash` is not used anywhere in your code. - 3│ MHash a b c has + 3│ MHash a b c implements ^^^^^ If you didn't intend on using `MHash` then remove it so future readers @@ -8449,16 +8449,16 @@ In roc, functions are always written as a lambda, like{} r#" app "test" provides [hash] to "./platform" - MHash has hash : a, b -> Num.U64 | a has MHash, b has Bool.Bool + MHash implements hash : a, b -> Num.U64 | a implements MHash, b implements Bool.Bool "# ), @r###" - ── HAS CLAUSE IS NOT AN ABILITY ────────────────────────── /code/proj/Main.roc ─ + ── IMPLEMENTS CLAUSE IS NOT AN ABILITY ──────────────────── /code/proj/Main.roc ─ - The type referenced in this "has" clause is not an ability: + The type referenced in this "implememts" clause is not an ability: - 3│ MHash has hash : a, b -> Num.U64 | a has MHash, b has Bool.Bool - ^^^^^^^^^ + 3│ MHash has hash : a, b -> Num.U64 | a implements MHash, b implements Bool.Bool + ^^^^^^^^^ "### ); @@ -8468,7 +8468,7 @@ In roc, functions are always written as a lambda, like{} r#" app "test" provides [ab1] to "./platform" - Ab1 has ab1 : a -> {} | a has Ab1, a has Ab1 + Ab1 implements ab1 : a -> {} | a implements Ab1, a implements Ab1 "# ), @r#" @@ -8476,13 +8476,13 @@ In roc, functions are always written as a lambda, like{} The `a` name is first defined here: - 3│ Ab1 has ab1 : a -> {} | a has Ab1, a has Ab1 - ^^^^^^^^^ + 3│ Ab1 implements ab1 : a -> {} | a implements Ab1, a implements Ab1 + ^^^^^^^^^^^^^^^^ But then it's defined a second time here: - 3│ Ab1 has ab1 : a -> {} | a has Ab1, a has Ab1 - ^^^^^^^^^ + 3│ Ab1 implements ab1 : a -> {} | a implements Ab1, a implements Ab1 + ^^^^^^^^^^^^^^^^ Since these variables have the same name, it's easy to use the wrong one by accident. Give one of them a new name. @@ -8495,9 +8495,9 @@ In roc, functions are always written as a lambda, like{} r#" app "test" provides [ab] to "./platform" - Ability has ab : a -> U64 | a has Ability + Ability implements ab : a -> U64 | a implements Ability - Ability has ab1 : a -> U64 | a has Ability + Ability implements ab1 : a -> U64 | a implements Ability "# ), @r#" @@ -8505,12 +8505,12 @@ In roc, functions are always written as a lambda, like{} The `Ability` name is first defined here: - 3│ Ability has ab : a -> U64 | a has Ability + 3│ Ability implements ab : a -> U64 | a implements Ability ^^^^^^^ But then it's defined a second time here: - 5│ Ability has ab1 : a -> U64 | a has Ability + 5│ Ability implements ab1 : a -> U64 | a implements Ability ^^^^^^^ Since these abilities have the same name, it's easy to use the wrong @@ -8524,22 +8524,22 @@ In roc, functions are always written as a lambda, like{} r#" app "test" provides [] to "./platform" - Ability has ab : {} -> {} + Ability implements ab : {} -> {} "# ), @r#" - ── ABILITY MEMBER MISSING HAS CLAUSE ───────────────────── /code/proj/Main.roc ─ + ── ABILITY MEMBER MISSING IMPLEMENTS CLAUSE ────────────── /code/proj/Main.roc ─ - The definition of the ability member `ab` does not include a `has` clause + The definition of the ability member `ab` does not include an `implements` clause binding a type variable to the ability `Ability`: - 3│ Ability has ab : {} -> {} - ^^ + 3│ Ability implements ab : {} -> {} + ^^ - Ability members must include a `has` clause binding a type variable to + Ability members must include an `implements` clause binding a type variable to an ability, like - a has Ability + a implements Ability Otherwise, the function does not need to be part of the ability! @@ -8547,7 +8547,7 @@ In roc, functions are always written as a lambda, like{} `Ability` is not used anywhere in your code. - 3│ Ability has ab : {} -> {} + 3│ Ability implements ab : {} -> {} ^^^^^^^ If you didn't intend on using `Ability` then remove it so future readers @@ -8561,7 +8561,7 @@ In roc, functions are always written as a lambda, like{} r#" app "test" provides [] to "./platform" - MEq has eq : a, b -> Bool.Bool | a has MEq, b has MEq + MEq implements eq : a, b -> Bool.Bool | a implements MEq, b implements MEq "# ), @r#" @@ -8570,8 +8570,8 @@ In roc, functions are always written as a lambda, like{} The definition of the ability member `eq` includes multiple variables bound to the `MEq`` ability:` - 3│ MEq has eq : a, b -> Bool.Bool | a has MEq, b has MEq - ^^^^^^^^^^^^^^^^^^^^ + 3│ MEq implements eq : a, b -> Bool.Bool | a implements MEq, b implements MEq + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Ability members can only bind one type variable to their parent ability. Otherwise, I wouldn't know what type implements an ability by @@ -8587,33 +8587,33 @@ In roc, functions are always written as a lambda, like{} r#" app "test" provides [f] to "./platform" - MHash has hash : (a | a has MHash) -> Num.U64 + MHash implements hash : (a | a implements MHash) -> Num.U64 - f : a -> Num.U64 | a has MHash + f : a -> Num.U64 | a implements MHash "# ), @r###" - ── ILLEGAL HAS CLAUSE ──────────────────────────────────── /code/proj/Main.roc ─ + ── ILLEGAL IMPLEMENTS CLAUSE ───────────────────────────── /code/proj/Main.roc ─ - A `has` clause is not allowed here: + An `implements` clause is not allowed here: - 3│ MHash has hash : (a | a has MHash) -> Num.U64 - ^^^^^^^^^^^ + 3│ MHash implements hash : (a | a implements MHash) -> Num.U64 + ^^^^^^^^^^^^^^^^^^ - `has` clauses can only be specified on the top-level type annotations. + `implements` clauses can only be specified on the top-level type annotations. - ── ABILITY MEMBER MISSING HAS CLAUSE ───────────────────── /code/proj/Main.roc ─ + ── ABILITY MEMBER MISSING IMPLEMENTS CLAUSE ────────────── /code/proj/Main.roc ─ - The definition of the ability member `hash` does not include a `has` + The definition of the ability member `hash` does not include an `implements` clause binding a type variable to the ability `MHash`: - 3│ MHash has hash : (a | a has MHash) -> Num.U64 - ^^^^ + 3│ MHash implements hash : (a | a implements MHash) -> Num.U64 + ^^^^ - Ability members must include a `has` clause binding a type variable to + Ability members must include an `implements` clause binding a type variable to an ability, like - a has MHash + a implements MHash Otherwise, the function does not need to be part of the ability! "### @@ -8625,9 +8625,9 @@ In roc, functions are always written as a lambda, like{} r#" app "test" provides [hash] to "./platform" - MHash has hash : a -> U64 | a has MHash + MHash implements hash : a -> U64 | a implements MHash - Id := U32 has [MHash {hash}] + Id := U32 implements [MHash {hash}] hash = \@Id n -> n "# @@ -8656,11 +8656,11 @@ In roc, functions are always written as a lambda, like{} r#" app "test" provides [eq, le] to "./platform" - MEq has - eq : a, a -> Bool | a has MEq - le : a, a -> Bool | a has MEq + MEq implements + eq : a, a -> Bool | a implements MEq + le : a, a -> Bool | a implements MEq - Id := U64 has [MEq {eq}] + Id := U64 implements [MEq {eq}] eq = \@Id m, @Id n -> m == n "# @@ -8670,8 +8670,8 @@ In roc, functions are always written as a lambda, like{} This type does not fully implement the `MEq` ability: - 7│ Id := U64 has [MEq {eq}] - ^^^^^^^^ + 7│ Id := U64 implements [MEq {eq}] + ^^^^^^^^ The following necessary members are missing implementations: @@ -8685,8 +8685,8 @@ In roc, functions are always written as a lambda, like{} r#" app "test" provides [hash] to "./platform" - MHash has - hash : a -> U64 | a has MHash + MHash implements + hash : a -> U64 | a implements MHash hash = \_ -> 0u64 "# @@ -8710,11 +8710,11 @@ In roc, functions are always written as a lambda, like{} r#" app "test" provides [hash, One, Two] to "./platform" - MHash has - hash : a -> U64 | a has MHash + MHash implements + hash : a -> U64 | a implements MHash - One := {} has [MHash {hash}] - Two := {} has [MHash {hash}] + One := {} implements [MHash {hash}] + Two := {} implements [MHash {hash}] hash = \_ -> 0u64 "# @@ -8726,8 +8726,8 @@ In roc, functions are always written as a lambda, like{} This ability member specialization is already claimed to specialize another opaque type: - 7│ Two := {} has [MHash {hash}] - ^^^^ + 7│ Two := {} implements [MHash {hash}] + ^^^^ Previously, we found it to specialize `hash` for `One`. @@ -8764,11 +8764,11 @@ In roc, functions are always written as a lambda, like{} r#" app "test" provides [hash, One, Two] to "./platform" - MHash has - hash : a -> U64 | a has MHash + MHash implements + hash : a -> U64 | a implements MHash - One := {} has [MHash {hash}] - Two := {} has [MHash {hash}] + One := {} implements [MHash {hash}] + Two := {} implements [MHash {hash}] hash = \@One _ -> 0u64 "# @@ -8779,8 +8779,8 @@ In roc, functions are always written as a lambda, like{} This ability member specialization is already claimed to specialize another opaque type: - 7│ Two := {} has [MHash {hash}] - ^^^^ + 7│ Two := {} implements [MHash {hash}] + ^^^^ Previously, we found it to specialize `hash` for `One`. @@ -8795,10 +8795,10 @@ In roc, functions are always written as a lambda, like{} r#" app "test" provides [eq] to "./platform" - MEq has - eq : a, a -> Bool | a has MEq + MEq implements + eq : a, a -> Bool | a implements MEq - You := {} has [MEq {eq}] + You := {} implements [MEq {eq}] AndI := {} eq = \@You {}, @AndI {} -> False @@ -8831,9 +8831,9 @@ In roc, functions are always written as a lambda, like{} app "test" provides [hash] to "./platform" MHash has - hash : a -> U64 | a has MHash + hash : a -> U64 | a implements MHash - Id := U64 has [MHash {hash}] + Id := U64 implements [MHash {hash}] hash : Id -> U32 hash = \@Id n -> n @@ -8865,7 +8865,7 @@ In roc, functions are always written as a lambda, like{} app "test" provides [noGoodVeryBadTerrible] to "./platform" MHash has - hash : a -> U64 | a has MHash + hash : a -> U64 | a implements MHash Id := U64 has [MHash {hash}] @@ -8913,7 +8913,7 @@ In roc, functions are always written as a lambda, like{} main = MHash has - hash : a -> U64 | a has MHash + hash : a -> U64 | a implements MHash 123 "# @@ -8924,7 +8924,7 @@ In roc, functions are always written as a lambda, like{} This ability definition is not on the top-level of a module: 4│> MHash has - 5│> hash : a -> U64 | a has MHash + 5│> hash : a -> U64 | a implements MHash Abilities can only be defined on the top-level of a Roc module. "# @@ -8937,12 +8937,12 @@ In roc, functions are always written as a lambda, like{} app "test" provides [hash, hashable] to "./platform" MHash has - hash : a -> U64 | a has MHash + hash : a -> U64 | a implements MHash Id := U64 has [MHash {hash}] hash = \@Id n -> n - hashable : a | a has MHash + hashable : a | a implements MHash hashable = @Id 15 "# ), @@ -8951,7 +8951,7 @@ In roc, functions are always written as a lambda, like{} Something is off with the body of the `hashable` definition: - 9│ hashable : a | a has MHash + 9│ hashable : a | a implements MHash 10│ hashable = @Id 15 ^^^^^^ @@ -8963,7 +8963,7 @@ In roc, functions are always written as a lambda, like{} a | a has MHash - Note: The type variable `a` says it can take on any value that has the + Note: The type variable `a` says it can take on any value that implements the ability `MHash`. But, I see that the type is only ever used as a a `Id` value. Can you @@ -8978,7 +8978,7 @@ In roc, functions are always written as a lambda, like{} app "test" provides [result] to "./platform" MHash has - hash : a -> U64 | a has MHash + hash : a -> U64 | a implements MHash mulMHashes : MHash, MHash -> U64 mulMHashes = \x, y -> hash x * hash y @@ -9003,9 +9003,9 @@ In roc, functions are always written as a lambda, like{} Abilities can only be used in type annotations to constrain type variables. - Hint: Perhaps you meant to include a `has` annotation, like + Hint: Perhaps you meant to include an `implements` annotation, like - a has MHash + a implements MHash ── ABILITY USED AS TYPE ────────────────────────────────── /code/proj/Main.roc ─ @@ -9017,9 +9017,9 @@ In roc, functions are always written as a lambda, like{} Abilities can only be used in type annotations to constrain type variables. - Hint: Perhaps you meant to include a `has` annotation, like + Hint: Perhaps you meant to include an `implements` annotation, like - b has MHash + b implements MHash "### ); @@ -9153,7 +9153,7 @@ In roc, functions are always written as a lambda, like{} r#" app "test" provides [main] to "./platform" - Default has default : {} -> a | a has Default + Default has default : {} -> a | a implements Default main = A := {} has [Default {default}] @@ -9404,7 +9404,7 @@ In roc, functions are always written as a lambda, like{} r#" app "test" provides [A] to "./platform" - MEq has eq : a, a -> U64 | a has MEq + MEq has eq : a, a -> U64 | a implements MEq A := U8 has [MEq {eq}] "# @@ -9440,7 +9440,7 @@ In roc, functions are always written as a lambda, like{} r#" app "test" provides [A, myMEq] to "./platform" - MEq has eq : a, a -> Bool | a has MEq + MEq has eq : a, a -> Bool | a implements MEq A := U8 has [ MEq {eq: aMEq} ] @@ -9481,7 +9481,7 @@ In roc, functions are always written as a lambda, like{} r#" app "test" provides [A, myMEq] to "./platform" - MEq has eq : a, a -> Bool | a has MEq + MEq has eq : a, a -> Bool | a implements MEq A := U8 has [ MEq {eq ? aMEq} ] @@ -9559,7 +9559,7 @@ In roc, functions are always written as a lambda, like{} r#" app "test" provides [A] to "./platform" - MEq has eq : a, a -> Bool | a has MEq + MEq has eq : a, a -> Bool | a implements MEq A := U8 has [ MEq {eq : Bool.eq} ] "# @@ -9594,7 +9594,7 @@ In roc, functions are always written as a lambda, like{} r#" app "test" provides [A] to "./platform" - MEq has eq : a, a -> Bool | a has MEq + MEq has eq : a, a -> Bool | a implements MEq A := U8 has [ MEq {eq : \m, n -> m == n} ] "# @@ -9631,7 +9631,7 @@ In roc, functions are always written as a lambda, like{} r#" app "test" provides [A] to "./platform" - MEq has eq : a, a -> Bool | a has MEq + MEq has eq : a, a -> Bool | a implements MEq A := U8 has [ MEq {eq: eqA, eq: eqA} ] @@ -9684,7 +9684,7 @@ In roc, functions are always written as a lambda, like{} r#" app "test" provides [A] to "./platform" - Ab has ab : a -> a | a has Ab + Ab has ab : a -> a | a implements Ab A := {} has [Ab] "# @@ -9945,9 +9945,9 @@ In roc, functions are always written as a lambda, like{} r#" app "test" provides [x] to "./platform" - Foo has foo : a -> a | a has Foo + Foo has foo : a -> a | a implements Foo - F a b := b | a has Foo + F a b := b | a implements Foo MHash := {} @@ -10475,7 +10475,7 @@ I recommend using camelCase. It's the standard style in Roc code! r#" app "test" provides [hash, Id] to "./platform" - MHash has hash : a -> U64 | a has MHash + MHash has hash : a -> U64 | a implements MHash Id := {} @@ -10501,7 +10501,7 @@ I recommend using camelCase. It's the standard style in Roc code! r#" app "test" provides [hash, Id, Id2] to "./platform" - MHash has hash : a -> U64 | a has MHash + MHash has hash : a -> U64 | a implements MHash Id := {} has [MHash {hash}] Id2 := {} @@ -10657,7 +10657,7 @@ I recommend using camelCase. It's the standard style in Roc code! app "test" imports [Decode.{decoder}] provides [main] to "./platform" main = - myDecoder : Decoder (a -> a) fmt | fmt has DecoderFormatting + myDecoder : Decoder (a -> a) fmt | fmt implements DecoderFormatting myDecoder = decoder myDecoder @@ -10688,7 +10688,7 @@ I recommend using camelCase. It's the standard style in Roc code! A := {} main = - myDecoder : Decoder {x : A} fmt | fmt has DecoderFormatting + myDecoder : Decoder {x : A} fmt | fmt implements DecoderFormatting myDecoder = decoder myDecoder @@ -10907,7 +10907,7 @@ I recommend using camelCase. It's the standard style in Roc code! app "test" imports [Decode.{decoder}] provides [main] to "./platform" main = - myDecoder : Decoder {x : Str, y ? Str} fmt | fmt has DecoderFormatting + myDecoder : Decoder {x : Str, y ? Str} fmt | fmt implements DecoderFormatting myDecoder = decoder myDecoder @@ -11320,7 +11320,7 @@ I recommend using camelCase. It's the standard style in Roc code! r#" app "test" provides [main] to "./platform" - foo : a -> {} | a has Hash + foo : a -> {} | a implements Hash main = foo {a: "", b: 1} "# @@ -11334,7 +11334,7 @@ I recommend using camelCase. It's the standard style in Roc code! r#" app "test" provides [main] to "./platform" - foo : a -> {} | a has Hash + foo : a -> {} | a implements Hash t : [A {}, B U8 U64, C Str] @@ -11350,7 +11350,7 @@ I recommend using camelCase. It's the standard style in Roc code! r#" app "test" provides [main] to "./platform" - foo : a -> {} | a has Hash + foo : a -> {} | a implements Hash main = foo (\x -> x) "# @@ -11377,7 +11377,7 @@ I recommend using camelCase. It's the standard style in Roc code! r#" app "test" provides [main] to "./platform" - foo : a -> {} | a has Hash + foo : a -> {} | a implements Hash main = foo (A (\x -> x) B) "# @@ -11410,7 +11410,7 @@ I recommend using camelCase. It's the standard style in Roc code! r#" app "test" provides [main] to "./platform" - foo : a -> {} | a has Hash + foo : a -> {} | a implements Hash main = foo ("", 1) "# @@ -11423,7 +11423,7 @@ I recommend using camelCase. It's the standard style in Roc code! r#" app "test" provides [main] to "./platform" - foo : a -> {} | a has Hash + foo : a -> {} | a implements Hash main = foo ("", \{} -> {}) "# @@ -11705,7 +11705,7 @@ I recommend using camelCase. It's the standard style in Roc code! r#" app "test" provides [main] to "./platform" - foo : a -> {} | a has Eq + foo : a -> {} | a implements Eq main = foo {a: "", b: 1} "# @@ -11719,7 +11719,7 @@ I recommend using camelCase. It's the standard style in Roc code! r#" app "test" provides [main] to "./platform" - foo : a -> {} | a has Eq + foo : a -> {} | a implements Eq t : [A {}, B U8 U64, C Str] @@ -11735,7 +11735,7 @@ I recommend using camelCase. It's the standard style in Roc code! r#" app "test" provides [main] to "./platform" - foo : a -> {} | a has Eq + foo : a -> {} | a implements Eq main = foo (\x -> x) "# @@ -11762,7 +11762,7 @@ I recommend using camelCase. It's the standard style in Roc code! r#" app "test" provides [main] to "./platform" - foo : a -> {} | a has Eq + foo : a -> {} | a implements Eq main = foo (A (\x -> x) B) "# @@ -11841,7 +11841,7 @@ I recommend using camelCase. It's the standard style in Roc code! r#" app "test" provides [main] to "./platform" - foo : a -> {} | a has Eq + foo : a -> {} | a implements Eq main = foo ("", 1) "# @@ -11854,7 +11854,7 @@ I recommend using camelCase. It's the standard style in Roc code! r#" app "test" provides [main] to "./platform" - foo : a -> {} | a has Eq + foo : a -> {} | a implements Eq main = foo ("", 1.0f64) "# @@ -11934,7 +11934,7 @@ I recommend using camelCase. It's the standard style in Roc code! r#" app "test" provides [f] to "./platform" - F a : a | a has Hash + F a : a | a implements Hash f : F ({} -> {}) "# @@ -12033,7 +12033,7 @@ I recommend using camelCase. It's the standard style in Roc code! duplicate_ability_in_has_clause, indoc!( r#" - f : a -> {} | a has Hash & Hash + f : a -> {} | a implements Hash & Hash f "# @@ -12044,10 +12044,10 @@ I recommend using camelCase. It's the standard style in Roc code! I already saw that this type variable is bound to the `Hash` ability once before: - 4│ f : a -> {} | a has Hash & Hash - ^^^^ + 4│ f : a -> {} | a implements Hash & Hash + ^^^^ - Abilities only need to bound to a type variable once in a `has` clause! + Abilities only need to bound to a type variable once in an `implements` clause! "### ); @@ -12057,9 +12057,9 @@ I recommend using camelCase. It's the standard style in Roc code! r#" app "test" provides [main] to "./platform" - g : x -> x | x has Decoding & Encoding + g : x -> x | x implements Decoding & Encoding - main : x -> x | x has Encoding + main : x -> x | x implements Encoding main = \x -> g x "# ), @@ -12073,17 +12073,17 @@ I recommend using camelCase. It's the standard style in Roc code! This `x` value is a: - x | x has Encoding + x | x implements Encoding But `g` needs its 1st argument to be: - x | x has Encoding & Decoding + x | x implements Encoding & Decoding Note: The type variable `x` says it can take on any value that has only the ability `Encoding`. - But, I see that it's also used as if it has the ability `Decoding`. Can - you use `x` without that ability? If not, consider adding it to the `has` + But, I see that it's also used as if it implements the ability `Decoding`. Can + you use `x` without that ability? If not, consider adding it to the `implements` clause of `x`. "### ); @@ -12094,9 +12094,9 @@ I recommend using camelCase. It's the standard style in Roc code! r#" app "test" provides [main] to "./platform" - g : x -> x | x has Decoding & Encoding & Hash + g : x -> x | x implements Decoding & Encoding & Hash - main : x -> x | x has Encoding + main : x -> x | x implements Encoding main = \x -> g x "# ), @@ -12110,18 +12110,18 @@ I recommend using camelCase. It's the standard style in Roc code! This `x` value is a: - x | x has Encoding + x | x implements Encoding But `g` needs its 1st argument to be: - x | x has Hash & Encoding & Decoding + x | x implements Hash & Encoding & Decoding - Note: The type variable `x` says it can take on any value that has only + Note: The type variable `x` says it can take on any value that implements only the ability `Encoding`. - But, I see that it's also used as if it has the abilities `Hash` and + But, I see that it's also used as if it implements the abilities `Hash` and `Decoding`. Can you use `x` without those abilities? If not, consider - adding them to the `has` clause of `x`. + adding them to the `implements` clause of `x`. "### ); @@ -12131,10 +12131,10 @@ I recommend using camelCase. It's the standard style in Roc code! r#" app "test" provides [main] to "./platform" - f : x -> x | x has Hash - g : x -> x | x has Decoding & Encoding + f : x -> x | x implements Hash + g : x -> x | x implements Decoding & Encoding - main : x -> x | x has Hash & Encoding + main : x -> x | x implements Hash & Encoding main = \x -> g (f x) "# ), @@ -12148,17 +12148,17 @@ I recommend using camelCase. It's the standard style in Roc code! This `f` call produces: - x | x has Hash & Encoding + x | x implements Hash & Encoding But `g` needs its 1st argument to be: - x | x has Encoding & Decoding + x | x implements Encoding & Decoding - Note: The type variable `x` says it can take on any value that has only + Note: The type variable `x` says it can take on any value that implements only the abilities `Hash` and `Encoding`. - But, I see that it's also used as if it has the ability `Decoding`. Can - you use `x` without that ability? If not, consider adding it to the `has` + But, I see that it's also used as if it implements the ability `Decoding`. Can + you use `x` without that ability? If not, consider adding it to the `implements` clause of `x`. "### ); @@ -12898,8 +12898,9 @@ I recommend using camelCase. It's the standard style in Roc code! cannot be generated. - Tip: This type variable is not bound to `Eq`. Consider adding a `has` - clause to bind the type variable, like `| e has Bool.Eq` + Tip: This type variable is not bound to `Eq`. Consider adding an + `implements` clause to bind the type variable, like + `| e implements Bool.Eq` "### ); @@ -13365,7 +13366,7 @@ I recommend using camelCase. It's the standard style in Roc code! app "test" imports [Decode.{decoder}] provides [main] to "./platform" main = - myDecoder : Decoder Nat fmt | fmt has DecoderFormatting + myDecoder : Decoder Nat fmt | fmt implements DecoderFormatting myDecoder = decoder myDecoder @@ -13429,7 +13430,7 @@ I recommend using camelCase. It's the standard style in Roc code! app "test" imports [Decode.{decoder}] provides [main] to "./platform" main = - myDecoder : Decoder (U32, Str) fmt | fmt has DecoderFormatting + myDecoder : Decoder (U32, Str) fmt | fmt implements DecoderFormatting myDecoder = decoder myDecoder @@ -13444,7 +13445,7 @@ I recommend using camelCase. It's the standard style in Roc code! app "test" imports [Decode.{decoder}] provides [main] to "./platform" main = - myDecoder : Decoder (U32, {} -> {}) fmt | fmt has DecoderFormatting + myDecoder : Decoder (U32, {} -> {}) fmt | fmt implements DecoderFormatting myDecoder = decoder myDecoder From 31c06ca9793a17cdb06f333cc8fa0a7ffdaa7072 Mon Sep 17 00:00:00 2001 From: Bryce Miller Date: Sun, 21 May 2023 19:54:58 -0400 Subject: [PATCH 018/176] `has` -> `implements` --- crates/compiler/solve/tests/solve_expr.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/crates/compiler/solve/tests/solve_expr.rs b/crates/compiler/solve/tests/solve_expr.rs index 58cf662de3..584d7f1036 100644 --- a/crates/compiler/solve/tests/solve_expr.rs +++ b/crates/compiler/solve/tests/solve_expr.rs @@ -3411,7 +3411,7 @@ mod solve_expr { infer_eq_without_problem( indoc!( r#" - reconstructPath : Dict position position, position -> List position | position has Hash & Eq + reconstructPath : Dict position position, position -> List position | position implements Hash & Eq reconstructPath = \cameFrom, goal -> when Dict.get cameFrom goal is Err KeyNotFound -> @@ -3458,7 +3458,7 @@ mod solve_expr { Model position : { openSet : Set position } - cheapestOpen : Model position -> Result position [KeyNotFound] | position has Hash & Eq + cheapestOpen : Model position -> Result position [KeyNotFound] | position implements Hash & Eq cheapestOpen = \model -> folder = \resSmallestSoFar, position -> @@ -3473,7 +3473,7 @@ mod solve_expr { Set.walk model.openSet (Ok { position: boom {}, cost: 0.0 }) folder |> Result.map (\x -> x.position) - astar : Model position -> Result position [KeyNotFound] | position has Hash & Eq + astar : Model position -> Result position [KeyNotFound] | position implements Hash & Eq astar = \model -> cheapestOpen model main = @@ -4122,7 +4122,7 @@ mod solve_expr { Key k : Num k - removeHelpEQGT : Key k, RBTree (Key k) v -> RBTree (Key k) v | k has Hash & Eq + removeHelpEQGT : Key k, RBTree (Key k) v -> RBTree (Key k) v | k implements Hash & Eq removeHelpEQGT = \targetKey, dict -> when dict is Node color key value left right -> @@ -4236,7 +4236,7 @@ mod solve_expr { _ -> Empty - removeHelp : Key k, RBTree (Key k) v -> RBTree (Key k) v | k has Hash & Eq + removeHelp : Key k, RBTree (Key k) v -> RBTree (Key k) v | k implements Hash & Eq removeHelp = \targetKey, dict -> when dict is Empty -> @@ -4324,7 +4324,7 @@ mod solve_expr { RBTree k v : [Node NodeColor k v (RBTree k v) (RBTree k v), Empty] - removeHelp : Num k, RBTree (Num k) v -> RBTree (Num k) v | k has Hash & Eq + removeHelp : Num k, RBTree (Num k) v -> RBTree (Num k) v | k implements Hash & Eq removeHelp = \targetKey, dict -> when dict is Empty -> @@ -4359,7 +4359,7 @@ mod solve_expr { removeHelpPrepEQGT : Key k, RBTree (Key k) v, NodeColor, (Key k), v, RBTree (Key k) v, RBTree (Key k) v -> RBTree (Key k) v - removeHelpEQGT : Key k, RBTree (Key k) v -> RBTree (Key k) v | k has Hash & Eq + removeHelpEQGT : Key k, RBTree (Key k) v -> RBTree (Key k) v | k implements Hash & Eq removeHelpEQGT = \targetKey, dict -> when dict is Node color key value left right -> From 9bd207701011e2b82a05f2abadb78908976b919b Mon Sep 17 00:00:00 2001 From: Bryce Miller Date: Mon, 22 May 2023 21:59:02 -0400 Subject: [PATCH 019/176] `has [...]` -> `implements [...]` --- crates/reporting/tests/test_reporting.rs | 200 +++++++++++------------ 1 file changed, 100 insertions(+), 100 deletions(-) diff --git a/crates/reporting/tests/test_reporting.rs b/crates/reporting/tests/test_reporting.rs index 098e7a7b20..0bfef5101c 100644 --- a/crates/reporting/tests/test_reporting.rs +++ b/crates/reporting/tests/test_reporting.rs @@ -8747,7 +8747,7 @@ In roc, functions are always written as a lambda, like{} But the type annotation on `hash` says it must match: - a -> U64 | a has MHash + a -> U64 | a implements MHash Note: The specialized type is too general, and does not provide a concrete type where a type variable is bound to an ability. @@ -8867,7 +8867,7 @@ In roc, functions are always written as a lambda, like{} MHash has hash : a -> U64 | a implements MHash - Id := U64 has [MHash {hash}] + Id := U64 implements [MHash {hash}] hash = \@Id n -> n @@ -8939,7 +8939,7 @@ In roc, functions are always written as a lambda, like{} MHash has hash : a -> U64 | a implements MHash - Id := U64 has [MHash {hash}] + Id := U64 implements [MHash {hash}] hash = \@Id n -> n hashable : a | a implements MHash @@ -8961,7 +8961,7 @@ In roc, functions are always written as a lambda, like{} But the type annotation on `hashable` says it should be: - a | a has MHash + a | a implements MHash Note: The type variable `a` says it can take on any value that implements the ability `MHash`. @@ -8983,10 +8983,10 @@ In roc, functions are always written as a lambda, like{} mulMHashes : MHash, MHash -> U64 mulMHashes = \x, y -> hash x * hash y - Id := U64 has [MHash {hash: hashId}] + Id := U64 implements [MHash {hash: hashId}] hashId = \@Id n -> n - Three := {} has [MHash {hash: hashThree}] + Three := {} implements [MHash {hash: hashThree}] hashThree = \@Three _ -> 3 result = mulMHashes (@Id 100) (@Three {}) @@ -9156,7 +9156,7 @@ In roc, functions are always written as a lambda, like{} Default has default : {} -> a | a implements Default main = - A := {} has [Default {default}] + A := {} implements [Default {default}] default = \{} -> @A {} default {} "# @@ -9406,7 +9406,7 @@ In roc, functions are always written as a lambda, like{} MEq has eq : a, a -> U64 | a implements MEq - A := U8 has [MEq {eq}] + A := U8 implements [MEq {eq}] "# ), @r###" @@ -9414,8 +9414,8 @@ In roc, functions are always written as a lambda, like{} An implementation of `eq` could not be found in this scope: - 5│ A := U8 has [MEq {eq}] - ^^ + 5│ A := U8 implements [MEq {eq}] + ^^ Tip: consider adding a value of name `eq` in this scope, or using another variable that implements this ability member, like @@ -9425,8 +9425,8 @@ In roc, functions are always written as a lambda, like{} This type does not fully implement the `MEq` ability: - 5│ A := U8 has [MEq {eq}] - ^^^^^^^^ + 5│ A := U8 implements [MEq {eq}] + ^^^^^^^^ The following necessary members are missing implementations: @@ -9442,7 +9442,7 @@ In roc, functions are always written as a lambda, like{} MEq has eq : a, a -> Bool | a implements MEq - A := U8 has [ MEq {eq: aMEq} ] + A := U8 implements [ MEq {eq: aMEq} ] myMEq = \m, n -> m == n "# @@ -9452,8 +9452,8 @@ In roc, functions are always written as a lambda, like{} Nothing is named `aMEq` in this scope. - 5│ A := U8 has [ MEq {eq: aMEq} ] - ^^^^ + 5│ A := U8 implements [ MEq {eq: aMEq} ] + ^^^^ Did you mean one of these? @@ -9466,8 +9466,8 @@ In roc, functions are always written as a lambda, like{} This type does not fully implement the `MEq` ability: - 5│ A := U8 has [ MEq {eq: aMEq} ] - ^^^^^^^^^^^^^^ + 5│ A := U8 implements [ MEq {eq: aMEq} ] + ^^^^^^^^^^^^^^ The following necessary members are missing implementations: @@ -9483,7 +9483,7 @@ In roc, functions are always written as a lambda, like{} MEq has eq : a, a -> Bool | a implements MEq - A := U8 has [ MEq {eq ? aMEq} ] + A := U8 implements [ MEq {eq ? aMEq} ] myMEq = \m, n -> m == n "# @@ -9493,8 +9493,8 @@ In roc, functions are always written as a lambda, like{} Ability implementations cannot be optional: - 5│ A := U8 has [ MEq {eq ? aMEq} ] - ^^^^^^^^^ + 5│ A := U8 implements [ MEq {eq ? aMEq} ] + ^^^^^^^^^ Custom implementations must be supplied fully. @@ -9504,8 +9504,8 @@ In roc, functions are always written as a lambda, like{} This type does not fully implement the `MEq` ability: - 5│ A := U8 has [ MEq {eq ? aMEq} ] - ^^^^^^^^^^^^^^^ + 5│ A := U8 implements [ MEq {eq ? aMEq} ] + ^^^^^^^^^^^^^^^ The following necessary members are missing implementations: @@ -9521,7 +9521,7 @@ In roc, functions are always written as a lambda, like{} imports [] provides [A, myEncoder] to "./platform" - A := U8 has [ Encoding {toEncoder ? myEncoder} ] + A := U8 implements [ Encoding {toEncoder ? myEncoder} ] myEncoder = 1 "# @@ -9531,21 +9531,21 @@ In roc, functions are always written as a lambda, like{} Ability implementations cannot be optional: - 5│ A := U8 has [ Encoding {toEncoder ? myEncoder} ] - ^^^^^^^^^^^^^^^^^^^^^ + 5│ A := U8 implements [ Encoding {toEncoder ? myEncoder} ] + ^^^^^^^^^^^^^^^^^^^^^ Custom implementations must be supplied fully. Hint: if you want this implementation to be derived, don't include a - record of implementations. For example, has [Encoding] will attempt + record of implementations. For example, implements [Encoding] will attempt to derive `Encoding` ── INCOMPLETE ABILITY IMPLEMENTATION ───────────────────── /code/proj/Main.roc ─ This type does not fully implement the `Encoding` ability: - 5│ A := U8 has [ Encoding {toEncoder ? myEncoder} ] - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + 5│ A := U8 implements [ Encoding {toEncoder ? myEncoder} ] + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ The following necessary members are missing implementations: @@ -9561,7 +9561,7 @@ In roc, functions are always written as a lambda, like{} MEq has eq : a, a -> Bool | a implements MEq - A := U8 has [ MEq {eq : Bool.eq} ] + A := U8 implements [ MEq {eq : Bool.eq} ] "# ), @r###" @@ -9569,8 +9569,8 @@ In roc, functions are always written as a lambda, like{} This ability implementation is qualified: - 5│ A := U8 has [ MEq {eq : Bool.eq} ] - ^^^^^^^ + 5│ A := U8 implements [ MEq {eq : Bool.eq} ] + ^^^^^^^ Custom implementations must be defined in the local scope, and unqualified. @@ -9579,8 +9579,8 @@ In roc, functions are always written as a lambda, like{} This type does not fully implement the `MEq` ability: - 5│ A := U8 has [ MEq {eq : Bool.eq} ] - ^^^^^^^^^^^^^^^^^^ + 5│ A := U8 implements [ MEq {eq : Bool.eq} ] + ^^^^^^^^^^^^^^^^^^ The following necessary members are missing implementations: @@ -9596,7 +9596,7 @@ In roc, functions are always written as a lambda, like{} MEq has eq : a, a -> Bool | a implements MEq - A := U8 has [ MEq {eq : \m, n -> m == n} ] + A := U8 implements [ MEq {eq : \m, n -> m == n} ] "# ), @r###" @@ -9604,8 +9604,8 @@ In roc, functions are always written as a lambda, like{} This ability implementation is not an identifier: - 5│ A := U8 has [ MEq {eq : \m, n -> m == n} ] - ^^^^^^^^^^^^^^^ + 5│ A := U8 implements [ MEq {eq : \m, n -> m == n} ] + ^^^^^^^^^^^^^^^ Custom ability implementations defined in this position can only be unqualified identifiers, not arbitrary expressions. @@ -9616,8 +9616,8 @@ In roc, functions are always written as a lambda, like{} This type does not fully implement the `MEq` ability: - 5│ A := U8 has [ MEq {eq : \m, n -> m == n} ] - ^^^^^^^^^^^^^^^^^^^^^^^^^^ + 5│ A := U8 implements [ MEq {eq : \m, n -> m == n} ] + ^^^^^^^^^^^^^^^^^^^^^^^^^^ The following necessary members are missing implementations: @@ -9633,7 +9633,7 @@ In roc, functions are always written as a lambda, like{} MEq has eq : a, a -> Bool | a implements MEq - A := U8 has [ MEq {eq: eqA, eq: eqA} ] + A := U8 implements [ MEq {eq: eqA, eq: eqA} ] eqA = \@A m, @A n -> m == n "# @@ -9643,13 +9643,13 @@ In roc, functions are always written as a lambda, like{} This ability member implementation is duplicate: - 5│ A := U8 has [ MEq {eq: eqA, eq: eqA} ] - ^^^^^^^ + 5│ A := U8 implements [ MEq {eq: eqA, eq: eqA} ] + ^^^^^^^ The first implementation was defined here: - 5│ A := U8 has [ MEq {eq: eqA, eq: eqA} ] - ^^^^^^^ + 5│ A := U8 implements [ MEq {eq: eqA, eq: eqA} ] + ^^^^^^^ Only one custom implementation can be defined for an ability member. "### @@ -9663,7 +9663,7 @@ In roc, functions are always written as a lambda, like{} Foo := {} - A := U8 has [ Foo {} ] + A := U8 implements [ Foo {} ] "# ), @r###" @@ -9671,8 +9671,8 @@ In roc, functions are always written as a lambda, like{} This identifier is not an ability in scope: - 5│ A := U8 has [ Foo {} ] - ^^^ + 5│ A := U8 implements [ Foo {} ] + ^^^ Only abilities can be implemented. "### @@ -9686,7 +9686,7 @@ In roc, functions are always written as a lambda, like{} Ab has ab : a -> a | a implements Ab - A := {} has [Ab] + A := {} implements [Ab] "# ), @r###" @@ -9694,8 +9694,8 @@ In roc, functions are always written as a lambda, like{} This ability cannot be derived: - 5│ A := {} has [Ab] - ^^ + 5│ A := {} implements [Ab] + ^^ Only builtin abilities can be derived. @@ -9709,7 +9709,7 @@ In roc, functions are always written as a lambda, like{} r#" app "test" imports [] provides [A] to "./platform" - A a := a -> a has [Encode.Encoding] + A a := a -> a implements [Encode.Encoding] "# ), @r###" @@ -9717,8 +9717,8 @@ In roc, functions are always written as a lambda, like{} I can't derive an implementation of the `Encoding` ability for `A`: - 3│ A a := a -> a has [Encode.Encoding] - ^^^^^^^^^^^^^^^ + 3│ A a := a -> a implements [Encode.Encoding] + ^^^^^^^^^^^^^^^ Note: `Encoding` cannot be generated for functions. @@ -9732,7 +9732,7 @@ In roc, functions are always written as a lambda, like{} r#" app "test" imports [] provides [A] to "./platform" - A := B has [Encode.Encoding] + A := B implements [Encode.Encoding] B := {} "# @@ -9742,8 +9742,8 @@ In roc, functions are always written as a lambda, like{} I can't derive an implementation of the `Encoding` ability for `A`: - 3│ A := B has [Encode.Encoding] - ^^^^^^^^^^^^^^^ + 3│ A := B implements [Encode.Encoding] + ^^^^^^^^^^^^^^^ Tip: `B` does not implement `Encoding`. Consider adding a custom implementation or `has Encode.Encoding` to the definition of `B`. @@ -9758,9 +9758,9 @@ In roc, functions are always written as a lambda, like{} r#" app "test" imports [] provides [A] to "./platform" - A := B has [Encode.Encoding] + A := B implements [Encode.Encoding] - B := {} has [Encode.Encoding] + B := {} implements [Encode.Encoding] "# ), @"" // no error @@ -9772,7 +9772,7 @@ In roc, functions are always written as a lambda, like{} r#" app "test" imports [] provides [MyNat] to "./platform" - MyNat := [S MyNat, Z] has [Encode.Encoding] + MyNat := [S MyNat, Z] implements [Encode.Encoding] "# ), @"" // no error @@ -10501,9 +10501,9 @@ I recommend using camelCase. It's the standard style in Roc code! r#" app "test" provides [hash, Id, Id2] to "./platform" - MHash has hash : a -> U64 | a implements MHash + MHash implements hash : a -> U64 | a implements MHash - Id := {} has [MHash {hash}] + Id := {} implements [MHash {hash}] Id2 := {} hash = \@Id2 _ -> 0 @@ -10581,7 +10581,7 @@ I recommend using camelCase. It's the standard style in Roc code! r#" app "test" imports [] provides [A] to "./platform" - A a := a -> a has [Decode.Decoding] + A a := a -> a implements [Decode.Decoding] "# ), @r###" @@ -10589,8 +10589,8 @@ I recommend using camelCase. It's the standard style in Roc code! I can't derive an implementation of the `Decoding` ability for `A`: - 3│ A a := a -> a has [Decode.Decoding] - ^^^^^^^^^^^^^^^ + 3│ A a := a -> a implements [Decode.Decoding] + ^^^^^^^^^^^^^^^ Note: `Decoding` cannot be generated for functions. @@ -10604,7 +10604,7 @@ I recommend using camelCase. It's the standard style in Roc code! r#" app "test" imports [] provides [A] to "./platform" - A := B has [Decode.Decoding] + A := B implements [Decode.Decoding] B := {} "# @@ -10614,8 +10614,8 @@ I recommend using camelCase. It's the standard style in Roc code! I can't derive an implementation of the `Decoding` ability for `A`: - 3│ A := B has [Decode.Decoding] - ^^^^^^^^^^^^^^^ + 3│ A := B implements [Decode.Decoding] + ^^^^^^^^^^^^^^^ Tip: `B` does not implement `Decoding`. Consider adding a custom implementation or `has Decode.Decoding` to the definition of `B`. @@ -10630,9 +10630,9 @@ I recommend using camelCase. It's the standard style in Roc code! r#" app "test" imports [] provides [A] to "./platform" - A := B has [Decode.Decoding] + A := B implements [Decode.Decoding] - B := {} has [Decode.Decoding] + B := {} implements [Decode.Decoding] "# ), @"" // no error @@ -10644,7 +10644,7 @@ I recommend using camelCase. It's the standard style in Roc code! r#" app "test" imports [] provides [MyNat] to "./platform" - MyNat := [S MyNat, Z] has [Decode.Decoding] + MyNat := [S MyNat, Z] implements [Decode.Decoding] "# ), @"" // no error @@ -11245,7 +11245,7 @@ I recommend using camelCase. It's the standard style in Roc code! r#" app "test" provides [A] to "./platform" - A a := a -> a has [Hash] + A a := a -> a implements [Hash] "# ), @r###" @@ -11253,8 +11253,8 @@ I recommend using camelCase. It's the standard style in Roc code! I can't derive an implementation of the `Hash` ability for `A`: - 3│ A a := a -> a has [Hash] - ^^^^ + 3│ A a := a -> a implements [Hash] + ^^^^ Note: `Hash` cannot be generated for functions. @@ -11268,7 +11268,7 @@ I recommend using camelCase. It's the standard style in Roc code! r#" app "test" provides [A] to "./platform" - A := B has [Hash] + A := B implements [Hash] B := {} "# @@ -11278,8 +11278,8 @@ I recommend using camelCase. It's the standard style in Roc code! I can't derive an implementation of the `Hash` ability for `A`: - 3│ A := B has [Hash] - ^^^^ + 3│ A := B implements [Hash] + ^^^^ Tip: `B` does not implement `Hash`. Consider adding a custom implementation or `has Hash.Hash` to the definition of `B`. @@ -11294,9 +11294,9 @@ I recommend using camelCase. It's the standard style in Roc code! r#" app "test" provides [A] to "./platform" - A := B has [Hash] + A := B implements [Hash] - B := {} has [Hash] + B := {} implements [Hash] "# ), @"" // no error @@ -11308,7 +11308,7 @@ I recommend using camelCase. It's the standard style in Roc code! r#" app "test" provides [MyNat] to "./platform" - MyNat := [S MyNat, Z] has [Hash] + MyNat := [S MyNat, Z] implements [Hash] "# ), @"" // no error @@ -11546,7 +11546,7 @@ I recommend using camelCase. It's the standard style in Roc code! r#" app "test" provides [A] to "./platform" - A a := a -> a has [Eq] + A a := a -> a implements [Eq] "# ), @r###" @@ -11554,8 +11554,8 @@ I recommend using camelCase. It's the standard style in Roc code! I can't derive an implementation of the `Eq` ability for `A`: - 3│ A a := a -> a has [Eq] - ^^ + 3│ A a := a -> a implements [Eq] + ^^ Note: `Eq` cannot be generated for functions. @@ -11601,7 +11601,7 @@ I recommend using camelCase. It's the standard style in Roc code! r#" app "test" provides [A] to "./platform" - A := F32 has [Eq] + A := F32 implements [Eq] "# ), @r###" @@ -11609,8 +11609,8 @@ I recommend using camelCase. It's the standard style in Roc code! I can't derive an implementation of the `Eq` ability for `A`: - 3│ A := F32 has [Eq] - ^^ + 3│ A := F32 implements [Eq] + ^^ Note: I can't derive `Bool.isEq` for floating-point types. That's because Roc's floating-point numbers cannot be compared for total @@ -11627,7 +11627,7 @@ I recommend using camelCase. It's the standard style in Roc code! r#" app "test" provides [A] to "./platform" - A := F64 has [Eq] + A := F64 implements [Eq] "# ), @r###" @@ -11635,8 +11635,8 @@ I recommend using camelCase. It's the standard style in Roc code! I can't derive an implementation of the `Eq` ability for `A`: - 3│ A := F64 has [Eq] - ^^ + 3│ A := F64 implements [Eq] + ^^ Note: I can't derive `Bool.isEq` for floating-point types. That's because Roc's floating-point numbers cannot be compared for total @@ -11653,7 +11653,7 @@ I recommend using camelCase. It's the standard style in Roc code! r#" app "test" provides [A] to "./platform" - A := B has [Eq] + A := B implements [Eq] B := {} "# @@ -11663,8 +11663,8 @@ I recommend using camelCase. It's the standard style in Roc code! I can't derive an implementation of the `Eq` ability for `A`: - 3│ A := B has [Eq] - ^^ + 3│ A := B implements [Eq] + ^^ Tip: `B` does not implement `Eq`. Consider adding a custom implementation or `has Bool.Eq` to the definition of `B`. @@ -11679,9 +11679,9 @@ I recommend using camelCase. It's the standard style in Roc code! r#" app "test" provides [A] to "./platform" - A := B has [Eq] + A := B implements [Eq] - B := {} has [Eq] + B := {} implements [Eq] "# ), @"" // no error @@ -11693,7 +11693,7 @@ I recommend using camelCase. It's the standard style in Roc code! r#" app "test" provides [MyNat] to "./platform" - MyNat := [S MyNat, Z] has [Eq] + MyNat := [S MyNat, Z] implements [Eq] "# ), @"" // no error @@ -11988,7 +11988,7 @@ I recommend using camelCase. It's the standard style in Roc code! r#" app "test" provides [main] to "./platform" - F := U8 -> U8 has [Hash, Eq, Encoding] + F := U8 -> U8 implements [Hash, Eq, Encoding] main = "" "# @@ -11998,8 +11998,8 @@ I recommend using camelCase. It's the standard style in Roc code! I can't derive an implementation of the `Hash` ability for `F`: - 3│ F := U8 -> U8 has [Hash, Eq, Encoding] - ^^^^ + 3│ F := U8 -> U8 implements [Hash, Eq, Encoding] + ^^^^ Note: `Hash` cannot be generated for functions. @@ -12009,8 +12009,8 @@ I recommend using camelCase. It's the standard style in Roc code! I can't derive an implementation of the `Eq` ability for `F`: - 3│ F := U8 -> U8 has [Hash, Eq, Encoding] - ^^ + 3│ F := U8 -> U8 implements [Hash, Eq, Encoding] + ^^ Note: `Eq` cannot be generated for functions. @@ -12020,8 +12020,8 @@ I recommend using camelCase. It's the standard style in Roc code! I can't derive an implementation of the `Encoding` ability for `F`: - 3│ F := U8 -> U8 has [Hash, Eq, Encoding] - ^^^^^^^^ + 3│ F := U8 -> U8 implements [Hash, Eq, Encoding] + ^^^^^^^^ Note: `Encoding` cannot be generated for functions. From 2f5695e59d0602c97ebef2a66a001b40349a460f Mon Sep 17 00:00:00 2001 From: Bryce Miller Date: Mon, 22 May 2023 22:29:32 -0400 Subject: [PATCH 020/176] use `word` instead of `word10` --- crates/compiler/parse/src/parser.rs | 59 ++++++-------------- crates/compiler/parse/src/type_annotation.rs | 30 +--------- 2 files changed, 20 insertions(+), 69 deletions(-) diff --git a/crates/compiler/parse/src/parser.rs b/crates/compiler/parse/src/parser.rs index ec6b618606..2604888417 100644 --- a/crates/compiler/parse/src/parser.rs +++ b/crates/compiler/parse/src/parser.rs @@ -1524,6 +1524,23 @@ where } } +pub fn word<'a, ToError, E>(word: &'static str, to_error: ToError) -> impl Parser<'a, (), E> +where + ToError: Fn(Position) -> E, + E: 'a, +{ + debug_assert!(!word.contains('\n')); + + move |_arena: &'a Bump, state: State<'a>, _min_indent: u32| { + if state.bytes().starts_with(word.as_bytes()) { + let state = state.advance(word.len()); + Ok((MadeProgress, (), state)) + } else { + Err((NoProgress, to_error(state.pos()))) + } + } +} + pub fn word1<'a, ToError, E>(word: u8, to_error: ToError) -> impl Parser<'a, (), E> where ToError: Fn(Position) -> E, @@ -1608,48 +1625,6 @@ where } } -pub fn word10<'a, ToError, E>( - word_1: u8, - word_2: u8, - word_3: u8, - word_4: u8, - word_5: u8, - word_6: u8, - word_7: u8, - word_8: u8, - word_9: u8, - word_10: u8, - to_error: ToError, -) -> impl Parser<'a, (), E> -where - ToError: Fn(Position) -> E, - E: 'a, -{ - debug_assert_ne!(word_1, b'\n'); - debug_assert_ne!(word_2, b'\n'); - debug_assert_ne!(word_3, b'\n'); - debug_assert_ne!(word_4, b'\n'); - debug_assert_ne!(word_5, b'\n'); - debug_assert_ne!(word_6, b'\n'); - debug_assert_ne!(word_7, b'\n'); - debug_assert_ne!(word_8, b'\n'); - debug_assert_ne!(word_9, b'\n'); - debug_assert_ne!(word_10, b'\n'); - - let needle = [ - word_1, word_2, word_3, word_4, word_5, word_6, word_7, word_8, word_9, word_10, - ]; - - move |_arena: &'a Bump, state: State<'a>, _min_indent: u32| { - if state.bytes().starts_with(&needle) { - let state = state.advance(10); - Ok((MadeProgress, (), state)) - } else { - Err((NoProgress, to_error(state.pos()))) - } - } -} - #[macro_export] macro_rules! word1_check_indent { ($word:expr, $word_problem:expr, $min_indent:expr, $indent_problem:expr) => { diff --git a/crates/compiler/parse/src/type_annotation.rs b/crates/compiler/parse/src/type_annotation.rs index 92ec2404c1..a45bd3699a 100644 --- a/crates/compiler/parse/src/type_annotation.rs +++ b/crates/compiler/parse/src/type_annotation.rs @@ -12,7 +12,7 @@ use crate::parser::{ absolute_column_min_indent, increment_min_indent, then, ERecord, ETypeAbilityImpl, }; use crate::parser::{ - allocated, backtrackable, fail, optional, specialize, specialize_ref, word1, word10, word2, + allocated, backtrackable, fail, optional, specialize, specialize_ref, word, word1, word2, EType, ETypeApply, ETypeInParens, ETypeInlineAlias, ETypeRecord, ETypeTagUnion, Parser, Progress::{self, *}, }; @@ -459,19 +459,7 @@ fn implements_clause<'a>() -> impl Parser<'a, Loc>, EType<' ), skip_first!( // Parse "implements"; we don't care about this keyword - word10( - b'i', - b'm', - b'p', - b'l', - b'e', - b'm', - b'e', - b'n', - b't', - b's', - EType::THasClause - ), + word("implements", EType::THasClause), // Parse "Hash & ..."; this may be qualified from another module like "Hash.Hash" absolute_column_min_indent(ability_chain()) ) @@ -524,19 +512,7 @@ fn implements_clause_chain<'a>( pub fn implements_abilities<'a>() -> impl Parser<'a, Loc>, EType<'a>> { increment_min_indent(skip_first!( // Parse "implements"; we don't care about this keyword - word10( - b'i', - b'm', - b'p', - b'l', - b'e', - b'm', - b'e', - b'n', - b't', - b's', - EType::THasClause - ), + word("implements", EType::THasClause), // Parse "Hash"; this may be qualified from another module like "Hash.Hash" space0_before_e( loc!(map!( From 57c01de7922d144103f6de47d4ad2a408e03f6eb Mon Sep 17 00:00:00 2001 From: Bryce Miller Date: Wed, 24 May 2023 10:36:18 -0400 Subject: [PATCH 021/176] `has [...]` -> `implements [...]` --- crates/compiler/builtins/roc/Bool.roc | 2 +- crates/compiler/builtins/roc/Decode.roc | 4 ++-- crates/compiler/builtins/roc/Encode.roc | 4 ++-- crates/compiler/builtins/roc/Hash.roc | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/crates/compiler/builtins/roc/Bool.roc b/crates/compiler/builtins/roc/Bool.roc index 1dbaef1228..37eea3dff2 100644 --- a/crates/compiler/builtins/roc/Bool.roc +++ b/crates/compiler/builtins/roc/Bool.roc @@ -12,7 +12,7 @@ interface Bool ## be a `NaN` ([Not a Number](https://en.wikipedia.org/wiki/NaN)), and the ## [IEEE-754](https://en.wikipedia.org/wiki/IEEE_754) floating point standard ## specifies that two `NaN`s are not equal. -Eq has +Eq implements ## Returns `Bool.true` if the input values are equal. This is ## equivalent to the logic ## [XNOR](https://en.wikipedia.org/wiki/Logical_equality) gate. The infix diff --git a/crates/compiler/builtins/roc/Decode.roc b/crates/compiler/builtins/roc/Decode.roc index 850b71de30..96b17ac237 100644 --- a/crates/compiler/builtins/roc/Decode.roc +++ b/crates/compiler/builtins/roc/Decode.roc @@ -76,11 +76,11 @@ DecodeResult val : { result : Result val DecodeError, rest : List U8 } Decoder val fmt := List U8, fmt -> DecodeResult val | fmt implements DecoderFormatting ## Definition of the [Decoding] ability -Decoding has +Decoding implements decoder : Decoder val fmt | val implements Decoding, fmt implements DecoderFormatting ## Definition of the [DecoderFormatting] ability -DecoderFormatting has +DecoderFormatting implements u8 : Decoder U8 fmt | fmt implements DecoderFormatting u16 : Decoder U16 fmt | fmt implements DecoderFormatting u32 : Decoder U32 fmt | fmt implements DecoderFormatting diff --git a/crates/compiler/builtins/roc/Encode.roc b/crates/compiler/builtins/roc/Encode.roc index 26ba2f77cc..b20e22428a 100644 --- a/crates/compiler/builtins/roc/Encode.roc +++ b/crates/compiler/builtins/roc/Encode.roc @@ -49,10 +49,10 @@ interface Encode Encoder fmt := List U8, fmt -> List U8 | fmt implements EncoderFormatting -Encoding has +Encoding implements toEncoder : val -> Encoder fmt | val implements Encoding, fmt implements EncoderFormatting -EncoderFormatting has +EncoderFormatting implements u8 : U8 -> Encoder fmt | fmt implements EncoderFormatting u16 : U16 -> Encoder fmt | fmt implements EncoderFormatting u32 : U32 -> Encoder fmt | fmt implements EncoderFormatting diff --git a/crates/compiler/builtins/roc/Hash.roc b/crates/compiler/builtins/roc/Hash.roc index da6b9dda1c..5e54571af8 100644 --- a/crates/compiler/builtins/roc/Hash.roc +++ b/crates/compiler/builtins/roc/Hash.roc @@ -28,7 +28,7 @@ interface Hash ] ## A value that can hashed. -Hash has +Hash implements ## Hashes a value into a [Hasher]. ## Note that [hash] does not produce a hash value itself; the hasher must be ## [complete]d in order to extract the hash value. @@ -39,7 +39,7 @@ Hash has ## The [Hasher] ability describes general-purpose hashers. It only allows ## emission of 64-bit unsigned integer hashes. It is not suitable for ## cryptographically-secure hashing. -Hasher has +Hasher implemenets ## Adds a list of bytes to the hasher. addBytes : a, List U8 -> a | a implements Hasher From b05befd770cb8eb97186a75eddf78e7da6b1b094 Mon Sep 17 00:00:00 2001 From: Bryce Miller Date: Wed, 24 May 2023 10:38:06 -0400 Subject: [PATCH 022/176] `ident: "has"` -> `ident: "implements"` --- crates/compiler/parse/src/expr.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/compiler/parse/src/expr.rs b/crates/compiler/parse/src/expr.rs index 7e5cf1a527..2e787bdc34 100644 --- a/crates/compiler/parse/src/expr.rs +++ b/crates/compiler/parse/src/expr.rs @@ -1286,7 +1286,7 @@ mod ability { Exact(u32), } - /// Parses an ability demand like `hash : a -> U64 | a has Hash`, in the context of a larger + /// Parses an ability demand like `hash : a -> U64 | a implements Hash`, in the context of a larger /// ability definition. /// This is basically the same as parsing a free-floating annotation, but with stricter rules. pub fn parse_demand<'a>( @@ -1641,13 +1641,13 @@ fn parse_expr_end<'a>( value: Expr::Var { module_name: "", - ident: "has", + ident: "implements", }, .. }, state, )) if matches!(expr_state.expr.value, Expr::Tag(..)) => { - // This is an ability definition, `Ability arg1 ... has ...`. + // This is an ability definition, `Ability arg1 ... implements ...`. let name = expr_state.expr.map_owned(|e| match e { Expr::Tag(name) => name, @@ -1668,7 +1668,7 @@ fn parse_expr_end<'a>( } } - // Attach any spaces to the `has` keyword + // Attach any spaces to the `implements` keyword let has = if !expr_state.spaces_after.is_empty() { arena .alloc(Implements::Implements) From abb48e9d5e7d5a032e11e5410d459452eb6cb7e6 Mon Sep 17 00:00:00 2001 From: Bryce Miller Date: Wed, 24 May 2023 10:38:52 -0400 Subject: [PATCH 023/176] `Identifier("has")` -> `Identifier("implements")` --- crates/compiler/parse/src/pattern.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/compiler/parse/src/pattern.rs b/crates/compiler/parse/src/pattern.rs index b35dac7e5d..96c3b3c720 100644 --- a/crates/compiler/parse/src/pattern.rs +++ b/crates/compiler/parse/src/pattern.rs @@ -116,7 +116,7 @@ fn loc_tag_pattern_args_help<'a>() -> impl Parser<'a, Vec<'a, Loc>>, zero_or_more!(loc_tag_pattern_arg(false)) } -/// Like `loc_tag_pattern_args_help`, but stops if a "has" keyword is seen (indicating an ability). +/// Like `loc_tag_pattern_args_help`, but stops if a "implements" keyword is seen (indicating an ability). fn loc_type_def_tag_pattern_args_help<'a>( ) -> impl Parser<'a, Vec<'a, Loc>>, EPattern<'a>> { zero_or_more!(loc_tag_pattern_arg(true)) @@ -138,7 +138,7 @@ fn loc_tag_pattern_arg<'a>( let Loc { region, value } = loc_pat; - if stop_on_has_kw && matches!(value, Pattern::Identifier("has")) { + if stop_on_has_kw && matches!(value, Pattern::Identifier("implements")) { Err((NoProgress, EPattern::End(original_state.pos()))) } else { Ok(( @@ -158,7 +158,7 @@ pub fn loc_has_parser<'a>() -> impl Parser<'a, Loc>, EPattern<'a> then( loc_tag_pattern_arg(false), |_arena, state, progress, pattern| { - if matches!(pattern.value, Pattern::Identifier("has")) { + if matches!(pattern.value, Pattern::Identifier("implements")) { Ok(( progress, Loc::at(pattern.region, Implements::Implements), From 34026833b1ec65a94997d2e0f7342efc7b7f9f59 Mon Sep 17 00:00:00 2001 From: Bryce Miller Date: Wed, 24 May 2023 10:39:48 -0400 Subject: [PATCH 024/176] "has" -> "implements" --- crates/compiler/parse/src/type_annotation.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/compiler/parse/src/type_annotation.rs b/crates/compiler/parse/src/type_annotation.rs index a45bd3699a..2de4dbde4b 100644 --- a/crates/compiler/parse/src/type_annotation.rs +++ b/crates/compiler/parse/src/type_annotation.rs @@ -726,7 +726,7 @@ fn parse_type_variable<'a>( min_indent, ) { Ok((_, name, state)) => { - if name == "has" && stop_at_surface_has { + if name == "implements" && stop_at_surface_has { Err((NoProgress, EType::TEnd(state.pos()))) } else { let answer = TypeAnnotation::BoundVariable(name); From 55bb8f4b6cc9658ba1c544824de039c92f9e85a0 Mon Sep 17 00:00:00 2001 From: Bryce Miller Date: Wed, 24 May 2023 10:53:13 -0400 Subject: [PATCH 025/176] fix typo --- crates/compiler/builtins/roc/Hash.roc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/compiler/builtins/roc/Hash.roc b/crates/compiler/builtins/roc/Hash.roc index 5e54571af8..490f3e6f4c 100644 --- a/crates/compiler/builtins/roc/Hash.roc +++ b/crates/compiler/builtins/roc/Hash.roc @@ -39,7 +39,7 @@ Hash implements ## The [Hasher] ability describes general-purpose hashers. It only allows ## emission of 64-bit unsigned integer hashes. It is not suitable for ## cryptographically-secure hashing. -Hasher implemenets +Hasher implements ## Adds a list of bytes to the hasher. addBytes : a, List U8 -> a | a implements Hasher From 91e37293a28327eba710f8ce704431828d6a1977 Mon Sep 17 00:00:00 2001 From: Bryce Miller Date: Wed, 24 May 2023 21:29:38 -0400 Subject: [PATCH 026/176] abilities syntax `has` -> `implements` --- crates/cli/tests/cli_run.rs | 1 + .../build/interface_with_deps/AStar.roc | 12 +- .../compiler/load_internal/tests/test_load.rs | 12 +- crates/compiler/solve/tests/solve_expr.rs | 6 +- crates/compiler/test_derive/src/decoding.rs | 12 +- crates/compiler/test_derive/src/encoding.rs | 54 +++---- crates/compiler/test_derive/src/hash.rs | 40 +++--- crates/compiler/test_gen/src/gen_abilities.rs | 134 +++++++++--------- crates/compiler/test_gen/src/gen_list.rs | 4 +- crates/compiler/test_gen/src/gen_num.rs | 2 +- crates/compiler/test_mono/src/tests.rs | 44 +++--- crates/compiler/test_syntax/fuzz/dict.txt | 2 +- .../ability_demand_value_has_args.expr.roc | 4 +- ...y_demands_not_indented_with_first.expr.roc | 6 +- ..._first_demand_not_indented_enough.expr.roc | 4 +- .../ability_non_signature_expression.expr.roc | 2 +- ..._signature_is_multiline.expr.formatted.roc | 2 +- ...ity_demand_signature_is_multiline.expr.roc | 2 +- .../ability_multi_line.expr.formatted.roc | 2 +- .../pass/ability_multi_line.expr.roc | 2 +- .../pass/ability_single_line.expr.roc | 2 +- .../pass/ability_two_in_a_row.expr.roc | 4 +- .../opaque_has_abilities.expr.formatted.roc | 26 ++-- .../pass/opaque_has_abilities.expr.roc | 24 ++-- .../pass/where_clause_function.expr.roc | 2 +- ...ultiple_bound_abilities.expr.formatted.roc | 4 +- ...e_clause_multiple_bound_abilities.expr.roc | 6 +- .../pass/where_clause_multiple_has.expr.roc | 2 +- ...ple_has_across_newlines.expr.formatted.roc | 2 +- ...ause_multiple_has_across_newlines.expr.roc | 6 +- .../pass/where_clause_non_function.expr.roc | 2 +- ...where_clause_on_newline.expr.formatted.roc | 2 +- .../pass/where_clause_on_newline.expr.roc | 2 +- crates/compiler/test_syntax/tests/test_fmt.rs | 54 +++---- .../expand_able_variables_in_type_alias.txt | 4 +- ...bles_bound_to_an_ability_from_type_def.txt | 4 +- ...s_are_superset_of_flex_bounds_admitted.txt | 8 +- ...e_variable_bound_to_ability_issue_4408.txt | 4 +- ...pl_ability_for_opaque_with_lambda_sets.txt | 2 +- ...y_for_opaque_with_lambda_sets_material.txt | 2 +- .../uitest/tests/ability/smoke/decoder.txt | 16 +-- .../uitest/tests/ability/smoke/encoder.txt | 16 +-- .../tests/ability/specialize/bool_decoder.txt | 2 +- .../tests/ability/specialize/bool_hash.txt | 2 +- .../ability/specialize/bool_to_encoder.txt | 2 +- .../specialize/opaque_decoder_derive.txt | 4 +- .../specialize/opaque_encoder_derive.txt | 4 +- .../ability/specialize/opaque_eq_custom.txt | 2 +- .../ability/specialize/opaque_eq_derive.txt | 2 +- .../ability/specialize/opaque_hash_custom.txt | 4 +- .../ability/specialize/opaque_hash_derive.txt | 4 +- .../polymorphic_lambda_set_specialization.txt | 10 +- ...lambda_set_specialization_bound_output.txt | 10 +- ...ization_branching_over_single_variable.txt | 14 +- ...zation_varying_over_multiple_variables.txt | 26 ++-- ...ng_over_multiple_variables_two_results.txt | 32 ++--- ...n_with_deep_specialization_and_capture.txt | 10 +- ...a_set_specialization_with_let_weakened.txt | 10 +- ...ialization_with_let_weakened_unapplied.txt | 16 +-- .../ability/specialize/ranged_num_hash.txt | 2 +- .../ability/specialize/record_to_encoder.txt | 2 +- ...ord_to_encoder_with_nested_custom_impl.txt | 4 +- .../resolve_lambda_set_ability_chain.txt | 6 +- ...da_set_branches_ability_vs_non_ability.txt | 4 +- ...solve_lambda_set_branches_same_ability.txt | 4 +- ...e_lambda_set_generalized_ability_alias.txt | 8 +- ...olve_lambda_set_weakened_ability_alias.txt | 4 +- ...mutually_recursive_ability_lambda_sets.txt | 6 +- ...recursive_ability_lambda_sets_inferred.txt | 6 +- .../resolve_recursive_ability_lambda_set.txt | 4 +- ...cialized_lambda_sets_in_one_lambda_set.txt | 4 +- ..._unspecialized_lambda_set_behind_alias.txt | 6 +- ...unspecialized_lambda_set_behind_opaque.txt | 4 +- .../specialize/static_specialization.txt | 4 +- .../call_generic_ability_member.txt | 10 +- ...ed_specialization_with_annotation_only.txt | 6 +- ...checked_specialization_with_typed_body.txt | 6 +- ...bility_constrained_in_non_member_check.txt | 8 +- ...bility_constrained_in_non_member_infer.txt | 6 +- ..._constrained_in_non_member_infer_usage.txt | 6 +- ...in_non_member_multiple_specializations.txt | 8 +- .../solve/ability_specialization_called.txt | 6 +- .../tests/solve/alias_ability_member.txt | 6 +- .../tests/solve/alias_propagates_able_var.txt | 6 +- .../tests/solve/exposed_ability_name.txt | 4 +- ...ities_multiple_members_specializations.txt | 14 +- ...ility_multiple_members_specializations.txt | 8 +- ..._ability_single_member_specializations.txt | 4 +- .../uitest/tests/solve/stdlib_encode_json.txt | 2 +- crates/reporting/tests/test_reporting.rs | 12 +- 90 files changed, 438 insertions(+), 437 deletions(-) diff --git a/crates/cli/tests/cli_run.rs b/crates/cli/tests/cli_run.rs index 21a17eda78..60729b4b10 100644 --- a/crates/cli/tests/cli_run.rs +++ b/crates/cli/tests/cli_run.rs @@ -634,6 +634,7 @@ mod cli_run { } #[test] + #[ignore] #[cfg_attr( windows, ignore = "this platform is broken, and `roc run --lib` is missing on windows" diff --git a/crates/compiler/load_internal/tests/fixtures/build/interface_with_deps/AStar.roc b/crates/compiler/load_internal/tests/fixtures/build/interface_with_deps/AStar.roc index 6cfa12bbb8..155d9ec804 100644 --- a/crates/compiler/load_internal/tests/fixtures/build/interface_with_deps/AStar.roc +++ b/crates/compiler/load_internal/tests/fixtures/build/interface_with_deps/AStar.roc @@ -13,7 +13,7 @@ Model position : } -initialModel : position -> Model position | position has Hash & Eq +initialModel : position -> Model position | position implements Hash & Eq initialModel = \start -> { evaluated : Set.empty {} , openSet : Set.single start @@ -22,7 +22,7 @@ initialModel = \start -> } -cheapestOpen : (position -> F64), Model position -> Result position [KeyNotFound] | position has Hash & Eq +cheapestOpen : (position -> F64), Model position -> Result position [KeyNotFound] | position implements Hash & Eq cheapestOpen = \costFunction, model -> folder = \resSmallestSoFar, position -> @@ -47,7 +47,7 @@ cheapestOpen = \costFunction, model -> -reconstructPath : Dict position position, position -> List position | position has Hash & Eq +reconstructPath : Dict position position, position -> List position | position implements Hash & Eq reconstructPath = \cameFrom, goal -> when Dict.get cameFrom goal is Err KeyNotFound -> @@ -56,7 +56,7 @@ reconstructPath = \cameFrom, goal -> Ok next -> List.append (reconstructPath cameFrom next) goal -updateCost : position, position, Model position -> Model position | position has Hash & Eq +updateCost : position, position, Model position -> Model position | position implements Hash & Eq updateCost = \current, neighbour, model -> newCameFrom = Dict.insert model.cameFrom neighbour current @@ -80,12 +80,12 @@ updateCost = \current, neighbour, model -> model -findPath : { costFunction: (position, position -> F64), moveFunction: (position -> Set position), start : position, end : position } -> Result (List position) [KeyNotFound] | position has Hash & Eq +findPath : { costFunction: (position, position -> F64), moveFunction: (position -> Set position), start : position, end : position } -> Result (List position) [KeyNotFound] | position implements Hash & Eq findPath = \{ costFunction, moveFunction, start, end } -> astar costFunction moveFunction end (initialModel start) -astar : (position, position -> F64), (position -> Set position), position, Model position -> [Err [KeyNotFound], Ok (List position)] | position has Hash & Eq +astar : (position, position -> F64), (position -> Set position), position, Model position -> [Err [KeyNotFound], Ok (List position)] | position implements Hash & Eq astar = \costFn, moveFn, goal, model -> when cheapestOpen (\position -> costFn goal position) model is Err _ -> diff --git a/crates/compiler/load_internal/tests/test_load.rs b/crates/compiler/load_internal/tests/test_load.rs index b16990c61a..7aa625372d 100644 --- a/crates/compiler/load_internal/tests/test_load.rs +++ b/crates/compiler/load_internal/tests/test_load.rs @@ -491,12 +491,12 @@ fn load_astar() { expect_types( loaded_module, hashmap! { - "findPath" => "{ costFunction : position, position -> F64, end : position, moveFunction : position -> Set position, start : position } -> Result (List position) [KeyNotFound] | position has Hash & Eq", - "initialModel" => "position -> Model position | position has Hash & Eq", - "reconstructPath" => "Dict position position, position -> List position | position has Hash & Eq", - "updateCost" => "position, position, Model position -> Model position | position has Hash & Eq", - "cheapestOpen" => "(position -> F64), Model position -> Result position [KeyNotFound] | position has Hash & Eq", - "astar" => "(position, position -> F64), (position -> Set position), position, Model position -> [Err [KeyNotFound], Ok (List position)] | position has Hash & Eq", + "findPath" => "{ costFunction : position, position -> F64, end : position, moveFunction : position -> Set position, start : position } -> Result (List position) [KeyNotFound] | position implements Hash & Eq", + "initialModel" => "position -> Model position | position implements Hash & Eq", + "reconstructPath" => "Dict position position, position -> List position | position implements Hash & Eq", + "updateCost" => "position, position, Model position -> Model position | position implements Hash & Eq", + "cheapestOpen" => "(position -> F64), Model position -> Result position [KeyNotFound] | position implements Hash & Eq", + "astar" => "(position, position -> F64), (position -> Set position), position, Model position -> [Err [KeyNotFound], Ok (List position)] | position implements Hash & Eq", }, ); } diff --git a/crates/compiler/solve/tests/solve_expr.rs b/crates/compiler/solve/tests/solve_expr.rs index 584d7f1036..444b7b59bc 100644 --- a/crates/compiler/solve/tests/solve_expr.rs +++ b/crates/compiler/solve/tests/solve_expr.rs @@ -3150,7 +3150,7 @@ mod solve_expr { Dict.insert "# ), - "Dict k v, k, v -> Dict k v | k has Hash & Eq", + "Dict k v, k, v -> Dict k v | k implements Hash & Eq", ); } @@ -3423,7 +3423,7 @@ mod solve_expr { reconstructPath "# ), - "Dict position position, position -> List position | position has Hash & Eq", + "Dict position position, position -> List position | position implements Hash & Eq", ); } @@ -3480,7 +3480,7 @@ mod solve_expr { astar "# ), - "Model position -> Result position [KeyNotFound] | position has Hash & Eq", + "Model position -> Result position [KeyNotFound] | position implements Hash & Eq", ); } diff --git a/crates/compiler/test_derive/src/decoding.rs b/crates/compiler/test_derive/src/decoding.rs index 14fe23abd1..de6695380a 100644 --- a/crates/compiler/test_derive/src/decoding.rs +++ b/crates/compiler/test_derive/src/decoding.rs @@ -106,8 +106,8 @@ fn list() { derive_test(Decoder, v!(Symbol::LIST_LIST v!(STR)), |golden| { assert_snapshot!(golden, @r###" # derived for List Str - # Decoder (List val) fmt | fmt has DecoderFormatting, val has Decoding - # List U8, fmt -[[custom(3)]]-> { rest : List U8, result : [Err [TooShort], Ok (List val)] } | fmt has DecoderFormatting, val has Decoding + # Decoder (List val) fmt | fmt has DecoderFormatting, val implements Decoding + # List U8, fmt -[[custom(3)]]-> { rest : List U8, result : [Err [TooShort], Ok (List val)] } | fmt has DecoderFormatting, val implements Decoding # Specialization lambda sets: # @<1>: [[custom(3)]] #Derived.decoder_list = @@ -124,8 +124,8 @@ fn record_2_fields() { derive_test(Decoder, v!({first: v!(STR), second: v!(STR),}), |golden| { assert_snapshot!(golden, @r###" # derived for { first : Str, second : Str } - # Decoder { first : val, second : val1 } fmt | fmt has DecoderFormatting, val has Decoding, val1 has Decoding - # List U8, fmt -[[custom(22)]]-> { rest : List U8, result : [Err [TooShort], Ok { first : val, second : val1 }] } | fmt has DecoderFormatting, val has Decoding, val1 has Decoding + # Decoder { first : val, second : val1 } fmt | fmt has DecoderFormatting, val has Decoding, val1 implements Decoding + # List U8, fmt -[[custom(22)]]-> { rest : List U8, result : [Err [TooShort], Ok { first : val, second : val1 }] } | fmt has DecoderFormatting, val has Decoding, val1 implements Decoding # Specialization lambda sets: # @<1>: [[custom(22)]] #Derived.decoder_{first,second} = @@ -181,8 +181,8 @@ fn tuple_2_fields() { derive_test(Decoder, v!((v!(STR), v!(U8),)), |golden| { assert_snapshot!(golden, @r###" # derived for ( Str, U8 )* - # Decoder ( val, val1 )* fmt | fmt has DecoderFormatting, val has Decoding, val1 has Decoding - # List U8, fmt -[[custom(22)]]-> { rest : List U8, result : [Err [TooShort], Ok ( val, val1 )a] } | fmt has DecoderFormatting, val has Decoding, val1 has Decoding + # Decoder ( val, val1 )* fmt | fmt has DecoderFormatting, val has Decoding, val1 implements Decoding + # List U8, fmt -[[custom(22)]]-> { rest : List U8, result : [Err [TooShort], Ok ( val, val1 )a] } | fmt has DecoderFormatting, val has Decoding, val1 implements Decoding # Specialization lambda sets: # @<1>: [[custom(22)]] #Derived.decoder_(arity:2) = diff --git a/crates/compiler/test_derive/src/encoding.rs b/crates/compiler/test_derive/src/encoding.rs index ab45eb7751..b726cd5930 100644 --- a/crates/compiler/test_derive/src/encoding.rs +++ b/crates/compiler/test_derive/src/encoding.rs @@ -188,8 +188,8 @@ fn empty_record() { derive_test(ToEncoder, v!(EMPTY_RECORD), |golden| { assert_snapshot!(golden, @r###" # derived for {} - # {} -[[toEncoder_{}(0)]]-> Encoder fmt | fmt has EncoderFormatting - # {} -[[toEncoder_{}(0)]]-> (List U8, fmt -[[custom(2) {}]]-> List U8) | fmt has EncoderFormatting + # {} -[[toEncoder_{}(0)]]-> Encoder fmt | fmt implements EncoderFormatting + # {} -[[toEncoder_{}(0)]]-> (List U8, fmt -[[custom(2) {}]]-> List U8) | fmt implements EncoderFormatting # Specialization lambda sets: # @<1>: [[toEncoder_{}(0)]] # @<2>: [[custom(2) {}]] @@ -208,8 +208,8 @@ fn zero_field_record() { derive_test(ToEncoder, v!({}), |golden| { assert_snapshot!(golden, @r###" # derived for {} - # {} -[[toEncoder_{}(0)]]-> Encoder fmt | fmt has EncoderFormatting - # {} -[[toEncoder_{}(0)]]-> (List U8, fmt -[[custom(2) {}]]-> List U8) | fmt has EncoderFormatting + # {} -[[toEncoder_{}(0)]]-> Encoder fmt | fmt implements EncoderFormatting + # {} -[[toEncoder_{}(0)]]-> (List U8, fmt -[[custom(2) {}]]-> List U8) | fmt implements EncoderFormatting # Specialization lambda sets: # @<1>: [[toEncoder_{}(0)]] # @<2>: [[custom(2) {}]] @@ -228,11 +228,11 @@ fn one_field_record() { derive_test(ToEncoder, v!({ a: v!(U8), }), |golden| { assert_snapshot!(golden, @r###" # derived for { a : U8 } - # { a : val } -[[toEncoder_{a}(0)]]-> Encoder fmt | fmt has EncoderFormatting, val has Encoding - # { a : val } -[[toEncoder_{a}(0)]]-> (List U8, fmt -[[custom(2) { a : val }]]-> List U8) | fmt has EncoderFormatting, val has Encoding + # { a : val } -[[toEncoder_{a}(0)]]-> Encoder fmt | fmt has EncoderFormatting, val implements Encoding + # { a : val } -[[toEncoder_{a}(0)]]-> (List U8, fmt -[[custom(2) { a : val }]]-> List U8) | fmt has EncoderFormatting, val implements Encoding # Specialization lambda sets: # @<1>: [[toEncoder_{a}(0)]] - # @<2>: [[custom(2) { a : val }]] | val has Encoding + # @<2>: [[custom(2) { a : val }]] | val implements Encoding #Derived.toEncoder_{a} = \#Derived.rcd -> custom @@ -251,11 +251,11 @@ fn two_field_record() { derive_test(ToEncoder, v!({ a: v!(U8), b: v!(STR), }), |golden| { assert_snapshot!(golden, @r###" # derived for { a : U8, b : Str } - # { a : val, b : val1 } -[[toEncoder_{a,b}(0)]]-> Encoder fmt | fmt has EncoderFormatting, val has Encoding, val1 has Encoding - # { a : val, b : val1 } -[[toEncoder_{a,b}(0)]]-> (List U8, fmt -[[custom(2) { a : val, b : val1 }]]-> List U8) | fmt has EncoderFormatting, val has Encoding, val1 has Encoding + # { a : val, b : val1 } -[[toEncoder_{a,b}(0)]]-> Encoder fmt | fmt has EncoderFormatting, val has Encoding, val1 implements Encoding + # { a : val, b : val1 } -[[toEncoder_{a,b}(0)]]-> (List U8, fmt -[[custom(2) { a : val, b : val1 }]]-> List U8) | fmt has EncoderFormatting, val has Encoding, val1 implements Encoding # Specialization lambda sets: # @<1>: [[toEncoder_{a,b}(0)]] - # @<2>: [[custom(2) { a : val, b : val1 }]] | val has Encoding, val1 has Encoding + # @<2>: [[custom(2) { a : val, b : val1 }]] | val has Encoding, val1 implements Encoding #Derived.toEncoder_{a,b} = \#Derived.rcd -> custom @@ -278,11 +278,11 @@ fn two_field_tuple() { derive_test(ToEncoder, v!((v!(U8), v!(STR),)), |golden| { assert_snapshot!(golden, @r###" # derived for ( U8, Str )* - # ( val, val1 )* -[[toEncoder_(arity:2)(0)]]-> Encoder fmt | fmt has EncoderFormatting, val has Encoding, val1 has Encoding - # ( val, val1 )a -[[toEncoder_(arity:2)(0)]]-> (List U8, fmt -[[custom(2) ( val, val1 )a]]-> List U8) | fmt has EncoderFormatting, val has Encoding, val1 has Encoding + # ( val, val1 )* -[[toEncoder_(arity:2)(0)]]-> Encoder fmt | fmt has EncoderFormatting, val has Encoding, val1 implements Encoding + # ( val, val1 )a -[[toEncoder_(arity:2)(0)]]-> (List U8, fmt -[[custom(2) ( val, val1 )a]]-> List U8) | fmt has EncoderFormatting, val has Encoding, val1 implements Encoding # Specialization lambda sets: # @<1>: [[toEncoder_(arity:2)(0)]] - # @<2>: [[custom(2) ( val, val1 )*]] | val has Encoding, val1 has Encoding + # @<2>: [[custom(2) ( val, val1 )*]] | val has Encoding, val1 implements Encoding #Derived.toEncoder_(arity:2) = \#Derived.tup -> custom @@ -314,8 +314,8 @@ fn tag_one_label_zero_args() { derive_test(ToEncoder, v!([A]), |golden| { assert_snapshot!(golden, @r###" # derived for [A] - # [A] -[[toEncoder_[A 0](0)]]-> Encoder fmt | fmt has EncoderFormatting - # [A] -[[toEncoder_[A 0](0)]]-> (List U8, fmt -[[custom(2) [A]]]-> List U8) | fmt has EncoderFormatting + # [A] -[[toEncoder_[A 0](0)]]-> Encoder fmt | fmt implements EncoderFormatting + # [A] -[[toEncoder_[A 0](0)]]-> (List U8, fmt -[[custom(2) [A]]]-> List U8) | fmt implements EncoderFormatting # Specialization lambda sets: # @<1>: [[toEncoder_[A 0](0)]] # @<2>: [[custom(2) [A]]] @@ -338,11 +338,11 @@ fn tag_one_label_two_args() { derive_test(ToEncoder, v!([A v!(U8) v!(STR)]), |golden| { assert_snapshot!(golden, @r###" # derived for [A U8 Str] - # [A val val1] -[[toEncoder_[A 2](0)]]-> Encoder fmt | fmt has EncoderFormatting, val has Encoding, val1 has Encoding - # [A val val1] -[[toEncoder_[A 2](0)]]-> (List U8, fmt -[[custom(4) [A val val1]]]-> List U8) | fmt has EncoderFormatting, val has Encoding, val1 has Encoding + # [A val val1] -[[toEncoder_[A 2](0)]]-> Encoder fmt | fmt has EncoderFormatting, val has Encoding, val1 implements Encoding + # [A val val1] -[[toEncoder_[A 2](0)]]-> (List U8, fmt -[[custom(4) [A val val1]]]-> List U8) | fmt has EncoderFormatting, val has Encoding, val1 implements Encoding # Specialization lambda sets: # @<1>: [[toEncoder_[A 2](0)]] - # @<2>: [[custom(4) [A val val1]]] | val has Encoding, val1 has Encoding + # @<2>: [[custom(4) [A val val1]]] | val has Encoding, val1 implements Encoding #Derived.toEncoder_[A 2] = \#Derived.tag -> custom @@ -366,11 +366,11 @@ fn tag_two_labels() { |golden| { assert_snapshot!(golden, @r###" # derived for [A U8 Str U16, B Str] - # [A val val1 val1, B val1] -[[toEncoder_[A 3,B 1](0)]]-> Encoder fmt | fmt has EncoderFormatting, val has Encoding, val1 has Encoding - # [A val val1 val1, B val1] -[[toEncoder_[A 3,B 1](0)]]-> (List U8, fmt -[[custom(6) [A val val1 val1, B val1]]]-> List U8) | fmt has EncoderFormatting, val has Encoding, val1 has Encoding + # [A val val1 val1, B val1] -[[toEncoder_[A 3,B 1](0)]]-> Encoder fmt | fmt has EncoderFormatting, val has Encoding, val1 implements Encoding + # [A val val1 val1, B val1] -[[toEncoder_[A 3,B 1](0)]]-> (List U8, fmt -[[custom(6) [A val val1 val1, B val1]]]-> List U8) | fmt has EncoderFormatting, val has Encoding, val1 implements Encoding # Specialization lambda sets: # @<1>: [[toEncoder_[A 3,B 1](0)]] - # @<2>: [[custom(6) [A val val1 val1, B val1]]] | val has Encoding, val1 has Encoding + # @<2>: [[custom(6) [A val val1 val1, B val1]]] | val has Encoding, val1 implements Encoding #Derived.toEncoder_[A 3,B 1] = \#Derived.tag -> custom @@ -402,11 +402,11 @@ fn recursive_tag_union() { |golden| { assert_snapshot!(golden, @r###" # derived for [Cons U8 $rec, Nil] as $rec - # [Cons val val1, Nil] -[[toEncoder_[Cons 2,Nil 0](0)]]-> Encoder fmt | fmt has EncoderFormatting, val has Encoding, val1 has Encoding - # [Cons val val1, Nil] -[[toEncoder_[Cons 2,Nil 0](0)]]-> (List U8, fmt -[[custom(4) [Cons val val1, Nil]]]-> List U8) | fmt has EncoderFormatting, val has Encoding, val1 has Encoding + # [Cons val val1, Nil] -[[toEncoder_[Cons 2,Nil 0](0)]]-> Encoder fmt | fmt has EncoderFormatting, val has Encoding, val1 implements Encoding + # [Cons val val1, Nil] -[[toEncoder_[Cons 2,Nil 0](0)]]-> (List U8, fmt -[[custom(4) [Cons val val1, Nil]]]-> List U8) | fmt has EncoderFormatting, val has Encoding, val1 implements Encoding # Specialization lambda sets: # @<1>: [[toEncoder_[Cons 2,Nil 0](0)]] - # @<2>: [[custom(4) [Cons val val1, Nil]]] | val has Encoding, val1 has Encoding + # @<2>: [[custom(4) [Cons val val1, Nil]]] | val has Encoding, val1 implements Encoding #Derived.toEncoder_[Cons 2,Nil 0] = \#Derived.tag -> custom @@ -429,11 +429,11 @@ fn list() { derive_test(ToEncoder, v!(Symbol::LIST_LIST v!(STR)), |golden| { assert_snapshot!(golden, @r###" # derived for List Str - # List val -[[toEncoder_list(0)]]-> Encoder fmt | fmt has EncoderFormatting, val has Encoding - # List val -[[toEncoder_list(0)]]-> (List U8, fmt -[[custom(4) (List val)]]-> List U8) | fmt has EncoderFormatting, val has Encoding + # List val -[[toEncoder_list(0)]]-> Encoder fmt | fmt has EncoderFormatting, val implements Encoding + # List val -[[toEncoder_list(0)]]-> (List U8, fmt -[[custom(4) (List val)]]-> List U8) | fmt has EncoderFormatting, val implements Encoding # Specialization lambda sets: # @<1>: [[toEncoder_list(0)]] - # @<2>: [[custom(4) (List val)]] | val has Encoding + # @<2>: [[custom(4) (List val)]] | val implements Encoding #Derived.toEncoder_list = \#Derived.lst -> custom diff --git a/crates/compiler/test_derive/src/hash.rs b/crates/compiler/test_derive/src/hash.rs index 4847f1044e..669fb37d25 100644 --- a/crates/compiler/test_derive/src/hash.rs +++ b/crates/compiler/test_derive/src/hash.rs @@ -151,8 +151,8 @@ fn empty_record() { derive_test(Hash, v!(EMPTY_RECORD), |golden| { assert_snapshot!(golden, @r###" # derived for {} - # hasher, {} -[[hash_{}(0)]]-> hasher | hasher has Hasher - # hasher, {} -[[hash_{}(0)]]-> hasher | hasher has Hasher + # hasher, {} -[[hash_{}(0)]]-> hasher | hasher implements Hasher + # hasher, {} -[[hash_{}(0)]]-> hasher | hasher implements Hasher # Specialization lambda sets: # @<1>: [[hash_{}(0)]] #Derived.hash_{} = \#Derived.hasher, #Derived.rcd -> #Derived.hasher @@ -166,8 +166,8 @@ fn zero_field_record() { derive_test(Hash, v!({}), |golden| { assert_snapshot!(golden, @r###" # derived for {} - # hasher, {} -[[hash_{}(0)]]-> hasher | hasher has Hasher - # hasher, {} -[[hash_{}(0)]]-> hasher | hasher has Hasher + # hasher, {} -[[hash_{}(0)]]-> hasher | hasher implements Hasher + # hasher, {} -[[hash_{}(0)]]-> hasher | hasher implements Hasher # Specialization lambda sets: # @<1>: [[hash_{}(0)]] #Derived.hash_{} = \#Derived.hasher, #Derived.rcd -> #Derived.hasher @@ -181,8 +181,8 @@ fn one_field_record() { derive_test(Hash, v!({ a: v!(U8), }), |golden| { assert_snapshot!(golden, @r###" # derived for { a : U8 } - # hasher, { a : a } -[[hash_{a}(0)]]-> hasher | a has Hash, hasher has Hasher - # hasher, { a : a } -[[hash_{a}(0)]]-> hasher | a has Hash, hasher has Hasher + # hasher, { a : a } -[[hash_{a}(0)]]-> hasher | a has Hash, hasher implements Hasher + # hasher, { a : a } -[[hash_{a}(0)]]-> hasher | a has Hash, hasher implements Hasher # Specialization lambda sets: # @<1>: [[hash_{a}(0)]] #Derived.hash_{a} = @@ -197,8 +197,8 @@ fn two_field_record() { derive_test(Hash, v!({ a: v!(U8), b: v!(STR), }), |golden| { assert_snapshot!(golden, @r###" # derived for { a : U8, b : Str } - # hasher, { a : a, b : a1 } -[[hash_{a,b}(0)]]-> hasher | a has Hash, a1 has Hash, hasher has Hasher - # hasher, { a : a, b : a1 } -[[hash_{a,b}(0)]]-> hasher | a has Hash, a1 has Hash, hasher has Hasher + # hasher, { a : a, b : a1 } -[[hash_{a,b}(0)]]-> hasher | a has Hash, a1 has Hash, hasher implements Hasher + # hasher, { a : a, b : a1 } -[[hash_{a,b}(0)]]-> hasher | a has Hash, a1 has Hash, hasher implements Hasher # Specialization lambda sets: # @<1>: [[hash_{a,b}(0)]] #Derived.hash_{a,b} = @@ -214,8 +214,8 @@ fn two_element_tuple() { derive_test(Hash, v!((v!(U8), v!(STR),)), |golden| { assert_snapshot!(golden, @r###" # derived for ( U8, Str )* - # hasher, ( a, a1 )* -[[hash_(arity:2)(0)]]-> hasher | a has Hash, a1 has Hash, hasher has Hasher - # hasher, ( a, a1 )* -[[hash_(arity:2)(0)]]-> hasher | a has Hash, a1 has Hash, hasher has Hasher + # hasher, ( a, a1 )* -[[hash_(arity:2)(0)]]-> hasher | a has Hash, a1 has Hash, hasher implements Hasher + # hasher, ( a, a1 )* -[[hash_(arity:2)(0)]]-> hasher | a has Hash, a1 has Hash, hasher implements Hasher # Specialization lambda sets: # @<1>: [[hash_(arity:2)(0)]] #Derived.hash_(arity:2) = @@ -231,8 +231,8 @@ fn tag_one_label_no_payloads() { derive_test(Hash, v!([A]), |golden| { assert_snapshot!(golden, @r###" # derived for [A] - # hasher, [A] -[[hash_[A 0](0)]]-> hasher | hasher has Hasher - # hasher, [A] -[[hash_[A 0](0)]]-> hasher | hasher has Hasher + # hasher, [A] -[[hash_[A 0](0)]]-> hasher | hasher implements Hasher + # hasher, [A] -[[hash_[A 0](0)]]-> hasher | hasher implements Hasher # Specialization lambda sets: # @<1>: [[hash_[A 0](0)]] #Derived.hash_[A 0] = \#Derived.hasher, A -> #Derived.hasher @@ -246,8 +246,8 @@ fn tag_one_label_newtype() { derive_test(Hash, v!([A v!(U8) v!(STR)]), |golden| { assert_snapshot!(golden, @r###" # derived for [A U8 Str] - # hasher, [A a a1] -[[hash_[A 2](0)]]-> hasher | a has Hash, a1 has Hash, hasher has Hasher - # hasher, [A a a1] -[[hash_[A 2](0)]]-> hasher | a has Hash, a1 has Hash, hasher has Hasher + # hasher, [A a a1] -[[hash_[A 2](0)]]-> hasher | a has Hash, a1 has Hash, hasher implements Hasher + # hasher, [A a a1] -[[hash_[A 2](0)]]-> hasher | a has Hash, a1 has Hash, hasher implements Hasher # Specialization lambda sets: # @<1>: [[hash_[A 2](0)]] #Derived.hash_[A 2] = @@ -263,8 +263,8 @@ fn tag_two_labels() { derive_test(Hash, v!([A v!(U8) v!(STR) v!(U16), B v!(STR)]), |golden| { assert_snapshot!(golden, @r###" # derived for [A U8 Str U16, B Str] - # a, [A a1 a2 a3, B a3] -[[hash_[A 3,B 1](0)]]-> a | a has Hasher, a1 has Hash, a2 has Hash, a3 has Hash - # a, [A a1 a2 a3, B a3] -[[hash_[A 3,B 1](0)]]-> a | a has Hasher, a1 has Hash, a2 has Hash, a3 has Hash + # a, [A a1 a2 a3, B a3] -[[hash_[A 3,B 1](0)]]-> a | a has Hasher, a1 has Hash, a2 has Hash, a3 implements Hash + # a, [A a1 a2 a3, B a3] -[[hash_[A 3,B 1](0)]]-> a | a has Hasher, a1 has Hash, a2 has Hash, a3 implements Hash # Specialization lambda sets: # @<1>: [[hash_[A 3,B 1](0)]] #Derived.hash_[A 3,B 1] = @@ -285,8 +285,8 @@ fn tag_two_labels_no_payloads() { derive_test(Hash, v!([A, B]), |golden| { assert_snapshot!(golden, @r###" # derived for [A, B] - # a, [A, B] -[[hash_[A 0,B 0](0)]]-> a | a has Hasher - # a, [A, B] -[[hash_[A 0,B 0](0)]]-> a | a has Hasher + # a, [A, B] -[[hash_[A 0,B 0](0)]]-> a | a implements Hasher + # a, [A, B] -[[hash_[A 0,B 0](0)]]-> a | a implements Hasher # Specialization lambda sets: # @<1>: [[hash_[A 0,B 0](0)]] #Derived.hash_[A 0,B 0] = @@ -304,8 +304,8 @@ fn recursive_tag_union() { derive_test(Hash, v!([Nil, Cons v!(U8) v!(^lst) ] as lst), |golden| { assert_snapshot!(golden, @r###" # derived for [Cons U8 $rec, Nil] as $rec - # a, [Cons a1 a2, Nil] -[[hash_[Cons 2,Nil 0](0)]]-> a | a has Hasher, a1 has Hash, a2 has Hash - # a, [Cons a1 a2, Nil] -[[hash_[Cons 2,Nil 0](0)]]-> a | a has Hasher, a1 has Hash, a2 has Hash + # a, [Cons a1 a2, Nil] -[[hash_[Cons 2,Nil 0](0)]]-> a | a has Hasher, a1 has Hash, a2 implements Hash + # a, [Cons a1 a2, Nil] -[[hash_[Cons 2,Nil 0](0)]]-> a | a has Hasher, a1 has Hash, a2 implements Hash # Specialization lambda sets: # @<1>: [[hash_[Cons 2,Nil 0](0)]] #Derived.hash_[Cons 2,Nil 0] = diff --git a/crates/compiler/test_gen/src/gen_abilities.rs b/crates/compiler/test_gen/src/gen_abilities.rs index 022765b7a0..99f706d444 100644 --- a/crates/compiler/test_gen/src/gen_abilities.rs +++ b/crates/compiler/test_gen/src/gen_abilities.rs @@ -20,10 +20,10 @@ fn hash_specialization() { r#" app "test" provides [main] to "./platform" - MHash has - hash : a -> U64 | a has MHash + MHash implements + hash : a -> U64 | a implements MHash - Id := U64 has [MHash {hash}] + Id := U64 implements [MHash {hash}] hash = \@Id n -> n @@ -43,14 +43,14 @@ fn hash_specialization_multiple_add() { r#" app "test" provides [main] to "./platform" - MHash has - hash : a -> U64 | a has MHash + MHash implements + hash : a -> U64 | a implements MHash - Id := U64 has [ MHash {hash: hashId} ] + Id := U64 implements [ MHash {hash: hashId} ] hashId = \@Id n -> n - One := {} has [ MHash {hash: hashOne} ] + One := {} implements [ MHash {hash: hashOne} ] hashOne = \@One _ -> 1 @@ -70,10 +70,10 @@ fn alias_member_specialization() { r#" app "test" provides [main] to "./platform" - MHash has - hash : a -> U64 | a has MHash + MHash implements + hash : a -> U64 | a implements MHash - Id := U64 has [MHash {hash}] + Id := U64 implements [MHash {hash}] hash = \@Id n -> n @@ -95,13 +95,13 @@ fn ability_constrained_in_non_member_usage() { r#" app "test" provides [result] to "./platform" - MHash has - hash : a -> U64 | a has MHash + MHash implements + hash : a -> U64 | a implements MHash - mulMHashes : a, a -> U64 | a has MHash + mulMHashes : a, a -> U64 | a implements MHash mulMHashes = \x, y -> hash x * hash y - Id := U64 has [MHash {hash}] + Id := U64 implements [MHash {hash}] hash = \@Id n -> n result = mulMHashes (@Id 5) (@Id 7) @@ -120,12 +120,12 @@ fn ability_constrained_in_non_member_usage_inferred() { r#" app "test" provides [result] to "./platform" - MHash has - hash : a -> U64 | a has MHash + MHash implements + hash : a -> U64 | a implements MHash mulMHashes = \x, y -> hash x * hash y - Id := U64 has [MHash {hash}] + Id := U64 implements [MHash {hash}] hash = \@Id n -> n result = mulMHashes (@Id 5) (@Id 7) @@ -144,16 +144,16 @@ fn ability_constrained_in_non_member_multiple_specializations() { r#" app "test" provides [result] to "./platform" - MHash has - hash : a -> U64 | a has MHash + MHash implements + hash : a -> U64 | a implements MHash - mulMHashes : a, b -> U64 | a has MHash, b has MHash + mulMHashes : a, b -> U64 | a implements MHash, b implements MHash mulMHashes = \x, y -> hash x * hash y - Id := U64 has [MHash { hash: hashId }] + Id := U64 implements [MHash { hash: hashId }] hashId = \@Id n -> n - Three := {} has [MHash { hash: hashThree }] + Three := {} implements [MHash { hash: hashThree }] hashThree = \@Three _ -> 3 result = mulMHashes (@Id 100) (@Three {}) @@ -172,15 +172,15 @@ fn ability_constrained_in_non_member_multiple_specializations_inferred() { r#" app "test" provides [result] to "./platform" - MHash has - hash : a -> U64 | a has MHash + MHash implements + hash : a -> U64 | a implements MHash mulMHashes = \x, y -> hash x * hash y - Id := U64 has [MHash { hash: hashId }] + Id := U64 implements [MHash { hash: hashId }] hashId = \@Id n -> n - Three := {} has [MHash { hash: hashThree }] + Three := {} implements [MHash { hash: hashThree }] hashThree = \@Three _ -> 3 result = mulMHashes (@Id 100) (@Three {}) @@ -199,16 +199,16 @@ fn ability_used_as_type_still_compiles() { r#" app "test" provides [result] to "./platform" - MHash has - hash : a -> U64 | a has MHash + MHash implements + hash : a -> U64 | a implements MHash mulMHashes : MHash, MHash -> U64 mulMHashes = \x, y -> hash x * hash y - Id := U64 has [MHash { hash: hashId }] + Id := U64 implements [MHash { hash: hashId }] hashId = \@Id n -> n - Three := {} has [MHash { hash: hashThree }] + Three := {} implements [MHash { hash: hashThree }] hashThree = \@Three _ -> 3 result = mulMHashes (@Id 100) (@Three {}) @@ -227,15 +227,15 @@ fn bounds_to_multiple_abilities() { r#" app "test" provides [main] to "./platform" - Idempot has idempot : a -> a | a has Idempot - Consume has consume : a -> Str | a has Consume + Idempot implements idempot : a -> a | a implements Idempot + Consume implements consume : a -> Str | a implements Consume - Hello := Str has [Idempot { idempot: idempotHello }, Consume { consume: consumeHello }] + Hello := Str implements [Idempot { idempot: idempotHello }, Consume { consume: consumeHello }] idempotHello = \@Hello msg -> @Hello msg consumeHello = \@Hello msg -> msg - lifecycle : a -> Str | a has Idempot & Consume + lifecycle : a -> Str | a implements Idempot & Consume lifecycle = \x -> idempot x |> consume main = lifecycle (@Hello "hello world") @@ -254,26 +254,26 @@ fn encode() { r#" app "test" provides [myU8Bytes] to "./platform" - MEncoder fmt := List U8, fmt -> List U8 | fmt has Format + MEncoder fmt := List U8, fmt -> List U8 | fmt implements Format - MEncoding has - toEncoder : val -> MEncoder fmt | val has MEncoding, fmt has Format + MEncoding implements + toEncoder : val -> MEncoder fmt | val implements MEncoding, fmt implements Format - Format has - u8 : U8 -> MEncoder fmt | fmt has Format + Format implements + u8 : U8 -> MEncoder fmt | fmt implements Format - appendWith : List U8, MEncoder fmt, fmt -> List U8 | fmt has Format + appendWith : List U8, MEncoder fmt, fmt -> List U8 | fmt implements Format appendWith = \lst, (@MEncoder doFormat), fmt -> doFormat lst fmt - toBytes : val, fmt -> List U8 | val has MEncoding, fmt has Format + toBytes : val, fmt -> List U8 | val implements MEncoding, fmt implements Format toBytes = \val, fmt -> appendWith [] (toEncoder val) fmt - Linear := {} has [Format {u8}] + Linear := {} implements [Format {u8}] u8 = \n -> @MEncoder (\lst, @Linear {} -> List.append lst n) - Rgba := { r : U8, g : U8, b : U8, a : U8 } has [MEncoding {toEncoder}] + Rgba := { r : U8, g : U8, b : U8, a : U8 } implements [MEncoding {toEncoder}] toEncoder = \@Rgba {r, g, b, a} -> @MEncoder \lst, fmt -> lst @@ -301,19 +301,19 @@ fn decode() { MDecodeError : [TooShort, Leftover (List U8)] - MDecoder val fmt := List U8, fmt -> { result: Result val MDecodeError, rest: List U8 } | fmt has MDecoderFormatting + MDecoder val fmt := List U8, fmt -> { result: Result val MDecodeError, rest: List U8 } | fmt implements MDecoderFormatting - MDecoding has - decoder : MDecoder val fmt | val has MDecoding, fmt has MDecoderFormatting + MDecoding implements + decoder : MDecoder val fmt | val implements MDecoding, fmt implements MDecoderFormatting - MDecoderFormatting has - u8 : MDecoder U8 fmt | fmt has MDecoderFormatting + MDecoderFormatting implements + u8 : MDecoder U8 fmt | fmt implements MDecoderFormatting - decodeWith : List U8, MDecoder val fmt, fmt -> { result: Result val MDecodeError, rest: List U8 } | fmt has MDecoderFormatting + decodeWith : List U8, MDecoder val fmt, fmt -> { result: Result val MDecodeError, rest: List U8 } | fmt implements MDecoderFormatting decodeWith = \lst, (@MDecoder doDecode), fmt -> doDecode lst fmt fromBytes : List U8, fmt -> Result val MDecodeError - | fmt has MDecoderFormatting, val has MDecoding + | fmt implements MDecoderFormatting, val implements MDecoding fromBytes = \lst, fmt -> when decodeWith lst decoder fmt is { result, rest } -> @@ -323,14 +323,14 @@ fn decode() { else Err (Leftover rest) - Linear := {} has [MDecoderFormatting {u8}] + Linear := {} implements [MDecoderFormatting {u8}] u8 = @MDecoder \lst, @Linear {} -> when List.first lst is Ok n -> { result: Ok n, rest: List.dropFirst lst } Err _ -> { result: Err TooShort, rest: [] } - MyU8 := U8 has [MDecoding {decoder}] + MyU8 := U8 implements [MDecoding {decoder}] # impl MDecoding for MyU8 decoder = @MDecoder \lst, fmt -> @@ -358,7 +358,7 @@ fn encode_use_stdlib() { imports [Encode, Json] provides [main] to "./platform" - HelloWorld := {} has [Encoding {toEncoder}] + HelloWorld := {} implements [Encoding {toEncoder}] toEncoder = \@HelloWorld {} -> Encode.custom \bytes, fmt -> bytes @@ -386,7 +386,7 @@ fn encode_use_stdlib_without_wrapping_custom() { imports [Encode, Json] provides [main] to "./platform" - HelloWorld := {} has [Encoding {toEncoder}] + HelloWorld := {} implements [Encoding {toEncoder}] toEncoder = \@HelloWorld {} -> Encode.string "Hello, World!\n" main = @@ -411,7 +411,7 @@ fn encode_derive_to_encoder_for_opaque() { imports [Json] provides [main] to "./platform" - HelloWorld := { a: Str } has [Encoding] + HelloWorld := { a: Str } implements [Encoding] main = result = Str.fromUtf8 (Encode.toBytes (@HelloWorld { a: "Hello, World!" }) Json.json) @@ -435,7 +435,7 @@ fn to_encoder_encode_custom_has_capture() { imports [Encode, Json] provides [main] to "./platform" - HelloWorld := Str has [Encoding {toEncoder}] + HelloWorld := Str implements [Encoding {toEncoder}] toEncoder = \@HelloWorld s1 -> Encode.custom \bytes, fmt -> bytes @@ -881,7 +881,7 @@ fn encode_derived_generic_record_with_different_field_types() { imports [Encode, Json] provides [main] to "./platform" - Q a b := {a: a, b: b} has [Encoding] + Q a b := {a: a, b: b} implements [Encoding] q = @Q {a: 10u32, b: "fieldb"} @@ -907,7 +907,7 @@ fn encode_derived_generic_tag_with_different_field_types() { imports [Encode, Json] provides [main] to "./platform" - Q a b := [A a, B b] has [Encoding] + Q a b := [A a, B b] implements [Encoding] q : Q Str U32 q = @Q (B 67) @@ -934,7 +934,7 @@ fn decode_use_stdlib() { imports [Json] provides [main] to "./platform" - MyNum := U8 has [Decoding {decoder: myDecoder}] + MyNum := U8 implements [Decoding {decoder: myDecoder}] myDecoder = Decode.custom \bytes, fmt -> @@ -968,7 +968,7 @@ fn decode_derive_decoder_for_opaque() { imports [Json] provides [main] to "./platform" - HelloWorld := { a: Str } has [Decoding] + HelloWorld := { a: Str } implements [Decoding] main = when Str.toUtf8 """{"a":"Hello, World!"}""" |> Decode.fromBytes Json.json is @@ -991,7 +991,7 @@ fn decode_use_stdlib_json_list() { imports [Json] provides [main] to "./platform" - MyNumList := List U8 has [Decoding {decoder: myDecoder}] + MyNumList := List U8 implements [Decoding {decoder: myDecoder}] myDecoder = Decode.custom \bytes, fmt -> @@ -1414,7 +1414,7 @@ mod hash { const TEST_HASHER: &str = indoc!( r#" - THasher := List U8 has [Hasher { + THasher := List U8 implements [Hasher { addBytes: tAddBytes, addU8: tAddU8, addU16: tAddU16, @@ -1947,7 +1947,7 @@ mod hash { {} - Q := {{ a: U8, b: U8, c: U8 }} has [Hash] + Q := {{ a: U8, b: U8, c: U8 }} implements [Hash] q = @Q {{ a: 15, b: 27, c: 31 }} @@ -2000,7 +2000,7 @@ mod eq { r#" app "test" provides [main] to "./platform" - LyingEq := U8 has [Eq {isEq}] + LyingEq := U8 implements [Eq {isEq}] isEq = \@LyingEq m, @LyingEq n -> m != n @@ -2026,7 +2026,7 @@ mod eq { r#" app "test" provides [main] to "./platform" - Q := ({} -> Str) has [Eq {isEq: isEqQ}] + Q := ({} -> Str) implements [Eq {isEq: isEqQ}] isEqQ = \@Q _, @Q _ -> Bool.true @@ -2046,7 +2046,7 @@ mod eq { r#" app "test" provides [main] to "./platform" - Q := ({} -> Str) has [Eq {isEq: isEqQ}] + Q := ({} -> Str) implements [Eq {isEq: isEqQ}] isEqQ = \@Q f1, @Q f2 -> (f1 {} == f2 {}) @@ -2080,7 +2080,7 @@ mod eq { r#" app "test" provides [main] to "./platform" - Q := U8 has [Eq] + Q := U8 implements [Eq] main = (@Q 15) == (@Q 15) "# diff --git a/crates/compiler/test_gen/src/gen_list.rs b/crates/compiler/test_gen/src/gen_list.rs index c859ebf2f2..f343ea7830 100644 --- a/crates/compiler/test_gen/src/gen_list.rs +++ b/crates/compiler/test_gen/src/gen_list.rs @@ -960,7 +960,7 @@ fn list_walk_implements_position() { r#" Option a : [Some a, None] - find : List a, a -> Option Nat | a has Eq + find : List a, a -> Option Nat | a implements Eq find = \list, needle -> findHelp list needle |> .v @@ -3693,7 +3693,7 @@ fn list_walk_backwards_implements_position() { r#" Option a : [Some a, None] - find : List a, a -> Option Nat | a has Eq + find : List a, a -> Option Nat | a implements Eq find = \list, needle -> findHelp list needle |> .v diff --git a/crates/compiler/test_gen/src/gen_num.rs b/crates/compiler/test_gen/src/gen_num.rs index e29b62f71e..95df22275d 100644 --- a/crates/compiler/test_gen/src/gen_num.rs +++ b/crates/compiler/test_gen/src/gen_num.rs @@ -891,7 +891,7 @@ fn gen_wrap_int_neq() { assert_evals_to!( indoc!( r#" - wrappedNotEq : a, a -> Bool | a has Eq + wrappedNotEq : a, a -> Bool | a implements Eq wrappedNotEq = \num1, num2 -> num1 != num2 diff --git a/crates/compiler/test_mono/src/tests.rs b/crates/compiler/test_mono/src/tests.rs index 11296395a9..703ea122e8 100644 --- a/crates/compiler/test_mono/src/tests.rs +++ b/crates/compiler/test_mono/src/tests.rs @@ -1344,10 +1344,10 @@ fn specialize_ability_call() { r#" app "test" provides [main] to "./platform" - MHash has - hash : a -> U64 | a has MHash + MHash implements + hash : a -> U64 | a implements MHash - Id := U64 has [MHash {hash}] + Id := U64 implements [MHash {hash}] hash : Id -> U64 hash = \@Id n -> n @@ -1380,20 +1380,20 @@ fn encode() { r#" app "test" provides [myU8Bytes] to "./platform" - MEncoder fmt := List U8, fmt -> List U8 | fmt has Format + MEncoder fmt := List U8, fmt -> List U8 | fmt implements Format - MEncoding has - toEncoder : val -> MEncoder fmt | val has MEncoding, fmt has Format + MEncoding implements + toEncoder : val -> MEncoder fmt | val implements MEncoding, fmt implements Format - Format has - u8 : U8 -> MEncoder fmt | fmt has Format + Format implements + u8 : U8 -> MEncoder fmt | fmt implements Format - Linear := {} has [Format {u8}] + Linear := {} implements [Format {u8}] u8 = \n -> @MEncoder (\lst, @Linear {} -> List.append lst n) - MyU8 := U8 has [MEncoding {toEncoder}] + MyU8 := U8 implements [MEncoding {toEncoder}] toEncoder = \@MyU8 n -> u8 n @@ -2600,20 +2600,20 @@ fn unspecialized_lambda_set_unification_keeps_all_concrete_types_without_unifica r#" app "test" provides [main] to "./platform" - MEncoder fmt := List U8, fmt -> List U8 | fmt has Format + MEncoder fmt := List U8, fmt -> List U8 | fmt implements Format - MEncoding has - toEncoder : val -> MEncoder fmt | val has MEncoding, fmt has Format + MEncoding implements + toEncoder : val -> MEncoder fmt | val implements MEncoding, fmt implements Format - Format has - u8 : {} -> MEncoder fmt | fmt has Format - str : {} -> MEncoder fmt | fmt has Format - tag : MEncoder fmt -> MEncoder fmt | fmt has Format + Format implements + u8 : {} -> MEncoder fmt | fmt implements Format + str : {} -> MEncoder fmt | fmt implements Format + tag : MEncoder fmt -> MEncoder fmt | fmt implements Format - Linear := {} has [Format {u8: lU8, str: lStr, tag: lTag}] + Linear := {} implements [Format {u8: lU8, str: lStr, tag: lTag}] - MU8 := U8 has [MEncoding {toEncoder: toEncoderU8}] - MStr := Str has [MEncoding {toEncoder: toEncoderStr}] + MU8 := U8 implements [MEncoding {toEncoder: toEncoderU8}] + MStr := Str implements [MEncoding {toEncoder: toEncoderStr}] Q a b := { a: a, b: b } @@ -2663,7 +2663,7 @@ fn unspecialized_lambda_set_unification_keeps_all_concrete_types_without_unifica r#" app "test" imports [Json] provides [main] to "./platform" - Q a b := { a: a, b: b } has [Encoding {toEncoder: toEncoderQ}] + Q a b := { a: a, b: b } implements [Encoding {toEncoder: toEncoderQ}] toEncoderQ = \@Q t -> Encode.custom \bytes, fmt -> @@ -2701,7 +2701,7 @@ fn unspecialized_lambda_set_unification_does_not_duplicate_identical_concrete_ty r#" app "test" imports [Json] provides [main] to "./platform" - Q a b := { a: a, b: b } has [Encoding {toEncoder: toEncoderQ}] + Q a b := { a: a, b: b } implements [Encoding {toEncoder: toEncoderQ}] toEncoderQ = \@Q t -> Encode.custom \bytes, fmt -> diff --git a/crates/compiler/test_syntax/fuzz/dict.txt b/crates/compiler/test_syntax/fuzz/dict.txt index 805712e5ff..6368aa3e2d 100644 --- a/crates/compiler/test_syntax/fuzz/dict.txt +++ b/crates/compiler/test_syntax/fuzz/dict.txt @@ -6,7 +6,7 @@ "is" "expect" "dbg" -"has" +"implements" "app" "platform" diff --git a/crates/compiler/test_syntax/tests/snapshots/fail/ability_demand_value_has_args.expr.roc b/crates/compiler/test_syntax/tests/snapshots/fail/ability_demand_value_has_args.expr.roc index d6df16d287..3b411cb332 100644 --- a/crates/compiler/test_syntax/tests/snapshots/fail/ability_demand_value_has_args.expr.roc +++ b/crates/compiler/test_syntax/tests/snapshots/fail/ability_demand_value_has_args.expr.roc @@ -1,4 +1,4 @@ -MEq has - eq b c : a, a -> U64 | a has MEq +MEq implements + eq b c : a, a -> U64 | a implements MEq 1 diff --git a/crates/compiler/test_syntax/tests/snapshots/fail/ability_demands_not_indented_with_first.expr.roc b/crates/compiler/test_syntax/tests/snapshots/fail/ability_demands_not_indented_with_first.expr.roc index f07901e9cc..8d0aa047c9 100644 --- a/crates/compiler/test_syntax/tests/snapshots/fail/ability_demands_not_indented_with_first.expr.roc +++ b/crates/compiler/test_syntax/tests/snapshots/fail/ability_demands_not_indented_with_first.expr.roc @@ -1,5 +1,5 @@ -MEq has - eq : a, a -> U64 | a has MEq - neq : a, a -> U64 | a has MEq +MEq implements + eq : a, a -> U64 | a implements MEq + neq : a, a -> U64 | a implements MEq 1 diff --git a/crates/compiler/test_syntax/tests/snapshots/fail/ability_first_demand_not_indented_enough.expr.roc b/crates/compiler/test_syntax/tests/snapshots/fail/ability_first_demand_not_indented_enough.expr.roc index 3b76e70bc2..92086a5f15 100644 --- a/crates/compiler/test_syntax/tests/snapshots/fail/ability_first_demand_not_indented_enough.expr.roc +++ b/crates/compiler/test_syntax/tests/snapshots/fail/ability_first_demand_not_indented_enough.expr.roc @@ -1,4 +1,4 @@ -MEq has -eq : a, a -> U64 | a has MEq +MEq implements +eq : a, a -> U64 | a implements MEq 1 diff --git a/crates/compiler/test_syntax/tests/snapshots/fail/ability_non_signature_expression.expr.roc b/crates/compiler/test_syntax/tests/snapshots/fail/ability_non_signature_expression.expr.roc index 0651010e94..02772c6ee7 100644 --- a/crates/compiler/test_syntax/tests/snapshots/fail/ability_non_signature_expression.expr.roc +++ b/crates/compiler/test_syntax/tests/snapshots/fail/ability_non_signature_expression.expr.roc @@ -1,4 +1,4 @@ -MEq has +MEq implements 123 1 diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/ability_demand_signature_is_multiline.expr.formatted.roc b/crates/compiler/test_syntax/tests/snapshots/pass/ability_demand_signature_is_multiline.expr.formatted.roc index 9f2662a247..4056155950 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/ability_demand_signature_is_multiline.expr.formatted.roc +++ b/crates/compiler/test_syntax/tests/snapshots/pass/ability_demand_signature_is_multiline.expr.formatted.roc @@ -1,4 +1,4 @@ -Hash has +Hash implements hash : a -> U64 diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/ability_demand_signature_is_multiline.expr.roc b/crates/compiler/test_syntax/tests/snapshots/pass/ability_demand_signature_is_multiline.expr.roc index 5e218feb6e..02de08c9ec 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/ability_demand_signature_is_multiline.expr.roc +++ b/crates/compiler/test_syntax/tests/snapshots/pass/ability_demand_signature_is_multiline.expr.roc @@ -1,4 +1,4 @@ -Hash has +Hash implements hash : a -> U64 diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/ability_multi_line.expr.formatted.roc b/crates/compiler/test_syntax/tests/snapshots/pass/ability_multi_line.expr.formatted.roc index 56efcb2abc..740886df35 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/ability_multi_line.expr.formatted.roc +++ b/crates/compiler/test_syntax/tests/snapshots/pass/ability_multi_line.expr.formatted.roc @@ -1,4 +1,4 @@ -Hash has +Hash implements hash : a -> U64 hash2 : a -> U64 diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/ability_multi_line.expr.roc b/crates/compiler/test_syntax/tests/snapshots/pass/ability_multi_line.expr.roc index 795c19bad6..43b178a6bd 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/ability_multi_line.expr.roc +++ b/crates/compiler/test_syntax/tests/snapshots/pass/ability_multi_line.expr.roc @@ -1,4 +1,4 @@ -Hash has +Hash implements hash : a -> U64 hash2 : a -> U64 diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/ability_single_line.expr.roc b/crates/compiler/test_syntax/tests/snapshots/pass/ability_single_line.expr.roc index c3d8e53fab..798560ef41 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/ability_single_line.expr.roc +++ b/crates/compiler/test_syntax/tests/snapshots/pass/ability_single_line.expr.roc @@ -1,3 +1,3 @@ -Hash has hash : a -> U64 | a has Hash +Hash implements hash : a -> U64 | a implements Hash 1 diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/ability_two_in_a_row.expr.roc b/crates/compiler/test_syntax/tests/snapshots/pass/ability_two_in_a_row.expr.roc index f747842c70..1c5fad72e5 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/ability_two_in_a_row.expr.roc +++ b/crates/compiler/test_syntax/tests/snapshots/pass/ability_two_in_a_row.expr.roc @@ -1,5 +1,5 @@ -Ab1 has ab1 : a -> {} | a has Ab1 +Ab1 implements ab1 : a -> {} | a implements Ab1 -Ab2 has ab2 : a -> {} | a has Ab2 +Ab2 implements ab2 : a -> {} | a implements Ab2 1 diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/opaque_has_abilities.expr.formatted.roc b/crates/compiler/test_syntax/tests/snapshots/pass/opaque_has_abilities.expr.formatted.roc index 783b9d8c17..32173c522a 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/opaque_has_abilities.expr.formatted.roc +++ b/crates/compiler/test_syntax/tests/snapshots/pass/opaque_has_abilities.expr.formatted.roc @@ -1,24 +1,24 @@ -A := U8 has [Eq, Hash] +A := U8 implements [Eq, Hash] -A := a | a has Other - has [Eq, Hash] +A := a | a implements Other + implements [Eq, Hash] -A := a | a has Other - has [Eq, Hash] +A := a | a implements Other + implements [Eq, Hash] -A := U8 has [Eq { eq }, Hash { hash }] +A := U8 implements [Eq { eq }, Hash { hash }] -A := U8 has [Eq { eq, eq1 }] +A := U8 implements [Eq { eq, eq1 }] -A := U8 has [Eq { eq, eq1 }, Hash] +A := U8 implements [Eq { eq, eq1 }, Hash] -A := U8 has [Hash, Eq { eq, eq1 }] +A := U8 implements [Hash, Eq { eq, eq1 }] -A := U8 has [] +A := U8 implements [] -A := a | a has Other - has [Eq { eq }, Hash { hash }] +A := a | a implements Other + implements [Eq { eq }, Hash { hash }] -A := U8 has [Eq {}] +A := U8 implements [Eq {}] 0 \ No newline at end of file diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/opaque_has_abilities.expr.roc b/crates/compiler/test_syntax/tests/snapshots/pass/opaque_has_abilities.expr.roc index f8f0fe9e29..3228574abc 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/opaque_has_abilities.expr.roc +++ b/crates/compiler/test_syntax/tests/snapshots/pass/opaque_has_abilities.expr.roc @@ -1,23 +1,23 @@ -A := U8 has [Eq, Hash] +A := U8 implements [Eq, Hash] -A := a | a has Other has [Eq, Hash] +A := a | a implements Other implements [Eq, Hash] -A := a | a has Other - has [Eq, Hash] +A := a | a implements Other + implements [Eq, Hash] -A := U8 has [Eq {eq}, Hash {hash}] +A := U8 implements [Eq {eq}, Hash {hash}] -A := U8 has [Eq {eq, eq1}] +A := U8 implements [Eq {eq, eq1}] -A := U8 has [Eq {eq, eq1}, Hash] +A := U8 implements [Eq {eq, eq1}, Hash] -A := U8 has [Hash, Eq {eq, eq1}] +A := U8 implements [Hash, Eq {eq, eq1}] -A := U8 has [] +A := U8 implements [] -A := a | a has Other - has [Eq {eq}, Hash {hash}] +A := a | a implements Other + implements [Eq {eq}, Hash {hash}] -A := U8 has [Eq {}] +A := U8 implements [Eq {}] 0 diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_function.expr.roc b/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_function.expr.roc index ede845156a..6b11f13621 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_function.expr.roc +++ b/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_function.expr.roc @@ -1,3 +1,3 @@ -f : a -> (b -> c) | a has A +f : a -> (b -> c) | a implements A f diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_multiple_bound_abilities.expr.formatted.roc b/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_multiple_bound_abilities.expr.formatted.roc index 333e60e19b..70a5869e41 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_multiple_bound_abilities.expr.formatted.roc +++ b/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_multiple_bound_abilities.expr.formatted.roc @@ -1,5 +1,5 @@ -f : a -> b | a has Hash & Eq, b has Eq & Hash & Display +f : a -> b | a implements Hash & Eq, b implements Eq & Hash & Display -f : a -> b | a has Hash & Eq, b has Hash & Display & Eq +f : a -> b | a implements Hash & Eq, b implements Hash & Display & Eq f \ No newline at end of file diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_multiple_bound_abilities.expr.roc b/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_multiple_bound_abilities.expr.roc index 29f4f89026..2a151bfd52 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_multiple_bound_abilities.expr.roc +++ b/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_multiple_bound_abilities.expr.roc @@ -1,7 +1,7 @@ -f : a -> b | a has Hash & Eq, b has Eq & Hash & Display +f : a -> b | a implements Hash & Eq, b implements Eq & Hash & Display f : a -> b - | a has Hash & Eq, - b has Hash & Display & Eq + | a implements Hash & Eq, + b implements Hash & Display & Eq f diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_multiple_has.expr.roc b/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_multiple_has.expr.roc index a56e9fb184..4de00586ac 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_multiple_has.expr.roc +++ b/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_multiple_has.expr.roc @@ -1,3 +1,3 @@ -f : a -> (b -> c) | a has A, b has Eq, c has Ord +f : a -> (b -> c) | a implements A, b implements Eq, c implements Ord f diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_multiple_has_across_newlines.expr.formatted.roc b/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_multiple_has_across_newlines.expr.formatted.roc index 8ca6701ffc..1e2868883e 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_multiple_has_across_newlines.expr.formatted.roc +++ b/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_multiple_has_across_newlines.expr.formatted.roc @@ -1,3 +1,3 @@ -f : a -> (b -> c) | a has Hash, b has Eq, c has Ord +f : a -> (b -> c) | a has Hash, b has Eq, c implements Ord f \ No newline at end of file diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_multiple_has_across_newlines.expr.roc b/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_multiple_has_across_newlines.expr.roc index a5e89f075f..98fd144541 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_multiple_has_across_newlines.expr.roc +++ b/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_multiple_has_across_newlines.expr.roc @@ -1,6 +1,6 @@ f : a -> (b -> c) - | a has Hash, - b has Eq, - c has Ord + | a implements Hash, + b implements Eq, + c implements Ord f diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_non_function.expr.roc b/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_non_function.expr.roc index eb3374f992..d60270f465 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_non_function.expr.roc +++ b/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_non_function.expr.roc @@ -1,3 +1,3 @@ -f : a | a has A +f : a | a implements A f diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_on_newline.expr.formatted.roc b/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_on_newline.expr.formatted.roc index fb742eac39..bdef6cc7de 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_on_newline.expr.formatted.roc +++ b/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_on_newline.expr.formatted.roc @@ -1,3 +1,3 @@ -f : a -> U64 | a has Hash +f : a -> U64 | a implements Hash f \ No newline at end of file diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_on_newline.expr.roc b/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_on_newline.expr.roc index 7f29c770d3..050ad46910 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_on_newline.expr.roc +++ b/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_on_newline.expr.roc @@ -1,4 +1,4 @@ f : a -> U64 - | a has Hash + | a implements Hash f diff --git a/crates/compiler/test_syntax/tests/test_fmt.rs b/crates/compiler/test_syntax/tests/test_fmt.rs index 751b3f080b..8d092432bf 100644 --- a/crates/compiler/test_syntax/tests/test_fmt.rs +++ b/crates/compiler/test_syntax/tests/test_fmt.rs @@ -5428,7 +5428,7 @@ mod test_fmt { fn opaque_has_clause() { expr_formats_same(indoc!( r#" - A := U8 has [Eq, Hash] + A := U8 implements [Eq, Hash] 0 "# @@ -5439,7 +5439,7 @@ mod test_fmt { r#" A := U8 - has [Eq, Hash] + implements [Eq, Hash] 0 "# @@ -5447,7 +5447,7 @@ mod test_fmt { indoc!( r#" A := U8 - has [Eq, Hash] + implements [Eq, Hash] 0 "# @@ -5457,15 +5457,15 @@ mod test_fmt { expr_formats_to( indoc!( r#" - A := a | a has Hash has [ Eq, Hash ] + A := a | a implements Hash implements [ Eq, Hash ] 0 "# ), indoc!( r#" - A := a | a has Hash - has [Eq, Hash] + A := a | a implements Hash + implements [Eq, Hash] 0 "# @@ -5475,14 +5475,14 @@ mod test_fmt { expr_formats_to( indoc!( r#" - A := U8 has [] + A := U8 implements [] 0 "# ), indoc!( r#" - A := U8 has [] + A := U8 implements [] 0 "# @@ -5525,7 +5525,7 @@ mod test_fmt { fn opaque_has_with_impls() { expr_formats_same(indoc!( r#" - A := U8 has [Eq { eq }, Hash { hash }] + A := U8 implements [Eq { eq }, Hash { hash }] 0 "# @@ -5533,7 +5533,7 @@ mod test_fmt { expr_formats_same(indoc!( r#" - A := U8 has [Eq { eq, eq1 }] + A := U8 implements [Eq { eq, eq1 }] 0 "# @@ -5542,8 +5542,8 @@ mod test_fmt { expr_formats_to( indoc!( r#" - A := U8 has [Eq { eq, eq1 }] - A := U8 has [Eq { + A := U8 implements [Eq { eq, eq1 }] + A := U8 implements [Eq { eq, eq1 }] @@ -5553,8 +5553,8 @@ mod test_fmt { ), indoc!( r#" - A := U8 has [Eq { eq, eq1 }] - A := U8 has [ + A := U8 implements [Eq { eq, eq1 }] + A := U8 implements [ Eq { eq, eq1, @@ -5568,8 +5568,8 @@ mod test_fmt { expr_formats_same(indoc!( r#" - A := a | a has Other - has [Eq { eq }, Hash { hash }] + A := a | a implements Other + implements [Eq { eq }, Hash { hash }] 0 "# @@ -5577,7 +5577,7 @@ mod test_fmt { expr_formats_same(indoc!( r#" - A := U8 has [Eq {}] + A := U8 implements [Eq {}] 0 "# @@ -5625,7 +5625,7 @@ mod test_fmt { dataIndices : List Nat, data : List (T k v), size : Nat, - } | k has Hash & Eq + } | k implements Hash & Eq a "# @@ -5837,12 +5837,12 @@ mod test_fmt { r#" interface Foo exposes [] imports [] - A has + A implements ## This is member ab - ab : a -> a | a has A + ab : a -> a | a implements A ## This is member de - de : a -> a | a has A + de : a -> a | a implements A f = g "# @@ -5884,7 +5884,7 @@ mod test_fmt { fn clauses_with_multiple_abilities() { expr_formats_same(indoc!( r#" - f : {} -> a | a has Eq & Hash & Decode + f : {} -> a | a implements Eq & Hash & Decode f "# @@ -5893,8 +5893,8 @@ mod test_fmt { expr_formats_to( indoc!( r#" - f : {} -> a | a has Eq & Hash & Decode, - b has Eq & Hash + f : {} -> a | a implements Eq & Hash & Decode, + b implements Eq & Hash f "# @@ -5902,10 +5902,10 @@ mod test_fmt { indoc!( // TODO: ideally, this would look a bit nicer - consider // f : {} -> a - // | a has Eq & Hash & Decode, - // b has Eq & Hash + // | a implements Eq & Hash & Decode, + // b implements Eq & Hash r#" - f : {} -> a | a has Eq & Hash & Decode, b has Eq & Hash + f : {} -> a | a implements Eq & Hash & Decode, b implements Eq & Hash f "# diff --git a/crates/compiler/uitest/tests/ability/bounds/expand_able_variables_in_type_alias.txt b/crates/compiler/uitest/tests/ability/bounds/expand_able_variables_in_type_alias.txt index 8efd15d88d..6cc44c9d8b 100644 --- a/crates/compiler/uitest/tests/ability/bounds/expand_able_variables_in_type_alias.txt +++ b/crates/compiler/uitest/tests/ability/bounds/expand_able_variables_in_type_alias.txt @@ -1,7 +1,7 @@ # +opt infer:print_only_under_alias app "test" provides [main] to "./platform" -F a : a | a has Hash +F a : a | a implements Hash main : F a -> F a -#^^^^{-1} a -[[main(0)]]-> a | a has Hash +#^^^^{-1} a -[[main(0)]]-> a | a implements Hash diff --git a/crates/compiler/uitest/tests/ability/bounds/multiple_variables_bound_to_an_ability_from_type_def.txt b/crates/compiler/uitest/tests/ability/bounds/multiple_variables_bound_to_an_ability_from_type_def.txt index 5379b86d50..4d18952a60 100644 --- a/crates/compiler/uitest/tests/ability/bounds/multiple_variables_bound_to_an_ability_from_type_def.txt +++ b/crates/compiler/uitest/tests/ability/bounds/multiple_variables_bound_to_an_ability_from_type_def.txt @@ -1,7 +1,7 @@ # +opt infer:print_only_under_alias app "test" provides [main] to "./platform" -F a : a | a has Hash & Eq & Decoding +F a : a | a implements Hash & Eq & Decoding main : F a -> F a -#^^^^{-1} a -[[main(0)]]-> a | a has Hash & Decoding & Eq +#^^^^{-1} a -[[main(0)]]-> a | a implements Hash & Decoding & Eq diff --git a/crates/compiler/uitest/tests/ability/bounds/rigid_able_bounds_are_superset_of_flex_bounds_admitted.txt b/crates/compiler/uitest/tests/ability/bounds/rigid_able_bounds_are_superset_of_flex_bounds_admitted.txt index f262ca2265..a06679108d 100644 --- a/crates/compiler/uitest/tests/ability/bounds/rigid_able_bounds_are_superset_of_flex_bounds_admitted.txt +++ b/crates/compiler/uitest/tests/ability/bounds/rigid_able_bounds_are_superset_of_flex_bounds_admitted.txt @@ -1,8 +1,8 @@ app "test" provides [main] to "./platform" -f : x -> x | x has Hash -g : x -> x | x has Decoding & Encoding +f : x -> x | x implements Hash +g : x -> x | x implements Decoding & Encoding -main : x -> x | x has Hash & Decoding & Encoding +main : x -> x | x implements Hash & Decoding & Encoding main = \x -> x |> f |> g -#^^^^{-1} x -[[main(0)]]-> x | x has Hash & Encoding & Decoding +#^^^^{-1} x -[[main(0)]]-> x | x implements Hash & Encoding & Decoding diff --git a/crates/compiler/uitest/tests/ability/generalize_inferred_opaque_variable_bound_to_ability_issue_4408.txt b/crates/compiler/uitest/tests/ability/generalize_inferred_opaque_variable_bound_to_ability_issue_4408.txt index da1662ffa2..3868cf4d17 100644 --- a/crates/compiler/uitest/tests/ability/generalize_inferred_opaque_variable_bound_to_ability_issue_4408.txt +++ b/crates/compiler/uitest/tests/ability/generalize_inferred_opaque_variable_bound_to_ability_issue_4408.txt @@ -1,6 +1,6 @@ app "test" provides [top] to "./platform" -MDict u := (List u) | u has Hash & Eq +MDict u := (List u) | u implements Hash & Eq bot : MDict k -> MDict k bot = \@MDict data -> @@ -9,4 +9,4 @@ bot = \@MDict data -> top : MDict v -> MDict v top = \x -> bot x -#^^^{-1} MDict v -[[top(0)]]-> MDict v | v has Hash & Eq +#^^^{-1} MDict v -[[top(0)]]-> MDict v | v implements Hash & Eq diff --git a/crates/compiler/uitest/tests/ability/impl_ability_for_opaque_with_lambda_sets.txt b/crates/compiler/uitest/tests/ability/impl_ability_for_opaque_with_lambda_sets.txt index 57d44ca289..3198cd1bf3 100644 --- a/crates/compiler/uitest/tests/ability/impl_ability_for_opaque_with_lambda_sets.txt +++ b/crates/compiler/uitest/tests/ability/impl_ability_for_opaque_with_lambda_sets.txt @@ -1,6 +1,6 @@ app "test" provides [isEqQ] to "./platform" -Q := [ F (Str -> Str), G ] has [Eq { isEq: isEqQ }] +Q := [ F (Str -> Str), G ] implements [Eq { isEq: isEqQ }] isEqQ = \@Q q1, @Q q2 -> when T q1 q2 is #^^^^^{-1} Q, Q -[[isEqQ(0)]]-> Bool diff --git a/crates/compiler/uitest/tests/ability/impl_ability_for_opaque_with_lambda_sets_material.txt b/crates/compiler/uitest/tests/ability/impl_ability_for_opaque_with_lambda_sets_material.txt index a0a9335f0b..b47c5af154 100644 --- a/crates/compiler/uitest/tests/ability/impl_ability_for_opaque_with_lambda_sets_material.txt +++ b/crates/compiler/uitest/tests/ability/impl_ability_for_opaque_with_lambda_sets_material.txt @@ -1,7 +1,7 @@ # +opt infer:print_only_under_alias app "test" provides [main] to "./platform" -Q := ({} -> Str) has [Eq {isEq: isEqQ}] +Q := ({} -> Str) implements [Eq {isEq: isEqQ}] isEqQ = \@Q f1, @Q f2 -> (f1 {} == f2 {}) #^^^^^{-1} ({} -[[]]-> Str), ({} -[[]]-> Str) -[[isEqQ(2)]]-> [False, True] diff --git a/crates/compiler/uitest/tests/ability/smoke/decoder.txt b/crates/compiler/uitest/tests/ability/smoke/decoder.txt index de7b54136f..987ba16734 100644 --- a/crates/compiler/uitest/tests/ability/smoke/decoder.txt +++ b/crates/compiler/uitest/tests/ability/smoke/decoder.txt @@ -2,19 +2,19 @@ app "test" provides [myU8] to "./platform" MDecodeError : [TooShort, Leftover (List U8)] -MDecoder val fmt := List U8, fmt -> { result: Result val MDecodeError, rest: List U8 } | fmt has MDecoderFormatting +MDecoder val fmt := List U8, fmt -> { result: Result val MDecodeError, rest: List U8 } | fmt implements MDecoderFormatting MDecoding has - decoder : MDecoder val fmt | val has MDecoding, fmt has MDecoderFormatting + decoder : MDecoder val fmt | val has MDecoding, fmt implements MDecoderFormatting MDecoderFormatting has - u8 : MDecoder U8 fmt | fmt has MDecoderFormatting + u8 : MDecoder U8 fmt | fmt implements MDecoderFormatting -decodeWith : List U8, MDecoder val fmt, fmt -> { result: Result val MDecodeError, rest: List U8 } | fmt has MDecoderFormatting +decodeWith : List U8, MDecoder val fmt, fmt -> { result: Result val MDecodeError, rest: List U8 } | fmt implements MDecoderFormatting decodeWith = \lst, (@MDecoder doDecode), fmt -> doDecode lst fmt fromBytes : List U8, fmt -> Result val MDecodeError - | fmt has MDecoderFormatting, val has MDecoding + | fmt has MDecoderFormatting, val implements MDecoding fromBytes = \lst, fmt -> when decodeWith lst decoder fmt is { result, rest } -> @@ -23,7 +23,7 @@ fromBytes = \lst, fmt -> Err e -> Err e -Linear := {} has [MDecoderFormatting {u8}] +Linear := {} implements [MDecoderFormatting {u8}] u8 = @MDecoder \lst, @Linear {} -> #^^{-1} Linear#u8(11): MDecoder U8 Linear @@ -31,10 +31,10 @@ u8 = @MDecoder \lst, @Linear {} -> Ok n -> { result: Ok n, rest: List.dropFirst lst } Err _ -> { result: Err TooShort, rest: [] } -MyU8 := U8 has [MDecoding {decoder}] +MyU8 := U8 implements [MDecoding {decoder}] decoder = @MDecoder \lst, fmt -> -#^^^^^^^{-1} MyU8#decoder(12): MDecoder MyU8 fmt | fmt has MDecoderFormatting +#^^^^^^^{-1} MyU8#decoder(12): MDecoder MyU8 fmt | fmt implements MDecoderFormatting when decodeWith lst u8 fmt is { result, rest } -> { result: Result.map result (\n -> @MyU8 n), rest } diff --git a/crates/compiler/uitest/tests/ability/smoke/encoder.txt b/crates/compiler/uitest/tests/ability/smoke/encoder.txt index 57c37aef4c..a4a74c6822 100644 --- a/crates/compiler/uitest/tests/ability/smoke/encoder.txt +++ b/crates/compiler/uitest/tests/ability/smoke/encoder.txt @@ -1,29 +1,29 @@ app "test" provides [myU8Bytes] to "./platform" -MEncoder fmt := List U8, fmt -> List U8 | fmt has Format +MEncoder fmt := List U8, fmt -> List U8 | fmt implements Format MEncoding has - toEncoder : val -> MEncoder fmt | val has MEncoding, fmt has Format + toEncoder : val -> MEncoder fmt | val has MEncoding, fmt implements Format Format has - u8 : U8 -> MEncoder fmt | fmt has Format + u8 : U8 -> MEncoder fmt | fmt implements Format -appendWith : List U8, MEncoder fmt, fmt -> List U8 | fmt has Format +appendWith : List U8, MEncoder fmt, fmt -> List U8 | fmt implements Format appendWith = \lst, (@MEncoder doFormat), fmt -> doFormat lst fmt -toBytes : val, fmt -> List U8 | val has MEncoding, fmt has Format +toBytes : val, fmt -> List U8 | val has MEncoding, fmt implements Format toBytes = \val, fmt -> appendWith [] (toEncoder val) fmt -Linear := {} has [Format {u8}] +Linear := {} implements [Format {u8}] u8 = \n -> @MEncoder (\lst, @Linear {} -> List.append lst n) #^^{-1} Linear#u8(10): U8 -[[u8(10)]]-> MEncoder Linear -MyU8 := U8 has [MEncoding {toEncoder}] +MyU8 := U8 implements [MEncoding {toEncoder}] toEncoder = \@MyU8 n -> u8 n -#^^^^^^^^^{-1} MyU8#toEncoder(11): MyU8 -[[toEncoder(11)]]-> MEncoder fmt | fmt has Format +#^^^^^^^^^{-1} MyU8#toEncoder(11): MyU8 -[[toEncoder(11)]]-> MEncoder fmt | fmt implements Format myU8Bytes = toBytes (@MyU8 15) (@Linear {}) #^^^^^^^^^{-1} List U8 diff --git a/crates/compiler/uitest/tests/ability/specialize/bool_decoder.txt b/crates/compiler/uitest/tests/ability/specialize/bool_decoder.txt index ac21c79e7a..020da7aefc 100644 --- a/crates/compiler/uitest/tests/ability/specialize/bool_decoder.txt +++ b/crates/compiler/uitest/tests/ability/specialize/bool_decoder.txt @@ -3,4 +3,4 @@ app "test" provides [main] to "./platform" main : Decoder Bool _ main = Decode.custom \bytes, fmt -> Decode.decodeWith bytes Decode.decoder fmt - # ^^^^^^^^^^^^^^ Decoding#Decode.decoder(4): Decoder Bool fmt | fmt has DecoderFormatting + # ^^^^^^^^^^^^^^ Decoding#Decode.decoder(4): Decoder Bool fmt | fmt implements DecoderFormatting diff --git a/crates/compiler/uitest/tests/ability/specialize/bool_hash.txt b/crates/compiler/uitest/tests/ability/specialize/bool_hash.txt index 2c03583a11..fa6c3cccc0 100644 --- a/crates/compiler/uitest/tests/ability/specialize/bool_hash.txt +++ b/crates/compiler/uitest/tests/ability/specialize/bool_hash.txt @@ -2,4 +2,4 @@ app "test" provides [main] to "./platform" main = \h -> Hash.hash h Bool.true - # ^^^^^^^^^ Hash#Hash.hash(1): a, Bool -[[Hash.hashBool(9)]]-> a | a has Hasher + # ^^^^^^^^^ Hash#Hash.hash(1): a, Bool -[[Hash.hashBool(9)]]-> a | a implements Hasher diff --git a/crates/compiler/uitest/tests/ability/specialize/bool_to_encoder.txt b/crates/compiler/uitest/tests/ability/specialize/bool_to_encoder.txt index b08a6a8325..e2c6888373 100644 --- a/crates/compiler/uitest/tests/ability/specialize/bool_to_encoder.txt +++ b/crates/compiler/uitest/tests/ability/specialize/bool_to_encoder.txt @@ -1,4 +1,4 @@ app "test" provides [main] to "./platform" main = Encode.toEncoder Bool.true -# ^^^^^^^^^^^^^^^^ Encoding#Encode.toEncoder(2): Bool -[[] + fmt:Encode.bool(17):1]-> Encoder fmt | fmt has EncoderFormatting +# ^^^^^^^^^^^^^^^^ Encoding#Encode.toEncoder(2): Bool -[[] + fmt:Encode.bool(17):1]-> Encoder fmt | fmt implements EncoderFormatting diff --git a/crates/compiler/uitest/tests/ability/specialize/opaque_decoder_derive.txt b/crates/compiler/uitest/tests/ability/specialize/opaque_decoder_derive.txt index 65a68da3a4..13105803ad 100644 --- a/crates/compiler/uitest/tests/ability/specialize/opaque_decoder_derive.txt +++ b/crates/compiler/uitest/tests/ability/specialize/opaque_decoder_derive.txt @@ -1,9 +1,9 @@ # +opt infer:print_only_under_alias app "test" provides [main] to "./platform" -N := U8 has [Decoding] +N := U8 implements [Decoding] main : Decoder N _ main = Decode.custom \bytes, fmt -> Decode.decodeWith bytes Decode.decoder fmt -# ^^^^^^^^^^^^^^ N#Decode.decoder(3): List U8, fmt -[[7]]-> { rest : List U8, result : [Err [TooShort], Ok U8] } | fmt has DecoderFormatting +# ^^^^^^^^^^^^^^ N#Decode.decoder(3): List U8, fmt -[[7]]-> { rest : List U8, result : [Err [TooShort], Ok U8] } | fmt implements DecoderFormatting diff --git a/crates/compiler/uitest/tests/ability/specialize/opaque_encoder_derive.txt b/crates/compiler/uitest/tests/ability/specialize/opaque_encoder_derive.txt index 0deb0fef59..71decfe129 100644 --- a/crates/compiler/uitest/tests/ability/specialize/opaque_encoder_derive.txt +++ b/crates/compiler/uitest/tests/ability/specialize/opaque_encoder_derive.txt @@ -1,6 +1,6 @@ app "test" provides [main] to "./platform" -N := U8 has [Encoding] +N := U8 implements [Encoding] main = Encode.toEncoder (@N 15) -# ^^^^^^^^^^^^^^^^ N#Encode.toEncoder(3): N -[[#N_toEncoder(3)]]-> Encoder fmt | fmt has EncoderFormatting +# ^^^^^^^^^^^^^^^^ N#Encode.toEncoder(3): N -[[#N_toEncoder(3)]]-> Encoder fmt | fmt implements EncoderFormatting diff --git a/crates/compiler/uitest/tests/ability/specialize/opaque_eq_custom.txt b/crates/compiler/uitest/tests/ability/specialize/opaque_eq_custom.txt index 9d83310b13..8cb1c64cc7 100644 --- a/crates/compiler/uitest/tests/ability/specialize/opaque_eq_custom.txt +++ b/crates/compiler/uitest/tests/ability/specialize/opaque_eq_custom.txt @@ -1,6 +1,6 @@ app "test" provides [main] to "./platform" -Trivial := {} has [Eq {isEq}] +Trivial := {} implements [Eq {isEq}] isEq = \@Trivial {}, @Trivial {} -> Bool.true diff --git a/crates/compiler/uitest/tests/ability/specialize/opaque_eq_derive.txt b/crates/compiler/uitest/tests/ability/specialize/opaque_eq_derive.txt index cb840d7d28..173fd0674d 100644 --- a/crates/compiler/uitest/tests/ability/specialize/opaque_eq_derive.txt +++ b/crates/compiler/uitest/tests/ability/specialize/opaque_eq_derive.txt @@ -1,6 +1,6 @@ app "test" provides [main] to "./platform" -N := U8 has [Eq] +N := U8 implements [Eq] main = Bool.isEq (@N 15) (@N 23) # ^^^^^^^^^ N#Bool.isEq(3): N, N -[[#N_isEq(3)]]-> Bool diff --git a/crates/compiler/uitest/tests/ability/specialize/opaque_hash_custom.txt b/crates/compiler/uitest/tests/ability/specialize/opaque_hash_custom.txt index 4fb63b7df7..957352040c 100644 --- a/crates/compiler/uitest/tests/ability/specialize/opaque_hash_custom.txt +++ b/crates/compiler/uitest/tests/ability/specialize/opaque_hash_custom.txt @@ -1,8 +1,8 @@ app "test" provides [main] to "./platform" -Noop := {} has [Hash {hash}] +Noop := {} implements [Hash {hash}] hash = \hasher, @Noop {} -> hasher main = \hasher -> hash hasher (@Noop {}) -#^^^^{-1} hasher -[[main(0)]]-> hasher | hasher has Hasher +#^^^^{-1} hasher -[[main(0)]]-> hasher | hasher implements Hasher diff --git a/crates/compiler/uitest/tests/ability/specialize/opaque_hash_derive.txt b/crates/compiler/uitest/tests/ability/specialize/opaque_hash_derive.txt index 250e788a1c..b9aabd1cc5 100644 --- a/crates/compiler/uitest/tests/ability/specialize/opaque_hash_derive.txt +++ b/crates/compiler/uitest/tests/ability/specialize/opaque_hash_derive.txt @@ -1,6 +1,6 @@ app "test" provides [main] to "./platform" -N := U8 has [Hash] +N := U8 implements [Hash] main = \hasher, @N n -> Hash.hash hasher (@N n) -# ^^^^^^^^^ N#Hash.hash(3): a, N -[[#N_hash(3)]]-> a | a has Hasher +# ^^^^^^^^^ N#Hash.hash(3): a, N -[[#N_hash(3)]]-> a | a implements Hasher diff --git a/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization.txt b/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization.txt index 010746a21b..dfe79b44ae 100644 --- a/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization.txt +++ b/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization.txt @@ -1,13 +1,13 @@ app "test" provides [main] to "./platform" -F has f : a -> (b -> {}) | a has F, b has G -G has g : b -> {} | b has G +F has f : a -> (b -> {}) | a has F, b implements G +G has g : b -> {} | b implements G -Fo := {} has [F {f}] +Fo := {} implements [F {f}] f = \@Fo {} -> g -#^{-1} Fo#f(7): Fo -[[f(7)]]-> (b -[[] + b:g(4):1]-> {}) | b has G +#^{-1} Fo#f(7): Fo -[[f(7)]]-> (b -[[] + b:g(4):1]-> {}) | b implements G -Go := {} has [G {g}] +Go := {} implements [G {g}] g = \@Go {} -> {} #^{-1} Go#g(8): Go -[[g(8)]]-> {} diff --git a/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_bound_output.txt b/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_bound_output.txt index ab0dac137f..45a01d058d 100644 --- a/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_bound_output.txt +++ b/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_bound_output.txt @@ -1,13 +1,13 @@ app "test" provides [main] to "./platform" -F has f : a -> ({} -> b) | a has F, b has G -G has g : {} -> b | b has G +F has f : a -> ({} -> b) | a has F, b implements G +G has g : {} -> b | b implements G -Fo := {} has [F {f}] +Fo := {} implements [F {f}] f = \@Fo {} -> g -#^{-1} Fo#f(7): Fo -[[f(7)]]-> ({} -[[] + b:g(4):1]-> b) | b has G +#^{-1} Fo#f(7): Fo -[[f(7)]]-> ({} -[[] + b:g(4):1]-> b) | b implements G -Go := {} has [G {g}] +Go := {} implements [G {g}] g = \{} -> @Go {} #^{-1} Go#g(8): {} -[[g(8)]]-> Go diff --git a/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_branching_over_single_variable.txt b/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_branching_over_single_variable.txt index 242be08499..8b7e092a80 100644 --- a/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_branching_over_single_variable.txt +++ b/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_branching_over_single_variable.txt @@ -1,15 +1,15 @@ app "test" provides [f] to "./platform" -J has j : j -> (k -> {}) | j has J, k has K -K has k : k -> {} | k has K +J has j : j -> (k -> {}) | j has J, k implements K +K has k : k -> {} | k implements K -C := {} has [J {j: jC}] +C := {} implements [J {j: jC}] jC = \@C _ -> k -D := {} has [J {j: jD}] +D := {} implements [J {j: jD}] jD = \@D _ -> k -E := {} has [K {k}] +E := {} implements [K {k}] k = \@E _ -> {} f = \flag, a, c -> @@ -18,5 +18,5 @@ f = \flag, a, c -> A -> j a B -> j a it c -# ^ k | k has K -# ^^ k -[[] + j:j(2):2]-> {} | j has J, k has K +# ^ k | k implements K +# ^^ k -[[] + j:j(2):2]-> {} | j has J, k implements K diff --git a/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_varying_over_multiple_variables.txt b/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_varying_over_multiple_variables.txt index a71e0898aa..0209cfbdb0 100644 --- a/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_varying_over_multiple_variables.txt +++ b/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_varying_over_multiple_variables.txt @@ -1,32 +1,32 @@ app "test" provides [main] to "./platform" -J has j : j -> (k -> {}) | j has J, k has K -K has k : k -> {} | k has K +J has j : j -> (k -> {}) | j has J, k implements K +K has k : k -> {} | k implements K -C := {} has [J {j: jC}] +C := {} implements [J {j: jC}] jC = \@C _ -> k -#^^{-1} C -[[jC(8)]]-> (k -[[] + k:k(4):1]-> {}) | k has K +#^^{-1} C -[[jC(8)]]-> (k -[[] + k:k(4):1]-> {}) | k implements K -D := {} has [J {j: jD}] +D := {} implements [J {j: jD}] jD = \@D _ -> k -#^^{-1} D -[[jD(9)]]-> (k -[[] + k:k(4):1]-> {}) | k has K +#^^{-1} D -[[jD(9)]]-> (k -[[] + k:k(4):1]-> {}) | k implements K -E := {} has [K {k}] +E := {} implements [K {k}] k = \@E _ -> {} #^{-1} E#k(10): E -[[k(10)]]-> {} f = \flag, a, b -> -# ^ j | j has J -# ^ j | j has J +# ^ j | j implements J +# ^ j | j implements J it = -# ^^ k -[[] + j:j(2):2 + j1:j(2):2]-> {} | j has J, j1 has J, k has K +# ^^ k -[[] + j:j(2):2 + j1:j(2):2]-> {} | j has J, j1 has J, k implements K when flag is A -> j a - # ^ J#j(2): j -[[] + j:j(2):1]-> (k -[[] + j:j(2):2 + j1:j(2):2]-> {}) | j has J, j1 has J, k has K + # ^ J#j(2): j -[[] + j:j(2):1]-> (k -[[] + j:j(2):2 + j1:j(2):2]-> {}) | j has J, j1 has J, k implements K B -> j b - # ^ J#j(2): j -[[] + j:j(2):1]-> (k -[[] + j1:j(2):2 + j:j(2):2]-> {}) | j has J, j1 has J, k has K + # ^ J#j(2): j -[[] + j:j(2):1]-> (k -[[] + j1:j(2):2 + j:j(2):2]-> {}) | j has J, j1 has J, k implements K it -# ^^ k -[[] + j:j(2):2 + j1:j(2):2]-> {} | j has J, j1 has J, k has K +# ^^ k -[[] + j:j(2):2 + j1:j(2):2]-> {} | j has J, j1 has J, k implements K main = (f A (@C {}) (@D {})) (@E {}) # ^ [A, B], C, D -[[f(11)]]-> (E -[[k(10)]]-> {}) diff --git a/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_varying_over_multiple_variables_two_results.txt b/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_varying_over_multiple_variables_two_results.txt index 34a84a5d11..4a1dd5f38a 100644 --- a/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_varying_over_multiple_variables_two_results.txt +++ b/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_varying_over_multiple_variables_two_results.txt @@ -1,43 +1,43 @@ app "test" provides [main] to "./platform" -J has j : j -> (k -> {}) | j has J, k has K -K has k : k -> {} | k has K +J has j : j -> (k -> {}) | j has J, k implements K +K has k : k -> {} | k implements K -C := {} has [J {j: jC}] +C := {} implements [J {j: jC}] jC = \@C _ -> k -#^^{-1} C -[[jC(9)]]-> (k -[[] + k:k(4):1]-> {}) | k has K +#^^{-1} C -[[jC(9)]]-> (k -[[] + k:k(4):1]-> {}) | k implements K -D := {} has [J {j: jD}] +D := {} implements [J {j: jD}] jD = \@D _ -> k -#^^{-1} D -[[jD(10)]]-> (k -[[] + k:k(4):1]-> {}) | k has K +#^^{-1} D -[[jD(10)]]-> (k -[[] + k:k(4):1]-> {}) | k implements K -E := {} has [K {k: kE}] +E := {} implements [K {k: kE}] kE = \@E _ -> {} #^^{-1} E -[[kE(11)]]-> {} -F := {} has [K {k: kF}] +F := {} implements [K {k: kF}] kF = \@F _ -> {} #^^{-1} F -[[kF(12)]]-> {} f = \flag, a, b -> -# ^ j | j has J -# ^ j | j has J +# ^ j | j implements J +# ^ j | j implements J it = -# ^^ k -[[] + j:j(2):2 + j1:j(2):2]-> {} | j has J, j1 has J, k has K +# ^^ k -[[] + j:j(2):2 + j1:j(2):2]-> {} | j has J, j1 has J, k implements K when flag is A -> j a - # ^ J#j(2): j -[[] + j:j(2):1]-> (k -[[] + j:j(2):2 + j1:j(2):2]-> {}) | j has J, j1 has J, k has K + # ^ J#j(2): j -[[] + j:j(2):1]-> (k -[[] + j:j(2):2 + j1:j(2):2]-> {}) | j has J, j1 has J, k implements K B -> j b - # ^ J#j(2): j -[[] + j:j(2):1]-> (k -[[] + j1:j(2):2 + j:j(2):2]-> {}) | j has J, j1 has J, k has K + # ^ J#j(2): j -[[] + j:j(2):1]-> (k -[[] + j1:j(2):2 + j:j(2):2]-> {}) | j has J, j1 has J, k implements K it -# ^^ k -[[] + j:j(2):2 + j1:j(2):2]-> {} | j has J, j1 has J, k has K +# ^^ k -[[] + j:j(2):2 + j1:j(2):2]-> {} | j has J, j1 has J, k implements K main = #^^^^{-1} {} it = \x -> -# ^^ k -[[it(21)]]-> {} | k has K +# ^^ k -[[it(21)]]-> {} | k implements K (f A (@C {}) (@D {})) x -# ^ [A, B], C, D -[[f(13)]]-> (k -[[] + k:k(4):1]-> {}) | k has K +# ^ [A, B], C, D -[[f(13)]]-> (k -[[] + k:k(4):1]-> {}) | k implements K if Bool.true then it (@E {}) # ^^ E -[[it(21)]]-> {} diff --git a/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_with_deep_specialization_and_capture.txt b/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_with_deep_specialization_and_capture.txt index 1d1ab51d65..3c155d1173 100644 --- a/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_with_deep_specialization_and_capture.txt +++ b/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_with_deep_specialization_and_capture.txt @@ -1,13 +1,13 @@ app "test" provides [main] to "./platform" -F has f : a, b -> ({} -> ({} -> {})) | a has F, b has G -G has g : b -> ({} -> {}) | b has G +F has f : a, b -> ({} -> ({} -> {})) | a has F, b implements G +G has g : b -> ({} -> {}) | b implements G -Fo := {} has [F {f}] +Fo := {} implements [F {f}] f = \@Fo {}, b -> \{} -> g b -#^{-1} Fo#f(7): Fo, b -[[f(7)]]-> ({} -[[13 b]]-> ({} -[[] + b:g(4):2]-> {})) | b has G +#^{-1} Fo#f(7): Fo, b -[[f(7)]]-> ({} -[[13 b]]-> ({} -[[] + b:g(4):2]-> {})) | b implements G -Go := {} has [G {g}] +Go := {} implements [G {g}] g = \@Go {} -> \{} -> {} #^{-1} Go#g(8): Go -[[g(8)]]-> ({} -[[14]]-> {}) diff --git a/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_with_let_weakened.txt b/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_with_let_weakened.txt index fb24dd6496..8f3d9427b9 100644 --- a/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_with_let_weakened.txt +++ b/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_with_let_weakened.txt @@ -1,13 +1,13 @@ app "test" provides [main] to "./platform" -F has f : a -> (b -> {}) | a has F, b has G -G has g : b -> {} | b has G +F has f : a -> (b -> {}) | a has F, b implements G +G has g : b -> {} | b implements G -Fo := {} has [F {f}] +Fo := {} implements [F {f}] f = \@Fo {} -> g -#^{-1} Fo#f(7): Fo -[[f(7)]]-> (b -[[] + b:g(4):1]-> {}) | b has G +#^{-1} Fo#f(7): Fo -[[f(7)]]-> (b -[[] + b:g(4):1]-> {}) | b implements G -Go := {} has [G {g}] +Go := {} implements [G {g}] g = \@Go {} -> {} #^{-1} Go#g(8): Go -[[g(8)]]-> {} diff --git a/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_with_let_weakened_unapplied.txt b/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_with_let_weakened_unapplied.txt index 31cb72dd0f..6a159a5e62 100644 --- a/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_with_let_weakened_unapplied.txt +++ b/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_with_let_weakened_unapplied.txt @@ -1,19 +1,19 @@ app "test" provides [main] to "./platform" -F has f : a -> (b -> {}) | a has F, b has G -G has g : b -> {} | b has G +F has f : a -> (b -> {}) | a has F, b implements G +G has g : b -> {} | b implements G -Fo := {} has [F {f}] +Fo := {} implements [F {f}] f = \@Fo {} -> g -#^{-1} Fo#f(7): Fo -[[f(7)]]-> (b -[[] + b:g(4):1]-> {}) | b has G +#^{-1} Fo#f(7): Fo -[[f(7)]]-> (b -[[] + b:g(4):1]-> {}) | b implements G -Go := {} has [G {g}] +Go := {} implements [G {g}] g = \@Go {} -> {} #^{-1} Go#g(8): Go -[[g(8)]]-> {} main = -#^^^^{-1} b -[[] + b:g(4):1]-> {} | b has G +#^^^^{-1} b -[[] + b:g(4):1]-> {} | b implements G h = f (@Fo {}) -# ^ Fo#f(7): Fo -[[f(7)]]-> (b -[[] + b:g(4):1]-> {}) | b has G -# ^ b -[[] + b:g(4):1]-> {} | b has G +# ^ Fo#f(7): Fo -[[f(7)]]-> (b -[[] + b:g(4):1]-> {}) | b implements G +# ^ b -[[] + b:g(4):1]-> {} | b implements G h diff --git a/crates/compiler/uitest/tests/ability/specialize/ranged_num_hash.txt b/crates/compiler/uitest/tests/ability/specialize/ranged_num_hash.txt index fa65790b1f..8653bb77c7 100644 --- a/crates/compiler/uitest/tests/ability/specialize/ranged_num_hash.txt +++ b/crates/compiler/uitest/tests/ability/specialize/ranged_num_hash.txt @@ -2,4 +2,4 @@ app "test" provides [main] to "./platform" main = \h -> Hash.hash h 7 - # ^^^^^^^^^ Hash#Hash.hash(1): a, I64 -[[Hash.hashI64(13)]]-> a | a has Hasher + # ^^^^^^^^^ Hash#Hash.hash(1): a, I64 -[[Hash.hashI64(13)]]-> a | a implements Hasher diff --git a/crates/compiler/uitest/tests/ability/specialize/record_to_encoder.txt b/crates/compiler/uitest/tests/ability/specialize/record_to_encoder.txt index ac6dc4d265..390df75dfb 100644 --- a/crates/compiler/uitest/tests/ability/specialize/record_to_encoder.txt +++ b/crates/compiler/uitest/tests/ability/specialize/record_to_encoder.txt @@ -3,4 +3,4 @@ app "test" provides [main] to "./platform" main = toEncoder { a: "" } - # ^^^^^^^^^ Encoding#toEncoder(2): { a : Str } -[[#Derived.toEncoder_{a}(0)]]-> Encoder fmt | fmt has EncoderFormatting + # ^^^^^^^^^ Encoding#toEncoder(2): { a : Str } -[[#Derived.toEncoder_{a}(0)]]-> Encoder fmt | fmt implements EncoderFormatting diff --git a/crates/compiler/uitest/tests/ability/specialize/record_to_encoder_with_nested_custom_impl.txt b/crates/compiler/uitest/tests/ability/specialize/record_to_encoder_with_nested_custom_impl.txt index df9d14d788..ba43f3905f 100644 --- a/crates/compiler/uitest/tests/ability/specialize/record_to_encoder_with_nested_custom_impl.txt +++ b/crates/compiler/uitest/tests/ability/specialize/record_to_encoder_with_nested_custom_impl.txt @@ -2,8 +2,8 @@ app "test" imports [Encode.{ toEncoder, custom }] provides [main] to "./platform" -A := {} has [Encoding {toEncoder}] +A := {} implements [Encoding {toEncoder}] toEncoder = \@A _ -> custom \b, _ -> b main = toEncoder { a: @A {} } - # ^^^^^^^^^ Encoding#toEncoder(2): { a : A } -[[#Derived.toEncoder_{a}(0)]]-> Encoder fmt | fmt has EncoderFormatting + # ^^^^^^^^^ Encoding#toEncoder(2): { a : A } -[[#Derived.toEncoder_{a}(0)]]-> Encoder fmt | fmt implements EncoderFormatting diff --git a/crates/compiler/uitest/tests/ability/specialize/resolve_lambda_set_ability_chain.txt b/crates/compiler/uitest/tests/ability/specialize/resolve_lambda_set_ability_chain.txt index 68dfcf4582..00439c028a 100644 --- a/crates/compiler/uitest/tests/ability/specialize/resolve_lambda_set_ability_chain.txt +++ b/crates/compiler/uitest/tests/ability/specialize/resolve_lambda_set_ability_chain.txt @@ -1,9 +1,9 @@ app "test" provides [main] to "./platform" -Id1 has id1 : a -> a | a has Id1 -Id2 has id2 : a -> a | a has Id2 +Id1 has id1 : a -> a | a implements Id1 +Id2 has id2 : a -> a | a implements Id2 -A := {} has [Id1 {id1}, Id2 {id2}] +A := {} implements [Id1 {id1}, Id2 {id2}] id1 = \@A {} -> @A {} #^^^{-1} A#id1(6): A -[[id1(6)]]-> A diff --git a/crates/compiler/uitest/tests/ability/specialize/resolve_lambda_set_branches_ability_vs_non_ability.txt b/crates/compiler/uitest/tests/ability/specialize/resolve_lambda_set_branches_ability_vs_non_ability.txt index 358f3fa021..7fec6cf4b5 100644 --- a/crates/compiler/uitest/tests/ability/specialize/resolve_lambda_set_branches_ability_vs_non_ability.txt +++ b/crates/compiler/uitest/tests/ability/specialize/resolve_lambda_set_branches_ability_vs_non_ability.txt @@ -1,8 +1,8 @@ app "test" provides [main] to "./platform" -Id has id : a -> a | a has Id +Id has id : a -> a | a implements Id -A := {} has [Id {id}] +A := {} implements [Id {id}] id = \@A {} -> @A {} #^^{-1} A#id(4): A -[[id(4)]]-> A diff --git a/crates/compiler/uitest/tests/ability/specialize/resolve_lambda_set_branches_same_ability.txt b/crates/compiler/uitest/tests/ability/specialize/resolve_lambda_set_branches_same_ability.txt index 497b4a981c..7fd08456e2 100644 --- a/crates/compiler/uitest/tests/ability/specialize/resolve_lambda_set_branches_same_ability.txt +++ b/crates/compiler/uitest/tests/ability/specialize/resolve_lambda_set_branches_same_ability.txt @@ -1,8 +1,8 @@ app "test" provides [main] to "./platform" -Id has id : a -> a | a has Id +Id has id : a -> a | a implements Id -A := {} has [Id {id}] +A := {} implements [Id {id}] id = \@A {} -> @A {} #^^{-1} A#id(4): A -[[id(4)]]-> A diff --git a/crates/compiler/uitest/tests/ability/specialize/resolve_lambda_set_generalized_ability_alias.txt b/crates/compiler/uitest/tests/ability/specialize/resolve_lambda_set_generalized_ability_alias.txt index 541a32b3ca..172090ca5b 100644 --- a/crates/compiler/uitest/tests/ability/specialize/resolve_lambda_set_generalized_ability_alias.txt +++ b/crates/compiler/uitest/tests/ability/specialize/resolve_lambda_set_generalized_ability_alias.txt @@ -1,16 +1,16 @@ app "test" provides [main] to "./platform" -Id has id : a -> a | a has Id +Id has id : a -> a | a implements Id -A := {} has [Id {id}] +A := {} implements [Id {id}] id = \@A {} -> @A {} #^^{-1} A#id(4): A -[[id(4)]]-> A main = alias1 = \x -> id x - # ^^ Id#id(2): a -[[] + a:id(2):1]-> a | a has Id + # ^^ Id#id(2): a -[[] + a:id(2):1]-> a | a implements Id alias2 = \x -> alias1 x - # ^^^^^^ a -[[alias1(6)]]-> a | a has Id + # ^^^^^^ a -[[alias1(6)]]-> a | a implements Id a : A a = alias2 (@A {}) diff --git a/crates/compiler/uitest/tests/ability/specialize/resolve_lambda_set_weakened_ability_alias.txt b/crates/compiler/uitest/tests/ability/specialize/resolve_lambda_set_weakened_ability_alias.txt index af8b3f017a..004c1d70cb 100644 --- a/crates/compiler/uitest/tests/ability/specialize/resolve_lambda_set_weakened_ability_alias.txt +++ b/crates/compiler/uitest/tests/ability/specialize/resolve_lambda_set_weakened_ability_alias.txt @@ -1,8 +1,8 @@ app "test" provides [main] to "./platform" -Id has id : a -> a | a has Id +Id has id : a -> a | a implements Id -A := {} has [Id {id}] +A := {} implements [Id {id}] id = \@A {} -> @A {} #^^{-1} A#id(4): A -[[id(4)]]-> A diff --git a/crates/compiler/uitest/tests/ability/specialize/resolve_mutually_recursive_ability_lambda_sets.txt b/crates/compiler/uitest/tests/ability/specialize/resolve_mutually_recursive_ability_lambda_sets.txt index 91f70d7f7c..91e20eb8f9 100644 --- a/crates/compiler/uitest/tests/ability/specialize/resolve_mutually_recursive_ability_lambda_sets.txt +++ b/crates/compiler/uitest/tests/ability/specialize/resolve_mutually_recursive_ability_lambda_sets.txt @@ -1,10 +1,10 @@ app "test" provides [main] to "./platform" Bounce has - ping : a -> a | a has Bounce - pong : a -> a | a has Bounce + ping : a -> a | a implements Bounce + pong : a -> a | a implements Bounce -A := {} has [Bounce {ping: pingA, pong: pongA}] +A := {} implements [Bounce {ping: pingA, pong: pongA}] pingA = \@A {} -> pong (@A {}) # ^^^^ A#pong(6): A -[[pongA(6)]]-> A diff --git a/crates/compiler/uitest/tests/ability/specialize/resolve_mutually_recursive_ability_lambda_sets_inferred.txt b/crates/compiler/uitest/tests/ability/specialize/resolve_mutually_recursive_ability_lambda_sets_inferred.txt index 22b25a9adb..a6af367fe1 100644 --- a/crates/compiler/uitest/tests/ability/specialize/resolve_mutually_recursive_ability_lambda_sets_inferred.txt +++ b/crates/compiler/uitest/tests/ability/specialize/resolve_mutually_recursive_ability_lambda_sets_inferred.txt @@ -1,10 +1,10 @@ app "test" provides [main] to "./platform" Bounce has - ping : a -> a | a has Bounce - pong : a -> a | a has Bounce + ping : a -> a | a implements Bounce + pong : a -> a | a implements Bounce -A := {} has [Bounce {ping, pong}] +A := {} implements [Bounce {ping, pong}] ping = \@A {} -> pong (@A {}) # ^^^^ A#pong(6): A -[[pong(6)]]-> A diff --git a/crates/compiler/uitest/tests/ability/specialize/resolve_recursive_ability_lambda_set.txt b/crates/compiler/uitest/tests/ability/specialize/resolve_recursive_ability_lambda_set.txt index 6060616d70..db9090568e 100644 --- a/crates/compiler/uitest/tests/ability/specialize/resolve_recursive_ability_lambda_set.txt +++ b/crates/compiler/uitest/tests/ability/specialize/resolve_recursive_ability_lambda_set.txt @@ -1,8 +1,8 @@ app "test" provides [main] to "./platform" -Diverge has diverge : a -> a | a has Diverge +Diverge has diverge : a -> a | a implements Diverge -A := {} has [Diverge {diverge}] +A := {} implements [Diverge {diverge}] diverge : A -> A diverge = \@A {} -> diverge (@A {}) diff --git a/crates/compiler/uitest/tests/ability/specialize/resolve_two_unspecialized_lambda_sets_in_one_lambda_set.txt b/crates/compiler/uitest/tests/ability/specialize/resolve_two_unspecialized_lambda_sets_in_one_lambda_set.txt index 4e85e6905c..1b7828e9fe 100644 --- a/crates/compiler/uitest/tests/ability/specialize/resolve_two_unspecialized_lambda_sets_in_one_lambda_set.txt +++ b/crates/compiler/uitest/tests/ability/specialize/resolve_two_unspecialized_lambda_sets_in_one_lambda_set.txt @@ -3,9 +3,9 @@ app "test" provides [main] to "./platform" Thunk a : {} -> a -Id has id : a -> Thunk a | a has Id +Id has id : a -> Thunk a | a implements Id -A := {} has [Id {id}] +A := {} implements [Id {id}] id = \@A {} -> \{} -> @A {} #^^{-1} A#id(5): {} -[[id(5)]]-> ({} -[[8]]-> {}) diff --git a/crates/compiler/uitest/tests/ability/specialize/resolve_unspecialized_lambda_set_behind_alias.txt b/crates/compiler/uitest/tests/ability/specialize/resolve_unspecialized_lambda_set_behind_alias.txt index b08f4795a2..2965caa4ad 100644 --- a/crates/compiler/uitest/tests/ability/specialize/resolve_unspecialized_lambda_set_behind_alias.txt +++ b/crates/compiler/uitest/tests/ability/specialize/resolve_unspecialized_lambda_set_behind_alias.txt @@ -3,15 +3,15 @@ app "test" provides [main] to "./platform" Thunk a : {} -> a -Id has id : a -> Thunk a | a has Id +Id has id : a -> Thunk a | a implements Id -A := {} has [Id {id}] +A := {} implements [Id {id}] id = \@A {} -> \{} -> @A {} #^^{-1} A#id(5): {} -[[id(5)]]-> ({} -[[8]]-> {}) main = alias = \x -> id x - # ^^ Id#id(3): a -[[] + a:id(3):1]-> ({} -[[] + a:id(3):2]-> a) | a has Id + # ^^ Id#id(3): a -[[] + a:id(3):1]-> ({} -[[] + a:id(3):2]-> a) | a implements Id a : A a = (alias (@A {})) {} diff --git a/crates/compiler/uitest/tests/ability/specialize/resolve_unspecialized_lambda_set_behind_opaque.txt b/crates/compiler/uitest/tests/ability/specialize/resolve_unspecialized_lambda_set_behind_opaque.txt index ab960558bc..eec59f3109 100644 --- a/crates/compiler/uitest/tests/ability/specialize/resolve_unspecialized_lambda_set_behind_opaque.txt +++ b/crates/compiler/uitest/tests/ability/specialize/resolve_unspecialized_lambda_set_behind_opaque.txt @@ -3,9 +3,9 @@ app "test" provides [main] to "./platform" Thunk a := {} -> a -Id has id : a -> Thunk a | a has Id +Id has id : a -> Thunk a | a implements Id -A := {} has [Id {id}] +A := {} implements [Id {id}] id = \@A {} -> @Thunk (\{} -> @A {}) #^^{-1} A#id(5): {} -[[id(5)]]-> ({} -[[8]]-> {}) diff --git a/crates/compiler/uitest/tests/ability/specialize/static_specialization.txt b/crates/compiler/uitest/tests/ability/specialize/static_specialization.txt index 5ec8b64c60..79f047465a 100644 --- a/crates/compiler/uitest/tests/ability/specialize/static_specialization.txt +++ b/crates/compiler/uitest/tests/ability/specialize/static_specialization.txt @@ -1,8 +1,8 @@ app "test" provides [main] to "./platform" -Default has default : {} -> a | a has Default +Default has default : {} -> a | a implements Default -A := {} has [Default {default}] +A := {} implements [Default {default}] default = \{} -> @A {} main = diff --git a/crates/compiler/uitest/tests/instantiate/call_generic_ability_member.txt b/crates/compiler/uitest/tests/instantiate/call_generic_ability_member.txt index a0c045ee64..48a4646cf9 100644 --- a/crates/compiler/uitest/tests/instantiate/call_generic_ability_member.txt +++ b/crates/compiler/uitest/tests/instantiate/call_generic_ability_member.txt @@ -1,19 +1,19 @@ app "test" provides [main] to "./platform" X has - consume : a -> {} | a has X + consume : a -> {} | a implements X -O := {} has [X {consume: consumeO}] +O := {} implements [X {consume: consumeO}] consumeO = \@O {} -> {} -P := {} has [X {consume: consumeP}] +P := {} implements [X {consume: consumeP}] consumeP = \@P {} -> {} caller = \x -> consume x -# ^ a | a has X -# ^^^^^^^ X#consume(2): a -[[] + a:consume(2):1]-> {} | a has X +# ^ a | a implements X +# ^^^^^^^ X#consume(2): a -[[] + a:consume(2):1]-> {} | a implements X main = { a: caller (@O {}), diff --git a/crates/compiler/uitest/tests/solve/ability_checked_specialization_with_annotation_only.txt b/crates/compiler/uitest/tests/solve/ability_checked_specialization_with_annotation_only.txt index 35e7b3d362..b904dabe30 100644 --- a/crates/compiler/uitest/tests/solve/ability_checked_specialization_with_annotation_only.txt +++ b/crates/compiler/uitest/tests/solve/ability_checked_specialization_with_annotation_only.txt @@ -1,9 +1,9 @@ app "test" provides [hash] to "./platform" -MHash has - hash : a -> U64 | a has MHash +MHash implements + hash : a -> U64 | a implements MHash -Id := U64 has [MHash {hash}] +Id := U64 implements [MHash {hash}] hash : Id -> U64 #^^^^{-1} Id#hash(3): Id -[[hash(3)]]-> U64 diff --git a/crates/compiler/uitest/tests/solve/ability_checked_specialization_with_typed_body.txt b/crates/compiler/uitest/tests/solve/ability_checked_specialization_with_typed_body.txt index ecbe8c2922..19fba98d6f 100644 --- a/crates/compiler/uitest/tests/solve/ability_checked_specialization_with_typed_body.txt +++ b/crates/compiler/uitest/tests/solve/ability_checked_specialization_with_typed_body.txt @@ -1,9 +1,9 @@ app "test" provides [hash] to "./platform" -MHash has - hash : a -> U64 | a has MHash +MHash implements + hash : a -> U64 | a implements MHash -Id := U64 has [MHash {hash}] +Id := U64 implements [MHash {hash}] hash : Id -> U64 hash = \@Id n -> n diff --git a/crates/compiler/uitest/tests/solve/ability_constrained_in_non_member_check.txt b/crates/compiler/uitest/tests/solve/ability_constrained_in_non_member_check.txt index cdb461a6f2..e8f330c0e3 100644 --- a/crates/compiler/uitest/tests/solve/ability_constrained_in_non_member_check.txt +++ b/crates/compiler/uitest/tests/solve/ability_constrained_in_non_member_check.txt @@ -1,8 +1,8 @@ app "test" provides [hashEq] to "./platform" -MHash has - hash : a -> U64 | a has MHash +MHash implements + hash : a -> U64 | a implements MHash -hashEq : a, a -> Bool | a has MHash +hashEq : a, a -> Bool | a implements MHash hashEq = \x, y -> hash x == hash y -#^^^^^^{-1} a, a -[[hashEq(0)]]-> Bool | a has MHash +#^^^^^^{-1} a, a -[[hashEq(0)]]-> Bool | a implements MHash diff --git a/crates/compiler/uitest/tests/solve/ability_constrained_in_non_member_infer.txt b/crates/compiler/uitest/tests/solve/ability_constrained_in_non_member_infer.txt index caf1681ba5..5130b11d44 100644 --- a/crates/compiler/uitest/tests/solve/ability_constrained_in_non_member_infer.txt +++ b/crates/compiler/uitest/tests/solve/ability_constrained_in_non_member_infer.txt @@ -1,7 +1,7 @@ app "test" provides [hashEq] to "./platform" -MHash has - hash : a -> U64 | a has MHash +MHash implements + hash : a -> U64 | a implements MHash hashEq = \x, y -> hash x == hash y -#^^^^^^{-1} a, a1 -[[hashEq(0)]]-> Bool | a has MHash, a1 has MHash +#^^^^^^{-1} a, a1 -[[hashEq(0)]]-> Bool | a implements MHash, a1 implements MHash diff --git a/crates/compiler/uitest/tests/solve/ability_constrained_in_non_member_infer_usage.txt b/crates/compiler/uitest/tests/solve/ability_constrained_in_non_member_infer_usage.txt index 18d9d56846..30c0829af3 100644 --- a/crates/compiler/uitest/tests/solve/ability_constrained_in_non_member_infer_usage.txt +++ b/crates/compiler/uitest/tests/solve/ability_constrained_in_non_member_infer_usage.txt @@ -1,11 +1,11 @@ app "test" provides [result] to "./platform" -MHash has - hash : a -> U64 | a has MHash +MHash implements + hash : a -> U64 | a implements MHash hashEq = \x, y -> hash x == hash y -Id := U64 has [MHash {hash}] +Id := U64 implements [MHash {hash}] hash = \@Id n -> n result = hashEq (@Id 100) (@Id 101) diff --git a/crates/compiler/uitest/tests/solve/ability_constrained_in_non_member_multiple_specializations.txt b/crates/compiler/uitest/tests/solve/ability_constrained_in_non_member_multiple_specializations.txt index cd2e96ba48..552c80b60b 100644 --- a/crates/compiler/uitest/tests/solve/ability_constrained_in_non_member_multiple_specializations.txt +++ b/crates/compiler/uitest/tests/solve/ability_constrained_in_non_member_multiple_specializations.txt @@ -1,14 +1,14 @@ app "test" provides [result] to "./platform" -MHash has - hash : a -> U64 | a has MHash +MHash implements + hash : a -> U64 | a implements MHash mulMHashes = \x, y -> hash x * hash y -Id := U64 has [MHash { hash: hashId }] +Id := U64 implements [MHash { hash: hashId }] hashId = \@Id n -> n -Three := {} has [MHash { hash: hashThree }] +Three := {} implements [MHash { hash: hashThree }] hashThree = \@Three _ -> 3 result = mulMHashes (@Id 100) (@Three {}) diff --git a/crates/compiler/uitest/tests/solve/ability_specialization_called.txt b/crates/compiler/uitest/tests/solve/ability_specialization_called.txt index e88496dfda..20b56e049b 100644 --- a/crates/compiler/uitest/tests/solve/ability_specialization_called.txt +++ b/crates/compiler/uitest/tests/solve/ability_specialization_called.txt @@ -1,9 +1,9 @@ app "test" provides [zero] to "./platform" -MHash has - hash : a -> U64 | a has MHash +MHash implements + hash : a -> U64 | a implements MHash -Id := U64 has [MHash {hash}] +Id := U64 implements [MHash {hash}] hash = \@Id n -> n diff --git a/crates/compiler/uitest/tests/solve/alias_ability_member.txt b/crates/compiler/uitest/tests/solve/alias_ability_member.txt index e552bf692e..ab5f5d7e9c 100644 --- a/crates/compiler/uitest/tests/solve/alias_ability_member.txt +++ b/crates/compiler/uitest/tests/solve/alias_ability_member.txt @@ -1,9 +1,9 @@ app "test" provides [thething] to "./platform" -MHash has - hash : a -> U64 | a has MHash +MHash implements + hash : a -> U64 | a implements MHash thething = -#^^^^^^^^{-1} a -[[] + a:hash(2):1]-> U64 | a has MHash +#^^^^^^^^{-1} a -[[] + a:hash(2):1]-> U64 | a implements MHash itis = hash itis diff --git a/crates/compiler/uitest/tests/solve/alias_propagates_able_var.txt b/crates/compiler/uitest/tests/solve/alias_propagates_able_var.txt index 6696025603..01d4d57187 100644 --- a/crates/compiler/uitest/tests/solve/alias_propagates_able_var.txt +++ b/crates/compiler/uitest/tests/solve/alias_propagates_able_var.txt @@ -1,8 +1,8 @@ app "test" provides [zeroEncoder] to "./platform" -MEncoder fmt := List U8, fmt -> List U8 | fmt has Format +MEncoder fmt := List U8, fmt -> List U8 | fmt implements Format -Format has it : fmt -> {} | fmt has Format +Format implements it : fmt -> {} | fmt implements Format zeroEncoder = @MEncoder \lst, _ -> lst -#^^^^^^^^^^^{-1} MEncoder a | a has Format +#^^^^^^^^^^^{-1} MEncoder a | a implements Format diff --git a/crates/compiler/uitest/tests/solve/exposed_ability_name.txt b/crates/compiler/uitest/tests/solve/exposed_ability_name.txt index 3563c02521..875af03cea 100644 --- a/crates/compiler/uitest/tests/solve/exposed_ability_name.txt +++ b/crates/compiler/uitest/tests/solve/exposed_ability_name.txt @@ -1,6 +1,6 @@ app "test" provides [main] to "./platform" -MHash has hash : a -> U64 | a has MHash +MHash implements hash : a -> U64 | a implements MHash main = hash -# ^^^^ MHash#hash(2): a -[[] + a:hash(2):1]-> U64 | a has MHash +# ^^^^ MHash#hash(2): a -[[] + a:hash(2):1]-> U64 | a implements MHash diff --git a/crates/compiler/uitest/tests/solve/multiple_abilities_multiple_members_specializations.txt b/crates/compiler/uitest/tests/solve/multiple_abilities_multiple_members_specializations.txt index d124bd1687..b572ce562c 100644 --- a/crates/compiler/uitest/tests/solve/multiple_abilities_multiple_members_specializations.txt +++ b/crates/compiler/uitest/tests/solve/multiple_abilities_multiple_members_specializations.txt @@ -1,14 +1,14 @@ app "test" provides [hash, hash32, eq, le] to "./platform" -MHash has - hash : a -> U64 | a has MHash - hash32 : a -> U32 | a has MHash +MHash implements + hash : a -> U64 | a implements MHash + hash32 : a -> U32 | a implements MHash -Ord has - eq : a, a -> Bool | a has Ord - le : a, a -> Bool | a has Ord +Ord implements + eq : a, a -> Bool | a implements Ord + le : a, a -> Bool | a implements Ord -Id := U64 has [MHash {hash, hash32}, Ord {eq, le}] +Id := U64 implements [MHash {hash, hash32}, Ord {eq, le}] hash = \@Id n -> n #^^^^{-1} Id#hash(7): Id -[[hash(7)]]-> U64 diff --git a/crates/compiler/uitest/tests/solve/single_ability_multiple_members_specializations.txt b/crates/compiler/uitest/tests/solve/single_ability_multiple_members_specializations.txt index 7b73ffa9ff..37b18653c0 100644 --- a/crates/compiler/uitest/tests/solve/single_ability_multiple_members_specializations.txt +++ b/crates/compiler/uitest/tests/solve/single_ability_multiple_members_specializations.txt @@ -1,10 +1,10 @@ app "test" provides [hash, hash32] to "./platform" -MHash has - hash : a -> U64 | a has MHash - hash32 : a -> U32 | a has MHash +MHash implements + hash : a -> U64 | a implements MHash + hash32 : a -> U32 | a implements MHash -Id := U64 has [MHash {hash, hash32}] +Id := U64 implements [MHash {hash, hash32}] hash = \@Id n -> n #^^^^{-1} Id#hash(4): Id -[[hash(4)]]-> U64 diff --git a/crates/compiler/uitest/tests/solve/single_ability_single_member_specializations.txt b/crates/compiler/uitest/tests/solve/single_ability_single_member_specializations.txt index 33e30ed971..190a4d2701 100644 --- a/crates/compiler/uitest/tests/solve/single_ability_single_member_specializations.txt +++ b/crates/compiler/uitest/tests/solve/single_ability_single_member_specializations.txt @@ -1,8 +1,8 @@ app "test" provides [hash] to "./platform" -MHash has hash : a -> U64 | a has MHash +MHash implements hash : a -> U64 | a implements MHash -Id := U64 has [MHash {hash}] +Id := U64 implements [MHash {hash}] hash = \@Id n -> n #^^^^{-1} Id#hash(3): Id -[[hash(3)]]-> U64 diff --git a/crates/compiler/uitest/tests/solve/stdlib_encode_json.txt b/crates/compiler/uitest/tests/solve/stdlib_encode_json.txt index dfba0f19d6..5a0ec29697 100644 --- a/crates/compiler/uitest/tests/solve/stdlib_encode_json.txt +++ b/crates/compiler/uitest/tests/solve/stdlib_encode_json.txt @@ -2,7 +2,7 @@ app "test" imports [Json] provides [main] to "./platform" -HelloWorld := {} has [Encoding {toEncoder}] +HelloWorld := {} implements [Encoding {toEncoder}] toEncoder = \@HelloWorld {} -> Encode.custom \bytes, fmt -> diff --git a/crates/reporting/tests/test_reporting.rs b/crates/reporting/tests/test_reporting.rs index 0bfef5101c..a983adc8bc 100644 --- a/crates/reporting/tests/test_reporting.rs +++ b/crates/reporting/tests/test_reporting.rs @@ -8830,7 +8830,7 @@ In roc, functions are always written as a lambda, like{} r#" app "test" provides [hash] to "./platform" - MHash has + MHash implements hash : a -> U64 | a implements MHash Id := U64 implements [MHash {hash}] @@ -8864,7 +8864,7 @@ In roc, functions are always written as a lambda, like{} r#" app "test" provides [noGoodVeryBadTerrible] to "./platform" - MHash has + MHash implements hash : a -> U64 | a implements MHash Id := U64 implements [MHash {hash}] @@ -8912,7 +8912,7 @@ In roc, functions are always written as a lambda, like{} app "test" provides [main] to "./platform" main = - MHash has + MHash implements hash : a -> U64 | a implements MHash 123 @@ -8923,7 +8923,7 @@ In roc, functions are always written as a lambda, like{} This ability definition is not on the top-level of a module: - 4│> MHash has + 4│> MHash implements 5│> hash : a -> U64 | a implements MHash Abilities can only be defined on the top-level of a Roc module. @@ -8936,7 +8936,7 @@ In roc, functions are always written as a lambda, like{} r#" app "test" provides [hash, hashable] to "./platform" - MHash has + MHash implements hash : a -> U64 | a implements MHash Id := U64 implements [MHash {hash}] @@ -8977,7 +8977,7 @@ In roc, functions are always written as a lambda, like{} r#" app "test" provides [result] to "./platform" - MHash has + MHash implements hash : a -> U64 | a implements MHash mulMHashes : MHash, MHash -> U64 From dbc02045324f2681915beade9decab0dfc962326 Mon Sep 17 00:00:00 2001 From: Bryce Miller Date: Wed, 24 May 2023 21:30:16 -0400 Subject: [PATCH 027/176] abilities syntax `has` -> `implements` --- .../cli_testing_examples/benchmarks/AStar.roc | 12 ++-- crates/compiler/can/src/abilities.rs | 8 +-- crates/compiler/can/src/annotation.rs | 2 +- crates/compiler/can/src/def.rs | 14 ++-- crates/compiler/can/src/pattern.rs | 2 +- crates/compiler/can/src/scope.rs | 2 +- crates/compiler/derive/src/decoding.rs | 8 +-- crates/compiler/derive/src/decoding/list.rs | 10 +-- crates/compiler/derive/src/decoding/record.rs | 2 +- crates/compiler/derive/src/decoding/tuple.rs | 2 +- crates/compiler/derive/src/encoding.rs | 66 +++++++++---------- crates/compiler/derive/src/hash.rs | 14 ++-- crates/compiler/derive/src/util.rs | 2 +- crates/compiler/fmt/src/annotation.rs | 2 +- crates/compiler/gen_wasm/src/backend.rs | 9 ++- crates/compiler/load_internal/src/file.rs | 6 +- crates/compiler/solve/src/ability.rs | 2 +- crates/compiler/solve/src/solve.rs | 2 +- crates/compiler/types/src/pretty_print.rs | 4 +- crates/compiler/types/src/types.rs | 2 +- crates/compiler/unify/src/unify.rs | 2 +- 21 files changed, 89 insertions(+), 84 deletions(-) diff --git a/crates/cli_testing_examples/benchmarks/AStar.roc b/crates/cli_testing_examples/benchmarks/AStar.roc index 2021ac1877..95edcc7bc4 100644 --- a/crates/cli_testing_examples/benchmarks/AStar.roc +++ b/crates/cli_testing_examples/benchmarks/AStar.roc @@ -10,9 +10,9 @@ Model position : { openSet : Set position, costs : Dict position F64, cameFrom : Dict position position, -} | position has Hash & Eq +} | position implements Hash & Eq -initialModel : position -> Model position | position has Hash & Eq +initialModel : position -> Model position | position implements Hash & Eq initialModel = \start -> { evaluated: Set.empty {}, openSet: Set.single start, @@ -20,7 +20,7 @@ initialModel = \start -> { cameFrom: Dict.empty {}, } -cheapestOpen : (position -> F64), Model position -> Result position {} | position has Hash & Eq +cheapestOpen : (position -> F64), Model position -> Result position {} | position implements Hash & Eq cheapestOpen = \costFn, model -> model.openSet |> Set.toList @@ -35,13 +35,13 @@ cheapestOpen = \costFn, model -> |> Result.map .position |> Result.mapErr (\_ -> {}) -reconstructPath : Dict position position, position -> List position | position has Hash & Eq +reconstructPath : Dict position position, position -> List position | position implements Hash & Eq reconstructPath = \cameFrom, goal -> when Dict.get cameFrom goal is Err _ -> [] Ok next -> List.append (reconstructPath cameFrom next) goal -updateCost : position, position, Model position -> Model position | position has Hash & Eq +updateCost : position, position, Model position -> Model position | position implements Hash & Eq updateCost = \current, neighbor, model -> newCameFrom = Dict.insert model.cameFrom neighbor current @@ -70,7 +70,7 @@ updateCost = \current, neighbor, model -> else model -astar : (position, position -> F64), (position -> Set position), position, Model position -> Result (List position) {} | position has Hash & Eq +astar : (position, position -> F64), (position -> Set position), position, Model position -> Result (List position) {} | position implements Hash & Eq astar = \costFn, moveFn, goal, model -> when cheapestOpen (\source -> costFn source goal) model is Err {} -> Err {} diff --git a/crates/compiler/can/src/abilities.rs b/crates/compiler/can/src/abilities.rs index f5f056ebcb..4766b7eb7d 100644 --- a/crates/compiler/can/src/abilities.rs +++ b/crates/compiler/can/src/abilities.rs @@ -80,7 +80,7 @@ impl AbilityMemberData { /// Solved lambda sets for an ability member specialization. For example, if we have /// -/// Default has default : {} -[[] + a:default:1]-> a | a has Default +/// Default has default : {} -[[] + a:default:1]-> a | a implements Default /// /// A := {} /// default = \{} -[[closA]]-> @A {} @@ -144,7 +144,7 @@ pub struct IAbilitiesStore { /// /// For example, in the program /// - /// Hash has hash : a -> U64 | a has Hash + /// Hash has hash : a -> U64 | a implements Hash /// /// Id := {} implements [Hash {hash: myHash}] /// myHash = \@Id n -> n @@ -284,7 +284,7 @@ impl IAbilitiesStore { } /// Finds the implementation key for a symbol specializing the ability member, if it specializes any. - /// For example, suppose `hashId : Id -> U64` specializes `hash : a -> U64 | a has Hash`. + /// For example, suppose `hashId : Id -> U64` specializes `hash : a -> U64 | a implements Hash`. /// Calling this with `hashId` would retrieve (hash, hashId). pub fn impl_key(&self, specializing_symbol: Symbol) -> Option<&ImplKey> { self.specialization_to_root.get(&specializing_symbol) @@ -392,7 +392,7 @@ pub enum MarkError { impl IAbilitiesStore { /// Finds the symbol name and ability member definition for a symbol specializing the ability /// member, if it specializes any. - /// For example, suppose `hashId : Id -> U64` specializes `hash : a -> U64 | a has Hash`. + /// For example, suppose `hashId : Id -> U64` specializes `hash : a -> U64 | a implements Hash`. /// Calling this with `hashId` would retrieve the ability member data for `hash`, and what type /// `hashId` is specializing for. pub fn impl_key_and_def( diff --git a/crates/compiler/can/src/annotation.rs b/crates/compiler/can/src/annotation.rs index 63e9b8ef34..7906ccb5e6 100644 --- a/crates/compiler/can/src/annotation.rs +++ b/crates/compiler/can/src/annotation.rs @@ -296,7 +296,7 @@ pub(crate) fn canonicalize_annotation( let (annotation, region) = match annotation { TypeAnnotation::Where(annotation, clauses) => { - // Add each "has" clause. The association of a variable to an ability will be saved on + // Add each "implements" clause. The association of a variable to an ability will be saved on // `introduced_variables`, which we'll process later. for clause in clauses.iter() { let opt_err = canonicalize_has_clause( diff --git a/crates/compiler/can/src/def.rs b/crates/compiler/can/src/def.rs index 41d4800cfb..65ff7dc40b 100644 --- a/crates/compiler/can/src/def.rs +++ b/crates/compiler/can/src/def.rs @@ -480,7 +480,7 @@ fn canonicalize_claimed_ability_impl<'a>( // // interface F imports [] exposes [] // - // Hello := {} has [Encoding.{ toEncoder }] + // Hello := {} implements [Encoding.{ toEncoder }] // // toEncoder = \@Hello {} -> ... // @@ -492,7 +492,7 @@ fn canonicalize_claimed_ability_impl<'a>( // // interface F imports [Encoding.{ toEncoder }] exposes [] // - // Hello := {} has [Encoding.{ toEncoder }] + // Hello := {} implements [Encoding.{ toEncoder }] // // toEncoder = \@Hello {} -> ... // @@ -510,9 +510,9 @@ fn canonicalize_claimed_ability_impl<'a>( // definition symbol, for example when the ability is defined in the same // module as an implementer: // - // Eq has eq : a, a -> U64 | a has Eq + // Eq has eq : a, a -> U64 | a implements Eq // - // A := U8 has [Eq {eq}] + // A := U8 implements [Eq {eq}] // // So, do a final check that the implementation symbol is not resolved directly // to the member. @@ -749,8 +749,8 @@ fn canonicalize_opaque<'a>( // Did the user claim this implementation for a specialization of a different // type? e.g. // - // A has [Hash {hash: myHash}] - // B has [Hash {hash: myHash}] + // A implements [Hash {hash: myHash}] + // B implements [Hash {hash: myHash}] // // If so, that's an error and we drop the impl for this opaque type. let member_impl = match scope.abilities_store.impl_key(impl_symbol) { @@ -1398,7 +1398,7 @@ fn resolve_abilities( } [..] => { // There is more than one variable bound to the member signature, so something like - // Eq has eq : a, b -> Bool | a has Eq, b has Eq + // Eq has eq : a, b -> Bool | a has Eq, b implements Eq // We have no way of telling what type implements a particular instance of Eq in // this case (a or b?), so disallow it. let span_has_clauses = Region::across_all( diff --git a/crates/compiler/can/src/pattern.rs b/crates/compiler/can/src/pattern.rs index d881ad4257..5541ab4710 100644 --- a/crates/compiler/can/src/pattern.rs +++ b/crates/compiler/can/src/pattern.rs @@ -76,7 +76,7 @@ pub enum Pattern { Underscore, /// An identifier that marks a specialization of an ability member. - /// For example, given an ability member definition `hash : a -> U64 | a has Hash`, + /// For example, given an ability member definition `hash : a -> U64 | a implements Hash`, /// there may be the specialization `hash : Bool -> U64`. In this case we generate a /// new symbol for the specialized "hash" identifier. AbilityMemberSpecialization { diff --git a/crates/compiler/can/src/scope.rs b/crates/compiler/can/src/scope.rs index d1f4656ba7..9c2cf0aa75 100644 --- a/crates/compiler/can/src/scope.rs +++ b/crates/compiler/can/src/scope.rs @@ -33,7 +33,7 @@ pub struct Scope { imports: Vec<(Ident, Symbol, Region)>, /// Shadows of an ability member, for example a local specialization of `eq` for the ability - /// member `Eq has eq : a, a -> Bool | a has Eq` gets a shadow symbol it can use for its + /// member `Eq has eq : a, a -> Bool | a implements Eq` gets a shadow symbol it can use for its /// implementation. /// /// Only one shadow of an ability member is permitted per scope. diff --git a/crates/compiler/derive/src/decoding.rs b/crates/compiler/derive/src/decoding.rs index 2ba0b8cff8..acd58680b2 100644 --- a/crates/compiler/derive/src/decoding.rs +++ b/crates/compiler/derive/src/decoding.rs @@ -63,7 +63,7 @@ fn wrap_in_decode_custom_decode_with( // Decode.decodeWith bytes inner_decoder fmt : DecodeResult val let (decode_with_call, decode_with_result_var) = { - // Decode.decodeWith : List U8, Decoder val fmt, fmt -> DecodeResult val | fmt has DecoderFormatting + // Decode.decodeWith : List U8, Decoder val fmt, fmt -> DecodeResult val | fmt implements DecoderFormatting let decode_with_type = env.import_builtin_symbol_var(Symbol::DECODE_DECODE_WITH); // Decode.decodeWith : bytes, inner_decoder, fmt -> DecoderResult (List val) @@ -80,7 +80,7 @@ fn wrap_in_decode_custom_decode_with( )), ); - // List U8, Decoder val fmt, fmt -> DecodeResult val | fmt has DecoderFormatting + // List U8, Decoder val fmt, fmt -> DecodeResult val | fmt implements DecoderFormatting // ~ bytes, Decoder (List elem) fmt, fmt -> DecoderResult (List val) env.unify(decode_with_type, this_decode_with_fn_var); @@ -169,7 +169,7 @@ fn wrap_in_decode_custom_decode_with( // Decode.custom \bytes, fmt -> Decode.decodeWith bytes inner_decoder fmt let (decode_custom_call, decoder_var) = { - // (List U8, fmt -> DecodeResult val) -> Decoder val fmt | fmt has DecoderFormatting + // (List U8, fmt -> DecodeResult val) -> Decoder val fmt | fmt implements DecoderFormatting let decode_custom_type = env.import_builtin_symbol_var(Symbol::DECODE_CUSTOM); // (List U8, fmt -> DecodeResult (List elem)) -> Decoder (List elem) fmt @@ -185,7 +185,7 @@ fn wrap_in_decode_custom_decode_with( )), ); - // (List U8, fmt -> DecodeResult val) -> Decoder val fmt | fmt has DecoderFormatting + // (List U8, fmt -> DecodeResult val) -> Decoder val fmt | fmt implements DecoderFormatting // ~ (List U8, fmt -> DecodeResult (List elem)) -> Decoder (List elem) fmt env.unify(decode_custom_type, this_decode_custom_fn_var); diff --git a/crates/compiler/derive/src/decoding/list.rs b/crates/compiler/derive/src/decoding/list.rs index 53c89fd1bd..924c8047ec 100644 --- a/crates/compiler/derive/src/decoding/list.rs +++ b/crates/compiler/derive/src/decoding/list.rs @@ -15,7 +15,7 @@ use crate::util::Env; pub(crate) fn decoder(env: &mut Env<'_>, _def_symbol: Symbol) -> (Expr, Variable) { // Build // - // def_symbol : Decoder (List elem) fmt | elem has Decoding, fmt has DecoderFormatting + // def_symbol : Decoder (List elem) fmt | elem has Decoding, fmt implements DecoderFormatting // def_symbol = Decode.custom \bytes, fmt -> Decode.decodeWith bytes (Decode.list Decode.decoder) fmt // // NB: reduction to `Decode.list Decode.decoder` is not possible to the HRR. @@ -27,10 +27,10 @@ pub(crate) fn decoder(env: &mut Env<'_>, _def_symbol: Symbol) -> (Expr, Variable // List elem let elem_var = env.subs.fresh_unnamed_flex_var(); - // Decode.decoder : Decoder elem fmt | elem has Decoding, fmt has EncoderFormatting + // Decode.decoder : Decoder elem fmt | elem has Decoding, fmt implements EncoderFormatting let (elem_decoder, elem_decoder_var) = { // build `Decode.decoder : Decoder elem fmt` type - // Decoder val fmt | val has Decoding, fmt has EncoderFormatting + // Decoder val fmt | val has Decoding, fmt implements EncoderFormatting let elem_decoder_var = env.import_builtin_symbol_var(Symbol::DECODE_DECODER); // set val ~ elem @@ -52,7 +52,7 @@ pub(crate) fn decoder(env: &mut Env<'_>, _def_symbol: Symbol) -> (Expr, Variable }; // Build `Decode.list Decode.decoder` type - // Decoder val fmt -[uls]-> Decoder (List val) fmt | fmt has DecoderFormatting + // Decoder val fmt -[uls]-> Decoder (List val) fmt | fmt implements DecoderFormatting let decode_list_fn_var = env.import_builtin_symbol_var(Symbol::DECODE_LIST); // Decoder elem fmt -a-> b @@ -68,7 +68,7 @@ pub(crate) fn decoder(env: &mut Env<'_>, _def_symbol: Symbol) -> (Expr, Variable )), ); - // Decoder val fmt -[uls]-> Decoder (List val) fmt | fmt has DecoderFormatting + // Decoder val fmt -[uls]-> Decoder (List val) fmt | fmt implements DecoderFormatting // ~ Decoder elem fmt -a -> b env.unify(decode_list_fn_var, this_decode_list_fn_var); diff --git a/crates/compiler/derive/src/decoding/record.rs b/crates/compiler/derive/src/decoding/record.rs index d62ffe2f90..8549df9f7d 100644 --- a/crates/compiler/derive/src/decoding/record.rs +++ b/crates/compiler/derive/src/decoding/record.rs @@ -27,7 +27,7 @@ use super::wrap_in_decode_custom_decode_with; /// we'd like to generate an impl like /// /// ```roc -/// decoder : Decoder {first: a, second: b} fmt | a has Decoding, b has Decoding, fmt has DecoderFormatting +/// decoder : Decoder {first: a, second: b} fmt | a implements Decoding, b implements Decoding, fmt implements DecoderFormatting /// decoder = /// initialState : {f0: Result a [NoField], f1: Result b [NoField]} /// initialState = {f0: Err NoField, f1: Err NoField} diff --git a/crates/compiler/derive/src/decoding/tuple.rs b/crates/compiler/derive/src/decoding/tuple.rs index b6ce201691..15e9666427 100644 --- a/crates/compiler/derive/src/decoding/tuple.rs +++ b/crates/compiler/derive/src/decoding/tuple.rs @@ -28,7 +28,7 @@ use super::wrap_in_decode_custom_decode_with; /// we'd like to generate an impl like /// /// ```roc -/// decoder : Decoder (a, b) fmt | a has Decoding, b has Decoding, fmt has DecoderFormatting +/// decoder : Decoder (a, b) fmt | a implements Decoding, b implements Decoding, fmt implements DecoderFormatting /// decoder = /// initialState : {e0: Result a [NoElem], e1: Result b [NoElem]} /// initialState = {e0: Err NoElem, e1: Err NoElem} diff --git a/crates/compiler/derive/src/encoding.rs b/crates/compiler/derive/src/encoding.rs index 4073e960a9..959d8a8a43 100644 --- a/crates/compiler/derive/src/encoding.rs +++ b/crates/compiler/derive/src/encoding.rs @@ -121,7 +121,7 @@ fn to_encoder_list(env: &mut Env<'_>, fn_name: Symbol) -> (Expr, Variable) { ); // build `toEncoder elem` type - // val -[uls]-> Encoder fmt | fmt has EncoderFormatting + // val -[uls]-> Encoder fmt | fmt implements EncoderFormatting let to_encoder_fn_var = env.import_builtin_symbol_var(Symbol::ENCODE_TO_ENCODER); // elem -[clos]-> t1 @@ -136,11 +136,11 @@ fn to_encoder_list(env: &mut Env<'_>, fn_name: Symbol) -> (Expr, Variable) { )), ); - // val -[uls]-> Encoder fmt | fmt has EncoderFormatting + // val -[uls]-> Encoder fmt | fmt implements EncoderFormatting // ~ elem -[clos]-> t1 env.unify(to_encoder_fn_var, elem_to_encoder_fn_var); - // toEncoder : (typeof rcd.a) -[clos]-> Encoder fmt | fmt has EncoderFormatting + // toEncoder : (typeof rcd.a) -[clos]-> Encoder fmt | fmt implements EncoderFormatting let to_encoder_var = AbilityMember(Symbol::ENCODE_TO_ENCODER, None, elem_to_encoder_fn_var); let to_encoder_fn = Box::new(( to_encoder_fn_var, @@ -201,7 +201,7 @@ fn to_encoder_list(env: &mut Env<'_>, fn_name: Symbol) -> (Expr, Variable) { }); // build `Encode.list lst (\elem -> Encode.toEncoder elem)` type - // List e, (e -> Encoder fmt) -[uls]-> Encoder fmt | fmt has EncoderFormatting + // List e, (e -> Encoder fmt) -[uls]-> Encoder fmt | fmt implements EncoderFormatting let encode_list_fn_var = env.import_builtin_symbol_var(Symbol::ENCODE_LIST); // List elem, to_elem_encoder_fn_var -[clos]-> t1 @@ -218,11 +218,11 @@ fn to_encoder_list(env: &mut Env<'_>, fn_name: Symbol) -> (Expr, Variable) { )), ); - // List e, (e -> Encoder fmt) -[uls]-> Encoder fmt | fmt has EncoderFormatting + // List e, (e -> Encoder fmt) -[uls]-> Encoder fmt | fmt implements EncoderFormatting // ~ List elem, to_elem_encoder_fn_var -[clos]-> t1 env.unify(encode_list_fn_var, this_encode_list_fn_var); - // Encode.list : List elem, to_elem_encoder_fn_var -[clos]-> Encoder fmt | fmt has EncoderFormatting + // Encode.list : List elem, to_elem_encoder_fn_var -[clos]-> Encoder fmt | fmt implements EncoderFormatting let encode_list = AbilityMember(Symbol::ENCODE_LIST, None, this_encode_list_fn_var); let encode_list_fn = Box::new(( this_encode_list_fn_var, @@ -340,7 +340,7 @@ fn to_encoder_record( }; // build `toEncoder rcd.a` type - // val -[uls]-> Encoder fmt | fmt has EncoderFormatting + // val -[uls]-> Encoder fmt | fmt implements EncoderFormatting let to_encoder_fn_var = env.import_builtin_symbol_var(Symbol::ENCODE_TO_ENCODER); // (typeof rcd.a) -[clos]-> t1 @@ -355,11 +355,11 @@ fn to_encoder_record( )), ); - // val -[uls]-> Encoder fmt | fmt has EncoderFormatting + // val -[uls]-> Encoder fmt | fmt implements EncoderFormatting // ~ (typeof rcd.a) -[clos]-> t1 env.unify(to_encoder_fn_var, this_to_encoder_fn_var); - // toEncoder : (typeof rcd.a) -[clos]-> Encoder fmt | fmt has EncoderFormatting + // toEncoder : (typeof rcd.a) -[clos]-> Encoder fmt | fmt implements EncoderFormatting let to_encoder_var = AbilityMember(Symbol::ENCODE_TO_ENCODER, None, to_encoder_fn_var); let to_encoder_fn = Box::new(( to_encoder_fn_var, @@ -420,7 +420,7 @@ fn to_encoder_record( }; // build `Encode.record [ { key: .., value: ..}, .. ]` type - // List { key : Str, value : Encoder fmt } -[uls]-> Encoder fmt | fmt has EncoderFormatting + // List { key : Str, value : Encoder fmt } -[uls]-> Encoder fmt | fmt implements EncoderFormatting let encode_record_fn_var = env.import_builtin_symbol_var(Symbol::ENCODE_RECORD); // fields_list_var -[clos]-> t1 @@ -437,11 +437,11 @@ fn to_encoder_record( )), ); - // List { key : Str, value : Encoder fmt } -[uls]-> Encoder fmt | fmt has EncoderFormatting + // List { key : Str, value : Encoder fmt } -[uls]-> Encoder fmt | fmt implements EncoderFormatting // ~ fields_list_var -[clos]-> t1 env.unify(encode_record_fn_var, this_encode_record_fn_var); - // Encode.record : fields_list_var -[clos]-> Encoder fmt | fmt has EncoderFormatting + // Encode.record : fields_list_var -[clos]-> Encoder fmt | fmt implements EncoderFormatting let encode_record_var = AbilityMember(Symbol::ENCODE_RECORD, None, encode_record_fn_var); let encode_record_fn = Box::new(( encode_record_fn_var, @@ -543,7 +543,7 @@ fn to_encoder_tuple( }; // build `toEncoder tup.0` type - // val -[uls]-> Encoder fmt | fmt has EncoderFormatting + // val -[uls]-> Encoder fmt | fmt implements EncoderFormatting let to_encoder_fn_var = env.import_builtin_symbol_var(Symbol::ENCODE_TO_ENCODER); // (typeof tup.0) -[clos]-> t1 @@ -558,11 +558,11 @@ fn to_encoder_tuple( )), ); - // val -[uls]-> Encoder fmt | fmt has EncoderFormatting + // val -[uls]-> Encoder fmt | fmt implements EncoderFormatting // ~ (typeof tup.0) -[clos]-> t1 env.unify(to_encoder_fn_var, this_to_encoder_fn_var); - // toEncoder : (typeof tup.0) -[clos]-> Encoder fmt | fmt has EncoderFormatting + // toEncoder : (typeof tup.0) -[clos]-> Encoder fmt | fmt implements EncoderFormatting let to_encoder_var = AbilityMember(Symbol::ENCODE_TO_ENCODER, None, to_encoder_fn_var); let to_encoder_fn = Box::new(( to_encoder_fn_var, @@ -603,7 +603,7 @@ fn to_encoder_tuple( }; // build `Encode.tuple [ toEncoder tup.0, toEncoder tup.1 ]` type - // List (Encoder fmt) -[uls]-> Encoder fmt | fmt has EncoderFormatting + // List (Encoder fmt) -[uls]-> Encoder fmt | fmt implements EncoderFormatting let encode_tuple_fn_var = env.import_builtin_symbol_var(Symbol::ENCODE_TUPLE); // elem_encoders_list_var -[clos]-> t1 @@ -620,11 +620,11 @@ fn to_encoder_tuple( )), ); - // List (Encoder fmt) -[uls]-> Encoder fmt | fmt has EncoderFormatting + // List (Encoder fmt) -[uls]-> Encoder fmt | fmt implements EncoderFormatting // ~ elem_encoders_list_var -[clos]-> t1 env.unify(encode_tuple_fn_var, this_encode_tuple_fn_var); - // Encode.tuple : elem_encoders_list_var -[clos]-> Encoder fmt | fmt has EncoderFormatting + // Encode.tuple : elem_encoders_list_var -[clos]-> Encoder fmt | fmt implements EncoderFormatting let encode_tuple_var = AbilityMember(Symbol::ENCODE_TUPLE, None, encode_tuple_fn_var); let encode_tuple_fn = Box::new(( encode_tuple_fn_var, @@ -741,7 +741,7 @@ fn to_encoder_tag_union( .zip(payload_vars.iter()) .map(|(&sym, &sym_var)| { // build `toEncoder v1` type - // expected: val -[uls]-> Encoder fmt | fmt has EncoderFormatting + // expected: val -[uls]-> Encoder fmt | fmt implements EncoderFormatting let to_encoder_fn_var = env.import_builtin_symbol_var(Symbol::ENCODE_TO_ENCODER); @@ -759,11 +759,11 @@ fn to_encoder_tag_union( )), ); - // val -[uls]-> Encoder fmt | fmt has EncoderFormatting + // val -[uls]-> Encoder fmt | fmt implements EncoderFormatting // ~ t1 -[clos]-> t' env.unify(to_encoder_fn_var, this_to_encoder_fn_var); - // toEncoder : t1 -[clos]-> Encoder fmt | fmt has EncoderFormatting + // toEncoder : t1 -[clos]-> Encoder fmt | fmt implements EncoderFormatting let to_encoder_var = AbilityMember(Symbol::ENCODE_TO_ENCODER, None, this_to_encoder_fn_var); let to_encoder_fn = Box::new(( @@ -802,7 +802,7 @@ fn to_encoder_tag_union( }; // build `Encode.tag "A" [ ... ]` type - // expected: Str, List (Encoder fmt) -[uls]-> Encoder fmt | fmt has EncoderFormatting + // expected: Str, List (Encoder fmt) -[uls]-> Encoder fmt | fmt implements EncoderFormatting let encode_tag_fn_var = env.import_builtin_symbol_var(Symbol::ENCODE_TAG); // wanted: Str, List whole_encoders_var -[clos]-> t' @@ -821,11 +821,11 @@ fn to_encoder_tag_union( )), ); - // Str, List (Encoder fmt) -[uls]-> Encoder fmt | fmt has EncoderFormatting + // Str, List (Encoder fmt) -[uls]-> Encoder fmt | fmt implements EncoderFormatting // ~ Str, List whole_encoders_var -[clos]-> t' env.unify(encode_tag_fn_var, this_encode_tag_fn_var); - // Encode.tag : Str, List whole_encoders_var -[clos]-> Encoder fmt | fmt has EncoderFormatting + // Encode.tag : Str, List whole_encoders_var -[clos]-> Encoder fmt | fmt implements EncoderFormatting let encode_tag_var = AbilityMember(Symbol::ENCODE_TAG, None, this_encode_tag_fn_var); let encode_tag_fn = Box::new(( this_encode_tag_fn_var, @@ -954,15 +954,15 @@ fn wrap_in_encode_custom( let bytes_sym = env.new_symbol("bytes"); let bytes_var = Variable::LIST_U8; - // fmt: fmt | fmt has EncoderFormatting + // fmt: fmt | fmt implements EncoderFormatting let fmt_sym = env.new_symbol("fmt"); let fmt_var = env.subs.fresh_unnamed_flex_var(); // build `Encode.appendWith bytes encoder fmt` type - // expected: Encode.appendWith : List U8, Encoder fmt, fmt -[appendWith]-> List U8 | fmt has EncoderFormatting + // expected: Encode.appendWith : List U8, Encoder fmt, fmt -[appendWith]-> List U8 | fmt implements EncoderFormatting let append_with_fn_var = env.import_builtin_symbol_var(Symbol::ENCODE_APPEND_WITH); - // wanted: Encode.appendWith : List U8, encoder_var, fmt -[clos]-> List U8 | fmt has EncoderFormatting + // wanted: Encode.appendWith : List U8, encoder_var, fmt -[clos]-> List U8 | fmt implements EncoderFormatting let this_append_with_args_var_slice = VariableSubsSlice::insert_into_subs(env.subs, [Variable::LIST_U8, encoder_var, fmt_var]); let this_append_with_clos_var = env.subs.fresh_unnamed_flex_var(); // -[clos]-> @@ -975,11 +975,11 @@ fn wrap_in_encode_custom( )), ); - // List U8, Encoder fmt, fmt -[appendWith]-> List U8 | fmt has EncoderFormatting - // ~ List U8, encoder_var, fmt -[clos]-> List U8 | fmt has EncoderFormatting + // List U8, Encoder fmt, fmt -[appendWith]-> List U8 | fmt implements EncoderFormatting + // ~ List U8, encoder_var, fmt -[clos]-> List U8 | fmt implements EncoderFormatting env.unify(append_with_fn_var, this_append_with_fn_var); - // Encode.appendWith : List U8, encoder_var, fmt -[appendWith]-> List U8 | fmt has EncoderFormatting + // Encode.appendWith : List U8, encoder_var, fmt -[appendWith]-> List U8 | fmt implements EncoderFormatting let append_with_fn = Box::new(( this_append_with_fn_var, Loc::at_zero(Var(Symbol::ENCODE_APPEND_WITH, this_append_with_fn_var)), @@ -1050,7 +1050,7 @@ fn wrap_in_encode_custom( // Build // Encode.custom \bytes, fmt -> Encode.appendWith bytes encoder fmt // - // expected: Encode.custom : (List U8, fmt -> List U8) -> Encoder fmt | fmt has EncoderFormatting + // expected: Encode.custom : (List U8, fmt -> List U8) -> Encoder fmt | fmt implements EncoderFormatting let custom_fn_var = env.import_builtin_symbol_var(Symbol::ENCODE_CUSTOM); // wanted: Encode.custom : fn_var -[clos]-> t' @@ -1066,11 +1066,11 @@ fn wrap_in_encode_custom( )), ); - // (List U8, fmt -> List U8) -[..]-> Encoder fmt | fmt has EncoderFormatting + // (List U8, fmt -> List U8) -[..]-> Encoder fmt | fmt implements EncoderFormatting // ~ fn_var -[clos]-> t' env.unify(custom_fn_var, this_custom_fn_var); - // Encode.custom : (List U8, fmt -> List U8) -> Encoder fmt | fmt has EncoderFormatting + // Encode.custom : (List U8, fmt -> List U8) -> Encoder fmt | fmt implements EncoderFormatting let custom_fn = Box::new(( this_custom_fn_var, Loc::at_zero(Var(Symbol::ENCODE_CUSTOM, this_custom_fn_var)), diff --git a/crates/compiler/derive/src/hash.rs b/crates/compiler/derive/src/hash.rs index f01a28eac2..aa122c47d6 100644 --- a/crates/compiler/derive/src/hash.rs +++ b/crates/compiler/derive/src/hash.rs @@ -75,7 +75,7 @@ fn hash_record(env: &mut Env<'_>, fn_name: Symbol, fields: Vec) -> (V // Now, a hasher for this record is // - // hash_rcd : hasher, { f1: t1, ..., fn: tn } -> hasher | hasher has Hasher + // hash_rcd : hasher, { f1: t1, ..., fn: tn } -> hasher | hasher implements Hasher // hash_rcd = \hasher, rcd -> // Hash.hash ( // Hash.hash @@ -144,7 +144,7 @@ fn hash_tuple(env: &mut Env<'_>, fn_name: Symbol, arity: u32) -> (Variable, Expr // Now, a hasher for this tuple is // - // hash_tup : hasher, (t1, ..., tn) -> hasher | hasher has Hasher + // hash_tup : hasher, (t1, ..., tn) -> hasher | hasher implements Hasher // hash_tup = \hasher, tup -> // Hash.hash ( // Hash.hash @@ -227,7 +227,7 @@ fn hash_tag_union( // Now, a hasher for this tag union is // - // hash_union : hasher, [ A t11 .. t1n, ..., Q tq1 .. tqm ] -> hasher | hasher has Hasher + // hash_union : hasher, [ A t11 .. t1n, ..., Q tq1 .. tqm ] -> hasher | hasher implements Hasher // hash_union = \hasher, union -> // when union is // A x11 .. x1n -> Hash.hash (... (Hash.hash (Hash.uN hasher 0) x11) ...) x1n @@ -393,7 +393,7 @@ fn hash_newtype_tag_union( // Now, a hasher for this tag union is // - // hash_union : hasher, [ A t1 .. tn ] -> hasher | hasher has Hasher + // hash_union : hasher, [ A t1 .. tn ] -> hasher | hasher implements Hasher // hash_union = \hasher, A x1 .. xn -> // Hash.hash (... (Hash.hash discrHasher x1) ...) xn let hasher_sym = env.new_symbol("hasher"); @@ -462,7 +462,7 @@ fn call_hash_ability_member( // build `member ...` function type. `member` here is `Hash.hash` or `Hash.addU16`. // - // hasher, val -[uls]-> hasher | hasher has Hasher, val has Hash + // hasher, val -[uls]-> hasher | hasher has Hasher, val implements Hash let exposed_hash_fn_var = env.import_builtin_symbol_var(member); // (typeof body), (typeof field) -[clos]-> hasher_result @@ -479,11 +479,11 @@ fn call_hash_ability_member( )), ); - // hasher, val -[uls]-> hasher | hasher has Hasher, val has Hash + // hasher, val -[uls]-> hasher | hasher has Hasher, val implements Hash // ~ (typeof body), (typeof field) -[clos]-> hasher_result env.unify(exposed_hash_fn_var, this_hash_fn_var); - // Hash.hash : hasher, (typeof field) -[clos]-> hasher | hasher has Hasher, (typeof field) has Hash + // Hash.hash : hasher, (typeof field) -[clos]-> hasher | hasher has Hasher, (typeof field) implements Hash let hash_fn_head = Expr::AbilityMember(member, None, this_hash_fn_var); let hash_fn_data = Box::new(( this_hash_fn_var, diff --git a/crates/compiler/derive/src/util.rs b/crates/compiler/derive/src/util.rs index 2319dd2e12..1dfc38f89f 100644 --- a/crates/compiler/derive/src/util.rs +++ b/crates/compiler/derive/src/util.rs @@ -130,7 +130,7 @@ impl Env<'_> { }) .collect(); - // Since we're doing `{foo} ~ a | a has Encoding`, we may see "lambda sets to + // Since we're doing `{foo} ~ a | a implements Encoding`, we may see "lambda sets to // specialize" for e.g. `{foo}:toEncoder:1`, but these are actually just the // specialization lambda sets, so we don't need to do any extra work! // diff --git a/crates/compiler/fmt/src/annotation.rs b/crates/compiler/fmt/src/annotation.rs index 7b6c969dad..02f5f58e10 100644 --- a/crates/compiler/fmt/src/annotation.rs +++ b/crates/compiler/fmt/src/annotation.rs @@ -647,7 +647,7 @@ impl<'a> Formattable for Tag<'a> { impl<'a> Formattable for ImplementsClause<'a> { fn is_multiline(&self) -> bool { - // No, always put abilities in a "has" clause on one line + // No, always put abilities in an "implements" clause on one line false } diff --git a/crates/compiler/gen_wasm/src/backend.rs b/crates/compiler/gen_wasm/src/backend.rs index bc4277aec6..720f500d11 100644 --- a/crates/compiler/gen_wasm/src/backend.rs +++ b/crates/compiler/gen_wasm/src/backend.rs @@ -1106,8 +1106,13 @@ impl<'a, 'r> WasmBackend<'a, 'r> { *******************************************************************/ fn expr_literal(&mut self, lit: &Literal<'a>, storage: &StoredValue) { - let invalid_error = - || internal_error!("Literal value {:?} has invalid storage {:?}", lit, storage); + let invalid_error = || { + internal_error!( + "Literal value {:?} implements invalid storage {:?}", + lit, + storage + ) + }; match storage { StoredValue::VirtualMachineStack { value_type, .. } => { diff --git a/crates/compiler/load_internal/src/file.rs b/crates/compiler/load_internal/src/file.rs index 6bd3289525..0f3814687b 100644 --- a/crates/compiler/load_internal/src/file.rs +++ b/crates/compiler/load_internal/src/file.rs @@ -3172,7 +3172,7 @@ fn update<'a>( // # Default module // interface Default exposes [default, getDefault] // - // Default has default : {} -> a | a has Default + // Default has default : {} -> a | a implements Default // // getDefault = \{} -> default {} // @@ -4632,7 +4632,7 @@ fn build_header<'a>( // created an IdentId for this, when it was imported exposed // in a dependent module. // - // For example, if module A has [B.{ foo }], then + // For example, if module A implements [B.{ foo }], then // when we get here for B, `foo` will already have // an IdentId. We must reuse that! let ident_id = ident_ids.get_or_insert(loc_exposed.value.as_str()); @@ -4656,7 +4656,7 @@ fn build_header<'a>( // created an IdentId for this, when it was imported exposed // in a dependent module. // - // For example, if module A has [B.{ foo }], then + // For example, if module A implements [B.{ foo }], then // when we get here for B, `foo` will already have // an IdentId. We must reuse that! let ident_id = ident_ids.get_or_insert(loc_name.value.as_str()); diff --git a/crates/compiler/solve/src/ability.rs b/crates/compiler/solve/src/ability.rs index 47d0ba15a3..633cdc3110 100644 --- a/crates/compiler/solve/src/ability.rs +++ b/crates/compiler/solve/src/ability.rs @@ -739,7 +739,7 @@ trait DerivableVisitor { ) { // TODO: currently, just we suppose the presence of a flex var may // include more or less things which we can derive. But, we should - // instead recurse here, and add a `t ~ u | u has Decode` constraint as needed. + // instead recurse here, and add a `t ~ u | u implements Decode` constraint as needed. stack.push(ext); } } diff --git a/crates/compiler/solve/src/solve.rs b/crates/compiler/solve/src/solve.rs index ba31952537..72d1d3bfef 100644 --- a/crates/compiler/solve/src/solve.rs +++ b/crates/compiler/solve/src/solve.rs @@ -2510,7 +2510,7 @@ impl AmbientFunctionPolicy { }), Content::FlexVar(_) => { // Something like - // Encoder fmt : List U8, fmt -a-> List U8 | fmt has EncoderFormatting + // Encoder fmt : List U8, fmt -a-> List U8 | fmt implements EncoderFormatting // THEORY: Replace these with empty lambda sets. They will unify the same as a flex // var does, but allows us to record the ambient function properly. Content::LambdaSet(LambdaSet { diff --git a/crates/compiler/types/src/pretty_print.rs b/crates/compiler/types/src/pretty_print.rs index 77bbbb4da1..8e6d41d031 100644 --- a/crates/compiler/types/src/pretty_print.rs +++ b/crates/compiler/types/src/pretty_print.rs @@ -136,8 +136,8 @@ fn find_names_needed( if !root_appearances.contains_key(&root) { roots.push(root); } - // Able vars are always printed at least twice (in the signature, and in the "has" - // clause set). + // Able vars are always printed at least twice (in the signature, and in the + // "implements" clause set). root_appearances.insert(root, Appearances::Multiple); } RecursionVar { diff --git a/crates/compiler/types/src/types.rs b/crates/compiler/types/src/types.rs index 00eb2b0098..8d668e8207 100644 --- a/crates/compiler/types/src/types.rs +++ b/crates/compiler/types/src/types.rs @@ -1760,7 +1760,7 @@ pub enum Type { } /// A lambda set under an arrow in a ability member signature. For example, in -/// Default has default : {} -> a | a has Default +/// Default has default : {} -> a | a implements Default /// the unspecialized lambda set for the arrow "{} -> a" would be `a:default:1`. /// /// Lambda sets in member signatures are never known until those members are specialized at a diff --git a/crates/compiler/unify/src/unify.rs b/crates/compiler/unify/src/unify.rs index 383197a805..98a8aa1149 100644 --- a/crates/compiler/unify/src/unify.rs +++ b/crates/compiler/unify/src/unify.rs @@ -1302,7 +1302,7 @@ fn extract_specialization_lambda_set( // lambda set does not line up with one required by the ability member prototype. // As an example, consider // - // Q := [ F (Str -> Str) ] has [Eq {isEq}] + // Q := [ F (Str -> Str) ] implements [Eq {isEq}] // // isEq = \@Q _, @Q _ -> Bool.false // From 3b1dbafb2ecf22dba624bdbdcbab759a67bc2fc4 Mon Sep 17 00:00:00 2001 From: Bryce Miller Date: Wed, 24 May 2023 21:30:35 -0400 Subject: [PATCH 028/176] abilities syntax `has` -> `implements` in examples --- examples/cli/cli-platform/Env.roc | 4 ++-- examples/cli/cli-platform/EnvDecoding.roc | 2 +- examples/cli/cli-platform/File.roc | 4 ++-- examples/cli/cli-platform/Http.roc | 2 +- examples/python-interop/platform/main.roc | 2 +- examples/ruby-interop/platform/main.roc | 2 +- .../virtual-dom-wip/platform/Html/Internal/Client.roc | 8 ++++---- .../virtual-dom-wip/platform/Html/Internal/Server.roc | 4 ++-- examples/virtual-dom-wip/platform/client-side.roc | 2 +- 9 files changed, 15 insertions(+), 15 deletions(-) diff --git a/examples/cli/cli-platform/Env.roc b/examples/cli/cli-platform/Env.roc index 2826d34941..061ab69b28 100644 --- a/examples/cli/cli-platform/Env.roc +++ b/examples/cli/cli-platform/Env.roc @@ -65,7 +65,7 @@ var = \name -> ## - comma-separated lists (of either strings or numbers), as long as there are no spaces after the commas ## ## Trying to decode into any other types will always fail with a `DecodeErr`. -decode : Str -> Task val [VarNotFound, DecodeErr DecodeError] | val has Decoding +decode : Str -> Task val [VarNotFound, DecodeErr DecodeError] | val implements Decoding decode = \name -> Effect.envVar name |> Effect.map @@ -120,4 +120,4 @@ dict = # decode all the required vars only, and then decode the optional ones separately some other way. # Alternatively, it could make sense to have some sort of tag union convention here, e.g. # if decoding into a tag union of [Present val, Missing], then it knows what to do. -# decodeAll : Task val [] [EnvDecodingFailed Str] [Env] | val has Decoding +# decodeAll : Task val [] [EnvDecodingFailed Str] [Env] | val implements Decoding diff --git a/examples/cli/cli-platform/EnvDecoding.roc b/examples/cli/cli-platform/EnvDecoding.roc index ccc4a9f2bb..463c4ca58a 100644 --- a/examples/cli/cli-platform/EnvDecoding.roc +++ b/examples/cli/cli-platform/EnvDecoding.roc @@ -1,6 +1,6 @@ interface EnvDecoding exposes [EnvFormat, format] imports [] -EnvFormat := {} has [ +EnvFormat := {} implements [ DecoderFormatting { u8: envU8, u16: envU16, diff --git a/examples/cli/cli-platform/File.roc b/examples/cli/cli-platform/File.roc index 708fe1b7a6..9d91c6d7c8 100644 --- a/examples/cli/cli-platform/File.roc +++ b/examples/cli/cli-platform/File.roc @@ -26,7 +26,7 @@ WriteErr : InternalFile.WriteErr ## This opens the file first and closes it after writing to it. ## ## To write unformatted bytes to a file, you can use [File.writeBytes] instead. -write : Path, val, fmt -> Task {} [FileWriteErr Path WriteErr] | val has Encode.Encoding, fmt has Encode.EncoderFormatting +write : Path, val, fmt -> Task {} [FileWriteErr Path WriteErr] | val has Encode.Encoding, fmt implements Encode.EncoderFormatting write = \path, val, fmt -> bytes = Encode.toBytes val fmt @@ -119,7 +119,7 @@ readUtf8 = \path -> # Str # [FileReadErr Path ReadErr, FileReadDecodeErr Path [Leftover (List U8)]Decode.DecodeError ] # [Read [File]] -# | val has Decode.Decoding, fmt has Decode.DecoderFormatting +# | val has Decode.Decoding, fmt implements Decode.DecoderFormatting # read = \path, fmt -> # effect = Effect.map (Effect.fileReadBytes (InternalPath.toBytes path)) \result -> # when result is diff --git a/examples/cli/cli-platform/Http.roc b/examples/cli/cli-platform/Http.roc index 4e39bad419..372d10a481 100644 --- a/examples/cli/cli-platform/Http.roc +++ b/examples/cli/cli-platform/Http.roc @@ -56,7 +56,7 @@ stringBody : [MimeType Str], Str -> Body stringBody = \mimeType, str -> Body mimeType (Str.toUtf8 str) -# jsonBody : a -> Body | a has Encoding +# jsonBody : a -> Body | a implements Encoding # jsonBody = \val -> # Body (MimeType "application/json") (Encode.toBytes val Json.format) # diff --git a/examples/python-interop/platform/main.roc b/examples/python-interop/platform/main.roc index fb0832772f..3d9f16bbb2 100644 --- a/examples/python-interop/platform/main.roc +++ b/examples/python-interop/platform/main.roc @@ -1,5 +1,5 @@ platform "python-interop" - requires {} { main : arg -> ret | arg has Decoding, ret has Encoding } + requires {} { main : arg -> ret | arg has Decoding, ret implements Encoding } exposes [] packages {} imports [Json] diff --git a/examples/ruby-interop/platform/main.roc b/examples/ruby-interop/platform/main.roc index 96500cb448..07c6284f42 100644 --- a/examples/ruby-interop/platform/main.roc +++ b/examples/ruby-interop/platform/main.roc @@ -1,5 +1,5 @@ platform "ruby-interop" - requires {} { main : arg -> ret | arg has Decoding, ret has Encoding } + requires {} { main : arg -> ret | arg has Decoding, ret implements Encoding } exposes [] packages {} imports [Json] diff --git a/examples/virtual-dom-wip/platform/Html/Internal/Client.roc b/examples/virtual-dom-wip/platform/Html/Internal/Client.roc index c69ed2ce67..c8bc2f1b08 100644 --- a/examples/virtual-dom-wip/platform/Html/Internal/Client.roc +++ b/examples/virtual-dom-wip/platform/Html/Internal/Client.roc @@ -84,7 +84,7 @@ DiffState state : { rendered : RenderedTree state, patches : List Patch } # ------------------------------- # INITIALISATION # ------------------------------- -initClientApp : List U8, App state initData -> Effect (PlatformState state initData) | initData has Decoding +initClientApp : List U8, App state initData -> Effect (PlatformState state initData) | initData implements Decoding initClientApp = \json, app -> # Initialise the Roc representation of the rendered DOM, and calculate patches (for event listeners) { state, rendered, patches } = @@ -100,7 +100,7 @@ initClientApp = \json, app -> } # Testable helper function to initialise the app -initClientAppHelp : List U8, App state initData -> { state, rendered : RenderedTree state, patches : List Patch } | initData has Decoding +initClientAppHelp : List U8, App state initData -> { state, rendered : RenderedTree state, patches : List Patch } | initData implements Decoding initClientAppHelp = \json, app -> state = json @@ -200,7 +200,7 @@ JsEventResult state initData : { } ## Dispatch a JavaScript event to a Roc handler, given the handler ID and some JSON event data. -dispatchEvent : PlatformState state initData, List (List U8), HandlerId -> Effect (JsEventResult state initData) | initData has Decoding +dispatchEvent : PlatformState state initData, List (List U8), HandlerId -> Effect (JsEventResult state initData) | initData implements Decoding dispatchEvent = \platformState, eventData, handlerId -> { app, state, rendered } = platformState @@ -694,7 +694,7 @@ eqRenderedAttrs = \a, b -> && eqAttrDict a.domProps b.domProps && eqAttrDict a.styles b.styles -eqAttrDict : Dict Str v, Dict Str v -> Bool | v has Eq +eqAttrDict : Dict Str v, Dict Str v -> Bool | v implements Eq eqAttrDict = \a, b -> Dict.keys a |> List.all \k -> Dict.get a k == Dict.get b k diff --git a/examples/virtual-dom-wip/platform/Html/Internal/Server.roc b/examples/virtual-dom-wip/platform/Html/Internal/Server.roc index be871396d1..05f1493d11 100644 --- a/examples/virtual-dom-wip/platform/Html/Internal/Server.roc +++ b/examples/virtual-dom-wip/platform/Html/Internal/Server.roc @@ -57,7 +57,7 @@ appendRenderedStaticAttr = \{ buffer, styles }, attr -> # ------------------------------- # INITIALISATION # ------------------------------- -initServerApp : App state initData, initData, Str -> Result (Html []) [InvalidDocument] | initData has Encoding +initServerApp : App state initData, initData, Str -> Result (Html []) [InvalidDocument] | initData implements Encoding initServerApp = \app, initData, hostJavaScript -> initData |> Ok @@ -66,7 +66,7 @@ initServerApp = \app, initData, hostJavaScript -> |> translateStatic |> insertRocScript initData app.wasmUrl hostJavaScript -insertRocScript : Html [], initData, Str, Str -> Result (Html []) [InvalidDocument] | initData has Encoding +insertRocScript : Html [], initData, Str, Str -> Result (Html []) [InvalidDocument] | initData implements Encoding insertRocScript = \document, initData, wasmUrl, hostJavaScript -> encode = \value -> diff --git a/examples/virtual-dom-wip/platform/client-side.roc b/examples/virtual-dom-wip/platform/client-side.roc index 02bf4f7559..73e8603f53 100644 --- a/examples/virtual-dom-wip/platform/client-side.roc +++ b/examples/virtual-dom-wip/platform/client-side.roc @@ -26,7 +26,7 @@ ToHost state initData : { } # TODO: naming the type variables causes a type 'mismatch' -# main : FromHost state initData -> Effect (ToHost state initData) | initData has Decoding & Encoding +# main : FromHost state initData -> Effect (ToHost state initData) | initData implements Decoding & Encoding main : FromHost _ _ -> Effect (ToHost _ _) main = \fromHost -> if fromHost.isInitEvent then From d97d0c54830f18857a8dc4c987d3a277375e437f Mon Sep 17 00:00:00 2001 From: Bryce Miller Date: Fri, 26 May 2023 20:35:35 -0400 Subject: [PATCH 029/176] Re-enable test --- crates/cli/tests/cli_run.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/crates/cli/tests/cli_run.rs b/crates/cli/tests/cli_run.rs index 60729b4b10..21a17eda78 100644 --- a/crates/cli/tests/cli_run.rs +++ b/crates/cli/tests/cli_run.rs @@ -634,7 +634,6 @@ mod cli_run { } #[test] - #[ignore] #[cfg_attr( windows, ignore = "this platform is broken, and `roc run --lib` is missing on windows" From 33c2b9dfddc6cf49b729b7540eb1d3144c2d1d3a Mon Sep 17 00:00:00 2001 From: Bryce Miller Date: Fri, 26 May 2023 20:37:02 -0400 Subject: [PATCH 030/176] has -> implements in comments --- crates/compiler/can/src/def.rs | 2 +- crates/compiler/derive/src/decoding/list.rs | 6 +++--- crates/compiler/derive/src/hash.rs | 6 +++--- crates/compiler/load_internal/src/docs.rs | 2 +- crates/compiler/load_internal/src/file.rs | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/crates/compiler/can/src/def.rs b/crates/compiler/can/src/def.rs index 65ff7dc40b..94719ade9e 100644 --- a/crates/compiler/can/src/def.rs +++ b/crates/compiler/can/src/def.rs @@ -1398,7 +1398,7 @@ fn resolve_abilities( } [..] => { // There is more than one variable bound to the member signature, so something like - // Eq has eq : a, b -> Bool | a has Eq, b implements Eq + // Eq has eq : a, b -> Bool | a implements Eq, b implements Eq // We have no way of telling what type implements a particular instance of Eq in // this case (a or b?), so disallow it. let span_has_clauses = Region::across_all( diff --git a/crates/compiler/derive/src/decoding/list.rs b/crates/compiler/derive/src/decoding/list.rs index 924c8047ec..59fe3e091b 100644 --- a/crates/compiler/derive/src/decoding/list.rs +++ b/crates/compiler/derive/src/decoding/list.rs @@ -15,7 +15,7 @@ use crate::util::Env; pub(crate) fn decoder(env: &mut Env<'_>, _def_symbol: Symbol) -> (Expr, Variable) { // Build // - // def_symbol : Decoder (List elem) fmt | elem has Decoding, fmt implements DecoderFormatting + // def_symbol : Decoder (List elem) fmt | elem implements Decoding, fmt implements DecoderFormatting // def_symbol = Decode.custom \bytes, fmt -> Decode.decodeWith bytes (Decode.list Decode.decoder) fmt // // NB: reduction to `Decode.list Decode.decoder` is not possible to the HRR. @@ -27,10 +27,10 @@ pub(crate) fn decoder(env: &mut Env<'_>, _def_symbol: Symbol) -> (Expr, Variable // List elem let elem_var = env.subs.fresh_unnamed_flex_var(); - // Decode.decoder : Decoder elem fmt | elem has Decoding, fmt implements EncoderFormatting + // Decode.decoder : Decoder elem fmt | elem implements Decoding, fmt implements EncoderFormatting let (elem_decoder, elem_decoder_var) = { // build `Decode.decoder : Decoder elem fmt` type - // Decoder val fmt | val has Decoding, fmt implements EncoderFormatting + // Decoder val fmt | val implements Decoding, fmt implements EncoderFormatting let elem_decoder_var = env.import_builtin_symbol_var(Symbol::DECODE_DECODER); // set val ~ elem diff --git a/crates/compiler/derive/src/hash.rs b/crates/compiler/derive/src/hash.rs index aa122c47d6..d0fff82cee 100644 --- a/crates/compiler/derive/src/hash.rs +++ b/crates/compiler/derive/src/hash.rs @@ -462,7 +462,7 @@ fn call_hash_ability_member( // build `member ...` function type. `member` here is `Hash.hash` or `Hash.addU16`. // - // hasher, val -[uls]-> hasher | hasher has Hasher, val implements Hash + // hasher, val -[uls]-> hasher | hasher implements Hasher, val implements Hash let exposed_hash_fn_var = env.import_builtin_symbol_var(member); // (typeof body), (typeof field) -[clos]-> hasher_result @@ -479,11 +479,11 @@ fn call_hash_ability_member( )), ); - // hasher, val -[uls]-> hasher | hasher has Hasher, val implements Hash + // hasher, val -[uls]-> hasher | hasher implements Hasher, val implements Hash // ~ (typeof body), (typeof field) -[clos]-> hasher_result env.unify(exposed_hash_fn_var, this_hash_fn_var); - // Hash.hash : hasher, (typeof field) -[clos]-> hasher | hasher has Hasher, (typeof field) implements Hash + // Hash.hash : hasher, (typeof field) -[clos]-> hasher | hasher implements Hasher, (typeof field) implements Hash let hash_fn_head = Expr::AbilityMember(member, None, this_hash_fn_var); let hash_fn_data = Box::new(( this_hash_fn_var, diff --git a/crates/compiler/load_internal/src/docs.rs b/crates/compiler/load_internal/src/docs.rs index f74667f936..55db7563b3 100644 --- a/crates/compiler/load_internal/src/docs.rs +++ b/crates/compiler/load_internal/src/docs.rs @@ -450,7 +450,7 @@ fn contains_unexposed_type( false } Where(loc_ann, _loc_has_clauses) => { - // We assume all the abilities in the `has` clause are from exported modules. + // We assume all the abilities in the `implements` clause are from exported modules. // TODO don't assume this! Instead, look them up and verify. contains_unexposed_type(&loc_ann.value, exposed_module_ids, module_ids) } diff --git a/crates/compiler/load_internal/src/file.rs b/crates/compiler/load_internal/src/file.rs index 0f3814687b..9bb8965993 100644 --- a/crates/compiler/load_internal/src/file.rs +++ b/crates/compiler/load_internal/src/file.rs @@ -3172,7 +3172,7 @@ fn update<'a>( // # Default module // interface Default exposes [default, getDefault] // - // Default has default : {} -> a | a implements Default + // Default implements default : {} -> a | a implements Default // // getDefault = \{} -> default {} // From 58a84fdc29b0aa3206d6f5ed46ace77db496bbaf Mon Sep 17 00:00:00 2001 From: Bryce Miller Date: Fri, 26 May 2023 20:37:42 -0400 Subject: [PATCH 031/176] has -> implements in tests --- crates/compiler/test_derive/src/decoding.rs | 12 +++---- crates/compiler/test_derive/src/encoding.rs | 38 ++++++++++----------- crates/compiler/test_derive/src/hash.rs | 24 ++++++------- 3 files changed, 37 insertions(+), 37 deletions(-) diff --git a/crates/compiler/test_derive/src/decoding.rs b/crates/compiler/test_derive/src/decoding.rs index de6695380a..d77a3b396f 100644 --- a/crates/compiler/test_derive/src/decoding.rs +++ b/crates/compiler/test_derive/src/decoding.rs @@ -106,8 +106,8 @@ fn list() { derive_test(Decoder, v!(Symbol::LIST_LIST v!(STR)), |golden| { assert_snapshot!(golden, @r###" # derived for List Str - # Decoder (List val) fmt | fmt has DecoderFormatting, val implements Decoding - # List U8, fmt -[[custom(3)]]-> { rest : List U8, result : [Err [TooShort], Ok (List val)] } | fmt has DecoderFormatting, val implements Decoding + # Decoder (List val) fmt | fmt implements DecoderFormatting, val implements Decoding + # List U8, fmt -[[custom(3)]]-> { rest : List U8, result : [Err [TooShort], Ok (List val)] } | fmt implements DecoderFormatting, val implements Decoding # Specialization lambda sets: # @<1>: [[custom(3)]] #Derived.decoder_list = @@ -124,8 +124,8 @@ fn record_2_fields() { derive_test(Decoder, v!({first: v!(STR), second: v!(STR),}), |golden| { assert_snapshot!(golden, @r###" # derived for { first : Str, second : Str } - # Decoder { first : val, second : val1 } fmt | fmt has DecoderFormatting, val has Decoding, val1 implements Decoding - # List U8, fmt -[[custom(22)]]-> { rest : List U8, result : [Err [TooShort], Ok { first : val, second : val1 }] } | fmt has DecoderFormatting, val has Decoding, val1 implements Decoding + # Decoder { first : val, second : val1 } fmt | fmt implements DecoderFormatting, val has Decoding, val1 implements Decoding + # List U8, fmt -[[custom(22)]]-> { rest : List U8, result : [Err [TooShort], Ok { first : val, second : val1 }] } | fmt implements DecoderFormatting, val has Decoding, val1 implements Decoding # Specialization lambda sets: # @<1>: [[custom(22)]] #Derived.decoder_{first,second} = @@ -181,8 +181,8 @@ fn tuple_2_fields() { derive_test(Decoder, v!((v!(STR), v!(U8),)), |golden| { assert_snapshot!(golden, @r###" # derived for ( Str, U8 )* - # Decoder ( val, val1 )* fmt | fmt has DecoderFormatting, val has Decoding, val1 implements Decoding - # List U8, fmt -[[custom(22)]]-> { rest : List U8, result : [Err [TooShort], Ok ( val, val1 )a] } | fmt has DecoderFormatting, val has Decoding, val1 implements Decoding + # Decoder ( val, val1 )* fmt | fmt implements DecoderFormatting, val has Decoding, val1 implements Decoding + # List U8, fmt -[[custom(22)]]-> { rest : List U8, result : [Err [TooShort], Ok ( val, val1 )a] } | fmt implements DecoderFormatting, val has Decoding, val1 implements Decoding # Specialization lambda sets: # @<1>: [[custom(22)]] #Derived.decoder_(arity:2) = diff --git a/crates/compiler/test_derive/src/encoding.rs b/crates/compiler/test_derive/src/encoding.rs index b726cd5930..1bf376ec25 100644 --- a/crates/compiler/test_derive/src/encoding.rs +++ b/crates/compiler/test_derive/src/encoding.rs @@ -228,8 +228,8 @@ fn one_field_record() { derive_test(ToEncoder, v!({ a: v!(U8), }), |golden| { assert_snapshot!(golden, @r###" # derived for { a : U8 } - # { a : val } -[[toEncoder_{a}(0)]]-> Encoder fmt | fmt has EncoderFormatting, val implements Encoding - # { a : val } -[[toEncoder_{a}(0)]]-> (List U8, fmt -[[custom(2) { a : val }]]-> List U8) | fmt has EncoderFormatting, val implements Encoding + # { a : val } -[[toEncoder_{a}(0)]]-> Encoder fmt | fmt implements EncoderFormatting, val implements Encoding + # { a : val } -[[toEncoder_{a}(0)]]-> (List U8, fmt -[[custom(2) { a : val }]]-> List U8) | fmt implements EncoderFormatting, val implements Encoding # Specialization lambda sets: # @<1>: [[toEncoder_{a}(0)]] # @<2>: [[custom(2) { a : val }]] | val implements Encoding @@ -251,11 +251,11 @@ fn two_field_record() { derive_test(ToEncoder, v!({ a: v!(U8), b: v!(STR), }), |golden| { assert_snapshot!(golden, @r###" # derived for { a : U8, b : Str } - # { a : val, b : val1 } -[[toEncoder_{a,b}(0)]]-> Encoder fmt | fmt has EncoderFormatting, val has Encoding, val1 implements Encoding - # { a : val, b : val1 } -[[toEncoder_{a,b}(0)]]-> (List U8, fmt -[[custom(2) { a : val, b : val1 }]]-> List U8) | fmt has EncoderFormatting, val has Encoding, val1 implements Encoding + # { a : val, b : val1 } -[[toEncoder_{a,b}(0)]]-> Encoder fmt | fmt implements EncoderFormatting, val has Encoding, val1 implements Encoding + # { a : val, b : val1 } -[[toEncoder_{a,b}(0)]]-> (List U8, fmt -[[custom(2) { a : val, b : val1 }]]-> List U8) | fmt implements EncoderFormatting, val has Encoding, val1 implements Encoding # Specialization lambda sets: # @<1>: [[toEncoder_{a,b}(0)]] - # @<2>: [[custom(2) { a : val, b : val1 }]] | val has Encoding, val1 implements Encoding + # @<2>: [[custom(2) { a : val, b : val1 }]] | val implements Encoding, val1 implements Encoding #Derived.toEncoder_{a,b} = \#Derived.rcd -> custom @@ -278,11 +278,11 @@ fn two_field_tuple() { derive_test(ToEncoder, v!((v!(U8), v!(STR),)), |golden| { assert_snapshot!(golden, @r###" # derived for ( U8, Str )* - # ( val, val1 )* -[[toEncoder_(arity:2)(0)]]-> Encoder fmt | fmt has EncoderFormatting, val has Encoding, val1 implements Encoding - # ( val, val1 )a -[[toEncoder_(arity:2)(0)]]-> (List U8, fmt -[[custom(2) ( val, val1 )a]]-> List U8) | fmt has EncoderFormatting, val has Encoding, val1 implements Encoding + # ( val, val1 )* -[[toEncoder_(arity:2)(0)]]-> Encoder fmt | fmt implements EncoderFormatting, val has Encoding, val1 implements Encoding + # ( val, val1 )a -[[toEncoder_(arity:2)(0)]]-> (List U8, fmt -[[custom(2) ( val, val1 )a]]-> List U8) | fmt implements EncoderFormatting, val has Encoding, val1 implements Encoding # Specialization lambda sets: # @<1>: [[toEncoder_(arity:2)(0)]] - # @<2>: [[custom(2) ( val, val1 )*]] | val has Encoding, val1 implements Encoding + # @<2>: [[custom(2) ( val, val1 )*]] | val implements Encoding, val1 implements Encoding #Derived.toEncoder_(arity:2) = \#Derived.tup -> custom @@ -338,11 +338,11 @@ fn tag_one_label_two_args() { derive_test(ToEncoder, v!([A v!(U8) v!(STR)]), |golden| { assert_snapshot!(golden, @r###" # derived for [A U8 Str] - # [A val val1] -[[toEncoder_[A 2](0)]]-> Encoder fmt | fmt has EncoderFormatting, val has Encoding, val1 implements Encoding - # [A val val1] -[[toEncoder_[A 2](0)]]-> (List U8, fmt -[[custom(4) [A val val1]]]-> List U8) | fmt has EncoderFormatting, val has Encoding, val1 implements Encoding + # [A val val1] -[[toEncoder_[A 2](0)]]-> Encoder fmt | fmt implements EncoderFormatting, val has Encoding, val1 implements Encoding + # [A val val1] -[[toEncoder_[A 2](0)]]-> (List U8, fmt -[[custom(4) [A val val1]]]-> List U8) | fmt implements EncoderFormatting, val has Encoding, val1 implements Encoding # Specialization lambda sets: # @<1>: [[toEncoder_[A 2](0)]] - # @<2>: [[custom(4) [A val val1]]] | val has Encoding, val1 implements Encoding + # @<2>: [[custom(4) [A val val1]]] | val implements Encoding, val1 implements Encoding #Derived.toEncoder_[A 2] = \#Derived.tag -> custom @@ -366,11 +366,11 @@ fn tag_two_labels() { |golden| { assert_snapshot!(golden, @r###" # derived for [A U8 Str U16, B Str] - # [A val val1 val1, B val1] -[[toEncoder_[A 3,B 1](0)]]-> Encoder fmt | fmt has EncoderFormatting, val has Encoding, val1 implements Encoding - # [A val val1 val1, B val1] -[[toEncoder_[A 3,B 1](0)]]-> (List U8, fmt -[[custom(6) [A val val1 val1, B val1]]]-> List U8) | fmt has EncoderFormatting, val has Encoding, val1 implements Encoding + # [A val val1 val1, B val1] -[[toEncoder_[A 3,B 1](0)]]-> Encoder fmt | fmt implements EncoderFormatting, val has Encoding, val1 implements Encoding + # [A val val1 val1, B val1] -[[toEncoder_[A 3,B 1](0)]]-> (List U8, fmt -[[custom(6) [A val val1 val1, B val1]]]-> List U8) | fmt implements EncoderFormatting, val has Encoding, val1 implements Encoding # Specialization lambda sets: # @<1>: [[toEncoder_[A 3,B 1](0)]] - # @<2>: [[custom(6) [A val val1 val1, B val1]]] | val has Encoding, val1 implements Encoding + # @<2>: [[custom(6) [A val val1 val1, B val1]]] | val implements Encoding, val1 implements Encoding #Derived.toEncoder_[A 3,B 1] = \#Derived.tag -> custom @@ -402,11 +402,11 @@ fn recursive_tag_union() { |golden| { assert_snapshot!(golden, @r###" # derived for [Cons U8 $rec, Nil] as $rec - # [Cons val val1, Nil] -[[toEncoder_[Cons 2,Nil 0](0)]]-> Encoder fmt | fmt has EncoderFormatting, val has Encoding, val1 implements Encoding - # [Cons val val1, Nil] -[[toEncoder_[Cons 2,Nil 0](0)]]-> (List U8, fmt -[[custom(4) [Cons val val1, Nil]]]-> List U8) | fmt has EncoderFormatting, val has Encoding, val1 implements Encoding + # [Cons val val1, Nil] -[[toEncoder_[Cons 2,Nil 0](0)]]-> Encoder fmt | fmt implements EncoderFormatting, val has Encoding, val1 implements Encoding + # [Cons val val1, Nil] -[[toEncoder_[Cons 2,Nil 0](0)]]-> (List U8, fmt -[[custom(4) [Cons val val1, Nil]]]-> List U8) | fmt implements EncoderFormatting, val has Encoding, val1 implements Encoding # Specialization lambda sets: # @<1>: [[toEncoder_[Cons 2,Nil 0](0)]] - # @<2>: [[custom(4) [Cons val val1, Nil]]] | val has Encoding, val1 implements Encoding + # @<2>: [[custom(4) [Cons val val1, Nil]]] | val implements Encoding, val1 implements Encoding #Derived.toEncoder_[Cons 2,Nil 0] = \#Derived.tag -> custom @@ -429,8 +429,8 @@ fn list() { derive_test(ToEncoder, v!(Symbol::LIST_LIST v!(STR)), |golden| { assert_snapshot!(golden, @r###" # derived for List Str - # List val -[[toEncoder_list(0)]]-> Encoder fmt | fmt has EncoderFormatting, val implements Encoding - # List val -[[toEncoder_list(0)]]-> (List U8, fmt -[[custom(4) (List val)]]-> List U8) | fmt has EncoderFormatting, val implements Encoding + # List val -[[toEncoder_list(0)]]-> Encoder fmt | fmt implements EncoderFormatting, val implements Encoding + # List val -[[toEncoder_list(0)]]-> (List U8, fmt -[[custom(4) (List val)]]-> List U8) | fmt implements EncoderFormatting, val implements Encoding # Specialization lambda sets: # @<1>: [[toEncoder_list(0)]] # @<2>: [[custom(4) (List val)]] | val implements Encoding diff --git a/crates/compiler/test_derive/src/hash.rs b/crates/compiler/test_derive/src/hash.rs index 669fb37d25..a13fc7187b 100644 --- a/crates/compiler/test_derive/src/hash.rs +++ b/crates/compiler/test_derive/src/hash.rs @@ -181,8 +181,8 @@ fn one_field_record() { derive_test(Hash, v!({ a: v!(U8), }), |golden| { assert_snapshot!(golden, @r###" # derived for { a : U8 } - # hasher, { a : a } -[[hash_{a}(0)]]-> hasher | a has Hash, hasher implements Hasher - # hasher, { a : a } -[[hash_{a}(0)]]-> hasher | a has Hash, hasher implements Hasher + # hasher, { a : a } -[[hash_{a}(0)]]-> hasher | a implements Hash, hasher implements Hasher + # hasher, { a : a } -[[hash_{a}(0)]]-> hasher | a implements Hash, hasher implements Hasher # Specialization lambda sets: # @<1>: [[hash_{a}(0)]] #Derived.hash_{a} = @@ -197,8 +197,8 @@ fn two_field_record() { derive_test(Hash, v!({ a: v!(U8), b: v!(STR), }), |golden| { assert_snapshot!(golden, @r###" # derived for { a : U8, b : Str } - # hasher, { a : a, b : a1 } -[[hash_{a,b}(0)]]-> hasher | a has Hash, a1 has Hash, hasher implements Hasher - # hasher, { a : a, b : a1 } -[[hash_{a,b}(0)]]-> hasher | a has Hash, a1 has Hash, hasher implements Hasher + # hasher, { a : a, b : a1 } -[[hash_{a,b}(0)]]-> hasher | a implements Hash, a1 has Hash, hasher implements Hasher + # hasher, { a : a, b : a1 } -[[hash_{a,b}(0)]]-> hasher | a implements Hash, a1 has Hash, hasher implements Hasher # Specialization lambda sets: # @<1>: [[hash_{a,b}(0)]] #Derived.hash_{a,b} = @@ -214,8 +214,8 @@ fn two_element_tuple() { derive_test(Hash, v!((v!(U8), v!(STR),)), |golden| { assert_snapshot!(golden, @r###" # derived for ( U8, Str )* - # hasher, ( a, a1 )* -[[hash_(arity:2)(0)]]-> hasher | a has Hash, a1 has Hash, hasher implements Hasher - # hasher, ( a, a1 )* -[[hash_(arity:2)(0)]]-> hasher | a has Hash, a1 has Hash, hasher implements Hasher + # hasher, ( a, a1 )* -[[hash_(arity:2)(0)]]-> hasher | a implements Hash, a1 has Hash, hasher implements Hasher + # hasher, ( a, a1 )* -[[hash_(arity:2)(0)]]-> hasher | a implements Hash, a1 has Hash, hasher implements Hasher # Specialization lambda sets: # @<1>: [[hash_(arity:2)(0)]] #Derived.hash_(arity:2) = @@ -246,8 +246,8 @@ fn tag_one_label_newtype() { derive_test(Hash, v!([A v!(U8) v!(STR)]), |golden| { assert_snapshot!(golden, @r###" # derived for [A U8 Str] - # hasher, [A a a1] -[[hash_[A 2](0)]]-> hasher | a has Hash, a1 has Hash, hasher implements Hasher - # hasher, [A a a1] -[[hash_[A 2](0)]]-> hasher | a has Hash, a1 has Hash, hasher implements Hasher + # hasher, [A a a1] -[[hash_[A 2](0)]]-> hasher | a implements Hash, a1 has Hash, hasher implements Hasher + # hasher, [A a a1] -[[hash_[A 2](0)]]-> hasher | a implements Hash, a1 has Hash, hasher implements Hasher # Specialization lambda sets: # @<1>: [[hash_[A 2](0)]] #Derived.hash_[A 2] = @@ -263,8 +263,8 @@ fn tag_two_labels() { derive_test(Hash, v!([A v!(U8) v!(STR) v!(U16), B v!(STR)]), |golden| { assert_snapshot!(golden, @r###" # derived for [A U8 Str U16, B Str] - # a, [A a1 a2 a3, B a3] -[[hash_[A 3,B 1](0)]]-> a | a has Hasher, a1 has Hash, a2 has Hash, a3 implements Hash - # a, [A a1 a2 a3, B a3] -[[hash_[A 3,B 1](0)]]-> a | a has Hasher, a1 has Hash, a2 has Hash, a3 implements Hash + # a, [A a1 a2 a3, B a3] -[[hash_[A 3,B 1](0)]]-> a | a implements Hasher, a1 has Hash, a2 has Hash, a3 implements Hash + # a, [A a1 a2 a3, B a3] -[[hash_[A 3,B 1](0)]]-> a | a implements Hasher, a1 has Hash, a2 has Hash, a3 implements Hash # Specialization lambda sets: # @<1>: [[hash_[A 3,B 1](0)]] #Derived.hash_[A 3,B 1] = @@ -304,8 +304,8 @@ fn recursive_tag_union() { derive_test(Hash, v!([Nil, Cons v!(U8) v!(^lst) ] as lst), |golden| { assert_snapshot!(golden, @r###" # derived for [Cons U8 $rec, Nil] as $rec - # a, [Cons a1 a2, Nil] -[[hash_[Cons 2,Nil 0](0)]]-> a | a has Hasher, a1 has Hash, a2 implements Hash - # a, [Cons a1 a2, Nil] -[[hash_[Cons 2,Nil 0](0)]]-> a | a has Hasher, a1 has Hash, a2 implements Hash + # a, [Cons a1 a2, Nil] -[[hash_[Cons 2,Nil 0](0)]]-> a | a implements Hasher, a1 has Hash, a2 implements Hash + # a, [Cons a1 a2, Nil] -[[hash_[Cons 2,Nil 0](0)]]-> a | a implements Hasher, a1 has Hash, a2 implements Hash # Specialization lambda sets: # @<1>: [[hash_[Cons 2,Nil 0](0)]] #Derived.hash_[Cons 2,Nil 0] = From c68807bc5aedb91dd846928d1e73c4884ad65844 Mon Sep 17 00:00:00 2001 From: Bryce Miller Date: Fri, 26 May 2023 20:39:01 -0400 Subject: [PATCH 032/176] has -> implements in roc code --- ...use_multiple_has_across_newlines.expr.formatted.roc | 2 +- crates/compiler/uitest/tests/ability/smoke/decoder.txt | 4 ++-- crates/compiler/uitest/tests/ability/smoke/encoder.txt | 4 ++-- .../polymorphic_lambda_set_specialization.txt | 2 +- ...ymorphic_lambda_set_specialization_bound_output.txt | 2 +- ...t_specialization_branching_over_single_variable.txt | 4 ++-- ..._specialization_varying_over_multiple_variables.txt | 10 +++++----- ...ion_varying_over_multiple_variables_two_results.txt | 10 +++++----- ...ialization_with_deep_specialization_and_capture.txt | 2 +- ...hic_lambda_set_specialization_with_let_weakened.txt | 2 +- ..._set_specialization_with_let_weakened_unapplied.txt | 2 +- examples/cli/cli-platform/File.roc | 4 ++-- examples/python-interop/platform/main.roc | 2 +- examples/ruby-interop/platform/main.roc | 2 +- 14 files changed, 26 insertions(+), 26 deletions(-) diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_multiple_has_across_newlines.expr.formatted.roc b/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_multiple_has_across_newlines.expr.formatted.roc index 1e2868883e..0ebb9de5a0 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_multiple_has_across_newlines.expr.formatted.roc +++ b/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_multiple_has_across_newlines.expr.formatted.roc @@ -1,3 +1,3 @@ -f : a -> (b -> c) | a has Hash, b has Eq, c implements Ord +f : a -> (b -> c) | a implements Hash, b has Eq, c implements Ord f \ No newline at end of file diff --git a/crates/compiler/uitest/tests/ability/smoke/decoder.txt b/crates/compiler/uitest/tests/ability/smoke/decoder.txt index 987ba16734..77546828dd 100644 --- a/crates/compiler/uitest/tests/ability/smoke/decoder.txt +++ b/crates/compiler/uitest/tests/ability/smoke/decoder.txt @@ -5,7 +5,7 @@ MDecodeError : [TooShort, Leftover (List U8)] MDecoder val fmt := List U8, fmt -> { result: Result val MDecodeError, rest: List U8 } | fmt implements MDecoderFormatting MDecoding has - decoder : MDecoder val fmt | val has MDecoding, fmt implements MDecoderFormatting + decoder : MDecoder val fmt | val implements MDecoding, fmt implements MDecoderFormatting MDecoderFormatting has u8 : MDecoder U8 fmt | fmt implements MDecoderFormatting @@ -14,7 +14,7 @@ decodeWith : List U8, MDecoder val fmt, fmt -> { result: Result val MDecodeError decodeWith = \lst, (@MDecoder doDecode), fmt -> doDecode lst fmt fromBytes : List U8, fmt -> Result val MDecodeError - | fmt has MDecoderFormatting, val implements MDecoding + | fmt implements MDecoderFormatting, val implements MDecoding fromBytes = \lst, fmt -> when decodeWith lst decoder fmt is { result, rest } -> diff --git a/crates/compiler/uitest/tests/ability/smoke/encoder.txt b/crates/compiler/uitest/tests/ability/smoke/encoder.txt index a4a74c6822..f22517fb13 100644 --- a/crates/compiler/uitest/tests/ability/smoke/encoder.txt +++ b/crates/compiler/uitest/tests/ability/smoke/encoder.txt @@ -3,7 +3,7 @@ app "test" provides [myU8Bytes] to "./platform" MEncoder fmt := List U8, fmt -> List U8 | fmt implements Format MEncoding has - toEncoder : val -> MEncoder fmt | val has MEncoding, fmt implements Format + toEncoder : val -> MEncoder fmt | val implements MEncoding, fmt implements Format Format has u8 : U8 -> MEncoder fmt | fmt implements Format @@ -11,7 +11,7 @@ Format has appendWith : List U8, MEncoder fmt, fmt -> List U8 | fmt implements Format appendWith = \lst, (@MEncoder doFormat), fmt -> doFormat lst fmt -toBytes : val, fmt -> List U8 | val has MEncoding, fmt implements Format +toBytes : val, fmt -> List U8 | val implements MEncoding, fmt implements Format toBytes = \val, fmt -> appendWith [] (toEncoder val) fmt diff --git a/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization.txt b/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization.txt index dfe79b44ae..333219f2a8 100644 --- a/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization.txt +++ b/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization.txt @@ -1,6 +1,6 @@ app "test" provides [main] to "./platform" -F has f : a -> (b -> {}) | a has F, b implements G +F has f : a -> (b -> {}) | a implements F, b implements G G has g : b -> {} | b implements G Fo := {} implements [F {f}] diff --git a/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_bound_output.txt b/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_bound_output.txt index 45a01d058d..ed7cc865d3 100644 --- a/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_bound_output.txt +++ b/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_bound_output.txt @@ -1,6 +1,6 @@ app "test" provides [main] to "./platform" -F has f : a -> ({} -> b) | a has F, b implements G +F has f : a -> ({} -> b) | a implements F, b implements G G has g : {} -> b | b implements G Fo := {} implements [F {f}] diff --git a/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_branching_over_single_variable.txt b/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_branching_over_single_variable.txt index 8b7e092a80..951c75103c 100644 --- a/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_branching_over_single_variable.txt +++ b/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_branching_over_single_variable.txt @@ -1,6 +1,6 @@ app "test" provides [f] to "./platform" -J has j : j -> (k -> {}) | j has J, k implements K +J has j : j -> (k -> {}) | j implements J, k implements K K has k : k -> {} | k implements K C := {} implements [J {j: jC}] @@ -19,4 +19,4 @@ f = \flag, a, c -> B -> j a it c # ^ k | k implements K -# ^^ k -[[] + j:j(2):2]-> {} | j has J, k implements K +# ^^ k -[[] + j:j(2):2]-> {} | j implements J, k implements K diff --git a/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_varying_over_multiple_variables.txt b/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_varying_over_multiple_variables.txt index 0209cfbdb0..323d607f77 100644 --- a/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_varying_over_multiple_variables.txt +++ b/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_varying_over_multiple_variables.txt @@ -1,6 +1,6 @@ app "test" provides [main] to "./platform" -J has j : j -> (k -> {}) | j has J, k implements K +J has j : j -> (k -> {}) | j implements J, k implements K K has k : k -> {} | k implements K C := {} implements [J {j: jC}] @@ -19,14 +19,14 @@ f = \flag, a, b -> # ^ j | j implements J # ^ j | j implements J it = -# ^^ k -[[] + j:j(2):2 + j1:j(2):2]-> {} | j has J, j1 has J, k implements K +# ^^ k -[[] + j:j(2):2 + j1:j(2):2]-> {} | j implements J, j1 has J, k implements K when flag is A -> j a - # ^ J#j(2): j -[[] + j:j(2):1]-> (k -[[] + j:j(2):2 + j1:j(2):2]-> {}) | j has J, j1 has J, k implements K + # ^ J#j(2): j -[[] + j:j(2):1]-> (k -[[] + j:j(2):2 + j1:j(2):2]-> {}) | j implements J, j1 has J, k implements K B -> j b - # ^ J#j(2): j -[[] + j:j(2):1]-> (k -[[] + j1:j(2):2 + j:j(2):2]-> {}) | j has J, j1 has J, k implements K + # ^ J#j(2): j -[[] + j:j(2):1]-> (k -[[] + j1:j(2):2 + j:j(2):2]-> {}) | j implements J, j1 has J, k implements K it -# ^^ k -[[] + j:j(2):2 + j1:j(2):2]-> {} | j has J, j1 has J, k implements K +# ^^ k -[[] + j:j(2):2 + j1:j(2):2]-> {} | j implements J, j1 has J, k implements K main = (f A (@C {}) (@D {})) (@E {}) # ^ [A, B], C, D -[[f(11)]]-> (E -[[k(10)]]-> {}) diff --git a/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_varying_over_multiple_variables_two_results.txt b/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_varying_over_multiple_variables_two_results.txt index 4a1dd5f38a..a6f436e4b1 100644 --- a/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_varying_over_multiple_variables_two_results.txt +++ b/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_varying_over_multiple_variables_two_results.txt @@ -1,6 +1,6 @@ app "test" provides [main] to "./platform" -J has j : j -> (k -> {}) | j has J, k implements K +J has j : j -> (k -> {}) | j implements J, k implements K K has k : k -> {} | k implements K C := {} implements [J {j: jC}] @@ -23,14 +23,14 @@ f = \flag, a, b -> # ^ j | j implements J # ^ j | j implements J it = -# ^^ k -[[] + j:j(2):2 + j1:j(2):2]-> {} | j has J, j1 has J, k implements K +# ^^ k -[[] + j:j(2):2 + j1:j(2):2]-> {} | j implements J, j1 has J, k implements K when flag is A -> j a - # ^ J#j(2): j -[[] + j:j(2):1]-> (k -[[] + j:j(2):2 + j1:j(2):2]-> {}) | j has J, j1 has J, k implements K + # ^ J#j(2): j -[[] + j:j(2):1]-> (k -[[] + j:j(2):2 + j1:j(2):2]-> {}) | j implements J, j1 has J, k implements K B -> j b - # ^ J#j(2): j -[[] + j:j(2):1]-> (k -[[] + j1:j(2):2 + j:j(2):2]-> {}) | j has J, j1 has J, k implements K + # ^ J#j(2): j -[[] + j:j(2):1]-> (k -[[] + j1:j(2):2 + j:j(2):2]-> {}) | j implements J, j1 has J, k implements K it -# ^^ k -[[] + j:j(2):2 + j1:j(2):2]-> {} | j has J, j1 has J, k implements K +# ^^ k -[[] + j:j(2):2 + j1:j(2):2]-> {} | j implements J, j1 has J, k implements K main = #^^^^{-1} {} diff --git a/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_with_deep_specialization_and_capture.txt b/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_with_deep_specialization_and_capture.txt index 3c155d1173..6c83ef6b6a 100644 --- a/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_with_deep_specialization_and_capture.txt +++ b/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_with_deep_specialization_and_capture.txt @@ -1,6 +1,6 @@ app "test" provides [main] to "./platform" -F has f : a, b -> ({} -> ({} -> {})) | a has F, b implements G +F has f : a, b -> ({} -> ({} -> {})) | a implements F, b implements G G has g : b -> ({} -> {}) | b implements G Fo := {} implements [F {f}] diff --git a/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_with_let_weakened.txt b/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_with_let_weakened.txt index 8f3d9427b9..618d29dcc3 100644 --- a/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_with_let_weakened.txt +++ b/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_with_let_weakened.txt @@ -1,6 +1,6 @@ app "test" provides [main] to "./platform" -F has f : a -> (b -> {}) | a has F, b implements G +F has f : a -> (b -> {}) | a implements F, b implements G G has g : b -> {} | b implements G Fo := {} implements [F {f}] diff --git a/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_with_let_weakened_unapplied.txt b/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_with_let_weakened_unapplied.txt index 6a159a5e62..71dc02b2cc 100644 --- a/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_with_let_weakened_unapplied.txt +++ b/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_with_let_weakened_unapplied.txt @@ -1,6 +1,6 @@ app "test" provides [main] to "./platform" -F has f : a -> (b -> {}) | a has F, b implements G +F has f : a -> (b -> {}) | a implements F, b implements G G has g : b -> {} | b implements G Fo := {} implements [F {f}] diff --git a/examples/cli/cli-platform/File.roc b/examples/cli/cli-platform/File.roc index 9d91c6d7c8..97d8841792 100644 --- a/examples/cli/cli-platform/File.roc +++ b/examples/cli/cli-platform/File.roc @@ -26,7 +26,7 @@ WriteErr : InternalFile.WriteErr ## This opens the file first and closes it after writing to it. ## ## To write unformatted bytes to a file, you can use [File.writeBytes] instead. -write : Path, val, fmt -> Task {} [FileWriteErr Path WriteErr] | val has Encode.Encoding, fmt implements Encode.EncoderFormatting +write : Path, val, fmt -> Task {} [FileWriteErr Path WriteErr] | val implements Encode.Encoding, fmt implements Encode.EncoderFormatting write = \path, val, fmt -> bytes = Encode.toBytes val fmt @@ -119,7 +119,7 @@ readUtf8 = \path -> # Str # [FileReadErr Path ReadErr, FileReadDecodeErr Path [Leftover (List U8)]Decode.DecodeError ] # [Read [File]] -# | val has Decode.Decoding, fmt implements Decode.DecoderFormatting +# | val implements Decode.Decoding, fmt implements Decode.DecoderFormatting # read = \path, fmt -> # effect = Effect.map (Effect.fileReadBytes (InternalPath.toBytes path)) \result -> # when result is diff --git a/examples/python-interop/platform/main.roc b/examples/python-interop/platform/main.roc index 3d9f16bbb2..949cbe8dd2 100644 --- a/examples/python-interop/platform/main.roc +++ b/examples/python-interop/platform/main.roc @@ -1,5 +1,5 @@ platform "python-interop" - requires {} { main : arg -> ret | arg has Decoding, ret implements Encoding } + requires {} { main : arg -> ret | arg implements Decoding, ret implements Encoding } exposes [] packages {} imports [Json] diff --git a/examples/ruby-interop/platform/main.roc b/examples/ruby-interop/platform/main.roc index 07c6284f42..1cae530d89 100644 --- a/examples/ruby-interop/platform/main.roc +++ b/examples/ruby-interop/platform/main.roc @@ -1,5 +1,5 @@ platform "ruby-interop" - requires {} { main : arg -> ret | arg has Decoding, ret implements Encoding } + requires {} { main : arg -> ret | arg implements Decoding, ret implements Encoding } exposes [] packages {} imports [Json] From d3f6277ea31bb73811372aa1551081577178c5e0 Mon Sep 17 00:00:00 2001 From: Bryce Miller Date: Fri, 26 May 2023 22:59:11 -0400 Subject: [PATCH 033/176] has -> implements in comments --- crates/compiler/can/src/abilities.rs | 8 ++++---- crates/compiler/can/src/annotation.rs | 4 ++-- crates/compiler/can/src/def.rs | 4 ++-- crates/compiler/can/src/scope.rs | 2 +- crates/compiler/can/src/traverse.rs | 2 +- crates/compiler/types/src/subs.rs | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/crates/compiler/can/src/abilities.rs b/crates/compiler/can/src/abilities.rs index 4766b7eb7d..7f77c01bba 100644 --- a/crates/compiler/can/src/abilities.rs +++ b/crates/compiler/can/src/abilities.rs @@ -80,7 +80,7 @@ impl AbilityMemberData { /// Solved lambda sets for an ability member specialization. For example, if we have /// -/// Default has default : {} -[[] + a:default:1]-> a | a implements Default +/// Default implements default : {} -[[] + a:default:1]-> a | a implements Default /// /// A := {} /// default = \{} -[[closA]]-> @A {} @@ -144,7 +144,7 @@ pub struct IAbilitiesStore { /// /// For example, in the program /// - /// Hash has hash : a -> U64 | a implements Hash + /// Hash implements hash : a -> U64 | a implements Hash /// /// Id := {} implements [Hash {hash: myHash}] /// myHash = \@Id n -> n @@ -155,7 +155,7 @@ pub struct IAbilitiesStore { /// Information about all members composing abilities. ability_members: MutMap>, - /// Maps a tuple (member, type) specifying that `type` has an implementation of an ability + /// Maps a tuple (member, type) specifying that `type` implements an ability /// member `member`, to how that implementation is defined. declared_implementations: MutMap, @@ -414,7 +414,7 @@ impl IAbilitiesStore { } /// Returns an iterator over pairs ((ability member, type), implementation) specifying that - /// the give type has an implementation of an ability member. + /// the give type implements an ability member. pub fn iter_declared_implementations( &self, ) -> impl Iterator + '_ { diff --git a/crates/compiler/can/src/annotation.rs b/crates/compiler/can/src/annotation.rs index 7906ccb5e6..61e53000c2 100644 --- a/crates/compiler/can/src/annotation.rs +++ b/crates/compiler/can/src/annotation.rs @@ -122,7 +122,7 @@ pub struct NamedVariable { pub first_seen: Region, } -/// A type variable bound to an ability, like "a has Hash". +/// A type variable bound to an ability, like "a implements Hash". #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)] pub struct AbleVariable { pub variable: Variable, @@ -1040,7 +1040,7 @@ fn can_annotation_help( Where(_annotation, clauses) => { debug_assert!(!clauses.is_empty()); - // Has clauses are allowed only on the top level of a signature, which we handle elsewhere. + // Implements clauses are allowed only on the top level of a signature, which we handle elsewhere. env.problem(roc_problem::can::Problem::IllegalImplementsClause { region: Region::across_all(clauses.iter().map(|clause| &clause.region)), }); diff --git a/crates/compiler/can/src/def.rs b/crates/compiler/can/src/def.rs index 94719ade9e..3bd138657f 100644 --- a/crates/compiler/can/src/def.rs +++ b/crates/compiler/can/src/def.rs @@ -510,7 +510,7 @@ fn canonicalize_claimed_ability_impl<'a>( // definition symbol, for example when the ability is defined in the same // module as an implementer: // - // Eq has eq : a, a -> U64 | a implements Eq + // Eq implements eq : a, a -> U64 | a implements Eq // // A := U8 implements [Eq {eq}] // @@ -1398,7 +1398,7 @@ fn resolve_abilities( } [..] => { // There is more than one variable bound to the member signature, so something like - // Eq has eq : a, b -> Bool | a implements Eq, b implements Eq + // Eq implements eq : a, b -> Bool | a implements Eq, b implements Eq // We have no way of telling what type implements a particular instance of Eq in // this case (a or b?), so disallow it. let span_has_clauses = Region::across_all( diff --git a/crates/compiler/can/src/scope.rs b/crates/compiler/can/src/scope.rs index 9c2cf0aa75..678714999b 100644 --- a/crates/compiler/can/src/scope.rs +++ b/crates/compiler/can/src/scope.rs @@ -33,7 +33,7 @@ pub struct Scope { imports: Vec<(Ident, Symbol, Region)>, /// Shadows of an ability member, for example a local specialization of `eq` for the ability - /// member `Eq has eq : a, a -> Bool | a implements Eq` gets a shadow symbol it can use for its + /// member `Eq implements eq : a, a -> Bool | a implements Eq` gets a shadow symbol it can use for its /// implementation. /// /// Only one shadow of an ability member is permitted per scope. diff --git a/crates/compiler/can/src/traverse.rs b/crates/compiler/can/src/traverse.rs index c22096ea72..cbd0c43938 100644 --- a/crates/compiler/can/src/traverse.rs +++ b/crates/compiler/can/src/traverse.rs @@ -674,7 +674,7 @@ pub enum FoundSymbol { Symbol(Symbol), } -/// Given an ability Foo has foo : ..., returns (T, foo1) if the symbol at the given region is a +/// Given an ability Foo implements foo : ..., returns (T, foo1) if the symbol at the given region is a /// symbol foo1 that specializes foo for T. Otherwise if the symbol is foo but the specialization /// is unknown, (Foo, foo) is returned. Otherwise [None] is returned. pub fn find_symbol_at( diff --git a/crates/compiler/types/src/subs.rs b/crates/compiler/types/src/subs.rs index f244faa0f5..20ef7655f4 100644 --- a/crates/compiler/types/src/subs.rs +++ b/crates/compiler/types/src/subs.rs @@ -2359,7 +2359,7 @@ pub enum Content { /// This can only happen when unified with a [Self::RigidAbleVar]. FlexAbleVar(Option>, SubsSlice), /// Like a [Self::RigidVar], but is also bound to 1+ abilities. - /// For example, "a has Hash". + /// For example, "a implements Hash". RigidAbleVar(SubsIndex, SubsSlice), /// name given to a recursion variable RecursionVar { From d2503bb9f255e5d5ae710a6dc586d454fe6a4840 Mon Sep 17 00:00:00 2001 From: Bryce Miller Date: Fri, 26 May 2023 22:59:29 -0400 Subject: [PATCH 034/176] has -> implements --- crates/compiler/fmt/src/def.rs | 2 +- crates/compiler/test_derive/src/decoding.rs | 10 ++++----- crates/compiler/test_derive/src/encoding.rs | 24 ++++++++++----------- crates/compiler/test_derive/src/hash.rs | 24 ++++++++++----------- crates/compiler/test_derive/src/util.rs | 2 +- crates/compiler/types/src/pretty_print.rs | 2 +- crates/compiler/types/src/types.rs | 2 +- 7 files changed, 33 insertions(+), 33 deletions(-) diff --git a/crates/compiler/fmt/src/def.rs b/crates/compiler/fmt/src/def.rs index b2066f5ffe..ab53f9adda 100644 --- a/crates/compiler/fmt/src/def.rs +++ b/crates/compiler/fmt/src/def.rs @@ -134,7 +134,7 @@ impl<'a> Formattable for TypeDef<'a> { buf.indent(indent); } - buf.push_str(" has"); + buf.push_str(" implements"); if !self.is_multiline() { debug_assert_eq!(members.len(), 1); diff --git a/crates/compiler/test_derive/src/decoding.rs b/crates/compiler/test_derive/src/decoding.rs index d77a3b396f..b9c024ec66 100644 --- a/crates/compiler/test_derive/src/decoding.rs +++ b/crates/compiler/test_derive/src/decoding.rs @@ -87,7 +87,7 @@ fn derivable_record_ext_flex_var() { fn derivable_record_ext_flex_able_var() { check_derivable( Decoder, - v!({ a: v!(STR), }a has Symbol::DECODE_DECODER ), + v!({ a: v!(STR), }a implements Symbol::DECODE_DECODER ), DeriveKey::Decoder(FlatDecodableKey::Record(vec!["a".into()])), ); } @@ -124,8 +124,8 @@ fn record_2_fields() { derive_test(Decoder, v!({first: v!(STR), second: v!(STR),}), |golden| { assert_snapshot!(golden, @r###" # derived for { first : Str, second : Str } - # Decoder { first : val, second : val1 } fmt | fmt implements DecoderFormatting, val has Decoding, val1 implements Decoding - # List U8, fmt -[[custom(22)]]-> { rest : List U8, result : [Err [TooShort], Ok { first : val, second : val1 }] } | fmt implements DecoderFormatting, val has Decoding, val1 implements Decoding + # Decoder { first : val, second : val1 } fmt | fmt implements DecoderFormatting, val implements Decoding, val1 implements Decoding + # List U8, fmt -[[custom(22)]]-> { rest : List U8, result : [Err [TooShort], Ok { first : val, second : val1 }] } | fmt implements DecoderFormatting, val implements Decoding, val1 implements Decoding # Specialization lambda sets: # @<1>: [[custom(22)]] #Derived.decoder_{first,second} = @@ -181,8 +181,8 @@ fn tuple_2_fields() { derive_test(Decoder, v!((v!(STR), v!(U8),)), |golden| { assert_snapshot!(golden, @r###" # derived for ( Str, U8 )* - # Decoder ( val, val1 )* fmt | fmt implements DecoderFormatting, val has Decoding, val1 implements Decoding - # List U8, fmt -[[custom(22)]]-> { rest : List U8, result : [Err [TooShort], Ok ( val, val1 )a] } | fmt implements DecoderFormatting, val has Decoding, val1 implements Decoding + # Decoder ( val, val1 )* fmt | fmt implements DecoderFormatting, val implements Decoding, val1 implements Decoding + # List U8, fmt -[[custom(22)]]-> { rest : List U8, result : [Err [TooShort], Ok ( val, val1 )a] } | fmt implements DecoderFormatting, val implements Decoding, val1 implements Decoding # Specialization lambda sets: # @<1>: [[custom(22)]] #Derived.decoder_(arity:2) = diff --git a/crates/compiler/test_derive/src/encoding.rs b/crates/compiler/test_derive/src/encoding.rs index 1bf376ec25..481ab8ff7a 100644 --- a/crates/compiler/test_derive/src/encoding.rs +++ b/crates/compiler/test_derive/src/encoding.rs @@ -139,7 +139,7 @@ fn derivable_record_ext_flex_var() { fn derivable_record_ext_flex_able_var() { check_derivable( ToEncoder, - v!({ a: v!(STR), }a has Symbol::ENCODE_TO_ENCODER), + v!({ a: v!(STR), }a implements Symbol::ENCODE_TO_ENCODER), DeriveKey::ToEncoder(FlatEncodableKey::Record(vec!["a".into()])), ); } @@ -166,7 +166,7 @@ fn derivable_tag_ext_flex_var() { fn derivable_tag_ext_flex_able_var() { check_derivable( ToEncoder, - v!([ A v!(STR) ]a has Symbol::ENCODE_TO_ENCODER), + v!([ A v!(STR) ]a implements Symbol::ENCODE_TO_ENCODER), DeriveKey::ToEncoder(FlatEncodableKey::TagUnion(vec![("A".into(), 1)])), ); } @@ -251,8 +251,8 @@ fn two_field_record() { derive_test(ToEncoder, v!({ a: v!(U8), b: v!(STR), }), |golden| { assert_snapshot!(golden, @r###" # derived for { a : U8, b : Str } - # { a : val, b : val1 } -[[toEncoder_{a,b}(0)]]-> Encoder fmt | fmt implements EncoderFormatting, val has Encoding, val1 implements Encoding - # { a : val, b : val1 } -[[toEncoder_{a,b}(0)]]-> (List U8, fmt -[[custom(2) { a : val, b : val1 }]]-> List U8) | fmt implements EncoderFormatting, val has Encoding, val1 implements Encoding + # { a : val, b : val1 } -[[toEncoder_{a,b}(0)]]-> Encoder fmt | fmt implements EncoderFormatting, val implements Encoding, val1 implements Encoding + # { a : val, b : val1 } -[[toEncoder_{a,b}(0)]]-> (List U8, fmt -[[custom(2) { a : val, b : val1 }]]-> List U8) | fmt implements EncoderFormatting, val implements Encoding, val1 implements Encoding # Specialization lambda sets: # @<1>: [[toEncoder_{a,b}(0)]] # @<2>: [[custom(2) { a : val, b : val1 }]] | val implements Encoding, val1 implements Encoding @@ -278,8 +278,8 @@ fn two_field_tuple() { derive_test(ToEncoder, v!((v!(U8), v!(STR),)), |golden| { assert_snapshot!(golden, @r###" # derived for ( U8, Str )* - # ( val, val1 )* -[[toEncoder_(arity:2)(0)]]-> Encoder fmt | fmt implements EncoderFormatting, val has Encoding, val1 implements Encoding - # ( val, val1 )a -[[toEncoder_(arity:2)(0)]]-> (List U8, fmt -[[custom(2) ( val, val1 )a]]-> List U8) | fmt implements EncoderFormatting, val has Encoding, val1 implements Encoding + # ( val, val1 )* -[[toEncoder_(arity:2)(0)]]-> Encoder fmt | fmt implements EncoderFormatting, val implements Encoding, val1 implements Encoding + # ( val, val1 )a -[[toEncoder_(arity:2)(0)]]-> (List U8, fmt -[[custom(2) ( val, val1 )a]]-> List U8) | fmt implements EncoderFormatting, val implements Encoding, val1 implements Encoding # Specialization lambda sets: # @<1>: [[toEncoder_(arity:2)(0)]] # @<2>: [[custom(2) ( val, val1 )*]] | val implements Encoding, val1 implements Encoding @@ -338,8 +338,8 @@ fn tag_one_label_two_args() { derive_test(ToEncoder, v!([A v!(U8) v!(STR)]), |golden| { assert_snapshot!(golden, @r###" # derived for [A U8 Str] - # [A val val1] -[[toEncoder_[A 2](0)]]-> Encoder fmt | fmt implements EncoderFormatting, val has Encoding, val1 implements Encoding - # [A val val1] -[[toEncoder_[A 2](0)]]-> (List U8, fmt -[[custom(4) [A val val1]]]-> List U8) | fmt implements EncoderFormatting, val has Encoding, val1 implements Encoding + # [A val val1] -[[toEncoder_[A 2](0)]]-> Encoder fmt | fmt implements EncoderFormatting, val implements Encoding, val1 implements Encoding + # [A val val1] -[[toEncoder_[A 2](0)]]-> (List U8, fmt -[[custom(4) [A val val1]]]-> List U8) | fmt implements EncoderFormatting, val implements Encoding, val1 implements Encoding # Specialization lambda sets: # @<1>: [[toEncoder_[A 2](0)]] # @<2>: [[custom(4) [A val val1]]] | val implements Encoding, val1 implements Encoding @@ -366,8 +366,8 @@ fn tag_two_labels() { |golden| { assert_snapshot!(golden, @r###" # derived for [A U8 Str U16, B Str] - # [A val val1 val1, B val1] -[[toEncoder_[A 3,B 1](0)]]-> Encoder fmt | fmt implements EncoderFormatting, val has Encoding, val1 implements Encoding - # [A val val1 val1, B val1] -[[toEncoder_[A 3,B 1](0)]]-> (List U8, fmt -[[custom(6) [A val val1 val1, B val1]]]-> List U8) | fmt implements EncoderFormatting, val has Encoding, val1 implements Encoding + # [A val val1 val1, B val1] -[[toEncoder_[A 3,B 1](0)]]-> Encoder fmt | fmt implements EncoderFormatting, val implements Encoding, val1 implements Encoding + # [A val val1 val1, B val1] -[[toEncoder_[A 3,B 1](0)]]-> (List U8, fmt -[[custom(6) [A val val1 val1, B val1]]]-> List U8) | fmt implements EncoderFormatting, val implements Encoding, val1 implements Encoding # Specialization lambda sets: # @<1>: [[toEncoder_[A 3,B 1](0)]] # @<2>: [[custom(6) [A val val1 val1, B val1]]] | val implements Encoding, val1 implements Encoding @@ -402,8 +402,8 @@ fn recursive_tag_union() { |golden| { assert_snapshot!(golden, @r###" # derived for [Cons U8 $rec, Nil] as $rec - # [Cons val val1, Nil] -[[toEncoder_[Cons 2,Nil 0](0)]]-> Encoder fmt | fmt implements EncoderFormatting, val has Encoding, val1 implements Encoding - # [Cons val val1, Nil] -[[toEncoder_[Cons 2,Nil 0](0)]]-> (List U8, fmt -[[custom(4) [Cons val val1, Nil]]]-> List U8) | fmt implements EncoderFormatting, val has Encoding, val1 implements Encoding + # [Cons val val1, Nil] -[[toEncoder_[Cons 2,Nil 0](0)]]-> Encoder fmt | fmt implements EncoderFormatting, val implements Encoding, val1 implements Encoding + # [Cons val val1, Nil] -[[toEncoder_[Cons 2,Nil 0](0)]]-> (List U8, fmt -[[custom(4) [Cons val val1, Nil]]]-> List U8) | fmt implements EncoderFormatting, val implements Encoding, val1 implements Encoding # Specialization lambda sets: # @<1>: [[toEncoder_[Cons 2,Nil 0](0)]] # @<2>: [[custom(4) [Cons val val1, Nil]]] | val implements Encoding, val1 implements Encoding diff --git a/crates/compiler/test_derive/src/hash.rs b/crates/compiler/test_derive/src/hash.rs index a13fc7187b..1d645d5d8a 100644 --- a/crates/compiler/test_derive/src/hash.rs +++ b/crates/compiler/test_derive/src/hash.rs @@ -102,7 +102,7 @@ fn derivable_record_ext_flex_var() { fn derivable_record_ext_flex_able_var() { check_derivable( Hash, - v!({ a: v!(STR), }a has Symbol::DECODE_DECODER ), + v!({ a: v!(STR), }a implements Symbol::DECODE_DECODER ), DeriveKey::Hash(FlatHashKey::Record(vec!["a".into()])), ); } @@ -129,7 +129,7 @@ fn derivable_tag_ext_flex_var() { fn derivable_tag_ext_flex_able_var() { check_derivable( Hash, - v!([ A v!(STR) ]a has Symbol::ENCODE_TO_ENCODER), + v!([ A v!(STR) ]a implements Symbol::ENCODE_TO_ENCODER), DeriveKey::Hash(FlatHashKey::TagUnion(vec![("A".into(), 1)])), ); } @@ -197,8 +197,8 @@ fn two_field_record() { derive_test(Hash, v!({ a: v!(U8), b: v!(STR), }), |golden| { assert_snapshot!(golden, @r###" # derived for { a : U8, b : Str } - # hasher, { a : a, b : a1 } -[[hash_{a,b}(0)]]-> hasher | a implements Hash, a1 has Hash, hasher implements Hasher - # hasher, { a : a, b : a1 } -[[hash_{a,b}(0)]]-> hasher | a implements Hash, a1 has Hash, hasher implements Hasher + # hasher, { a : a, b : a1 } -[[hash_{a,b}(0)]]-> hasher | a implements Hash, a1 implements Hash, hasher implements Hasher + # hasher, { a : a, b : a1 } -[[hash_{a,b}(0)]]-> hasher | a implements Hash, a1 implements Hash, hasher implements Hasher # Specialization lambda sets: # @<1>: [[hash_{a,b}(0)]] #Derived.hash_{a,b} = @@ -214,8 +214,8 @@ fn two_element_tuple() { derive_test(Hash, v!((v!(U8), v!(STR),)), |golden| { assert_snapshot!(golden, @r###" # derived for ( U8, Str )* - # hasher, ( a, a1 )* -[[hash_(arity:2)(0)]]-> hasher | a implements Hash, a1 has Hash, hasher implements Hasher - # hasher, ( a, a1 )* -[[hash_(arity:2)(0)]]-> hasher | a implements Hash, a1 has Hash, hasher implements Hasher + # hasher, ( a, a1 )* -[[hash_(arity:2)(0)]]-> hasher | a implements Hash, a1 implements Hash, hasher implements Hasher + # hasher, ( a, a1 )* -[[hash_(arity:2)(0)]]-> hasher | a implements Hash, a1 implements Hash, hasher implements Hasher # Specialization lambda sets: # @<1>: [[hash_(arity:2)(0)]] #Derived.hash_(arity:2) = @@ -246,8 +246,8 @@ fn tag_one_label_newtype() { derive_test(Hash, v!([A v!(U8) v!(STR)]), |golden| { assert_snapshot!(golden, @r###" # derived for [A U8 Str] - # hasher, [A a a1] -[[hash_[A 2](0)]]-> hasher | a implements Hash, a1 has Hash, hasher implements Hasher - # hasher, [A a a1] -[[hash_[A 2](0)]]-> hasher | a implements Hash, a1 has Hash, hasher implements Hasher + # hasher, [A a a1] -[[hash_[A 2](0)]]-> hasher | a implements Hash, a1 implements Hash, hasher implements Hasher + # hasher, [A a a1] -[[hash_[A 2](0)]]-> hasher | a implements Hash, a1 implements Hash, hasher implements Hasher # Specialization lambda sets: # @<1>: [[hash_[A 2](0)]] #Derived.hash_[A 2] = @@ -263,8 +263,8 @@ fn tag_two_labels() { derive_test(Hash, v!([A v!(U8) v!(STR) v!(U16), B v!(STR)]), |golden| { assert_snapshot!(golden, @r###" # derived for [A U8 Str U16, B Str] - # a, [A a1 a2 a3, B a3] -[[hash_[A 3,B 1](0)]]-> a | a implements Hasher, a1 has Hash, a2 has Hash, a3 implements Hash - # a, [A a1 a2 a3, B a3] -[[hash_[A 3,B 1](0)]]-> a | a implements Hasher, a1 has Hash, a2 has Hash, a3 implements Hash + # a, [A a1 a2 a3, B a3] -[[hash_[A 3,B 1](0)]]-> a | a implements Hasher, a1 implements Hash, a2 implements Hash, a3 implements Hash + # a, [A a1 a2 a3, B a3] -[[hash_[A 3,B 1](0)]]-> a | a implements Hasher, a1 implements Hash, a2 implements Hash, a3 implements Hash # Specialization lambda sets: # @<1>: [[hash_[A 3,B 1](0)]] #Derived.hash_[A 3,B 1] = @@ -304,8 +304,8 @@ fn recursive_tag_union() { derive_test(Hash, v!([Nil, Cons v!(U8) v!(^lst) ] as lst), |golden| { assert_snapshot!(golden, @r###" # derived for [Cons U8 $rec, Nil] as $rec - # a, [Cons a1 a2, Nil] -[[hash_[Cons 2,Nil 0](0)]]-> a | a implements Hasher, a1 has Hash, a2 implements Hash - # a, [Cons a1 a2, Nil] -[[hash_[Cons 2,Nil 0](0)]]-> a | a implements Hasher, a1 has Hash, a2 implements Hash + # a, [Cons a1 a2, Nil] -[[hash_[Cons 2,Nil 0](0)]]-> a | a implements Hasher, a1 implements Hash, a2 implements Hash + # a, [Cons a1 a2, Nil] -[[hash_[Cons 2,Nil 0](0)]]-> a | a implements Hasher, a1 implements Hash, a2 implements Hash # Specialization lambda sets: # @<1>: [[hash_[Cons 2,Nil 0](0)]] #Derived.hash_[Cons 2,Nil 0] = diff --git a/crates/compiler/test_derive/src/util.rs b/crates/compiler/test_derive/src/util.rs index 566d433c9c..5e5edd4c44 100644 --- a/crates/compiler/test_derive/src/util.rs +++ b/crates/compiler/test_derive/src/util.rs @@ -182,7 +182,7 @@ macro_rules! v { use roc_types::subs::{Subs, Content}; |subs: &mut Subs| { roc_derive::synth_var(subs, Content::FlexVar(None)) } }}; - ($name:ident has $ability:path) => {{ + ($name:ident implements $ability:path) => {{ use roc_types::subs::{Subs, SubsIndex, SubsSlice, Content}; |subs: &mut Subs| { let name_index = diff --git a/crates/compiler/types/src/pretty_print.rs b/crates/compiler/types/src/pretty_print.rs index 8e6d41d031..b5bf03f4a2 100644 --- a/crates/compiler/types/src/pretty_print.rs +++ b/crates/compiler/types/src/pretty_print.rs @@ -604,7 +604,7 @@ fn variable_to_string( for (i, (var, abilities)) in ctx.able_variables.into_iter().enumerate() { buf.push_str(if i == 0 { " | " } else { ", " }); buf.push_str(var); - buf.push_str(" has"); + buf.push_str(" implements"); for (i, ability) in abilities.into_sorted_iter().enumerate() { if i > 0 { buf.push_str(" &"); diff --git a/crates/compiler/types/src/types.rs b/crates/compiler/types/src/types.rs index 8d668e8207..ded26f9819 100644 --- a/crates/compiler/types/src/types.rs +++ b/crates/compiler/types/src/types.rs @@ -4005,7 +4005,7 @@ fn write_debug_error_type_help(error_type: ErrorType, buf: &mut String, parens: buf.push('('); } buf.push_str(name.as_str()); - write!(buf, "has {:?}", symbol).unwrap(); + write!(buf, "implements {:?}", symbol).unwrap(); if write_parens { buf.push(')'); } From 76c54c2e7af08bf3cbc26e923f10bd67aa74eba9 Mon Sep 17 00:00:00 2001 From: Bryce Miller Date: Fri, 26 May 2023 23:09:22 -0400 Subject: [PATCH 035/176] `loc_has_parser` -> `loc_implements_parser` --- crates/compiler/parse/src/expr.rs | 4 ++-- crates/compiler/parse/src/pattern.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/compiler/parse/src/expr.rs b/crates/compiler/parse/src/expr.rs index 2e787bdc34..9d93de6b31 100644 --- a/crates/compiler/parse/src/expr.rs +++ b/crates/compiler/parse/src/expr.rs @@ -15,7 +15,7 @@ use crate::parser::{ word2, EClosure, EExpect, EExpr, EIf, EInParens, EList, ENumber, EPattern, ERecord, EString, EType, EWhen, Either, ParseResult, Parser, }; -use crate::pattern::{closure_param, loc_has_parser}; +use crate::pattern::{closure_param, loc_implements_parser}; use crate::state::State; use crate::string_literal::StrLikeLiteral; use crate::type_annotation; @@ -618,7 +618,7 @@ pub fn parse_single_def<'a>( if let Some((name, name_region, args)) = opt_tag_and_args { if let Ok((_, loc_has, state)) = - loc_has_parser().parse(arena, state.clone(), min_indent) + loc_implements_parser().parse(arena, state.clone(), min_indent) { let (_, (type_def, def_region), state) = finish_parsing_ability_def_help( min_indent, diff --git a/crates/compiler/parse/src/pattern.rs b/crates/compiler/parse/src/pattern.rs index 96c3b3c720..e279f37c63 100644 --- a/crates/compiler/parse/src/pattern.rs +++ b/crates/compiler/parse/src/pattern.rs @@ -154,7 +154,7 @@ fn loc_tag_pattern_arg<'a>( } } -pub fn loc_has_parser<'a>() -> impl Parser<'a, Loc>, EPattern<'a>> { +pub fn loc_implements_parser<'a>() -> impl Parser<'a, Loc>, EPattern<'a>> { then( loc_tag_pattern_arg(false), |_arena, state, progress, pattern| { From edf969809e826741961fc3d9bb5851e1e0f030c8 Mon Sep 17 00:00:00 2001 From: Bryce Miller Date: Fri, 26 May 2023 23:14:30 -0400 Subject: [PATCH 036/176] `alias_in_has_clause` -> `alias_in_implements_clause` --- crates/reporting/tests/test_reporting.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/reporting/tests/test_reporting.rs b/crates/reporting/tests/test_reporting.rs index a983adc8bc..7816cc8195 100644 --- a/crates/reporting/tests/test_reporting.rs +++ b/crates/reporting/tests/test_reporting.rs @@ -8444,7 +8444,7 @@ In roc, functions are always written as a lambda, like{} ); test_report!( - alias_in_has_clause, + alias_in_implements_clause, indoc!( r#" app "test" provides [hash] to "./platform" From 76551375b9bbc6493c2035c99f774ef96dd666b5 Mon Sep 17 00:00:00 2001 From: Bryce Miller Date: Fri, 26 May 2023 23:25:21 -0400 Subject: [PATCH 037/176] has -> implements in fn names --- crates/compiler/test_syntax/tests/test_fmt.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/compiler/test_syntax/tests/test_fmt.rs b/crates/compiler/test_syntax/tests/test_fmt.rs index 8d092432bf..4725aac92c 100644 --- a/crates/compiler/test_syntax/tests/test_fmt.rs +++ b/crates/compiler/test_syntax/tests/test_fmt.rs @@ -5425,7 +5425,7 @@ mod test_fmt { } #[test] - fn opaque_has_clause() { + fn opaque_implements_clause() { expr_formats_same(indoc!( r#" A := U8 implements [Eq, Hash] @@ -5522,7 +5522,7 @@ mod test_fmt { } #[test] - fn opaque_has_with_impls() { + fn opaque_implements_with_impls() { expr_formats_same(indoc!( r#" A := U8 implements [Eq { eq }, Hash { hash }] From 9640fcb6d4d390bce313f9631001897de175e248 Mon Sep 17 00:00:00 2001 From: Bryce Miller Date: Sun, 28 May 2023 13:07:48 -0400 Subject: [PATCH 038/176] Fix reporting tests --- crates/reporting/tests/test_reporting.rs | 103 ++++++++++++----------- 1 file changed, 54 insertions(+), 49 deletions(-) diff --git a/crates/reporting/tests/test_reporting.rs b/crates/reporting/tests/test_reporting.rs index 7816cc8195..6b3e7cd079 100644 --- a/crates/reporting/tests/test_reporting.rs +++ b/crates/reporting/tests/test_reporting.rs @@ -8278,7 +8278,7 @@ In roc, functions are always written as a lambda, like{} ability_non_signature_expression, indoc!( r#" - MEq implememts + MEq implements 123 1 @@ -8453,12 +8453,12 @@ In roc, functions are always written as a lambda, like{} "# ), @r###" - ── IMPLEMENTS CLAUSE IS NOT AN ABILITY ──────────────────── /code/proj/Main.roc ─ + ── IMPLEMENTS CLAUSE IS NOT AN ABILITY ─────────────────── /code/proj/Main.roc ─ - The type referenced in this "implememts" clause is not an ability: + The type referenced in this "implements" clause is not an ability: - 3│ MHash has hash : a, b -> Num.U64 | a implements MHash, b implements Bool.Bool - ^^^^^^^^^ + 3│ MHash implements hash : a, b -> Num.U64 | a implements MHash, b implements Bool.Bool + ^^^^^^^^^ "### ); @@ -8530,14 +8530,14 @@ In roc, functions are always written as a lambda, like{} @r#" ── ABILITY MEMBER MISSING IMPLEMENTS CLAUSE ────────────── /code/proj/Main.roc ─ - The definition of the ability member `ab` does not include an `implements` clause - binding a type variable to the ability `Ability`: + The definition of the ability member `ab` does not include an `implements` + clause binding a type variable to the ability `Ability`: 3│ Ability implements ab : {} -> {} ^^ - Ability members must include an `implements` clause binding a type variable to - an ability, like + Ability members must include an `implements` clause binding a type + variable to an ability, like a implements Ability @@ -8600,18 +8600,19 @@ In roc, functions are always written as a lambda, like{} 3│ MHash implements hash : (a | a implements MHash) -> Num.U64 ^^^^^^^^^^^^^^^^^^ - `implements` clauses can only be specified on the top-level type annotations. + `implements` clauses can only be specified on the top-level type + annotations. ── ABILITY MEMBER MISSING IMPLEMENTS CLAUSE ────────────── /code/proj/Main.roc ─ - The definition of the ability member `hash` does not include an `implements` - clause binding a type variable to the ability `MHash`: + The definition of the ability member `hash` does not include an + `implements` clause binding a type variable to the ability `MHash`: 3│ MHash implements hash : (a | a implements MHash) -> Num.U64 ^^^^ - Ability members must include an `implements` clause binding a type variable to - an ability, like + Ability members must include an `implements` clause binding a type + variable to an ability, like a implements MHash @@ -8963,8 +8964,8 @@ In roc, functions are always written as a lambda, like{} a | a implements MHash - Note: The type variable `a` says it can take on any value that implements the - ability `MHash`. + Note: The type variable `a` says it can take on any value that + implements the ability `MHash`. But, I see that the type is only ever used as a a `Id` value. Can you replace `a` with a more specific type? @@ -9153,7 +9154,7 @@ In roc, functions are always written as a lambda, like{} r#" app "test" provides [main] to "./platform" - Default has default : {} -> a | a implements Default + Default implements default : {} -> a | a implements Default main = A := {} implements [Default {default}] @@ -9361,7 +9362,7 @@ In roc, functions are always written as a lambda, like{} cannot be generated. Tip: `A` does not implement `Encoding`. Consider adding a custom - implementation or `has Encode.Encoding` to the definition of `A`. + implementation or `implements Encode.Encoding` to the definition of `A`. "### ); @@ -9404,7 +9405,7 @@ In roc, functions are always written as a lambda, like{} r#" app "test" provides [A] to "./platform" - MEq has eq : a, a -> U64 | a implements MEq + MEq implements eq : a, a -> U64 | a implements MEq A := U8 implements [MEq {eq}] "# @@ -9440,7 +9441,7 @@ In roc, functions are always written as a lambda, like{} r#" app "test" provides [A, myMEq] to "./platform" - MEq has eq : a, a -> Bool | a implements MEq + MEq implements eq : a, a -> Bool | a implements MEq A := U8 implements [ MEq {eq: aMEq} ] @@ -9481,7 +9482,7 @@ In roc, functions are always written as a lambda, like{} r#" app "test" provides [A, myMEq] to "./platform" - MEq has eq : a, a -> Bool | a implements MEq + MEq implements eq : a, a -> Bool | a implements MEq A := U8 implements [ MEq {eq ? aMEq} ] @@ -9537,8 +9538,8 @@ In roc, functions are always written as a lambda, like{} Custom implementations must be supplied fully. Hint: if you want this implementation to be derived, don't include a - record of implementations. For example, implements [Encoding] will attempt - to derive `Encoding` + record of implementations. For example, implements [Encoding] will + attempt to derive `Encoding` ── INCOMPLETE ABILITY IMPLEMENTATION ───────────────────── /code/proj/Main.roc ─ @@ -9559,7 +9560,7 @@ In roc, functions are always written as a lambda, like{} r#" app "test" provides [A] to "./platform" - MEq has eq : a, a -> Bool | a implements MEq + MEq implements eq : a, a -> Bool | a implements MEq A := U8 implements [ MEq {eq : Bool.eq} ] "# @@ -9594,7 +9595,7 @@ In roc, functions are always written as a lambda, like{} r#" app "test" provides [A] to "./platform" - MEq has eq : a, a -> Bool | a implements MEq + MEq implements eq : a, a -> Bool | a implements MEq A := U8 implements [ MEq {eq : \m, n -> m == n} ] "# @@ -9631,7 +9632,7 @@ In roc, functions are always written as a lambda, like{} r#" app "test" provides [A] to "./platform" - MEq has eq : a, a -> Bool | a implements MEq + MEq implements eq : a, a -> Bool | a implements MEq A := U8 implements [ MEq {eq: eqA, eq: eqA} ] @@ -9684,7 +9685,7 @@ In roc, functions are always written as a lambda, like{} r#" app "test" provides [A] to "./platform" - Ab has ab : a -> a | a implements Ab + Ab implements ab : a -> a | a implements Ab A := {} implements [Ab] "# @@ -9746,7 +9747,7 @@ In roc, functions are always written as a lambda, like{} ^^^^^^^^^^^^^^^ Tip: `B` does not implement `Encoding`. Consider adding a custom - implementation or `has Encode.Encoding` to the definition of `B`. + implementation or `implements Encode.Encoding` to the definition of `B`. Tip: You can define a custom implementation of `Encoding` for `A`. "### @@ -9945,7 +9946,7 @@ In roc, functions are always written as a lambda, like{} r#" app "test" provides [x] to "./platform" - Foo has foo : a -> a | a implements Foo + Foo implements foo : a -> a | a implements Foo F a b := b | a implements Foo @@ -10475,7 +10476,7 @@ I recommend using camelCase. It's the standard style in Roc code! r#" app "test" provides [hash, Id] to "./platform" - MHash has hash : a -> U64 | a implements MHash + MHash implements hash : a -> U64 | a implements MHash Id := {} @@ -10618,9 +10619,10 @@ I recommend using camelCase. It's the standard style in Roc code! ^^^^^^^^^^^^^^^ Tip: `B` does not implement `Decoding`. Consider adding a custom - implementation or `has Decode.Decoding` to the definition of `B`. + implementation or `implements Decode.Decoding` to the definition of `B`. Tip: You can define a custom implementation of `Decoding` for `A`. + "### ); @@ -10713,7 +10715,7 @@ I recommend using camelCase. It's the standard style in Roc code! cannot be generated. Tip: `A` does not implement `Decoding`. Consider adding a custom - implementation or `has Decode.Decoding` to the definition of `A`. + implementation or `implements Decode.Decoding` to the definition of `A`. "### ); @@ -11282,9 +11284,10 @@ I recommend using camelCase. It's the standard style in Roc code! ^^^^ Tip: `B` does not implement `Hash`. Consider adding a custom - implementation or `has Hash.Hash` to the definition of `B`. + implementation or `implements Hash.Hash` to the definition of `B`. Tip: You can define a custom implementation of `Hash` for `A`. + "### ); @@ -11667,9 +11670,10 @@ I recommend using camelCase. It's the standard style in Roc code! ^^ Tip: `B` does not implement `Eq`. Consider adding a custom implementation - or `has Bool.Eq` to the definition of `B`. + or `implements Bool.Eq` to the definition of `B`. Tip: You can define a custom implementation of `Eq` for `A`. + "### ); @@ -12047,7 +12051,8 @@ I recommend using camelCase. It's the standard style in Roc code! 4│ f : a -> {} | a implements Hash & Hash ^^^^ - Abilities only need to bound to a type variable once in an `implements` clause! + Abilities only need to bound to a type variable once in an `implements` + clause! "### ); @@ -12079,12 +12084,12 @@ I recommend using camelCase. It's the standard style in Roc code! x | x implements Encoding & Decoding - Note: The type variable `x` says it can take on any value that has only - the ability `Encoding`. + Note: The type variable `x` says it can take on any value that + implements only the ability `Encoding`. - But, I see that it's also used as if it implements the ability `Decoding`. Can - you use `x` without that ability? If not, consider adding it to the `implements` - clause of `x`. + But, I see that it's also used as if it implements the ability + `Decoding`. Can you use `x` without that ability? If not, consider adding + it to the `implements` clause of `x`. "### ); @@ -12116,11 +12121,11 @@ I recommend using camelCase. It's the standard style in Roc code! x | x implements Hash & Encoding & Decoding - Note: The type variable `x` says it can take on any value that implements only - the ability `Encoding`. + Note: The type variable `x` says it can take on any value that + implements only the ability `Encoding`. - But, I see that it's also used as if it implements the abilities `Hash` and - `Decoding`. Can you use `x` without those abilities? If not, consider + But, I see that it's also used as if it implements the abilities `Hash` + and `Decoding`. Can you use `x` without those abilities? If not, consider adding them to the `implements` clause of `x`. "### ); @@ -12154,12 +12159,12 @@ I recommend using camelCase. It's the standard style in Roc code! x | x implements Encoding & Decoding - Note: The type variable `x` says it can take on any value that implements only - the abilities `Hash` and `Encoding`. + Note: The type variable `x` says it can take on any value that + implements only the abilities `Hash` and `Encoding`. - But, I see that it's also used as if it implements the ability `Decoding`. Can - you use `x` without that ability? If not, consider adding it to the `implements` - clause of `x`. + But, I see that it's also used as if it implements the ability + `Decoding`. Can you use `x` without that ability? If not, consider adding + it to the `implements` clause of `x`. "### ); From e514d0cb8398b413c111cb2003338f667506b764 Mon Sep 17 00:00:00 2001 From: Bryce Miller Date: Mon, 29 May 2023 07:21:27 -0400 Subject: [PATCH 039/176] Define and use IMPLEMENTS const in roc_parse::keyword --- Cargo.lock | 1 + crates/compiler/fmt/src/annotation.rs | 4 ++-- crates/compiler/fmt/src/def.rs | 4 ++-- crates/compiler/parse/src/expr.rs | 2 +- crates/compiler/parse/src/keyword.rs | 5 +++++ crates/compiler/parse/src/pattern.rs | 7 +++++-- crates/compiler/parse/src/type_annotation.rs | 6 +++--- crates/compiler/types/Cargo.toml | 1 + crates/compiler/types/src/pretty_print.rs | 3 ++- crates/compiler/types/src/types.rs | 2 +- crates/reporting/src/error/canonicalize.rs | 18 +++++++++--------- crates/reporting/src/error/type.rs | 10 +++++----- 12 files changed, 37 insertions(+), 26 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f93741602b..05a7a9cc41 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4014,6 +4014,7 @@ dependencies = [ "roc_debug_flags", "roc_error_macros", "roc_module", + "roc_parse", "roc_region", "roc_serialize", "static_assertions", diff --git a/crates/compiler/fmt/src/annotation.rs b/crates/compiler/fmt/src/annotation.rs index 02f5f58e10..472ff3ed9c 100644 --- a/crates/compiler/fmt/src/annotation.rs +++ b/crates/compiler/fmt/src/annotation.rs @@ -654,7 +654,7 @@ impl<'a> Formattable for ImplementsClause<'a> { fn format_with_options(&self, buf: &mut Buf, parens: Parens, newlines: Newlines, indent: u16) { buf.push_str(self.var.value.extract_spaces().item); buf.spaces(1); - buf.push_str("implements"); + buf.push_str(roc_parse::keyword::IMPLEMENTS); buf.spaces(1); for (i, ab) in self.abilities.iter().enumerate() { @@ -753,7 +753,7 @@ impl<'a> Formattable for ImplementsAbilities<'a> { buf.newline(); buf.indent(indent); } - buf.push_str("implements"); + buf.push_str(roc_parse::keyword::IMPLEMENTS); buf.spaces(1); fmt_collection(buf, indent, Braces::Square, *has_abilities, Newlines::No); } diff --git a/crates/compiler/fmt/src/def.rs b/crates/compiler/fmt/src/def.rs index ab53f9adda..c71d327d9c 100644 --- a/crates/compiler/fmt/src/def.rs +++ b/crates/compiler/fmt/src/def.rs @@ -133,8 +133,8 @@ impl<'a> Formattable for TypeDef<'a> { fmt_pattern(buf, &var.value, indent, Parens::NotNeeded); buf.indent(indent); } - - buf.push_str(" implements"); + buf.push(' '); + buf.push_str(roc_parse::keyword::IMPLEMENTS); if !self.is_multiline() { debug_assert_eq!(members.len(), 1); diff --git a/crates/compiler/parse/src/expr.rs b/crates/compiler/parse/src/expr.rs index 9d93de6b31..6b279cef38 100644 --- a/crates/compiler/parse/src/expr.rs +++ b/crates/compiler/parse/src/expr.rs @@ -1641,7 +1641,7 @@ fn parse_expr_end<'a>( value: Expr::Var { module_name: "", - ident: "implements", + ident: crate::keyword::IMPLEMENTS, }, .. }, diff --git a/crates/compiler/parse/src/keyword.rs b/crates/compiler/parse/src/keyword.rs index e20ce81870..e37f0c5e5c 100644 --- a/crates/compiler/parse/src/keyword.rs +++ b/crates/compiler/parse/src/keyword.rs @@ -1,3 +1,4 @@ +// These keywords are valid in expressions pub const IF: &str = "if"; pub const THEN: &str = "then"; pub const ELSE: &str = "else"; @@ -9,4 +10,8 @@ pub const EXPECT: &str = "expect"; pub const EXPECT_FX: &str = "expect-fx"; pub const CRASH: &str = "crash"; +// These keywords are valid in types +pub const IMPLEMENTS: &str = "implements"; +pub const WHERE: &str = "where"; + pub const KEYWORDS: [&str; 10] = [IF, THEN, ELSE, WHEN, AS, IS, DBG, EXPECT, EXPECT_FX, CRASH]; diff --git a/crates/compiler/parse/src/pattern.rs b/crates/compiler/parse/src/pattern.rs index e279f37c63..19afb719b9 100644 --- a/crates/compiler/parse/src/pattern.rs +++ b/crates/compiler/parse/src/pattern.rs @@ -138,7 +138,7 @@ fn loc_tag_pattern_arg<'a>( let Loc { region, value } = loc_pat; - if stop_on_has_kw && matches!(value, Pattern::Identifier("implements")) { + if stop_on_has_kw && matches!(value, Pattern::Identifier(crate::keyword::IMPLEMENTS)) { Err((NoProgress, EPattern::End(original_state.pos()))) } else { Ok(( @@ -158,7 +158,10 @@ pub fn loc_implements_parser<'a>() -> impl Parser<'a, Loc>, EPatt then( loc_tag_pattern_arg(false), |_arena, state, progress, pattern| { - if matches!(pattern.value, Pattern::Identifier("implements")) { + if matches!( + pattern.value, + Pattern::Identifier(crate::keyword::IMPLEMENTS) + ) { Ok(( progress, Loc::at(pattern.region, Implements::Implements), diff --git a/crates/compiler/parse/src/type_annotation.rs b/crates/compiler/parse/src/type_annotation.rs index 2de4dbde4b..a0fab6842f 100644 --- a/crates/compiler/parse/src/type_annotation.rs +++ b/crates/compiler/parse/src/type_annotation.rs @@ -459,7 +459,7 @@ fn implements_clause<'a>() -> impl Parser<'a, Loc>, EType<' ), skip_first!( // Parse "implements"; we don't care about this keyword - word("implements", EType::THasClause), + word(crate::keyword::IMPLEMENTS, EType::THasClause), // Parse "Hash & ..."; this may be qualified from another module like "Hash.Hash" absolute_column_min_indent(ability_chain()) ) @@ -512,7 +512,7 @@ fn implements_clause_chain<'a>( pub fn implements_abilities<'a>() -> impl Parser<'a, Loc>, EType<'a>> { increment_min_indent(skip_first!( // Parse "implements"; we don't care about this keyword - word("implements", EType::THasClause), + word(crate::keyword::IMPLEMENTS, EType::THasClause), // Parse "Hash"; this may be qualified from another module like "Hash.Hash" space0_before_e( loc!(map!( @@ -726,7 +726,7 @@ fn parse_type_variable<'a>( min_indent, ) { Ok((_, name, state)) => { - if name == "implements" && stop_at_surface_has { + if name == crate::keyword::IMPLEMENTS && stop_at_surface_has { Err((NoProgress, EType::TEnd(state.pos()))) } else { let answer = TypeAnnotation::BoundVariable(name); diff --git a/crates/compiler/types/Cargo.toml b/crates/compiler/types/Cargo.toml index bb727200ea..535490107e 100644 --- a/crates/compiler/types/Cargo.toml +++ b/crates/compiler/types/Cargo.toml @@ -14,6 +14,7 @@ roc_error_macros = { path = "../../error_macros" } roc_module = { path = "../module" } roc_region = { path = "../region" } roc_serialize = { path = "../serialize" } +roc_parse = { path = "../parse" } ven_pretty = { path = "../../vendor/pretty" } diff --git a/crates/compiler/types/src/pretty_print.rs b/crates/compiler/types/src/pretty_print.rs index b5bf03f4a2..b132a0199e 100644 --- a/crates/compiler/types/src/pretty_print.rs +++ b/crates/compiler/types/src/pretty_print.rs @@ -604,7 +604,8 @@ fn variable_to_string( for (i, (var, abilities)) in ctx.able_variables.into_iter().enumerate() { buf.push_str(if i == 0 { " | " } else { ", " }); buf.push_str(var); - buf.push_str(" implements"); + buf.push(' '); + buf.push_str(roc_parse::keyword::IMPLEMENTS); for (i, ability) in abilities.into_sorted_iter().enumerate() { if i > 0 { buf.push_str(" &"); diff --git a/crates/compiler/types/src/types.rs b/crates/compiler/types/src/types.rs index ded26f9819..efd49d2088 100644 --- a/crates/compiler/types/src/types.rs +++ b/crates/compiler/types/src/types.rs @@ -4005,7 +4005,7 @@ fn write_debug_error_type_help(error_type: ErrorType, buf: &mut String, parens: buf.push('('); } buf.push_str(name.as_str()); - write!(buf, "implements {:?}", symbol).unwrap(); + write!(buf, "{} {:?}", roc_parse::keyword::IMPLEMENTS, symbol).unwrap(); if write_parens { buf.push(')'); } diff --git a/crates/reporting/src/error/canonicalize.rs b/crates/reporting/src/error/canonicalize.rs index a3332a06f2..47f770890e 100644 --- a/crates/reporting/src/error/canonicalize.rs +++ b/crates/reporting/src/error/canonicalize.rs @@ -664,12 +664,12 @@ pub fn can_problem<'b>( doc = alloc.stack([ alloc.concat([ alloc.reflow("An "), - alloc.keyword("implements"), + alloc.keyword(roc_parse::keyword::IMPLEMENTS), alloc.reflow(" clause is not allowed here:"), ]), alloc.region(lines.convert_region(region)), alloc.concat([ - alloc.keyword("implements"), + alloc.keyword(roc_parse::keyword::IMPLEMENTS), alloc.reflow( " clauses can only be specified on the top-level type annotations.", ), @@ -688,7 +688,7 @@ pub fn can_problem<'b>( alloc.region(lines.convert_region(region)), alloc.concat([ alloc.reflow("Abilities only need to bound to a type variable once in an "), - alloc.keyword("implements"), + alloc.keyword(roc_parse::keyword::IMPLEMENTS), alloc.reflow(" clause!"), ]), ]); @@ -705,7 +705,7 @@ pub fn can_problem<'b>( alloc.reflow("The definition of the ability member "), alloc.symbol_unqualified(member), alloc.reflow(" does not include an "), - alloc.keyword("implements"), + alloc.keyword(roc_parse::keyword::IMPLEMENTS), alloc.reflow(" clause binding a type variable to the ability "), alloc.symbol_unqualified(ability), alloc.reflow(":"), @@ -713,13 +713,13 @@ pub fn can_problem<'b>( alloc.region(lines.convert_region(region)), alloc.concat([ alloc.reflow("Ability members must include an "), - alloc.keyword("implements"), + alloc.keyword(roc_parse::keyword::IMPLEMENTS), alloc.reflow(" clause binding a type variable to an ability, like"), ]), alloc.type_block(alloc.concat([ alloc.type_variable("a".into()), alloc.space(), - alloc.keyword("implements"), + alloc.keyword(roc_parse::keyword::IMPLEMENTS), alloc.space(), alloc.symbol_unqualified(ability), ])), @@ -781,12 +781,12 @@ pub fn can_problem<'b>( alloc .hint("") .append(alloc.reflow("Perhaps you meant to include an ")) - .append(alloc.keyword("implements")) + .append(alloc.keyword(roc_parse::keyword::IMPLEMENTS)) .append(alloc.reflow(" annotation, like")), alloc.type_block(alloc.concat([ alloc.type_variable(suggested_var_name), alloc.space(), - alloc.keyword("implements"), + alloc.keyword(roc_parse::keyword::IMPLEMENTS), alloc.space(), alloc.symbol_unqualified(ability), ])), @@ -853,7 +853,7 @@ pub fn can_problem<'b>( let hint = if ability.is_builtin() { alloc.hint("").append( alloc.reflow("if you want this implementation to be derived, don't include a record of implementations. For example,") - .append(alloc.type_block(alloc.concat([alloc.type_str("implements ["), alloc.symbol_unqualified(ability), alloc.type_str("]")]))) + .append(alloc.type_block(alloc.concat([alloc.type_str(roc_parse::keyword::IMPLEMENTS), alloc.type_str(" ["), alloc.symbol_unqualified(ability), alloc.type_str("]")]))) .append(alloc.reflow(" will attempt to derive ").append(alloc.symbol_unqualified(ability)))) } else { alloc.nil() diff --git a/crates/reporting/src/error/type.rs b/crates/reporting/src/error/type.rs index 9647b0208b..2223bbd825 100644 --- a/crates/reporting/src/error/type.rs +++ b/crates/reporting/src/error/type.rs @@ -373,7 +373,7 @@ fn underivable_hint<'b>( alloc.concat([ alloc.reflow(" or "), alloc.inline_type_block(alloc.concat([ - alloc.keyword("implements"), + alloc.keyword(roc_parse::keyword::IMPLEMENTS), alloc.space(), alloc.symbol_qualified(ability), ])), @@ -400,13 +400,13 @@ fn underivable_hint<'b>( alloc.reflow("This type variable is not bound to "), alloc.symbol_unqualified(ability), alloc.reflow(". Consider adding an "), - alloc.keyword("implements"), + alloc.keyword(roc_parse::keyword::IMPLEMENTS), alloc.reflow(" clause to bind the type variable, like "), alloc.inline_type_block(alloc.concat([ alloc.string("| ".to_string()), alloc.type_variable(v.clone()), alloc.space(), - alloc.keyword("implements"), + alloc.keyword(roc_parse::keyword::IMPLEMENTS), alloc.space(), alloc.symbol_qualified(ability), ])), @@ -2758,7 +2758,7 @@ fn type_with_able_vars<'b>( doc.push(alloc.string(if i == 0 { " | " } else { ", " }.to_string())); doc.push(alloc.type_variable(var)); doc.push(alloc.space()); - doc.push(alloc.keyword("implements")); + doc.push(alloc.keyword(roc_parse::keyword::IMPLEMENTS)); for (i, ability) in abilities.into_sorted_iter().enumerate() { if i > 0 { @@ -4532,7 +4532,7 @@ fn type_problem_to_pretty<'b>( alloc.reflow("it") }, alloc.reflow(" to the "), - alloc.keyword("implements"), + alloc.keyword(roc_parse::keyword::IMPLEMENTS), alloc.reflow(" clause of "), alloc.type_variable(name), alloc.reflow("."), From 9e4b14d3d9c79c78a4fc34428f27793745771c21 Mon Sep 17 00:00:00 2001 From: Bryce Miller Date: Mon, 29 May 2023 07:22:50 -0400 Subject: [PATCH 040/176] Fix typo --- crates/compiler/can/src/abilities.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/compiler/can/src/abilities.rs b/crates/compiler/can/src/abilities.rs index 7f77c01bba..26d5643c9a 100644 --- a/crates/compiler/can/src/abilities.rs +++ b/crates/compiler/can/src/abilities.rs @@ -414,7 +414,7 @@ impl IAbilitiesStore { } /// Returns an iterator over pairs ((ability member, type), implementation) specifying that - /// the give type implements an ability member. + /// the given type implements an ability member. pub fn iter_declared_implementations( &self, ) -> impl Iterator + '_ { From 98338f6e2052e8587f91becf689873638d100786 Mon Sep 17 00:00:00 2001 From: Bryce Miller Date: Mon, 29 May 2023 08:35:51 -0400 Subject: [PATCH 041/176] has -> implements --- crates/compiler/builtins/roc/Hash.roc | 2 +- crates/compiler/builtins/roc/Set.roc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/compiler/builtins/roc/Hash.roc b/crates/compiler/builtins/roc/Hash.roc index 25aafdf552..3bbff810d5 100644 --- a/crates/compiler/builtins/roc/Hash.roc +++ b/crates/compiler/builtins/roc/Hash.roc @@ -117,7 +117,7 @@ hashNat = \hasher, n -> i128OfDec : Dec -> I128 ## Adds a single [Dec] to a hasher. -hashDec : a, Dec -> a | a has Hasher +hashDec : a, Dec -> a | a implements Hasher hashDec = \hasher, n -> hashI128 hasher (i128OfDec n) ## Adds a container of [Hash]able elements to a [Hasher] by hashing each element. diff --git a/crates/compiler/builtins/roc/Set.roc b/crates/compiler/builtins/roc/Set.roc index fdbc1f41ed..660243881e 100644 --- a/crates/compiler/builtins/roc/Set.roc +++ b/crates/compiler/builtins/roc/Set.roc @@ -47,7 +47,7 @@ isEq = \xs, ys -> else Break Bool.false -hashSet : hasher, Set k -> hasher | k has Hash & Eq, hasher has Hasher +hashSet : hasher, Set k -> hasher | k implements Hash & Eq, hasher implements Hasher hashSet = \hasher, @Set inner -> Hash.hash hasher inner ## Creates a new empty `Set`. From 35a27daecf5ffd43e6f775b869a40f7f2a9ac554 Mon Sep 17 00:00:00 2001 From: Bryce Miller Date: Tue, 30 May 2023 07:32:29 -0400 Subject: [PATCH 042/176] formatting --- crates/compiler/builtins/roc/Set.roc | 1 - 1 file changed, 1 deletion(-) diff --git a/crates/compiler/builtins/roc/Set.roc b/crates/compiler/builtins/roc/Set.roc index 660243881e..4d08af15bf 100644 --- a/crates/compiler/builtins/roc/Set.roc +++ b/crates/compiler/builtins/roc/Set.roc @@ -23,7 +23,6 @@ interface Set Hash.{ Hash, Hasher }, ] - ## Provides a [set](https://en.wikipedia.org/wiki/Set_(abstract_data_type)) ## type which stores a collection of unique values, without any ordering Set k := Dict.Dict k {} | k implements Hash & Eq From b4aa4a9089b71ed577ef82e3c2831a23cefc5a9e Mon Sep 17 00:00:00 2001 From: Bryce Miller Date: Fri, 2 Jun 2023 07:53:38 -0400 Subject: [PATCH 043/176] Fix syntax derp --- crates/compiler/builtins/roc/Dict.roc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/compiler/builtins/roc/Dict.roc b/crates/compiler/builtins/roc/Dict.roc index e02a2e5263..c5cb986aa4 100644 --- a/crates/compiler/builtins/roc/Dict.roc +++ b/crates/compiler/builtins/roc/Dict.roc @@ -177,7 +177,7 @@ single = \k, v -> ## |> Dict.insert 4 "Four" ## |> Bool.isEq (Dict.fromList [(1, "One"), (2, "Two"), (3, "Three"), (4, "Four")]) ## ``` -fromList : List (k, v) -> Dict k v | k Hash & Eq +fromList : List (k, v) -> Dict k v | k implements Hash & Eq fromList = \data -> # TODO: make this efficient. Should just set data and then set all indicies in the hashmap. List.walk data (empty {}) (\dict, (k, v) -> insert dict k v) @@ -687,7 +687,7 @@ rehash = \@Dict { metadata, dataIndices, data, size } -> rehashHelper newDict metadata dataIndices data 0 -rehashHelper : Dict k v, List I8, List Nat, List (k, v), Nat -> Dict k v | k implements Hash & implements +rehashHelper : Dict k v, List I8, List Nat, List (k, v), Nat -> Dict k v | k implements Hash & Eq rehashHelper = \dict, oldMetadata, oldDataIndices, oldData, index -> when List.get oldMetadata index is Ok md -> From fd846b9a7a05ecaa3d70efd24e52b03bccc18585 Mon Sep 17 00:00:00 2001 From: Bryce Miller Date: Fri, 2 Jun 2023 07:53:52 -0400 Subject: [PATCH 044/176] increase stack size for debug tests --- crates/compiler/test_gen/src/gen_list.rs | 51 ++++++++++++++---------- crates/compiler/test_gen/src/gen_tags.rs | 19 +++++---- 2 files changed, 41 insertions(+), 29 deletions(-) diff --git a/crates/compiler/test_gen/src/gen_list.rs b/crates/compiler/test_gen/src/gen_list.rs index f343ea7830..2e0d767237 100644 --- a/crates/compiler/test_gen/src/gen_list.rs +++ b/crates/compiler/test_gen/src/gen_list.rs @@ -3811,6 +3811,9 @@ fn list_range_length_overflow() { #[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))] mod pattern_match { + #[allow(unused_imports)] + use crate::helpers::with_larger_debug_stack; + #[cfg(feature = "gen-llvm")] use crate::helpers::llvm::assert_evals_to; @@ -3857,8 +3860,9 @@ mod pattern_match { #[test] fn ranged_matches_head() { - assert_evals_to!( - r#" + with_larger_debug_stack(|| { + assert_evals_to!( + r#" helper = \l -> when l is [] -> 1u8 [A] -> 2u8 @@ -3874,21 +3878,23 @@ mod pattern_match { helper [B], helper [B, A], helper [B, B], helper [B, A, B, B], ] "#, - RocList::from_slice(&[ - 1, // - 2, // - 3, 3, 3, 3, // - 4, 4, 4, 4, // - 5, 5, 5, 5, // - ]), - RocList - ) + RocList::from_slice(&[ + 1, // + 2, // + 3, 3, 3, 3, // + 4, 4, 4, 4, // + 5, 5, 5, 5, // + ]), + RocList + ) + }) } #[test] fn ranged_matches_tail() { - assert_evals_to!( - r#" + with_larger_debug_stack(|| { + assert_evals_to!( + r#" helper = \l -> when l is [] -> 1u8 [A] -> 2u8 @@ -3904,15 +3910,16 @@ mod pattern_match { helper [B], helper [A, B], helper [B, B], helper [B, A, B, B], ] "#, - RocList::from_slice(&[ - 1, // - 2, // - 3, 3, 3, 3, // - 4, 4, 4, 4, // - 5, 5, 5, 5, // - ]), - RocList - ) + RocList::from_slice(&[ + 1, // + 2, // + 3, 3, 3, 3, // + 4, 4, 4, 4, // + 5, 5, 5, 5, // + ]), + RocList + ) + }) } #[test] diff --git a/crates/compiler/test_gen/src/gen_tags.rs b/crates/compiler/test_gen/src/gen_tags.rs index bdfef4a93b..970295ca24 100644 --- a/crates/compiler/test_gen/src/gen_tags.rs +++ b/crates/compiler/test_gen/src/gen_tags.rs @@ -1,3 +1,6 @@ +#[allow(unused_imports)] +use crate::helpers::with_larger_debug_stack; + #[cfg(feature = "gen-llvm")] use crate::helpers::llvm::assert_evals_to; @@ -2167,9 +2170,10 @@ fn refcount_nullable_unwrapped_needing_no_refcount_issue_5027() { #[test] #[cfg(any(feature = "gen-llvm"))] fn issue_5162_recast_nested_nullable_unwrapped_layout() { - assert_evals_to!( - indoc!( - r###" + with_larger_debug_stack(|| { + assert_evals_to!( + indoc!( + r###" app "test" provides [main] to "./platform" Concept : [ @@ -2184,10 +2188,11 @@ fn issue_5162_recast_nested_nullable_unwrapped_layout() { when Dict.single bottom 0 is _ -> Bool.true "### - ), - true, - bool - ); + ), + true, + bool + ); + }) } #[test] From cb08225bf0b85b6d6d46c9222d959bdfcbf45fa3 Mon Sep 17 00:00:00 2001 From: Bryce Miller Date: Mon, 5 Jun 2023 20:19:00 -0400 Subject: [PATCH 045/176] `|` -> `where` --- .../cli_testing_examples/benchmarks/AStar.roc | 12 +- crates/compiler/builtins/roc/Bool.roc | 4 +- crates/compiler/builtins/roc/Decode.roc | 48 ++--- crates/compiler/builtins/roc/Dict.roc | 58 +++--- crates/compiler/builtins/roc/Encode.roc | 50 ++--- crates/compiler/builtins/roc/Hash.roc | 32 +-- crates/compiler/builtins/roc/List.roc | 10 +- crates/compiler/builtins/roc/Set.roc | 32 +-- crates/compiler/can/src/abilities.rs | 8 +- crates/compiler/can/src/def.rs | 4 +- crates/compiler/can/src/pattern.rs | 2 +- crates/compiler/can/src/scope.rs | 2 +- crates/compiler/derive/src/decoding.rs | 8 +- crates/compiler/derive/src/decoding/list.rs | 10 +- crates/compiler/derive/src/decoding/record.rs | 2 +- crates/compiler/derive/src/decoding/tuple.rs | 2 +- crates/compiler/derive/src/encoding.rs | 66 +++--- crates/compiler/derive/src/hash.rs | 14 +- crates/compiler/derive/src/util.rs | 2 +- crates/compiler/fmt/src/annotation.rs | 15 +- crates/compiler/fmt/src/def.rs | 2 +- crates/compiler/load_internal/src/file.rs | 2 +- .../build/interface_with_deps/AStar.roc | 12 +- .../compiler/load_internal/tests/test_load.rs | 12 +- crates/compiler/parse/src/ast.rs | 6 +- crates/compiler/parse/src/keyword.rs | 4 +- crates/compiler/parse/src/type_annotation.rs | 23 +- crates/compiler/solve/src/ability.rs | 2 +- crates/compiler/solve/src/solve.rs | 2 +- crates/compiler/solve/tests/solve_expr.rs | 20 +- crates/compiler/test_derive/src/decoding.rs | 12 +- crates/compiler/test_derive/src/encoding.rs | 54 ++--- crates/compiler/test_derive/src/hash.rs | 40 ++-- crates/compiler/test_gen/src/gen_abilities.rs | 46 ++-- crates/compiler/test_gen/src/gen_list.rs | 4 +- crates/compiler/test_gen/src/gen_num.rs | 2 +- crates/compiler/test_mono/src/tests.rs | 18 +- .../ability_demand_value_has_args.expr.roc | 2 +- ...y_demands_not_indented_with_first.expr.roc | 4 +- ..._first_demand_not_indented_enough.expr.roc | 2 +- .../pass/ability_single_line.expr.roc | 2 +- .../pass/ability_two_in_a_row.expr.roc | 4 +- .../opaque_has_abilities.expr.formatted.roc | 6 +- .../pass/opaque_has_abilities.expr.roc | 6 +- .../pass/where_clause_function.expr.roc | 2 +- ...ultiple_bound_abilities.expr.formatted.roc | 4 +- ...e_clause_multiple_bound_abilities.expr.roc | 4 +- .../pass/where_clause_multiple_has.expr.roc | 2 +- ...ple_has_across_newlines.expr.formatted.roc | 2 +- ...ause_multiple_has_across_newlines.expr.roc | 2 +- .../pass/where_clause_non_function.expr.roc | 2 +- ...where_clause_on_newline.expr.formatted.roc | 2 +- .../pass/where_clause_on_newline.expr.roc | 2 +- crates/compiler/test_syntax/tests/test_fmt.rs | 20 +- crates/compiler/types/src/pretty_print.rs | 8 +- crates/compiler/types/src/types.rs | 2 +- .../expand_able_variables_in_type_alias.txt | 4 +- ...bles_bound_to_an_ability_from_type_def.txt | 4 +- ...s_are_superset_of_flex_bounds_admitted.txt | 8 +- ...e_variable_bound_to_ability_issue_4408.txt | 4 +- .../uitest/tests/ability/smoke/decoder.txt | 12 +- .../uitest/tests/ability/smoke/encoder.txt | 12 +- .../tests/ability/specialize/bool_decoder.txt | 2 +- .../tests/ability/specialize/bool_hash.txt | 2 +- .../ability/specialize/bool_to_encoder.txt | 2 +- .../specialize/opaque_decoder_derive.txt | 2 +- .../specialize/opaque_encoder_derive.txt | 2 +- .../ability/specialize/opaque_hash_custom.txt | 2 +- .../ability/specialize/opaque_hash_derive.txt | 2 +- .../polymorphic_lambda_set_specialization.txt | 6 +- ...lambda_set_specialization_bound_output.txt | 6 +- ...ization_branching_over_single_variable.txt | 8 +- ...zation_varying_over_multiple_variables.txt | 20 +- ...ng_over_multiple_variables_two_results.txt | 24 +-- ...n_with_deep_specialization_and_capture.txt | 6 +- ...a_set_specialization_with_let_weakened.txt | 6 +- ...ialization_with_let_weakened_unapplied.txt | 12 +- .../ability/specialize/ranged_num_hash.txt | 2 +- .../ability/specialize/record_to_encoder.txt | 2 +- ...ord_to_encoder_with_nested_custom_impl.txt | 2 +- .../resolve_lambda_set_ability_chain.txt | 4 +- ...da_set_branches_ability_vs_non_ability.txt | 2 +- ...solve_lambda_set_branches_same_ability.txt | 2 +- ...e_lambda_set_generalized_ability_alias.txt | 6 +- ...olve_lambda_set_weakened_ability_alias.txt | 2 +- ...mutually_recursive_ability_lambda_sets.txt | 4 +- ...recursive_ability_lambda_sets_inferred.txt | 4 +- .../resolve_recursive_ability_lambda_set.txt | 2 +- ...cialized_lambda_sets_in_one_lambda_set.txt | 2 +- ..._unspecialized_lambda_set_behind_alias.txt | 4 +- ...unspecialized_lambda_set_behind_opaque.txt | 2 +- .../specialize/static_specialization.txt | 2 +- .../call_generic_ability_member.txt | 6 +- ...ed_specialization_with_annotation_only.txt | 2 +- ...checked_specialization_with_typed_body.txt | 2 +- ...bility_constrained_in_non_member_check.txt | 6 +- ...bility_constrained_in_non_member_infer.txt | 4 +- ..._constrained_in_non_member_infer_usage.txt | 2 +- ...in_non_member_multiple_specializations.txt | 2 +- .../solve/ability_specialization_called.txt | 2 +- .../tests/solve/alias_ability_member.txt | 4 +- .../tests/solve/alias_propagates_able_var.txt | 6 +- .../tests/solve/exposed_ability_name.txt | 4 +- ...ities_multiple_members_specializations.txt | 8 +- ...ility_multiple_members_specializations.txt | 4 +- ..._ability_single_member_specializations.txt | 2 +- crates/reporting/src/error/type.rs | 11 +- crates/reporting/tests/test_reporting.rs | 196 +++++++++--------- examples/cli/cli-platform/Env.roc | 4 +- examples/cli/cli-platform/File.roc | 4 +- examples/cli/cli-platform/Http.roc | 2 +- examples/python-interop/platform/main.roc | 2 +- examples/ruby-interop/platform/main.roc | 2 +- .../platform/Html/Internal/Client.roc | 6 +- .../platform/Html/Internal/Server.roc | 4 +- .../virtual-dom-wip/platform/client-side.roc | 2 +- www/generate_tutorial/src/tutorial.roc | 54 ++--- 117 files changed, 637 insertions(+), 612 deletions(-) diff --git a/crates/cli_testing_examples/benchmarks/AStar.roc b/crates/cli_testing_examples/benchmarks/AStar.roc index 95edcc7bc4..14f4a42dbc 100644 --- a/crates/cli_testing_examples/benchmarks/AStar.roc +++ b/crates/cli_testing_examples/benchmarks/AStar.roc @@ -10,9 +10,9 @@ Model position : { openSet : Set position, costs : Dict position F64, cameFrom : Dict position position, -} | position implements Hash & Eq +} where position implements Hash & Eq -initialModel : position -> Model position | position implements Hash & Eq +initialModel : position -> Model position where position implements Hash & Eq initialModel = \start -> { evaluated: Set.empty {}, openSet: Set.single start, @@ -20,7 +20,7 @@ initialModel = \start -> { cameFrom: Dict.empty {}, } -cheapestOpen : (position -> F64), Model position -> Result position {} | position implements Hash & Eq +cheapestOpen : (position -> F64), Model position -> Result position {} where position implements Hash & Eq cheapestOpen = \costFn, model -> model.openSet |> Set.toList @@ -35,13 +35,13 @@ cheapestOpen = \costFn, model -> |> Result.map .position |> Result.mapErr (\_ -> {}) -reconstructPath : Dict position position, position -> List position | position implements Hash & Eq +reconstructPath : Dict position position, position -> List position where position implements Hash & Eq reconstructPath = \cameFrom, goal -> when Dict.get cameFrom goal is Err _ -> [] Ok next -> List.append (reconstructPath cameFrom next) goal -updateCost : position, position, Model position -> Model position | position implements Hash & Eq +updateCost : position, position, Model position -> Model position where position implements Hash & Eq updateCost = \current, neighbor, model -> newCameFrom = Dict.insert model.cameFrom neighbor current @@ -70,7 +70,7 @@ updateCost = \current, neighbor, model -> else model -astar : (position, position -> F64), (position -> Set position), position, Model position -> Result (List position) {} | position implements Hash & Eq +astar : (position, position -> F64), (position -> Set position), position, Model position -> Result (List position) {} where position implements Hash & Eq astar = \costFn, moveFn, goal, model -> when cheapestOpen (\source -> costFn source goal) model is Err {} -> Err {} diff --git a/crates/compiler/builtins/roc/Bool.roc b/crates/compiler/builtins/roc/Bool.roc index 37eea3dff2..c6d331a915 100644 --- a/crates/compiler/builtins/roc/Bool.roc +++ b/crates/compiler/builtins/roc/Bool.roc @@ -30,7 +30,7 @@ Eq implements ## for more detail. ## 5. Functions cannot be compared for structural equality, therefore Roc ## cannot derive `isEq` for types that contain functions. - isEq : a, a -> Bool | a implements Eq + isEq : a, a -> Bool where a implements Eq ## Represents the boolean true and false using an opaque type. ## `Bool` implements the `Eq` ability. @@ -116,7 +116,7 @@ not : Bool -> Bool ## expect (Bool.false != Bool.false) == Bool.false ## expect "Apples" != "Oranges" ## ``` -isNotEq : a, a -> Bool | a implements Eq +isNotEq : a, a -> Bool where a implements Eq isNotEq = \a, b -> structuralNotEq a b # INTERNAL COMPILER USE ONLY: used to lower calls to `isEq` to structural diff --git a/crates/compiler/builtins/roc/Decode.roc b/crates/compiler/builtins/roc/Decode.roc index 96b17ac237..dc68427b81 100644 --- a/crates/compiler/builtins/roc/Decode.roc +++ b/crates/compiler/builtins/roc/Decode.roc @@ -73,30 +73,30 @@ DecodeResult val : { result : Result val DecodeError, rest : List U8 } ## Decodes a `List U8` of utf-8 bytes where `val` is the type of the decoded ## value, and `fmt` is a [Decoder] which implements the [DecoderFormatting] ## ability -Decoder val fmt := List U8, fmt -> DecodeResult val | fmt implements DecoderFormatting +Decoder val fmt := List U8, fmt -> DecodeResult val where fmt implements DecoderFormatting ## Definition of the [Decoding] ability Decoding implements - decoder : Decoder val fmt | val implements Decoding, fmt implements DecoderFormatting + decoder : Decoder val fmt where val implements Decoding, fmt implements DecoderFormatting ## Definition of the [DecoderFormatting] ability DecoderFormatting implements - u8 : Decoder U8 fmt | fmt implements DecoderFormatting - u16 : Decoder U16 fmt | fmt implements DecoderFormatting - u32 : Decoder U32 fmt | fmt implements DecoderFormatting - u64 : Decoder U64 fmt | fmt implements DecoderFormatting - u128 : Decoder U128 fmt | fmt implements DecoderFormatting - i8 : Decoder I8 fmt | fmt implements DecoderFormatting - i16 : Decoder I16 fmt | fmt implements DecoderFormatting - i32 : Decoder I32 fmt | fmt implements DecoderFormatting - i64 : Decoder I64 fmt | fmt implements DecoderFormatting - i128 : Decoder I128 fmt | fmt implements DecoderFormatting - f32 : Decoder F32 fmt | fmt implements DecoderFormatting - f64 : Decoder F64 fmt | fmt implements DecoderFormatting - dec : Decoder Dec fmt | fmt implements DecoderFormatting - bool : Decoder Bool fmt | fmt implements DecoderFormatting - string : Decoder Str fmt | fmt implements DecoderFormatting - list : Decoder elem fmt -> Decoder (List elem) fmt | fmt implements DecoderFormatting + u8 : Decoder U8 fmt where fmt implements DecoderFormatting + u16 : Decoder U16 fmt where fmt implements DecoderFormatting + u32 : Decoder U32 fmt where fmt implements DecoderFormatting + u64 : Decoder U64 fmt where fmt implements DecoderFormatting + u128 : Decoder U128 fmt where fmt implements DecoderFormatting + i8 : Decoder I8 fmt where fmt implements DecoderFormatting + i16 : Decoder I16 fmt where fmt implements DecoderFormatting + i32 : Decoder I32 fmt where fmt implements DecoderFormatting + i64 : Decoder I64 fmt where fmt implements DecoderFormatting + i128 : Decoder I128 fmt where fmt implements DecoderFormatting + f32 : Decoder F32 fmt where fmt implements DecoderFormatting + f64 : Decoder F64 fmt where fmt implements DecoderFormatting + dec : Decoder Dec fmt where fmt implements DecoderFormatting + bool : Decoder Bool fmt where fmt implements DecoderFormatting + string : Decoder Str fmt where fmt implements DecoderFormatting + list : Decoder elem fmt -> Decoder (List elem) fmt where fmt implements DecoderFormatting ## `record state stepField finalizer` decodes a record field-by-field. ## @@ -104,7 +104,7 @@ DecoderFormatting implements ## `Skip` if the field is not a part of the decoded record. ## ## `finalizer` should produce the record value from the decoded `state`. - record : state, (state, Str -> [Keep (Decoder state fmt), Skip]), (state -> Result val DecodeError) -> Decoder val fmt | fmt implements DecoderFormatting + record : state, (state, Str -> [Keep (Decoder state fmt), Skip]), (state -> Result val DecodeError) -> Decoder val fmt where fmt implements DecoderFormatting ## `tuple state stepElem finalizer` decodes a tuple element-by-element. ## @@ -113,7 +113,7 @@ DecoderFormatting implements ## index passed to `stepElem` is 0-indexed. ## ## `finalizer` should produce the tuple value from the decoded `state`. - tuple : state, (state, Nat -> [Next (Decoder state fmt), TooLong]), (state -> Result val DecodeError) -> Decoder val fmt | fmt implements DecoderFormatting + tuple : state, (state, Nat -> [Next (Decoder state fmt), TooLong]), (state -> Result val DecodeError) -> Decoder val fmt where fmt implements DecoderFormatting ## Build a custom [Decoder] function. For example the implementation of ## `decodeBool` could be defined as follows; @@ -125,11 +125,11 @@ DecoderFormatting implements ## ['t', 'r', 'u', 'e', ..] -> { result: Ok Bool.true, rest: List.drop bytes 4 } ## _ -> { result: Err TooShort, rest: bytes } ## ``` -custom : (List U8, fmt -> DecodeResult val) -> Decoder val fmt | fmt implements DecoderFormatting +custom : (List U8, fmt -> DecodeResult val) -> Decoder val fmt where fmt implements DecoderFormatting custom = \decode -> @Decoder decode ## Decode a `List U8` utf-8 bytes using a specific [Decoder] function -decodeWith : List U8, Decoder val fmt, fmt -> DecodeResult val | fmt implements DecoderFormatting +decodeWith : List U8, Decoder val fmt, fmt -> DecodeResult val where fmt implements DecoderFormatting decodeWith = \bytes, @Decoder decode, fmt -> decode bytes fmt ## Decode a `List U8` utf-8 bytes and return a [DecodeResult](#DecodeResult) @@ -141,7 +141,7 @@ decodeWith = \bytes, @Decoder decode, fmt -> decode bytes fmt ## ## actual.result == expected ## ``` -fromBytesPartial : List U8, fmt -> DecodeResult val | val implements Decoding, fmt implements DecoderFormatting +fromBytesPartial : List U8, fmt -> DecodeResult val where val implements Decoding, fmt implements DecoderFormatting fromBytesPartial = \bytes, fmt -> decodeWith bytes decoder fmt ## Decode a `List U8` utf-8 bytes and return a [Result] with no leftover bytes @@ -155,7 +155,7 @@ fromBytesPartial = \bytes, fmt -> decodeWith bytes decoder fmt ## ## actual == expected ## ``` -fromBytes : List U8, fmt -> Result val [Leftover (List U8)]DecodeError | val implements Decoding, fmt implements DecoderFormatting +fromBytes : List U8, fmt -> Result val [Leftover (List U8)]DecodeError where val implements Decoding, fmt implements DecoderFormatting fromBytes = \bytes, fmt -> when fromBytesPartial bytes fmt is { result, rest } -> diff --git a/crates/compiler/builtins/roc/Dict.roc b/crates/compiler/builtins/roc/Dict.roc index c5cb986aa4..0e88557123 100644 --- a/crates/compiler/builtins/roc/Dict.roc +++ b/crates/compiler/builtins/roc/Dict.roc @@ -97,7 +97,7 @@ Dict k v := { dataIndices : List Nat, data : List (k, v), size : Nat, -} | k implements Hash & Eq +} where k implements Hash & Eq implements [ Eq { isEq, @@ -107,7 +107,7 @@ Dict k v := { }, ] -isEq : Dict k v, Dict k v -> Bool | k implements Hash & Eq, v implements Eq +isEq : Dict k v, Dict k v -> Bool where k implements Hash & Eq, v implements Eq isEq = \xs, ys -> if len xs != len ys then Bool.false @@ -120,14 +120,14 @@ isEq = \xs, ys -> _ -> Break Bool.false -hashDict : hasher, Dict k v -> hasher | k implements Hash & Eq, v implements Hash, hasher implements Hasher +hashDict : hasher, Dict k v -> hasher where k implements Hash & Eq, v implements Hash, hasher implements Hasher hashDict = \hasher, dict -> Hash.hashUnordered hasher (toList dict) List.walk ## Return an empty dictionary. ## ``` ## emptyDict = Dict.empty {} ## ``` -empty : {} -> Dict k v | k implements Hash & Eq +empty : {} -> Dict k v where k implements Hash & Eq empty = \{} -> @Dict { metadata: List.repeat emptySlot 8, @@ -144,7 +144,7 @@ empty = \{} -> ## ## capacityOfDict = Dict.capacity foodDict ## ``` -capacity : Dict k v -> Nat | k implements Hash & Eq +capacity : Dict k v -> Nat where k implements Hash & Eq capacity = \@Dict { dataIndices } -> cap = List.len dataIndices @@ -153,7 +153,7 @@ capacity = \@Dict { dataIndices } -> ## Return a dictionary with space allocated for a number of entries. This ## may provide a performance optimization if you know how many entries will be ## inserted. -withCapacity : Nat -> Dict k v | k implements Hash & Eq +withCapacity : Nat -> Dict k v where k implements Hash & Eq withCapacity = \_ -> # TODO: power of 2 * 8 and actual implementation empty {} @@ -164,7 +164,7 @@ withCapacity = \_ -> ## Dict.single "A" "B" ## |> Bool.isEq (Dict.insert (Dict.empty {}) "A" "B") ## ``` -single : k, v -> Dict k v | k implements Hash & Eq +single : k, v -> Dict k v where k implements Hash & Eq single = \k, v -> insert (empty {}) k v @@ -177,7 +177,7 @@ single = \k, v -> ## |> Dict.insert 4 "Four" ## |> Bool.isEq (Dict.fromList [(1, "One"), (2, "Two"), (3, "Three"), (4, "Four")]) ## ``` -fromList : List (k, v) -> Dict k v | k implements Hash & Eq +fromList : List (k, v) -> Dict k v where k implements Hash & Eq fromList = \data -> # TODO: make this efficient. Should just set data and then set all indicies in the hashmap. List.walk data (empty {}) (\dict, (k, v) -> insert dict k v) @@ -192,7 +192,7 @@ fromList = \data -> ## |> Dict.len ## |> Bool.isEq 3 ## ``` -len : Dict k v -> Nat | k implements Hash & Eq +len : Dict k v -> Nat where k implements Hash & Eq len = \@Dict { size } -> size @@ -208,7 +208,7 @@ len = \@Dict { size } -> ## ## expect Dict.len clearSongs == 0 ## ``` -clear : Dict k v -> Dict k v | k implements Hash & Eq +clear : Dict k v -> Dict k v where k implements Hash & Eq clear = \@Dict { metadata, dataIndices, data } -> cap = List.len dataIndices @@ -236,7 +236,7 @@ clear = \@Dict { metadata, dataIndices, data } -> ## |> Dict.walk 0 (\count, _, qty -> count + qty) ## |> Bool.isEq 36 ## ``` -walk : Dict k v, state, (state, k, v -> state) -> state | k implements Hash & Eq +walk : Dict k v, state, (state, k, v -> state) -> state where k implements Hash & Eq walk = \@Dict { data }, initialState, transform -> List.walk data initialState (\state, (k, v) -> transform state k v) @@ -268,7 +268,7 @@ walk = \@Dict { data }, initialState, transform -> ## ## expect someoneIsAnAdult == Bool.true ## ``` -walkUntil : Dict k v, state, (state, k, v -> [Continue state, Break state]) -> state | k implements Hash & Eq +walkUntil : Dict k v, state, (state, k, v -> [Continue state, Break state]) -> state where k implements Hash & Eq walkUntil = \@Dict { data }, initialState, transform -> List.walkUntil data initialState (\state, (k, v) -> transform state k v) @@ -283,7 +283,7 @@ walkUntil = \@Dict { data }, initialState, transform -> ## expect Dict.get dictionary 1 == Ok "Apple" ## expect Dict.get dictionary 2000 == Err KeyNotFound ## ``` -get : Dict k v, k -> Result v [KeyNotFound] | k implements Hash & Eq +get : Dict k v, k -> Result v [KeyNotFound] where k implements Hash & Eq get = \@Dict { metadata, dataIndices, data }, key -> hashKey = createLowLevelHasher PseudoRandSeed @@ -311,7 +311,7 @@ get = \@Dict { metadata, dataIndices, data }, key -> ## |> Dict.contains 1234 ## |> Bool.isEq Bool.true ## ``` -contains : Dict k v, k -> Bool | k implements Hash & Eq +contains : Dict k v, k -> Bool where k implements Hash & Eq contains = \@Dict { metadata, dataIndices, data }, key -> hashKey = createLowLevelHasher PseudoRandSeed @@ -336,7 +336,7 @@ contains = \@Dict { metadata, dataIndices, data }, key -> ## |> Dict.get "Apples" ## |> Bool.isEq (Ok 12) ## ``` -insert : Dict k v, k, v -> Dict k v | k implements Hash & Eq +insert : Dict k v, k, v -> Dict k v where k implements Hash & Eq insert = \@Dict { metadata, dataIndices, data, size }, key, value -> hashKey = createLowLevelHasher PseudoRandSeed @@ -382,7 +382,7 @@ insert = \@Dict { metadata, dataIndices, data, size }, key, value -> ## |> Dict.len ## |> Bool.isEq 0 ## ``` -remove : Dict k v, k -> Dict k v | k implements Hash & Eq +remove : Dict k v, k -> Dict k v where k implements Hash & Eq remove = \@Dict { metadata, dataIndices, data, size }, key -> # TODO: change this from swap remove to tombstone and test is performance is still good. hashKey = @@ -426,7 +426,7 @@ remove = \@Dict { metadata, dataIndices, data, size }, key -> ## expect Dict.update (Dict.single "a" Bool.false) "a" alterValue == Dict.single "a" Bool.true ## expect Dict.update (Dict.single "a" Bool.true) "a" alterValue == Dict.empty {} ## ``` -update : Dict k v, k, ([Present v, Missing] -> [Present v, Missing]) -> Dict k v | k implements Hash & Eq +update : Dict k v, k, ([Present v, Missing] -> [Present v, Missing]) -> Dict k v where k implements Hash & Eq update = \dict, key, alter -> # TODO: look into optimizing by merging substeps and reducing lookups. possibleValue = @@ -449,7 +449,7 @@ update = \dict, key, alter -> ## |> Dict.toList ## |> Bool.isEq [(1, "One"), (2, "Two"), (3, "Three"), (4, "Four")] ## ``` -toList : Dict k v -> List (k, v) | k implements Hash & Eq +toList : Dict k v -> List (k, v) where k implements Hash & Eq toList = \@Dict { data } -> data @@ -464,7 +464,7 @@ toList = \@Dict { data } -> ## |> Dict.keys ## |> Bool.isEq [1,2,3,4] ## ``` -keys : Dict k v -> List k | k implements Hash & Eq +keys : Dict k v -> List k where k implements Hash & Eq keys = \@Dict { data } -> List.map data (\(k, _) -> k) @@ -479,7 +479,7 @@ keys = \@Dict { data } -> ## |> Dict.values ## |> Bool.isEq ["One","Two","Three","Four"] ## ``` -values : Dict k v -> List v | k implements Hash & Eq +values : Dict k v -> List v where k implements Hash & Eq values = \@Dict { data } -> List.map data (\(_, v) -> v) @@ -507,7 +507,7 @@ values = \@Dict { data } -> ## expect ## Dict.insertAll first second == expected ## ``` -insertAll : Dict k v, Dict k v -> Dict k v | k implements Hash & Eq +insertAll : Dict k v, Dict k v -> Dict k v where k implements Hash & Eq insertAll = \xs, ys -> walk ys xs insert @@ -529,7 +529,7 @@ insertAll = \xs, ys -> ## ## expect Dict.keepShared first second == first ## ``` -keepShared : Dict k v, Dict k v -> Dict k v | k implements Hash & Eq +keepShared : Dict k v, Dict k v -> Dict k v where k implements Hash & Eq keepShared = \xs, ys -> walk xs @@ -561,11 +561,11 @@ keepShared = \xs, ys -> ## ## expect Dict.removeAll first second == expected ## ``` -removeAll : Dict k v, Dict k v -> Dict k v | k implements Hash & Eq +removeAll : Dict k v, Dict k v -> Dict k v where k implements Hash & Eq removeAll = \xs, ys -> walk ys xs (\state, k, _ -> remove state k) -swapAndUpdateDataIndex : Dict k v, Nat, Nat -> Dict k v | k implements Hash & Eq +swapAndUpdateDataIndex : Dict k v, Nat, Nat -> Dict k v where k implements Hash & Eq swapAndUpdateDataIndex = \@Dict { metadata, dataIndices, data, size }, removedIndex, lastIndex -> (key, _) = listGetUnsafe data lastIndex hashKey = @@ -629,7 +629,7 @@ nextEmptyOrDeletedHelper = \metadata, probe, offset -> # TODO: investigate if this needs to be split into more specific helper functions. # There is a chance that returning specific sub-info like the value would be faster. -findIndexHelper : List I8, List Nat, List (k, v), I8, k, Probe, Nat -> Result Nat [NotFound] | k implements Hash & Eq +findIndexHelper : List I8, List Nat, List (k, v), I8, k, Probe, Nat -> Result Nat [NotFound] where k implements Hash & Eq findIndexHelper = \metadata, dataIndices, data, h2Key, key, probe, offset -> # For finding a value, we must search past all deleted element tombstones. index = Num.addWrap (mul8 probe.slotIndex) offset @@ -661,7 +661,7 @@ findIndexHelper = \metadata, dataIndices, data, h2Key, key, probe, offset -> # This is how we grow the container. # If we aren't to the load factor yet, just ignore this. # The container must have an updated size including any elements about to be inserted. -maybeRehash : Dict k v -> Dict k v | k implements Hash & Eq +maybeRehash : Dict k v -> Dict k v where k implements Hash & Eq maybeRehash = \@Dict { metadata, dataIndices, data, size } -> cap = List.len dataIndices maxLoadCap = @@ -674,7 +674,7 @@ maybeRehash = \@Dict { metadata, dataIndices, data, size } -> @Dict { metadata, dataIndices, data, size } # TODO: switch rehash to iterate data and eventually clear out tombstones as well. -rehash : Dict k v -> Dict k v | k implements Hash & Eq +rehash : Dict k v -> Dict k v where k implements Hash & Eq rehash = \@Dict { metadata, dataIndices, data, size } -> newLen = 2 * List.len dataIndices newDict = @@ -687,7 +687,7 @@ rehash = \@Dict { metadata, dataIndices, data, size } -> rehashHelper newDict metadata dataIndices data 0 -rehashHelper : Dict k v, List I8, List Nat, List (k, v), Nat -> Dict k v | k implements Hash & Eq +rehashHelper : Dict k v, List I8, List Nat, List (k, v), Nat -> Dict k v where k implements Hash & Eq rehashHelper = \dict, oldMetadata, oldDataIndices, oldData, index -> when List.get oldMetadata index is Ok md -> @@ -708,7 +708,7 @@ rehashHelper = \dict, oldMetadata, oldDataIndices, oldData, index -> # Walked entire list, complete now. dict -insertForRehash : Dict k v, k, Nat -> Dict k v | k implements Hash & Eq +insertForRehash : Dict k v, k, Nat -> Dict k v where k implements Hash & Eq insertForRehash = \@Dict { metadata, dataIndices, data, size }, key, dataIndex -> hashKey = createLowLevelHasher PseudoRandSeed diff --git a/crates/compiler/builtins/roc/Encode.roc b/crates/compiler/builtins/roc/Encode.roc index b20e22428a..af8b0307c1 100644 --- a/crates/compiler/builtins/roc/Encode.roc +++ b/crates/compiler/builtins/roc/Encode.roc @@ -47,40 +47,40 @@ interface Encode Bool.{ Bool }, ] -Encoder fmt := List U8, fmt -> List U8 | fmt implements EncoderFormatting +Encoder fmt := List U8, fmt -> List U8 where fmt implements EncoderFormatting Encoding implements - toEncoder : val -> Encoder fmt | val implements Encoding, fmt implements EncoderFormatting + toEncoder : val -> Encoder fmt where val implements Encoding, fmt implements EncoderFormatting EncoderFormatting implements - u8 : U8 -> Encoder fmt | fmt implements EncoderFormatting - u16 : U16 -> Encoder fmt | fmt implements EncoderFormatting - u32 : U32 -> Encoder fmt | fmt implements EncoderFormatting - u64 : U64 -> Encoder fmt | fmt implements EncoderFormatting - u128 : U128 -> Encoder fmt | fmt implements EncoderFormatting - i8 : I8 -> Encoder fmt | fmt implements EncoderFormatting - i16 : I16 -> Encoder fmt | fmt implements EncoderFormatting - i32 : I32 -> Encoder fmt | fmt implements EncoderFormatting - i64 : I64 -> Encoder fmt | fmt implements EncoderFormatting - i128 : I128 -> Encoder fmt | fmt implements EncoderFormatting - f32 : F32 -> Encoder fmt | fmt implements EncoderFormatting - f64 : F64 -> Encoder fmt | fmt implements EncoderFormatting - dec : Dec -> Encoder fmt | fmt implements EncoderFormatting - bool : Bool -> Encoder fmt | fmt implements EncoderFormatting - string : Str -> Encoder fmt | fmt implements EncoderFormatting - list : List elem, (elem -> Encoder fmt) -> Encoder fmt | fmt implements EncoderFormatting - record : List { key : Str, value : Encoder fmt } -> Encoder fmt | fmt implements EncoderFormatting - tuple : List (Encoder fmt) -> Encoder fmt | fmt implements EncoderFormatting - tag : Str, List (Encoder fmt) -> Encoder fmt | fmt implements EncoderFormatting + 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 -custom : (List U8, fmt -> List U8) -> Encoder fmt | fmt implements EncoderFormatting +custom : (List U8, fmt -> List U8) -> Encoder fmt where fmt implements EncoderFormatting custom = \encoder -> @Encoder encoder -appendWith : List U8, Encoder fmt, fmt -> List U8 | fmt implements EncoderFormatting +appendWith : List U8, Encoder fmt, fmt -> List U8 where fmt implements EncoderFormatting appendWith = \lst, @Encoder doEncoding, fmt -> doEncoding lst fmt -append : List U8, val, fmt -> List U8 | val implements Encoding, fmt implements EncoderFormatting +append : List U8, val, fmt -> List U8 where val implements Encoding, fmt implements EncoderFormatting append = \lst, val, fmt -> appendWith lst (toEncoder val) fmt -toBytes : val, fmt -> List U8 | val implements Encoding, fmt implements EncoderFormatting +toBytes : val, fmt -> List U8 where val implements Encoding, fmt implements EncoderFormatting toBytes = \val, fmt -> appendWith [] (toEncoder val) fmt diff --git a/crates/compiler/builtins/roc/Hash.roc b/crates/compiler/builtins/roc/Hash.roc index 3bbff810d5..d96f1c5eb0 100644 --- a/crates/compiler/builtins/roc/Hash.roc +++ b/crates/compiler/builtins/roc/Hash.roc @@ -33,7 +33,7 @@ Hash implements ## Hashes a value into a [Hasher]. ## Note that [hash] does not produce a hash value itself; the hasher must be ## [complete]d in order to extract the hash value. - hash : hasher, a -> hasher | a implements Hash, hasher implements Hasher + hash : hasher, a -> hasher where a implements Hash, hasher implements Hasher ## Describes a hashing algorithm that is fed bytes and produces an integer hash. ## @@ -42,26 +42,26 @@ Hash implements ## cryptographically-secure hashing. Hasher implements ## Adds a list of bytes to the hasher. - addBytes : a, List U8 -> a | a implements Hasher + addBytes : a, List U8 -> a where a implements Hasher ## Adds a single U8 to the hasher. - addU8 : a, U8 -> a | a implements Hasher + addU8 : a, U8 -> a where a implements Hasher ## Adds a single U16 to the hasher. - addU16 : a, U16 -> a | a implements Hasher + addU16 : a, U16 -> a where a implements Hasher ## Adds a single U32 to the hasher. - addU32 : a, U32 -> a | a implements Hasher + addU32 : a, U32 -> a where a implements Hasher ## Adds a single U64 to the hasher. - addU64 : a, U64 -> a | a implements Hasher + addU64 : a, U64 -> a where a implements Hasher ## Adds a single U128 to the hasher. - addU128 : a, U128 -> a | a implements Hasher + addU128 : a, U128 -> a where a implements Hasher ## Completes the hasher, extracting a hash value from its ## accumulated hash state. - complete : a -> U64 | a implements Hasher + complete : a -> U64 where a implements Hasher ## Adds a string into a [Hasher] by hashing its UTF-8 bytes. hashStrBytes = \hasher, s -> @@ -73,33 +73,33 @@ hashList = \hasher, lst -> hash accumHasher elem ## Adds a single [Bool] to a hasher. -hashBool : a, Bool -> a | a implements Hasher +hashBool : a, Bool -> a where a implements Hasher hashBool = \hasher, b -> asU8 = if b then 1 else 0 addU8 hasher asU8 ## Adds a single I8 to a hasher. -hashI8 : a, I8 -> a | a implements Hasher +hashI8 : a, I8 -> a where a implements Hasher hashI8 = \hasher, n -> addU8 hasher (Num.toU8 n) ## Adds a single I16 to a hasher. -hashI16 : a, I16 -> a | a implements Hasher +hashI16 : a, I16 -> a where a implements Hasher hashI16 = \hasher, n -> addU16 hasher (Num.toU16 n) ## Adds a single I32 to a hasher. -hashI32 : a, I32 -> a | a implements Hasher +hashI32 : a, I32 -> a where a implements Hasher hashI32 = \hasher, n -> addU32 hasher (Num.toU32 n) ## Adds a single I64 to a hasher. -hashI64 : a, I64 -> a | a implements Hasher +hashI64 : a, I64 -> a where a implements Hasher hashI64 = \hasher, n -> addU64 hasher (Num.toU64 n) ## Adds a single I128 to a hasher. -hashI128 : a, I128 -> a | a implements Hasher +hashI128 : a, I128 -> a where a implements Hasher hashI128 = \hasher, n -> addU128 hasher (Num.toU128 n) ## Adds a single Nat to a hasher. -hashNat : a, Nat -> a | a implements Hasher +hashNat : a, Nat -> a where a implements Hasher hashNat = \hasher, n -> isPlatform32bit = x : Nat @@ -117,7 +117,7 @@ hashNat = \hasher, n -> i128OfDec : Dec -> I128 ## Adds a single [Dec] to a hasher. -hashDec : a, Dec -> a | a implements Hasher +hashDec : a, Dec -> a where a implements Hasher hashDec = \hasher, n -> hashI128 hasher (i128OfDec n) ## Adds a container of [Hash]able elements to a [Hasher] by hashing each element. diff --git a/crates/compiler/builtins/roc/List.roc b/crates/compiler/builtins/roc/List.roc index 5e3259fc78..c713dff612 100644 --- a/crates/compiler/builtins/roc/List.roc +++ b/crates/compiler/builtins/roc/List.roc @@ -363,7 +363,7 @@ join = \lists -> List.walk lists (List.withCapacity totalLength) (\state, list -> List.concat state list) -contains : List a, a -> Bool | a implements Eq +contains : List a, a -> Bool where a implements Eq contains = \list, needle -> List.any list (\x -> x == needle) @@ -1037,7 +1037,7 @@ intersperse = \list, sep -> ## is considered to "start with" an empty list. ## ## If the first list is empty, this only returns `Bool.true` if the second list is empty. -startsWith : List elem, List elem -> Bool | elem implements Eq +startsWith : List elem, List elem -> Bool where elem implements Eq startsWith = \list, prefix -> # TODO once we have seamless slices, verify that this wouldn't # have better performance with a function like List.compareSublists @@ -1049,7 +1049,7 @@ startsWith = \list, prefix -> ## is considered to "end with" an empty list. ## ## If the first list is empty, this only returns `Bool.true` if the second list is empty. -endsWith : List elem, List elem -> Bool | elem implements Eq +endsWith : List elem, List elem -> Bool where elem implements Eq endsWith = \list, suffix -> # TODO once we have seamless slices, verify that this wouldn't # have better performance with a function like List.compareSublists @@ -1079,7 +1079,7 @@ split = \elements, userSplitIndex -> ## ``` ## List.splitFirst [Foo, Z, Bar, Z, Baz] Z == Ok { before: [Foo], after: [Bar, Z, Baz] } ## ``` -splitFirst : List elem, elem -> Result { before : List elem, after : List elem } [NotFound] | elem implements Eq +splitFirst : List elem, elem -> Result { before : List elem, after : List elem } [NotFound] where elem implements Eq splitFirst = \list, delimiter -> when List.findFirstIndex list (\elem -> elem == delimiter) is Ok index -> @@ -1095,7 +1095,7 @@ splitFirst = \list, delimiter -> ## ``` ## List.splitLast [Foo, Z, Bar, Z, Baz] Z == Ok { before: [Foo, Z, Bar], after: [Baz] } ## ``` -splitLast : List elem, elem -> Result { before : List elem, after : List elem } [NotFound] | elem implements Eq +splitLast : List elem, elem -> Result { before : List elem, after : List elem } [NotFound] where elem implements Eq splitLast = \list, delimiter -> when List.findLastIndex list (\elem -> elem == delimiter) is Ok index -> diff --git a/crates/compiler/builtins/roc/Set.roc b/crates/compiler/builtins/roc/Set.roc index 4d08af15bf..53871d45a0 100644 --- a/crates/compiler/builtins/roc/Set.roc +++ b/crates/compiler/builtins/roc/Set.roc @@ -25,7 +25,7 @@ interface Set ## Provides a [set](https://en.wikipedia.org/wiki/Set_(abstract_data_type)) ## type which stores a collection of unique values, without any ordering -Set k := Dict.Dict k {} | k implements Hash & Eq +Set k := Dict.Dict k {} where k implements Hash & Eq implements [ Eq { isEq, @@ -35,7 +35,7 @@ Set k := Dict.Dict k {} | k implements Hash & Eq }, ] -isEq : Set k, Set k -> Bool | k implements Hash & Eq +isEq : Set k, Set k -> Bool where k implements Hash & Eq isEq = \xs, ys -> if len xs != len ys then Bool.false @@ -46,7 +46,7 @@ isEq = \xs, ys -> else Break Bool.false -hashSet : hasher, Set k -> hasher | k implements Hash & Eq, hasher implements Hasher +hashSet : hasher, Set k -> hasher where k implements Hash & Eq, hasher implements Hasher hashSet = \hasher, @Set inner -> Hash.hash hasher inner ## Creates a new empty `Set`. @@ -56,7 +56,7 @@ hashSet = \hasher, @Set inner -> Hash.hash hasher inner ## ## expect countValues == 0 ## ``` -empty : {} -> Set k | k implements Hash & Eq +empty : {} -> Set k where k implements Hash & Eq empty = \{} -> @Set (Dict.empty {}) ## Creates a new `Set` with a single value. @@ -66,7 +66,7 @@ empty = \{} -> @Set (Dict.empty {}) ## ## expect countValues == 1 ## ``` -single : k -> Set k | k implements Hash & Eq +single : k -> Set k where k implements Hash & Eq single = \key -> Dict.single key {} |> @Set @@ -82,7 +82,7 @@ single = \key -> ## ## expect countValues == 3 ## ``` -insert : Set k, k -> Set k | k implements Hash & Eq +insert : Set k, k -> Set k where k implements Hash & Eq insert = \@Set dict, key -> Dict.insert dict key {} |> @Set @@ -115,7 +115,7 @@ expect ## ## expect countValues == 3 ## ``` -len : Set k -> Nat | k implements Hash & Eq +len : Set k -> Nat where k implements Hash & Eq len = \@Set dict -> Dict.len dict @@ -145,7 +145,7 @@ expect ## expect has10 == Bool.false ## expect has20 == Bool.true ## ``` -remove : Set k, k -> Set k | k implements Hash & Eq +remove : Set k, k -> Set k where k implements Hash & Eq remove = \@Set dict, key -> Dict.remove dict key |> @Set @@ -164,7 +164,7 @@ remove = \@Set dict, key -> ## expect hasApple == Bool.true ## expect hasBanana == Bool.false ## ``` -contains : Set k, k -> Bool | k implements Hash & Eq +contains : Set k, k -> Bool where k implements Hash & Eq contains = \@Set dict, key -> Dict.contains dict key @@ -177,7 +177,7 @@ contains = \@Set dict, key -> ## ## expect Set.toList numbers == values ## ``` -toList : Set k -> List k | k implements Hash & Eq +toList : Set k -> List k where k implements Hash & Eq toList = \@Set dict -> Dict.keys dict @@ -191,7 +191,7 @@ toList = \@Set dict -> ## ## expect Set.fromList [Pear, Apple, Banana] == values ## ``` -fromList : List k -> Set k | k implements Hash & Eq +fromList : List k -> Set k where k implements Hash & Eq fromList = \list -> initial = @Set (Dict.withCapacity (List.len list)) @@ -207,7 +207,7 @@ fromList = \list -> ## ## expect Set.union set1 set2 == Set.fromList [Left, Right] ## ``` -union : Set k, Set k -> Set k | k implements Hash & Eq +union : Set k, Set k -> Set k where k implements Hash & Eq union = \@Set dict1, @Set dict2 -> Dict.insertAll dict1 dict2 |> @Set @@ -220,7 +220,7 @@ union = \@Set dict1, @Set dict2 -> ## ## expect Set.intersection set1 set2 == Set.single Left ## ``` -intersection : Set k, Set k -> Set k | k implements Hash & Eq +intersection : Set k, Set k -> Set k where k implements Hash & Eq intersection = \@Set dict1, @Set dict2 -> Dict.keepShared dict1 dict2 |> @Set @@ -234,7 +234,7 @@ intersection = \@Set dict1, @Set dict2 -> ## ## expect Set.difference first second == Set.fromList [Up, Down] ## ``` -difference : Set k, Set k -> Set k | k implements Hash & Eq +difference : Set k, Set k -> Set k where k implements Hash & Eq difference = \@Set dict1, @Set dict2 -> Dict.removeAll dict1 dict2 |> @Set @@ -257,7 +257,7 @@ difference = \@Set dict1, @Set dict2 -> ## ## expect result == 2 ## ``` -walk : Set k, state, (state, k -> state) -> state | k implements Hash & Eq +walk : Set k, state, (state, k -> state) -> state where k implements Hash & Eq walk = \@Set dict, state, step -> Dict.walk dict state (\s, k, _ -> step s k) @@ -276,7 +276,7 @@ walk = \@Set dict, state, step -> ## ## expect result == FoundTheAnswer ## ``` -walkUntil : Set k, state, (state, k -> [Continue state, Break state]) -> state | k implements Hash & Eq +walkUntil : Set k, state, (state, k -> [Continue state, Break state]) -> state where k implements Hash & Eq walkUntil = \@Set dict, state, step -> Dict.walkUntil dict state (\s, k, _ -> step s k) diff --git a/crates/compiler/can/src/abilities.rs b/crates/compiler/can/src/abilities.rs index 26d5643c9a..43bef5f8a6 100644 --- a/crates/compiler/can/src/abilities.rs +++ b/crates/compiler/can/src/abilities.rs @@ -80,7 +80,7 @@ impl AbilityMemberData { /// Solved lambda sets for an ability member specialization. For example, if we have /// -/// Default implements default : {} -[[] + a:default:1]-> a | a implements Default +/// Default implements default : {} -[[] + a:default:1]-> a where a implements Default /// /// A := {} /// default = \{} -[[closA]]-> @A {} @@ -144,7 +144,7 @@ pub struct IAbilitiesStore { /// /// For example, in the program /// - /// Hash implements hash : a -> U64 | a implements Hash + /// Hash implements hash : a -> U64 where a implements Hash /// /// Id := {} implements [Hash {hash: myHash}] /// myHash = \@Id n -> n @@ -284,7 +284,7 @@ impl IAbilitiesStore { } /// Finds the implementation key for a symbol specializing the ability member, if it specializes any. - /// For example, suppose `hashId : Id -> U64` specializes `hash : a -> U64 | a implements Hash`. + /// For example, suppose `hashId : Id -> U64` specializes `hash : a -> U64 where a implements Hash`. /// Calling this with `hashId` would retrieve (hash, hashId). pub fn impl_key(&self, specializing_symbol: Symbol) -> Option<&ImplKey> { self.specialization_to_root.get(&specializing_symbol) @@ -392,7 +392,7 @@ pub enum MarkError { impl IAbilitiesStore { /// Finds the symbol name and ability member definition for a symbol specializing the ability /// member, if it specializes any. - /// For example, suppose `hashId : Id -> U64` specializes `hash : a -> U64 | a implements Hash`. + /// For example, suppose `hashId : Id -> U64` specializes `hash : a -> U64 where a implements Hash`. /// Calling this with `hashId` would retrieve the ability member data for `hash`, and what type /// `hashId` is specializing for. pub fn impl_key_and_def( diff --git a/crates/compiler/can/src/def.rs b/crates/compiler/can/src/def.rs index 3bd138657f..758c058a92 100644 --- a/crates/compiler/can/src/def.rs +++ b/crates/compiler/can/src/def.rs @@ -510,7 +510,7 @@ fn canonicalize_claimed_ability_impl<'a>( // definition symbol, for example when the ability is defined in the same // module as an implementer: // - // Eq implements eq : a, a -> U64 | a implements Eq + // Eq implements eq : a, a -> U64 where a implements Eq // // A := U8 implements [Eq {eq}] // @@ -1398,7 +1398,7 @@ fn resolve_abilities( } [..] => { // There is more than one variable bound to the member signature, so something like - // Eq implements eq : a, b -> Bool | a implements Eq, b implements Eq + // Eq implements eq : a, b -> Bool where a implements Eq, b implements Eq // We have no way of telling what type implements a particular instance of Eq in // this case (a or b?), so disallow it. let span_has_clauses = Region::across_all( diff --git a/crates/compiler/can/src/pattern.rs b/crates/compiler/can/src/pattern.rs index 5541ab4710..565d57fca9 100644 --- a/crates/compiler/can/src/pattern.rs +++ b/crates/compiler/can/src/pattern.rs @@ -76,7 +76,7 @@ pub enum Pattern { Underscore, /// An identifier that marks a specialization of an ability member. - /// For example, given an ability member definition `hash : a -> U64 | a implements Hash`, + /// For example, given an ability member definition `hash : a -> U64 where a implements Hash`, /// there may be the specialization `hash : Bool -> U64`. In this case we generate a /// new symbol for the specialized "hash" identifier. AbilityMemberSpecialization { diff --git a/crates/compiler/can/src/scope.rs b/crates/compiler/can/src/scope.rs index 678714999b..e0b847c56e 100644 --- a/crates/compiler/can/src/scope.rs +++ b/crates/compiler/can/src/scope.rs @@ -33,7 +33,7 @@ pub struct Scope { imports: Vec<(Ident, Symbol, Region)>, /// Shadows of an ability member, for example a local specialization of `eq` for the ability - /// member `Eq implements eq : a, a -> Bool | a implements Eq` gets a shadow symbol it can use for its + /// member `Eq implements eq : a, a -> Bool where a implements Eq` gets a shadow symbol it can use for its /// implementation. /// /// Only one shadow of an ability member is permitted per scope. diff --git a/crates/compiler/derive/src/decoding.rs b/crates/compiler/derive/src/decoding.rs index acd58680b2..9f0b29c807 100644 --- a/crates/compiler/derive/src/decoding.rs +++ b/crates/compiler/derive/src/decoding.rs @@ -63,7 +63,7 @@ fn wrap_in_decode_custom_decode_with( // Decode.decodeWith bytes inner_decoder fmt : DecodeResult val let (decode_with_call, decode_with_result_var) = { - // Decode.decodeWith : List U8, Decoder val fmt, fmt -> DecodeResult val | fmt implements DecoderFormatting + // Decode.decodeWith : List U8, Decoder val fmt, fmt -> DecodeResult val where fmt implements DecoderFormatting let decode_with_type = env.import_builtin_symbol_var(Symbol::DECODE_DECODE_WITH); // Decode.decodeWith : bytes, inner_decoder, fmt -> DecoderResult (List val) @@ -80,7 +80,7 @@ fn wrap_in_decode_custom_decode_with( )), ); - // List U8, Decoder val fmt, fmt -> DecodeResult val | fmt implements DecoderFormatting + // List U8, Decoder val fmt, fmt -> DecodeResult val where fmt implements DecoderFormatting // ~ bytes, Decoder (List elem) fmt, fmt -> DecoderResult (List val) env.unify(decode_with_type, this_decode_with_fn_var); @@ -169,7 +169,7 @@ fn wrap_in_decode_custom_decode_with( // Decode.custom \bytes, fmt -> Decode.decodeWith bytes inner_decoder fmt let (decode_custom_call, decoder_var) = { - // (List U8, fmt -> DecodeResult val) -> Decoder val fmt | fmt implements DecoderFormatting + // (List U8, fmt -> DecodeResult val) -> Decoder val fmt where fmt implements DecoderFormatting let decode_custom_type = env.import_builtin_symbol_var(Symbol::DECODE_CUSTOM); // (List U8, fmt -> DecodeResult (List elem)) -> Decoder (List elem) fmt @@ -185,7 +185,7 @@ fn wrap_in_decode_custom_decode_with( )), ); - // (List U8, fmt -> DecodeResult val) -> Decoder val fmt | fmt implements DecoderFormatting + // (List U8, fmt -> DecodeResult val) -> Decoder val fmt where fmt implements DecoderFormatting // ~ (List U8, fmt -> DecodeResult (List elem)) -> Decoder (List elem) fmt env.unify(decode_custom_type, this_decode_custom_fn_var); diff --git a/crates/compiler/derive/src/decoding/list.rs b/crates/compiler/derive/src/decoding/list.rs index 59fe3e091b..ed2cd66de8 100644 --- a/crates/compiler/derive/src/decoding/list.rs +++ b/crates/compiler/derive/src/decoding/list.rs @@ -15,7 +15,7 @@ use crate::util::Env; pub(crate) fn decoder(env: &mut Env<'_>, _def_symbol: Symbol) -> (Expr, Variable) { // Build // - // def_symbol : Decoder (List elem) fmt | elem implements Decoding, fmt implements DecoderFormatting + // def_symbol : Decoder (List elem) fmt where elem implements Decoding, fmt implements DecoderFormatting // def_symbol = Decode.custom \bytes, fmt -> Decode.decodeWith bytes (Decode.list Decode.decoder) fmt // // NB: reduction to `Decode.list Decode.decoder` is not possible to the HRR. @@ -27,10 +27,10 @@ pub(crate) fn decoder(env: &mut Env<'_>, _def_symbol: Symbol) -> (Expr, Variable // List elem let elem_var = env.subs.fresh_unnamed_flex_var(); - // Decode.decoder : Decoder elem fmt | elem implements Decoding, fmt implements EncoderFormatting + // Decode.decoder : Decoder elem fmt where elem implements Decoding, fmt implements EncoderFormatting let (elem_decoder, elem_decoder_var) = { // build `Decode.decoder : Decoder elem fmt` type - // Decoder val fmt | val implements Decoding, fmt implements EncoderFormatting + // Decoder val fmt where val implements Decoding, fmt implements EncoderFormatting let elem_decoder_var = env.import_builtin_symbol_var(Symbol::DECODE_DECODER); // set val ~ elem @@ -52,7 +52,7 @@ pub(crate) fn decoder(env: &mut Env<'_>, _def_symbol: Symbol) -> (Expr, Variable }; // Build `Decode.list Decode.decoder` type - // Decoder val fmt -[uls]-> Decoder (List val) fmt | fmt implements DecoderFormatting + // Decoder val fmt -[uls]-> Decoder (List val) fmt where fmt implements DecoderFormatting let decode_list_fn_var = env.import_builtin_symbol_var(Symbol::DECODE_LIST); // Decoder elem fmt -a-> b @@ -68,7 +68,7 @@ pub(crate) fn decoder(env: &mut Env<'_>, _def_symbol: Symbol) -> (Expr, Variable )), ); - // Decoder val fmt -[uls]-> Decoder (List val) fmt | fmt implements DecoderFormatting + // Decoder val fmt -[uls]-> Decoder (List val) fmt where fmt implements DecoderFormatting // ~ Decoder elem fmt -a -> b env.unify(decode_list_fn_var, this_decode_list_fn_var); diff --git a/crates/compiler/derive/src/decoding/record.rs b/crates/compiler/derive/src/decoding/record.rs index 8549df9f7d..adc0196002 100644 --- a/crates/compiler/derive/src/decoding/record.rs +++ b/crates/compiler/derive/src/decoding/record.rs @@ -27,7 +27,7 @@ use super::wrap_in_decode_custom_decode_with; /// we'd like to generate an impl like /// /// ```roc -/// decoder : Decoder {first: a, second: b} fmt | a implements Decoding, b implements Decoding, fmt implements DecoderFormatting +/// decoder : Decoder {first: a, second: b} fmt where a implements Decoding, b implements Decoding, fmt implements DecoderFormatting /// decoder = /// initialState : {f0: Result a [NoField], f1: Result b [NoField]} /// initialState = {f0: Err NoField, f1: Err NoField} diff --git a/crates/compiler/derive/src/decoding/tuple.rs b/crates/compiler/derive/src/decoding/tuple.rs index 15e9666427..a327bdfded 100644 --- a/crates/compiler/derive/src/decoding/tuple.rs +++ b/crates/compiler/derive/src/decoding/tuple.rs @@ -28,7 +28,7 @@ use super::wrap_in_decode_custom_decode_with; /// we'd like to generate an impl like /// /// ```roc -/// decoder : Decoder (a, b) fmt | a implements Decoding, b implements Decoding, fmt implements DecoderFormatting +/// decoder : Decoder (a, b) fmt where a implements Decoding, b implements Decoding, fmt implements DecoderFormatting /// decoder = /// initialState : {e0: Result a [NoElem], e1: Result b [NoElem]} /// initialState = {e0: Err NoElem, e1: Err NoElem} diff --git a/crates/compiler/derive/src/encoding.rs b/crates/compiler/derive/src/encoding.rs index 959d8a8a43..ccade76936 100644 --- a/crates/compiler/derive/src/encoding.rs +++ b/crates/compiler/derive/src/encoding.rs @@ -121,7 +121,7 @@ fn to_encoder_list(env: &mut Env<'_>, fn_name: Symbol) -> (Expr, Variable) { ); // build `toEncoder elem` type - // val -[uls]-> Encoder fmt | fmt implements EncoderFormatting + // val -[uls]-> Encoder fmt where fmt implements EncoderFormatting let to_encoder_fn_var = env.import_builtin_symbol_var(Symbol::ENCODE_TO_ENCODER); // elem -[clos]-> t1 @@ -136,11 +136,11 @@ fn to_encoder_list(env: &mut Env<'_>, fn_name: Symbol) -> (Expr, Variable) { )), ); - // val -[uls]-> Encoder fmt | fmt implements EncoderFormatting + // val -[uls]-> Encoder fmt where fmt implements EncoderFormatting // ~ elem -[clos]-> t1 env.unify(to_encoder_fn_var, elem_to_encoder_fn_var); - // toEncoder : (typeof rcd.a) -[clos]-> Encoder fmt | fmt implements EncoderFormatting + // toEncoder : (typeof rcd.a) -[clos]-> Encoder fmt where fmt implements EncoderFormatting let to_encoder_var = AbilityMember(Symbol::ENCODE_TO_ENCODER, None, elem_to_encoder_fn_var); let to_encoder_fn = Box::new(( to_encoder_fn_var, @@ -201,7 +201,7 @@ fn to_encoder_list(env: &mut Env<'_>, fn_name: Symbol) -> (Expr, Variable) { }); // build `Encode.list lst (\elem -> Encode.toEncoder elem)` type - // List e, (e -> Encoder fmt) -[uls]-> Encoder fmt | fmt implements EncoderFormatting + // List e, (e -> Encoder fmt) -[uls]-> Encoder fmt where fmt implements EncoderFormatting let encode_list_fn_var = env.import_builtin_symbol_var(Symbol::ENCODE_LIST); // List elem, to_elem_encoder_fn_var -[clos]-> t1 @@ -218,11 +218,11 @@ fn to_encoder_list(env: &mut Env<'_>, fn_name: Symbol) -> (Expr, Variable) { )), ); - // List e, (e -> Encoder fmt) -[uls]-> Encoder fmt | fmt implements EncoderFormatting + // List e, (e -> Encoder fmt) -[uls]-> Encoder fmt where fmt implements EncoderFormatting // ~ List elem, to_elem_encoder_fn_var -[clos]-> t1 env.unify(encode_list_fn_var, this_encode_list_fn_var); - // Encode.list : List elem, to_elem_encoder_fn_var -[clos]-> Encoder fmt | fmt implements EncoderFormatting + // Encode.list : List elem, to_elem_encoder_fn_var -[clos]-> Encoder fmt where fmt implements EncoderFormatting let encode_list = AbilityMember(Symbol::ENCODE_LIST, None, this_encode_list_fn_var); let encode_list_fn = Box::new(( this_encode_list_fn_var, @@ -340,7 +340,7 @@ fn to_encoder_record( }; // build `toEncoder rcd.a` type - // val -[uls]-> Encoder fmt | fmt implements EncoderFormatting + // val -[uls]-> Encoder fmt where fmt implements EncoderFormatting let to_encoder_fn_var = env.import_builtin_symbol_var(Symbol::ENCODE_TO_ENCODER); // (typeof rcd.a) -[clos]-> t1 @@ -355,11 +355,11 @@ fn to_encoder_record( )), ); - // val -[uls]-> Encoder fmt | fmt implements EncoderFormatting + // val -[uls]-> Encoder fmt where fmt implements EncoderFormatting // ~ (typeof rcd.a) -[clos]-> t1 env.unify(to_encoder_fn_var, this_to_encoder_fn_var); - // toEncoder : (typeof rcd.a) -[clos]-> Encoder fmt | fmt implements EncoderFormatting + // toEncoder : (typeof rcd.a) -[clos]-> Encoder fmt where fmt implements EncoderFormatting let to_encoder_var = AbilityMember(Symbol::ENCODE_TO_ENCODER, None, to_encoder_fn_var); let to_encoder_fn = Box::new(( to_encoder_fn_var, @@ -420,7 +420,7 @@ fn to_encoder_record( }; // build `Encode.record [ { key: .., value: ..}, .. ]` type - // List { key : Str, value : Encoder fmt } -[uls]-> Encoder fmt | fmt implements EncoderFormatting + // List { key : Str, value : Encoder fmt } -[uls]-> Encoder fmt where fmt implements EncoderFormatting let encode_record_fn_var = env.import_builtin_symbol_var(Symbol::ENCODE_RECORD); // fields_list_var -[clos]-> t1 @@ -437,11 +437,11 @@ fn to_encoder_record( )), ); - // List { key : Str, value : Encoder fmt } -[uls]-> Encoder fmt | fmt implements EncoderFormatting + // List { key : Str, value : Encoder fmt } -[uls]-> Encoder fmt where fmt implements EncoderFormatting // ~ fields_list_var -[clos]-> t1 env.unify(encode_record_fn_var, this_encode_record_fn_var); - // Encode.record : fields_list_var -[clos]-> Encoder fmt | fmt implements EncoderFormatting + // Encode.record : fields_list_var -[clos]-> Encoder fmt where fmt implements EncoderFormatting let encode_record_var = AbilityMember(Symbol::ENCODE_RECORD, None, encode_record_fn_var); let encode_record_fn = Box::new(( encode_record_fn_var, @@ -543,7 +543,7 @@ fn to_encoder_tuple( }; // build `toEncoder tup.0` type - // val -[uls]-> Encoder fmt | fmt implements EncoderFormatting + // val -[uls]-> Encoder fmt where fmt implements EncoderFormatting let to_encoder_fn_var = env.import_builtin_symbol_var(Symbol::ENCODE_TO_ENCODER); // (typeof tup.0) -[clos]-> t1 @@ -558,11 +558,11 @@ fn to_encoder_tuple( )), ); - // val -[uls]-> Encoder fmt | fmt implements EncoderFormatting + // val -[uls]-> Encoder fmt where fmt implements EncoderFormatting // ~ (typeof tup.0) -[clos]-> t1 env.unify(to_encoder_fn_var, this_to_encoder_fn_var); - // toEncoder : (typeof tup.0) -[clos]-> Encoder fmt | fmt implements EncoderFormatting + // toEncoder : (typeof tup.0) -[clos]-> Encoder fmt where fmt implements EncoderFormatting let to_encoder_var = AbilityMember(Symbol::ENCODE_TO_ENCODER, None, to_encoder_fn_var); let to_encoder_fn = Box::new(( to_encoder_fn_var, @@ -603,7 +603,7 @@ fn to_encoder_tuple( }; // build `Encode.tuple [ toEncoder tup.0, toEncoder tup.1 ]` type - // List (Encoder fmt) -[uls]-> Encoder fmt | fmt implements EncoderFormatting + // List (Encoder fmt) -[uls]-> Encoder fmt where fmt implements EncoderFormatting let encode_tuple_fn_var = env.import_builtin_symbol_var(Symbol::ENCODE_TUPLE); // elem_encoders_list_var -[clos]-> t1 @@ -620,11 +620,11 @@ fn to_encoder_tuple( )), ); - // List (Encoder fmt) -[uls]-> Encoder fmt | fmt implements EncoderFormatting + // List (Encoder fmt) -[uls]-> Encoder fmt where fmt implements EncoderFormatting // ~ elem_encoders_list_var -[clos]-> t1 env.unify(encode_tuple_fn_var, this_encode_tuple_fn_var); - // Encode.tuple : elem_encoders_list_var -[clos]-> Encoder fmt | fmt implements EncoderFormatting + // Encode.tuple : elem_encoders_list_var -[clos]-> Encoder fmt where fmt implements EncoderFormatting let encode_tuple_var = AbilityMember(Symbol::ENCODE_TUPLE, None, encode_tuple_fn_var); let encode_tuple_fn = Box::new(( encode_tuple_fn_var, @@ -741,7 +741,7 @@ fn to_encoder_tag_union( .zip(payload_vars.iter()) .map(|(&sym, &sym_var)| { // build `toEncoder v1` type - // expected: val -[uls]-> Encoder fmt | fmt implements EncoderFormatting + // expected: val -[uls]-> Encoder fmt where fmt implements EncoderFormatting let to_encoder_fn_var = env.import_builtin_symbol_var(Symbol::ENCODE_TO_ENCODER); @@ -759,11 +759,11 @@ fn to_encoder_tag_union( )), ); - // val -[uls]-> Encoder fmt | fmt implements EncoderFormatting + // val -[uls]-> Encoder fmt where fmt implements EncoderFormatting // ~ t1 -[clos]-> t' env.unify(to_encoder_fn_var, this_to_encoder_fn_var); - // toEncoder : t1 -[clos]-> Encoder fmt | fmt implements EncoderFormatting + // toEncoder : t1 -[clos]-> Encoder fmt where fmt implements EncoderFormatting let to_encoder_var = AbilityMember(Symbol::ENCODE_TO_ENCODER, None, this_to_encoder_fn_var); let to_encoder_fn = Box::new(( @@ -802,7 +802,7 @@ fn to_encoder_tag_union( }; // build `Encode.tag "A" [ ... ]` type - // expected: Str, List (Encoder fmt) -[uls]-> Encoder fmt | fmt implements EncoderFormatting + // expected: Str, List (Encoder fmt) -[uls]-> Encoder fmt where fmt implements EncoderFormatting let encode_tag_fn_var = env.import_builtin_symbol_var(Symbol::ENCODE_TAG); // wanted: Str, List whole_encoders_var -[clos]-> t' @@ -821,11 +821,11 @@ fn to_encoder_tag_union( )), ); - // Str, List (Encoder fmt) -[uls]-> Encoder fmt | fmt implements EncoderFormatting + // Str, List (Encoder fmt) -[uls]-> Encoder fmt where fmt implements EncoderFormatting // ~ Str, List whole_encoders_var -[clos]-> t' env.unify(encode_tag_fn_var, this_encode_tag_fn_var); - // Encode.tag : Str, List whole_encoders_var -[clos]-> Encoder fmt | fmt implements EncoderFormatting + // Encode.tag : Str, List whole_encoders_var -[clos]-> Encoder fmt where fmt implements EncoderFormatting let encode_tag_var = AbilityMember(Symbol::ENCODE_TAG, None, this_encode_tag_fn_var); let encode_tag_fn = Box::new(( this_encode_tag_fn_var, @@ -954,15 +954,15 @@ fn wrap_in_encode_custom( let bytes_sym = env.new_symbol("bytes"); let bytes_var = Variable::LIST_U8; - // fmt: fmt | fmt implements EncoderFormatting + // fmt: fmt where fmt implements EncoderFormatting let fmt_sym = env.new_symbol("fmt"); let fmt_var = env.subs.fresh_unnamed_flex_var(); // build `Encode.appendWith bytes encoder fmt` type - // expected: Encode.appendWith : List U8, Encoder fmt, fmt -[appendWith]-> List U8 | fmt implements EncoderFormatting + // expected: Encode.appendWith : List U8, Encoder fmt, fmt -[appendWith]-> List U8 where fmt implements EncoderFormatting let append_with_fn_var = env.import_builtin_symbol_var(Symbol::ENCODE_APPEND_WITH); - // wanted: Encode.appendWith : List U8, encoder_var, fmt -[clos]-> List U8 | fmt implements EncoderFormatting + // wanted: Encode.appendWith : List U8, encoder_var, fmt -[clos]-> List U8 where fmt implements EncoderFormatting let this_append_with_args_var_slice = VariableSubsSlice::insert_into_subs(env.subs, [Variable::LIST_U8, encoder_var, fmt_var]); let this_append_with_clos_var = env.subs.fresh_unnamed_flex_var(); // -[clos]-> @@ -975,11 +975,11 @@ fn wrap_in_encode_custom( )), ); - // List U8, Encoder fmt, fmt -[appendWith]-> List U8 | fmt implements EncoderFormatting - // ~ List U8, encoder_var, fmt -[clos]-> List U8 | fmt implements EncoderFormatting + // List U8, Encoder fmt, fmt -[appendWith]-> List U8 where fmt implements EncoderFormatting + // ~ List U8, encoder_var, fmt -[clos]-> List U8 where fmt implements EncoderFormatting env.unify(append_with_fn_var, this_append_with_fn_var); - // Encode.appendWith : List U8, encoder_var, fmt -[appendWith]-> List U8 | fmt implements EncoderFormatting + // Encode.appendWith : List U8, encoder_var, fmt -[appendWith]-> List U8 where fmt implements EncoderFormatting let append_with_fn = Box::new(( this_append_with_fn_var, Loc::at_zero(Var(Symbol::ENCODE_APPEND_WITH, this_append_with_fn_var)), @@ -1050,7 +1050,7 @@ fn wrap_in_encode_custom( // Build // Encode.custom \bytes, fmt -> Encode.appendWith bytes encoder fmt // - // expected: Encode.custom : (List U8, fmt -> List U8) -> Encoder fmt | fmt implements EncoderFormatting + // expected: Encode.custom : (List U8, fmt -> List U8) -> Encoder fmt where fmt implements EncoderFormatting let custom_fn_var = env.import_builtin_symbol_var(Symbol::ENCODE_CUSTOM); // wanted: Encode.custom : fn_var -[clos]-> t' @@ -1066,11 +1066,11 @@ fn wrap_in_encode_custom( )), ); - // (List U8, fmt -> List U8) -[..]-> Encoder fmt | fmt implements EncoderFormatting + // (List U8, fmt -> List U8) -[..]-> Encoder fmt where fmt implements EncoderFormatting // ~ fn_var -[clos]-> t' env.unify(custom_fn_var, this_custom_fn_var); - // Encode.custom : (List U8, fmt -> List U8) -> Encoder fmt | fmt implements EncoderFormatting + // Encode.custom : (List U8, fmt -> List U8) -> Encoder fmt where fmt implements EncoderFormatting let custom_fn = Box::new(( this_custom_fn_var, Loc::at_zero(Var(Symbol::ENCODE_CUSTOM, this_custom_fn_var)), diff --git a/crates/compiler/derive/src/hash.rs b/crates/compiler/derive/src/hash.rs index d0fff82cee..0580f16a3b 100644 --- a/crates/compiler/derive/src/hash.rs +++ b/crates/compiler/derive/src/hash.rs @@ -75,7 +75,7 @@ fn hash_record(env: &mut Env<'_>, fn_name: Symbol, fields: Vec) -> (V // Now, a hasher for this record is // - // hash_rcd : hasher, { f1: t1, ..., fn: tn } -> hasher | hasher implements Hasher + // hash_rcd : hasher, { f1: t1, ..., fn: tn } -> hasher where hasher implements Hasher // hash_rcd = \hasher, rcd -> // Hash.hash ( // Hash.hash @@ -144,7 +144,7 @@ fn hash_tuple(env: &mut Env<'_>, fn_name: Symbol, arity: u32) -> (Variable, Expr // Now, a hasher for this tuple is // - // hash_tup : hasher, (t1, ..., tn) -> hasher | hasher implements Hasher + // hash_tup : hasher, (t1, ..., tn) -> hasher where hasher implements Hasher // hash_tup = \hasher, tup -> // Hash.hash ( // Hash.hash @@ -227,7 +227,7 @@ fn hash_tag_union( // Now, a hasher for this tag union is // - // hash_union : hasher, [ A t11 .. t1n, ..., Q tq1 .. tqm ] -> hasher | hasher implements Hasher + // hash_union : hasher, [ A t11 .. t1n, ..., Q tq1 .. tqm ] -> hasher where hasher implements Hasher // hash_union = \hasher, union -> // when union is // A x11 .. x1n -> Hash.hash (... (Hash.hash (Hash.uN hasher 0) x11) ...) x1n @@ -393,7 +393,7 @@ fn hash_newtype_tag_union( // Now, a hasher for this tag union is // - // hash_union : hasher, [ A t1 .. tn ] -> hasher | hasher implements Hasher + // hash_union : hasher, [ A t1 .. tn ] -> hasher where hasher implements Hasher // hash_union = \hasher, A x1 .. xn -> // Hash.hash (... (Hash.hash discrHasher x1) ...) xn let hasher_sym = env.new_symbol("hasher"); @@ -462,7 +462,7 @@ fn call_hash_ability_member( // build `member ...` function type. `member` here is `Hash.hash` or `Hash.addU16`. // - // hasher, val -[uls]-> hasher | hasher implements Hasher, val implements Hash + // hasher, val -[uls]-> hasher where hasher implements Hasher, val implements Hash let exposed_hash_fn_var = env.import_builtin_symbol_var(member); // (typeof body), (typeof field) -[clos]-> hasher_result @@ -479,11 +479,11 @@ fn call_hash_ability_member( )), ); - // hasher, val -[uls]-> hasher | hasher implements Hasher, val implements Hash + // hasher, val -[uls]-> hasher where hasher implements Hasher, val implements Hash // ~ (typeof body), (typeof field) -[clos]-> hasher_result env.unify(exposed_hash_fn_var, this_hash_fn_var); - // Hash.hash : hasher, (typeof field) -[clos]-> hasher | hasher implements Hasher, (typeof field) implements Hash + // Hash.hash : hasher, (typeof field) -[clos]-> hasher where hasher implements Hasher, (typeof field) implements Hash let hash_fn_head = Expr::AbilityMember(member, None, this_hash_fn_var); let hash_fn_data = Box::new(( this_hash_fn_var, diff --git a/crates/compiler/derive/src/util.rs b/crates/compiler/derive/src/util.rs index 1dfc38f89f..8403866721 100644 --- a/crates/compiler/derive/src/util.rs +++ b/crates/compiler/derive/src/util.rs @@ -130,7 +130,7 @@ impl Env<'_> { }) .collect(); - // Since we're doing `{foo} ~ a | a implements Encoding`, we may see "lambda sets to + // Since we're doing `{foo} ~ a where a implements Encoding`, we may see "lambda sets to // specialize" for e.g. `{foo}:toEncoder:1`, but these are actually just the // specialization lambda sets, so we don't need to do any extra work! // diff --git a/crates/compiler/fmt/src/annotation.rs b/crates/compiler/fmt/src/annotation.rs index 472ff3ed9c..56762d9c31 100644 --- a/crates/compiler/fmt/src/annotation.rs +++ b/crates/compiler/fmt/src/annotation.rs @@ -350,16 +350,23 @@ impl<'a> Formattable for TypeAnnotation<'a> { } } - Where(annot, has_clauses) => { + Where(annot, implements_clauses) => { annot.format_with_options(buf, parens, newlines, indent); - if has_clauses.iter().any(|has| has.is_multiline()) { + if implements_clauses + .iter() + .any(|implements| implements.is_multiline()) + { buf.newline(); buf.indent(indent); } else { buf.spaces(1); } - for (i, has) in has_clauses.iter().enumerate() { - buf.push(if i == 0 { '|' } else { ',' }); + for (i, has) in implements_clauses.iter().enumerate() { + buf.push_str(if i == 0 { + roc_parse::keyword::WHERE + } else { + "," + }); buf.spaces(1); has.format_with_options(buf, parens, newlines, indent); } diff --git a/crates/compiler/fmt/src/def.rs b/crates/compiler/fmt/src/def.rs index c71d327d9c..a391b11f49 100644 --- a/crates/compiler/fmt/src/def.rs +++ b/crates/compiler/fmt/src/def.rs @@ -133,7 +133,7 @@ impl<'a> Formattable for TypeDef<'a> { fmt_pattern(buf, &var.value, indent, Parens::NotNeeded); buf.indent(indent); } - buf.push(' '); + buf.spaces(1); buf.push_str(roc_parse::keyword::IMPLEMENTS); if !self.is_multiline() { diff --git a/crates/compiler/load_internal/src/file.rs b/crates/compiler/load_internal/src/file.rs index 81d5b48a5c..31cef9057f 100644 --- a/crates/compiler/load_internal/src/file.rs +++ b/crates/compiler/load_internal/src/file.rs @@ -3171,7 +3171,7 @@ fn update<'a>( // # Default module // interface Default exposes [default, getDefault] // - // Default implements default : {} -> a | a implements Default + // Default implements default : {} -> a where a implements Default // // getDefault = \{} -> default {} // diff --git a/crates/compiler/load_internal/tests/fixtures/build/interface_with_deps/AStar.roc b/crates/compiler/load_internal/tests/fixtures/build/interface_with_deps/AStar.roc index 155d9ec804..b9b44ddbd6 100644 --- a/crates/compiler/load_internal/tests/fixtures/build/interface_with_deps/AStar.roc +++ b/crates/compiler/load_internal/tests/fixtures/build/interface_with_deps/AStar.roc @@ -13,7 +13,7 @@ Model position : } -initialModel : position -> Model position | position implements Hash & Eq +initialModel : position -> Model position where position implements Hash & Eq initialModel = \start -> { evaluated : Set.empty {} , openSet : Set.single start @@ -22,7 +22,7 @@ initialModel = \start -> } -cheapestOpen : (position -> F64), Model position -> Result position [KeyNotFound] | position implements Hash & Eq +cheapestOpen : (position -> F64), Model position -> Result position [KeyNotFound] where position implements Hash & Eq cheapestOpen = \costFunction, model -> folder = \resSmallestSoFar, position -> @@ -47,7 +47,7 @@ cheapestOpen = \costFunction, model -> -reconstructPath : Dict position position, position -> List position | position implements Hash & Eq +reconstructPath : Dict position position, position -> List position where position implements Hash & Eq reconstructPath = \cameFrom, goal -> when Dict.get cameFrom goal is Err KeyNotFound -> @@ -56,7 +56,7 @@ reconstructPath = \cameFrom, goal -> Ok next -> List.append (reconstructPath cameFrom next) goal -updateCost : position, position, Model position -> Model position | position implements Hash & Eq +updateCost : position, position, Model position -> Model position where position implements Hash & Eq updateCost = \current, neighbour, model -> newCameFrom = Dict.insert model.cameFrom neighbour current @@ -80,12 +80,12 @@ updateCost = \current, neighbour, model -> model -findPath : { costFunction: (position, position -> F64), moveFunction: (position -> Set position), start : position, end : position } -> Result (List position) [KeyNotFound] | position implements Hash & Eq +findPath : { costFunction: (position, position -> F64), moveFunction: (position -> Set position), start : position, end : position } -> Result (List position) [KeyNotFound] where position implements Hash & Eq findPath = \{ costFunction, moveFunction, start, end } -> astar costFunction moveFunction end (initialModel start) -astar : (position, position -> F64), (position -> Set position), position, Model position -> [Err [KeyNotFound], Ok (List position)] | position implements Hash & Eq +astar : (position, position -> F64), (position -> Set position), position, Model position -> [Err [KeyNotFound], Ok (List position)] where position implements Hash & Eq astar = \costFn, moveFn, goal, model -> when cheapestOpen (\position -> costFn goal position) model is Err _ -> diff --git a/crates/compiler/load_internal/tests/test_load.rs b/crates/compiler/load_internal/tests/test_load.rs index 7aa625372d..5a770d0cb4 100644 --- a/crates/compiler/load_internal/tests/test_load.rs +++ b/crates/compiler/load_internal/tests/test_load.rs @@ -491,12 +491,12 @@ fn load_astar() { expect_types( loaded_module, hashmap! { - "findPath" => "{ costFunction : position, position -> F64, end : position, moveFunction : position -> Set position, start : position } -> Result (List position) [KeyNotFound] | position implements Hash & Eq", - "initialModel" => "position -> Model position | position implements Hash & Eq", - "reconstructPath" => "Dict position position, position -> List position | position implements Hash & Eq", - "updateCost" => "position, position, Model position -> Model position | position implements Hash & Eq", - "cheapestOpen" => "(position -> F64), Model position -> Result position [KeyNotFound] | position implements Hash & Eq", - "astar" => "(position, position -> F64), (position -> Set position), position, Model position -> [Err [KeyNotFound], Ok (List position)] | position implements Hash & Eq", + "findPath" => "{ costFunction : position, position -> F64, end : position, moveFunction : position -> Set position, start : position } -> Result (List position) [KeyNotFound] where position implements Hash & Eq", + "initialModel" => "position -> Model position where position implements Hash & Eq", + "reconstructPath" => "Dict position position, position -> List position where position implements Hash & Eq", + "updateCost" => "position, position, Model position -> Model position where position implements Hash & Eq", + "cheapestOpen" => "(position -> F64), Model position -> Result position [KeyNotFound] where position implements Hash & Eq", + "astar" => "(position, position -> F64), (position -> Set position), position, Model position -> [Err [KeyNotFound], Ok (List position)] where position implements Hash & Eq", }, ); } diff --git a/crates/compiler/parse/src/ast.rs b/crates/compiler/parse/src/ast.rs index 88e6db4210..662d5de071 100644 --- a/crates/compiler/parse/src/ast.rs +++ b/crates/compiler/parse/src/ast.rs @@ -365,7 +365,7 @@ pub enum Implements<'a> { SpaceAfter(&'a Implements<'a>, &'a [CommentOrNewline<'a>]), } -/// An ability demand is a value defining the ability; for example `hash : a -> U64 | a implements Hash` +/// An ability demand is a value defining the ability; for example `hash : a -> U64 where a implements Hash` /// for a `Hash` ability. #[derive(Debug, Clone, Copy, PartialEq)] pub struct AbilityMember<'a> { @@ -399,7 +399,7 @@ pub enum TypeDef<'a> { /// An ability definition. E.g. /// Hash implements - /// hash : a -> U64 | a implements Hash + /// hash : a -> U64 where a implements Hash Ability { header: TypeHeader<'a>, loc_implements: Loc>, @@ -641,7 +641,7 @@ pub enum TypeAnnotation<'a> { /// The `*` type variable, e.g. in (List *) Wildcard, - /// A "where" clause demanding abilities designated by a `|`, e.g. `a -> U64 | a implements Hash` + /// A "where" clause demanding abilities designated by a `where`, e.g. `a -> U64 where a implements Hash` Where(&'a Loc>, &'a [Loc>]), // We preserve this for the formatter; canonicalization ignores it. diff --git a/crates/compiler/parse/src/keyword.rs b/crates/compiler/parse/src/keyword.rs index e37f0c5e5c..102fd43a7c 100644 --- a/crates/compiler/parse/src/keyword.rs +++ b/crates/compiler/parse/src/keyword.rs @@ -14,4 +14,6 @@ pub const CRASH: &str = "crash"; pub const IMPLEMENTS: &str = "implements"; pub const WHERE: &str = "where"; -pub const KEYWORDS: [&str; 10] = [IF, THEN, ELSE, WHEN, AS, IS, DBG, EXPECT, EXPECT_FX, CRASH]; +pub const KEYWORDS: [&str; 11] = [ + IF, THEN, ELSE, WHEN, AS, IS, DBG, EXPECT, EXPECT_FX, CRASH, WHERE, +]; diff --git a/crates/compiler/parse/src/type_annotation.rs b/crates/compiler/parse/src/type_annotation.rs index a0fab6842f..6f33073a66 100644 --- a/crates/compiler/parse/src/type_annotation.rs +++ b/crates/compiler/parse/src/type_annotation.rs @@ -479,14 +479,16 @@ fn implements_clause<'a>() -> impl Parser<'a, Loc>, EType<' ) } -/// Parse a chain of `implements` clauses, e.g. " | a implements Hash, b implements Eq". -/// Returns the clauses and spaces before the starting "|", if there were any. +/// Parse a chain of `implements` clauses, e.g. " where a implements Hash, b implements Eq". +/// Returns the clauses and spaces before the starting "where", if there were any. fn implements_clause_chain<'a>( ) -> impl Parser<'a, (&'a [CommentOrNewline<'a>], &'a [Loc>]), EType<'a>> { move |arena, state: State<'a>, min_indent: u32| { - let (_, (spaces_before, ()), state) = - and!(space0_e(EType::TIndentStart), word1(b'|', EType::TWhereBar)) - .parse(arena, state, min_indent)?; + let (_, (spaces_before, ()), state) = and!( + space0_e(EType::TIndentStart), + word(crate::keyword::WHERE, EType::TWhereBar) + ) + .parse(arena, state, min_indent)?; // Parse the first clause (there must be one), then the rest let (_, first_clause, state) = implements_clause().parse(arena, state, min_indent)?; @@ -645,11 +647,12 @@ fn expression<'a>( // Finally, try to parse a where clause if there is one. // The where clause must be at least as deep as where the type annotation started. match implements_clause_chain().parse(arena, state.clone(), min_indent) { - Ok((where_progress, (spaces_before, has_chain), state)) => { - let region = Region::span_across(&annot.region, &has_chain.last().unwrap().region); + Ok((where_progress, (spaces_before, implements_chain), state)) => { + let region = + Region::span_across(&annot.region, &implements_chain.last().unwrap().region); let type_annot = if !spaces_before.is_empty() { - // We're transforming the spaces_before the '|' - // into spaces_after the thing before the '|' + // We're transforming the spaces_before the 'where' + // into spaces_after the thing before the 'where' let spaced = arena .alloc(annot.value) .with_spaces_after(spaces_before, annot.region); @@ -657,7 +660,7 @@ fn expression<'a>( } else { &*arena.alloc(annot) }; - let where_annot = TypeAnnotation::Where(type_annot, has_chain); + let where_annot = TypeAnnotation::Where(type_annot, implements_chain); Ok(( where_progress.or(progress), Loc::at(region, where_annot), diff --git a/crates/compiler/solve/src/ability.rs b/crates/compiler/solve/src/ability.rs index 633cdc3110..170e951f37 100644 --- a/crates/compiler/solve/src/ability.rs +++ b/crates/compiler/solve/src/ability.rs @@ -739,7 +739,7 @@ trait DerivableVisitor { ) { // TODO: currently, just we suppose the presence of a flex var may // include more or less things which we can derive. But, we should - // instead recurse here, and add a `t ~ u | u implements Decode` constraint as needed. + // instead recurse here, and add a `t ~ u where u implements Decode` constraint as needed. stack.push(ext); } } diff --git a/crates/compiler/solve/src/solve.rs b/crates/compiler/solve/src/solve.rs index 72d1d3bfef..6962907544 100644 --- a/crates/compiler/solve/src/solve.rs +++ b/crates/compiler/solve/src/solve.rs @@ -2510,7 +2510,7 @@ impl AmbientFunctionPolicy { }), Content::FlexVar(_) => { // Something like - // Encoder fmt : List U8, fmt -a-> List U8 | fmt implements EncoderFormatting + // Encoder fmt : List U8, fmt -a-> List U8 where fmt implements EncoderFormatting // THEORY: Replace these with empty lambda sets. They will unify the same as a flex // var does, but allows us to record the ambient function properly. Content::LambdaSet(LambdaSet { diff --git a/crates/compiler/solve/tests/solve_expr.rs b/crates/compiler/solve/tests/solve_expr.rs index 444b7b59bc..c5e0065c32 100644 --- a/crates/compiler/solve/tests/solve_expr.rs +++ b/crates/compiler/solve/tests/solve_expr.rs @@ -3150,7 +3150,7 @@ mod solve_expr { Dict.insert "# ), - "Dict k v, k, v -> Dict k v | k implements Hash & Eq", + "Dict k v, k, v -> Dict k v where k implements Hash & Eq", ); } @@ -3411,7 +3411,7 @@ mod solve_expr { infer_eq_without_problem( indoc!( r#" - reconstructPath : Dict position position, position -> List position | position implements Hash & Eq + reconstructPath : Dict position position, position -> List position where position implements Hash & Eq reconstructPath = \cameFrom, goal -> when Dict.get cameFrom goal is Err KeyNotFound -> @@ -3423,7 +3423,7 @@ mod solve_expr { reconstructPath "# ), - "Dict position position, position -> List position | position implements Hash & Eq", + "Dict position position, position -> List position where position implements Hash & Eq", ); } @@ -3458,7 +3458,7 @@ mod solve_expr { Model position : { openSet : Set position } - cheapestOpen : Model position -> Result position [KeyNotFound] | position implements Hash & Eq + cheapestOpen : Model position -> Result position [KeyNotFound] where position implements Hash & Eq cheapestOpen = \model -> folder = \resSmallestSoFar, position -> @@ -3473,14 +3473,14 @@ mod solve_expr { Set.walk model.openSet (Ok { position: boom {}, cost: 0.0 }) folder |> Result.map (\x -> x.position) - astar : Model position -> Result position [KeyNotFound] | position implements Hash & Eq + astar : Model position -> Result position [KeyNotFound] where position implements Hash & Eq astar = \model -> cheapestOpen model main = astar "# ), - "Model position -> Result position [KeyNotFound] | position implements Hash & Eq", + "Model position -> Result position [KeyNotFound] where position implements Hash & Eq", ); } @@ -4122,7 +4122,7 @@ mod solve_expr { Key k : Num k - removeHelpEQGT : Key k, RBTree (Key k) v -> RBTree (Key k) v | k implements Hash & Eq + removeHelpEQGT : Key k, RBTree (Key k) v -> RBTree (Key k) v where k implements Hash & Eq removeHelpEQGT = \targetKey, dict -> when dict is Node color key value left right -> @@ -4236,7 +4236,7 @@ mod solve_expr { _ -> Empty - removeHelp : Key k, RBTree (Key k) v -> RBTree (Key k) v | k implements Hash & Eq + removeHelp : Key k, RBTree (Key k) v -> RBTree (Key k) v where k implements Hash & Eq removeHelp = \targetKey, dict -> when dict is Empty -> @@ -4324,7 +4324,7 @@ mod solve_expr { RBTree k v : [Node NodeColor k v (RBTree k v) (RBTree k v), Empty] - removeHelp : Num k, RBTree (Num k) v -> RBTree (Num k) v | k implements Hash & Eq + removeHelp : Num k, RBTree (Num k) v -> RBTree (Num k) v where k implements Hash & Eq removeHelp = \targetKey, dict -> when dict is Empty -> @@ -4359,7 +4359,7 @@ mod solve_expr { removeHelpPrepEQGT : Key k, RBTree (Key k) v, NodeColor, (Key k), v, RBTree (Key k) v, RBTree (Key k) v -> RBTree (Key k) v - removeHelpEQGT : Key k, RBTree (Key k) v -> RBTree (Key k) v | k implements Hash & Eq + removeHelpEQGT : Key k, RBTree (Key k) v -> RBTree (Key k) v where k implements Hash & Eq removeHelpEQGT = \targetKey, dict -> when dict is Node color key value left right -> diff --git a/crates/compiler/test_derive/src/decoding.rs b/crates/compiler/test_derive/src/decoding.rs index b9c024ec66..edba290303 100644 --- a/crates/compiler/test_derive/src/decoding.rs +++ b/crates/compiler/test_derive/src/decoding.rs @@ -106,8 +106,8 @@ fn list() { derive_test(Decoder, v!(Symbol::LIST_LIST v!(STR)), |golden| { assert_snapshot!(golden, @r###" # derived for List Str - # Decoder (List val) fmt | fmt implements DecoderFormatting, val implements Decoding - # List U8, fmt -[[custom(3)]]-> { rest : List U8, result : [Err [TooShort], Ok (List val)] } | fmt implements DecoderFormatting, val implements Decoding + # Decoder (List val) fmt where fmt implements DecoderFormatting, val implements Decoding + # List U8, fmt -[[custom(3)]]-> { rest : List U8, result : [Err [TooShort], Ok (List val)] } where fmt implements DecoderFormatting, val implements Decoding # Specialization lambda sets: # @<1>: [[custom(3)]] #Derived.decoder_list = @@ -124,8 +124,8 @@ fn record_2_fields() { derive_test(Decoder, v!({first: v!(STR), second: v!(STR),}), |golden| { assert_snapshot!(golden, @r###" # derived for { first : Str, second : Str } - # Decoder { first : val, second : val1 } fmt | fmt implements DecoderFormatting, val implements Decoding, val1 implements Decoding - # List U8, fmt -[[custom(22)]]-> { rest : List U8, result : [Err [TooShort], Ok { first : val, second : val1 }] } | fmt implements DecoderFormatting, val implements Decoding, val1 implements Decoding + # Decoder { first : val, second : val1 } fmt where fmt implements DecoderFormatting, val implements Decoding, val1 implements Decoding + # List U8, fmt -[[custom(22)]]-> { rest : List U8, result : [Err [TooShort], Ok { first : val, second : val1 }] } where fmt implements DecoderFormatting, val implements Decoding, val1 implements Decoding # Specialization lambda sets: # @<1>: [[custom(22)]] #Derived.decoder_{first,second} = @@ -181,8 +181,8 @@ fn tuple_2_fields() { derive_test(Decoder, v!((v!(STR), v!(U8),)), |golden| { assert_snapshot!(golden, @r###" # derived for ( Str, U8 )* - # Decoder ( val, val1 )* fmt | fmt implements DecoderFormatting, val implements Decoding, val1 implements Decoding - # List U8, fmt -[[custom(22)]]-> { rest : List U8, result : [Err [TooShort], Ok ( val, val1 )a] } | fmt implements DecoderFormatting, val implements Decoding, val1 implements Decoding + # Decoder ( val, val1 )* fmt where fmt implements DecoderFormatting, val implements Decoding, val1 implements Decoding + # List U8, fmt -[[custom(22)]]-> { rest : List U8, result : [Err [TooShort], Ok ( val, val1 )a] } where fmt implements DecoderFormatting, val implements Decoding, val1 implements Decoding # Specialization lambda sets: # @<1>: [[custom(22)]] #Derived.decoder_(arity:2) = diff --git a/crates/compiler/test_derive/src/encoding.rs b/crates/compiler/test_derive/src/encoding.rs index 481ab8ff7a..8274062059 100644 --- a/crates/compiler/test_derive/src/encoding.rs +++ b/crates/compiler/test_derive/src/encoding.rs @@ -188,8 +188,8 @@ fn empty_record() { derive_test(ToEncoder, v!(EMPTY_RECORD), |golden| { assert_snapshot!(golden, @r###" # derived for {} - # {} -[[toEncoder_{}(0)]]-> Encoder fmt | fmt implements EncoderFormatting - # {} -[[toEncoder_{}(0)]]-> (List U8, fmt -[[custom(2) {}]]-> List U8) | fmt implements EncoderFormatting + # {} -[[toEncoder_{}(0)]]-> Encoder fmt where fmt implements EncoderFormatting + # {} -[[toEncoder_{}(0)]]-> (List U8, fmt -[[custom(2) {}]]-> List U8) where fmt implements EncoderFormatting # Specialization lambda sets: # @<1>: [[toEncoder_{}(0)]] # @<2>: [[custom(2) {}]] @@ -208,8 +208,8 @@ fn zero_field_record() { derive_test(ToEncoder, v!({}), |golden| { assert_snapshot!(golden, @r###" # derived for {} - # {} -[[toEncoder_{}(0)]]-> Encoder fmt | fmt implements EncoderFormatting - # {} -[[toEncoder_{}(0)]]-> (List U8, fmt -[[custom(2) {}]]-> List U8) | fmt implements EncoderFormatting + # {} -[[toEncoder_{}(0)]]-> Encoder fmt where fmt implements EncoderFormatting + # {} -[[toEncoder_{}(0)]]-> (List U8, fmt -[[custom(2) {}]]-> List U8) where fmt implements EncoderFormatting # Specialization lambda sets: # @<1>: [[toEncoder_{}(0)]] # @<2>: [[custom(2) {}]] @@ -228,11 +228,11 @@ fn one_field_record() { derive_test(ToEncoder, v!({ a: v!(U8), }), |golden| { assert_snapshot!(golden, @r###" # derived for { a : U8 } - # { a : val } -[[toEncoder_{a}(0)]]-> Encoder fmt | fmt implements EncoderFormatting, val implements Encoding - # { a : val } -[[toEncoder_{a}(0)]]-> (List U8, fmt -[[custom(2) { a : val }]]-> List U8) | fmt implements EncoderFormatting, val implements Encoding + # { a : val } -[[toEncoder_{a}(0)]]-> Encoder fmt where fmt implements EncoderFormatting, val implements Encoding + # { a : val } -[[toEncoder_{a}(0)]]-> (List U8, fmt -[[custom(2) { a : val }]]-> List U8) where fmt implements EncoderFormatting, val implements Encoding # Specialization lambda sets: # @<1>: [[toEncoder_{a}(0)]] - # @<2>: [[custom(2) { a : val }]] | val implements Encoding + # @<2>: [[custom(2) { a : val }]] where val implements Encoding #Derived.toEncoder_{a} = \#Derived.rcd -> custom @@ -251,11 +251,11 @@ fn two_field_record() { derive_test(ToEncoder, v!({ a: v!(U8), b: v!(STR), }), |golden| { assert_snapshot!(golden, @r###" # derived for { a : U8, b : Str } - # { a : val, b : val1 } -[[toEncoder_{a,b}(0)]]-> Encoder fmt | fmt implements EncoderFormatting, val implements Encoding, val1 implements Encoding - # { a : val, b : val1 } -[[toEncoder_{a,b}(0)]]-> (List U8, fmt -[[custom(2) { a : val, b : val1 }]]-> List U8) | fmt implements EncoderFormatting, val implements Encoding, val1 implements Encoding + # { a : val, b : val1 } -[[toEncoder_{a,b}(0)]]-> Encoder fmt where fmt implements EncoderFormatting, val implements Encoding, val1 implements Encoding + # { a : val, b : val1 } -[[toEncoder_{a,b}(0)]]-> (List U8, fmt -[[custom(2) { a : val, b : val1 }]]-> List U8) where fmt implements EncoderFormatting, val implements Encoding, val1 implements Encoding # Specialization lambda sets: # @<1>: [[toEncoder_{a,b}(0)]] - # @<2>: [[custom(2) { a : val, b : val1 }]] | val implements Encoding, val1 implements Encoding + # @<2>: [[custom(2) { a : val, b : val1 }]] where val implements Encoding, val1 implements Encoding #Derived.toEncoder_{a,b} = \#Derived.rcd -> custom @@ -278,11 +278,11 @@ fn two_field_tuple() { derive_test(ToEncoder, v!((v!(U8), v!(STR),)), |golden| { assert_snapshot!(golden, @r###" # derived for ( U8, Str )* - # ( val, val1 )* -[[toEncoder_(arity:2)(0)]]-> Encoder fmt | fmt implements EncoderFormatting, val implements Encoding, val1 implements Encoding - # ( val, val1 )a -[[toEncoder_(arity:2)(0)]]-> (List U8, fmt -[[custom(2) ( val, val1 )a]]-> List U8) | fmt implements EncoderFormatting, val implements Encoding, val1 implements Encoding + # ( val, val1 )* -[[toEncoder_(arity:2)(0)]]-> Encoder fmt where fmt implements EncoderFormatting, val implements Encoding, val1 implements Encoding + # ( val, val1 )a -[[toEncoder_(arity:2)(0)]]-> (List U8, fmt -[[custom(2) ( val, val1 )a]]-> List U8) where fmt implements EncoderFormatting, val implements Encoding, val1 implements Encoding # Specialization lambda sets: # @<1>: [[toEncoder_(arity:2)(0)]] - # @<2>: [[custom(2) ( val, val1 )*]] | val implements Encoding, val1 implements Encoding + # @<2>: [[custom(2) ( val, val1 )*]] where val implements Encoding, val1 implements Encoding #Derived.toEncoder_(arity:2) = \#Derived.tup -> custom @@ -314,8 +314,8 @@ fn tag_one_label_zero_args() { derive_test(ToEncoder, v!([A]), |golden| { assert_snapshot!(golden, @r###" # derived for [A] - # [A] -[[toEncoder_[A 0](0)]]-> Encoder fmt | fmt implements EncoderFormatting - # [A] -[[toEncoder_[A 0](0)]]-> (List U8, fmt -[[custom(2) [A]]]-> List U8) | fmt implements EncoderFormatting + # [A] -[[toEncoder_[A 0](0)]]-> Encoder fmt where fmt implements EncoderFormatting + # [A] -[[toEncoder_[A 0](0)]]-> (List U8, fmt -[[custom(2) [A]]]-> List U8) where fmt implements EncoderFormatting # Specialization lambda sets: # @<1>: [[toEncoder_[A 0](0)]] # @<2>: [[custom(2) [A]]] @@ -338,11 +338,11 @@ fn tag_one_label_two_args() { derive_test(ToEncoder, v!([A v!(U8) v!(STR)]), |golden| { assert_snapshot!(golden, @r###" # derived for [A U8 Str] - # [A val val1] -[[toEncoder_[A 2](0)]]-> Encoder fmt | fmt implements EncoderFormatting, val implements Encoding, val1 implements Encoding - # [A val val1] -[[toEncoder_[A 2](0)]]-> (List U8, fmt -[[custom(4) [A val val1]]]-> List U8) | fmt implements EncoderFormatting, val implements Encoding, val1 implements Encoding + # [A val val1] -[[toEncoder_[A 2](0)]]-> Encoder fmt where fmt implements EncoderFormatting, val implements Encoding, val1 implements Encoding + # [A val val1] -[[toEncoder_[A 2](0)]]-> (List U8, fmt -[[custom(4) [A val val1]]]-> List U8) where fmt implements EncoderFormatting, val implements Encoding, val1 implements Encoding # Specialization lambda sets: # @<1>: [[toEncoder_[A 2](0)]] - # @<2>: [[custom(4) [A val val1]]] | val implements Encoding, val1 implements Encoding + # @<2>: [[custom(4) [A val val1]]] where val implements Encoding, val1 implements Encoding #Derived.toEncoder_[A 2] = \#Derived.tag -> custom @@ -366,11 +366,11 @@ fn tag_two_labels() { |golden| { assert_snapshot!(golden, @r###" # derived for [A U8 Str U16, B Str] - # [A val val1 val1, B val1] -[[toEncoder_[A 3,B 1](0)]]-> Encoder fmt | fmt implements EncoderFormatting, val implements Encoding, val1 implements Encoding - # [A val val1 val1, B val1] -[[toEncoder_[A 3,B 1](0)]]-> (List U8, fmt -[[custom(6) [A val val1 val1, B val1]]]-> List U8) | fmt implements EncoderFormatting, val implements Encoding, val1 implements Encoding + # [A val val1 val1, B val1] -[[toEncoder_[A 3,B 1](0)]]-> Encoder fmt where fmt implements EncoderFormatting, val implements Encoding, val1 implements Encoding + # [A val val1 val1, B val1] -[[toEncoder_[A 3,B 1](0)]]-> (List U8, fmt -[[custom(6) [A val val1 val1, B val1]]]-> List U8) where fmt implements EncoderFormatting, val implements Encoding, val1 implements Encoding # Specialization lambda sets: # @<1>: [[toEncoder_[A 3,B 1](0)]] - # @<2>: [[custom(6) [A val val1 val1, B val1]]] | val implements Encoding, val1 implements Encoding + # @<2>: [[custom(6) [A val val1 val1, B val1]]] where val implements Encoding, val1 implements Encoding #Derived.toEncoder_[A 3,B 1] = \#Derived.tag -> custom @@ -402,11 +402,11 @@ fn recursive_tag_union() { |golden| { assert_snapshot!(golden, @r###" # derived for [Cons U8 $rec, Nil] as $rec - # [Cons val val1, Nil] -[[toEncoder_[Cons 2,Nil 0](0)]]-> Encoder fmt | fmt implements EncoderFormatting, val implements Encoding, val1 implements Encoding - # [Cons val val1, Nil] -[[toEncoder_[Cons 2,Nil 0](0)]]-> (List U8, fmt -[[custom(4) [Cons val val1, Nil]]]-> List U8) | fmt implements EncoderFormatting, val implements Encoding, val1 implements Encoding + # [Cons val val1, Nil] -[[toEncoder_[Cons 2,Nil 0](0)]]-> Encoder fmt where fmt implements EncoderFormatting, val implements Encoding, val1 implements Encoding + # [Cons val val1, Nil] -[[toEncoder_[Cons 2,Nil 0](0)]]-> (List U8, fmt -[[custom(4) [Cons val val1, Nil]]]-> List U8) where fmt implements EncoderFormatting, val implements Encoding, val1 implements Encoding # Specialization lambda sets: # @<1>: [[toEncoder_[Cons 2,Nil 0](0)]] - # @<2>: [[custom(4) [Cons val val1, Nil]]] | val implements Encoding, val1 implements Encoding + # @<2>: [[custom(4) [Cons val val1, Nil]]] where val implements Encoding, val1 implements Encoding #Derived.toEncoder_[Cons 2,Nil 0] = \#Derived.tag -> custom @@ -429,11 +429,11 @@ fn list() { derive_test(ToEncoder, v!(Symbol::LIST_LIST v!(STR)), |golden| { assert_snapshot!(golden, @r###" # derived for List Str - # List val -[[toEncoder_list(0)]]-> Encoder fmt | fmt implements EncoderFormatting, val implements Encoding - # List val -[[toEncoder_list(0)]]-> (List U8, fmt -[[custom(4) (List val)]]-> List U8) | fmt implements EncoderFormatting, val implements Encoding + # List val -[[toEncoder_list(0)]]-> Encoder fmt where fmt implements EncoderFormatting, val implements Encoding + # List val -[[toEncoder_list(0)]]-> (List U8, fmt -[[custom(4) (List val)]]-> List U8) where fmt implements EncoderFormatting, val implements Encoding # Specialization lambda sets: # @<1>: [[toEncoder_list(0)]] - # @<2>: [[custom(4) (List val)]] | val implements Encoding + # @<2>: [[custom(4) (List val)]] where val implements Encoding #Derived.toEncoder_list = \#Derived.lst -> custom diff --git a/crates/compiler/test_derive/src/hash.rs b/crates/compiler/test_derive/src/hash.rs index 1d645d5d8a..96a119199e 100644 --- a/crates/compiler/test_derive/src/hash.rs +++ b/crates/compiler/test_derive/src/hash.rs @@ -151,8 +151,8 @@ fn empty_record() { derive_test(Hash, v!(EMPTY_RECORD), |golden| { assert_snapshot!(golden, @r###" # derived for {} - # hasher, {} -[[hash_{}(0)]]-> hasher | hasher implements Hasher - # hasher, {} -[[hash_{}(0)]]-> hasher | hasher implements Hasher + # hasher, {} -[[hash_{}(0)]]-> hasher where hasher implements Hasher + # hasher, {} -[[hash_{}(0)]]-> hasher where hasher implements Hasher # Specialization lambda sets: # @<1>: [[hash_{}(0)]] #Derived.hash_{} = \#Derived.hasher, #Derived.rcd -> #Derived.hasher @@ -166,8 +166,8 @@ fn zero_field_record() { derive_test(Hash, v!({}), |golden| { assert_snapshot!(golden, @r###" # derived for {} - # hasher, {} -[[hash_{}(0)]]-> hasher | hasher implements Hasher - # hasher, {} -[[hash_{}(0)]]-> hasher | hasher implements Hasher + # hasher, {} -[[hash_{}(0)]]-> hasher where hasher implements Hasher + # hasher, {} -[[hash_{}(0)]]-> hasher where hasher implements Hasher # Specialization lambda sets: # @<1>: [[hash_{}(0)]] #Derived.hash_{} = \#Derived.hasher, #Derived.rcd -> #Derived.hasher @@ -181,8 +181,8 @@ fn one_field_record() { derive_test(Hash, v!({ a: v!(U8), }), |golden| { assert_snapshot!(golden, @r###" # derived for { a : U8 } - # hasher, { a : a } -[[hash_{a}(0)]]-> hasher | a implements Hash, hasher implements Hasher - # hasher, { a : a } -[[hash_{a}(0)]]-> hasher | a implements Hash, hasher implements Hasher + # hasher, { a : a } -[[hash_{a}(0)]]-> hasher where a implements Hash, hasher implements Hasher + # hasher, { a : a } -[[hash_{a}(0)]]-> hasher where a implements Hash, hasher implements Hasher # Specialization lambda sets: # @<1>: [[hash_{a}(0)]] #Derived.hash_{a} = @@ -197,8 +197,8 @@ fn two_field_record() { derive_test(Hash, v!({ a: v!(U8), b: v!(STR), }), |golden| { assert_snapshot!(golden, @r###" # derived for { a : U8, b : Str } - # hasher, { a : a, b : a1 } -[[hash_{a,b}(0)]]-> hasher | a implements Hash, a1 implements Hash, hasher implements Hasher - # hasher, { a : a, b : a1 } -[[hash_{a,b}(0)]]-> hasher | a implements Hash, a1 implements Hash, hasher implements Hasher + # hasher, { a : a, b : a1 } -[[hash_{a,b}(0)]]-> hasher where a implements Hash, a1 implements Hash, hasher implements Hasher + # hasher, { a : a, b : a1 } -[[hash_{a,b}(0)]]-> hasher where a implements Hash, a1 implements Hash, hasher implements Hasher # Specialization lambda sets: # @<1>: [[hash_{a,b}(0)]] #Derived.hash_{a,b} = @@ -214,8 +214,8 @@ fn two_element_tuple() { derive_test(Hash, v!((v!(U8), v!(STR),)), |golden| { assert_snapshot!(golden, @r###" # derived for ( U8, Str )* - # hasher, ( a, a1 )* -[[hash_(arity:2)(0)]]-> hasher | a implements Hash, a1 implements Hash, hasher implements Hasher - # hasher, ( a, a1 )* -[[hash_(arity:2)(0)]]-> hasher | a implements Hash, a1 implements Hash, hasher implements Hasher + # hasher, ( a, a1 )* -[[hash_(arity:2)(0)]]-> hasher where a implements Hash, a1 implements Hash, hasher implements Hasher + # hasher, ( a, a1 )* -[[hash_(arity:2)(0)]]-> hasher where a implements Hash, a1 implements Hash, hasher implements Hasher # Specialization lambda sets: # @<1>: [[hash_(arity:2)(0)]] #Derived.hash_(arity:2) = @@ -231,8 +231,8 @@ fn tag_one_label_no_payloads() { derive_test(Hash, v!([A]), |golden| { assert_snapshot!(golden, @r###" # derived for [A] - # hasher, [A] -[[hash_[A 0](0)]]-> hasher | hasher implements Hasher - # hasher, [A] -[[hash_[A 0](0)]]-> hasher | hasher implements Hasher + # hasher, [A] -[[hash_[A 0](0)]]-> hasher where hasher implements Hasher + # hasher, [A] -[[hash_[A 0](0)]]-> hasher where hasher implements Hasher # Specialization lambda sets: # @<1>: [[hash_[A 0](0)]] #Derived.hash_[A 0] = \#Derived.hasher, A -> #Derived.hasher @@ -246,8 +246,8 @@ fn tag_one_label_newtype() { derive_test(Hash, v!([A v!(U8) v!(STR)]), |golden| { assert_snapshot!(golden, @r###" # derived for [A U8 Str] - # hasher, [A a a1] -[[hash_[A 2](0)]]-> hasher | a implements Hash, a1 implements Hash, hasher implements Hasher - # hasher, [A a a1] -[[hash_[A 2](0)]]-> hasher | a implements Hash, a1 implements Hash, hasher implements Hasher + # hasher, [A a a1] -[[hash_[A 2](0)]]-> hasher where a implements Hash, a1 implements Hash, hasher implements Hasher + # hasher, [A a a1] -[[hash_[A 2](0)]]-> hasher where a implements Hash, a1 implements Hash, hasher implements Hasher # Specialization lambda sets: # @<1>: [[hash_[A 2](0)]] #Derived.hash_[A 2] = @@ -263,8 +263,8 @@ fn tag_two_labels() { derive_test(Hash, v!([A v!(U8) v!(STR) v!(U16), B v!(STR)]), |golden| { assert_snapshot!(golden, @r###" # derived for [A U8 Str U16, B Str] - # a, [A a1 a2 a3, B a3] -[[hash_[A 3,B 1](0)]]-> a | a implements Hasher, a1 implements Hash, a2 implements Hash, a3 implements Hash - # a, [A a1 a2 a3, B a3] -[[hash_[A 3,B 1](0)]]-> a | a implements Hasher, a1 implements Hash, a2 implements Hash, a3 implements Hash + # a, [A a1 a2 a3, B a3] -[[hash_[A 3,B 1](0)]]-> a where a implements Hasher, a1 implements Hash, a2 implements Hash, a3 implements Hash + # a, [A a1 a2 a3, B a3] -[[hash_[A 3,B 1](0)]]-> a where a implements Hasher, a1 implements Hash, a2 implements Hash, a3 implements Hash # Specialization lambda sets: # @<1>: [[hash_[A 3,B 1](0)]] #Derived.hash_[A 3,B 1] = @@ -285,8 +285,8 @@ fn tag_two_labels_no_payloads() { derive_test(Hash, v!([A, B]), |golden| { assert_snapshot!(golden, @r###" # derived for [A, B] - # a, [A, B] -[[hash_[A 0,B 0](0)]]-> a | a implements Hasher - # a, [A, B] -[[hash_[A 0,B 0](0)]]-> a | a implements Hasher + # a, [A, B] -[[hash_[A 0,B 0](0)]]-> a where a implements Hasher + # a, [A, B] -[[hash_[A 0,B 0](0)]]-> a where a implements Hasher # Specialization lambda sets: # @<1>: [[hash_[A 0,B 0](0)]] #Derived.hash_[A 0,B 0] = @@ -304,8 +304,8 @@ fn recursive_tag_union() { derive_test(Hash, v!([Nil, Cons v!(U8) v!(^lst) ] as lst), |golden| { assert_snapshot!(golden, @r###" # derived for [Cons U8 $rec, Nil] as $rec - # a, [Cons a1 a2, Nil] -[[hash_[Cons 2,Nil 0](0)]]-> a | a implements Hasher, a1 implements Hash, a2 implements Hash - # a, [Cons a1 a2, Nil] -[[hash_[Cons 2,Nil 0](0)]]-> a | a implements Hasher, a1 implements Hash, a2 implements Hash + # a, [Cons a1 a2, Nil] -[[hash_[Cons 2,Nil 0](0)]]-> a where a implements Hasher, a1 implements Hash, a2 implements Hash + # a, [Cons a1 a2, Nil] -[[hash_[Cons 2,Nil 0](0)]]-> a where a implements Hasher, a1 implements Hash, a2 implements Hash # Specialization lambda sets: # @<1>: [[hash_[Cons 2,Nil 0](0)]] #Derived.hash_[Cons 2,Nil 0] = diff --git a/crates/compiler/test_gen/src/gen_abilities.rs b/crates/compiler/test_gen/src/gen_abilities.rs index a154da57ce..222f426365 100644 --- a/crates/compiler/test_gen/src/gen_abilities.rs +++ b/crates/compiler/test_gen/src/gen_abilities.rs @@ -21,7 +21,7 @@ fn hash_specialization() { app "test" provides [main] to "./platform" MHash implements - hash : a -> U64 | a implements MHash + hash : a -> U64 where a implements MHash Id := U64 implements [MHash {hash}] @@ -44,7 +44,7 @@ fn hash_specialization_multiple_add() { app "test" provides [main] to "./platform" MHash implements - hash : a -> U64 | a implements MHash + hash : a -> U64 where a implements MHash Id := U64 implements [ MHash {hash: hashId} ] @@ -71,7 +71,7 @@ fn alias_member_specialization() { app "test" provides [main] to "./platform" MHash implements - hash : a -> U64 | a implements MHash + hash : a -> U64 where a implements MHash Id := U64 implements [MHash {hash}] @@ -96,9 +96,9 @@ fn ability_constrained_in_non_member_usage() { app "test" provides [result] to "./platform" MHash implements - hash : a -> U64 | a implements MHash + hash : a -> U64 where a implements MHash - mulMHashes : a, a -> U64 | a implements MHash + mulMHashes : a, a -> U64 where a implements MHash mulMHashes = \x, y -> hash x * hash y Id := U64 implements [MHash {hash}] @@ -121,7 +121,7 @@ fn ability_constrained_in_non_member_usage_inferred() { app "test" provides [result] to "./platform" MHash implements - hash : a -> U64 | a implements MHash + hash : a -> U64 where a implements MHash mulMHashes = \x, y -> hash x * hash y @@ -145,9 +145,9 @@ fn ability_constrained_in_non_member_multiple_specializations() { app "test" provides [result] to "./platform" MHash implements - hash : a -> U64 | a implements MHash + hash : a -> U64 where a implements MHash - mulMHashes : a, b -> U64 | a implements MHash, b implements MHash + mulMHashes : a, b -> U64 where a implements MHash, b implements MHash mulMHashes = \x, y -> hash x * hash y Id := U64 implements [MHash { hash: hashId }] @@ -173,7 +173,7 @@ fn ability_constrained_in_non_member_multiple_specializations_inferred() { app "test" provides [result] to "./platform" MHash implements - hash : a -> U64 | a implements MHash + hash : a -> U64 where a implements MHash mulMHashes = \x, y -> hash x * hash y @@ -200,7 +200,7 @@ fn ability_used_as_type_still_compiles() { app "test" provides [result] to "./platform" MHash implements - hash : a -> U64 | a implements MHash + hash : a -> U64 where a implements MHash mulMHashes : MHash, MHash -> U64 mulMHashes = \x, y -> hash x * hash y @@ -227,15 +227,15 @@ fn bounds_to_multiple_abilities() { r#" app "test" provides [main] to "./platform" - Idempot implements idempot : a -> a | a implements Idempot - Consume implements consume : a -> Str | a implements Consume + Idempot implements idempot : a -> a where a implements Idempot + Consume implements consume : a -> Str where a implements Consume Hello := Str implements [Idempot { idempot: idempotHello }, Consume { consume: consumeHello }] idempotHello = \@Hello msg -> @Hello msg consumeHello = \@Hello msg -> msg - lifecycle : a -> Str | a implements Idempot & Consume + lifecycle : a -> Str where a implements Idempot & Consume lifecycle = \x -> idempot x |> consume main = lifecycle (@Hello "hello world") @@ -254,18 +254,18 @@ fn encode() { r#" app "test" provides [myU8Bytes] to "./platform" - MEncoder fmt := List U8, fmt -> List U8 | fmt implements Format + MEncoder fmt := List U8, fmt -> List U8 where fmt implements Format MEncoding implements - toEncoder : val -> MEncoder fmt | val implements MEncoding, fmt implements Format + toEncoder : val -> MEncoder fmt where val implements MEncoding, fmt implements Format Format implements - u8 : U8 -> MEncoder fmt | fmt implements Format + u8 : U8 -> MEncoder fmt where fmt implements Format - appendWith : List U8, MEncoder fmt, fmt -> List U8 | fmt implements Format + appendWith : List U8, MEncoder fmt, fmt -> List U8 where fmt implements Format appendWith = \lst, (@MEncoder doFormat), fmt -> doFormat lst fmt - toBytes : val, fmt -> List U8 | val implements MEncoding, fmt implements Format + toBytes : val, fmt -> List U8 where val implements MEncoding, fmt implements Format toBytes = \val, fmt -> appendWith [] (toEncoder val) fmt @@ -301,19 +301,19 @@ fn decode() { MDecodeError : [TooShort, Leftover (List U8)] - MDecoder val fmt := List U8, fmt -> { result: Result val MDecodeError, rest: List U8 } | fmt implements MDecoderFormatting + MDecoder val fmt := List U8, fmt -> { result: Result val MDecodeError, rest: List U8 } where fmt implements MDecoderFormatting MDecoding implements - decoder : MDecoder val fmt | val implements MDecoding, fmt implements MDecoderFormatting + decoder : MDecoder val fmt where val implements MDecoding, fmt implements MDecoderFormatting MDecoderFormatting implements - u8 : MDecoder U8 fmt | fmt implements MDecoderFormatting + u8 : MDecoder U8 fmt where fmt implements MDecoderFormatting - decodeWith : List U8, MDecoder val fmt, fmt -> { result: Result val MDecodeError, rest: List U8 } | fmt implements MDecoderFormatting + decodeWith : List U8, MDecoder val fmt, fmt -> { result: Result val MDecodeError, rest: List U8 } where fmt implements MDecoderFormatting decodeWith = \lst, (@MDecoder doDecode), fmt -> doDecode lst fmt fromBytes : List U8, fmt -> Result val MDecodeError - | fmt implements MDecoderFormatting, val implements MDecoding + where fmt implements MDecoderFormatting, val implements MDecoding fromBytes = \lst, fmt -> when decodeWith lst decoder fmt is { result, rest } -> diff --git a/crates/compiler/test_gen/src/gen_list.rs b/crates/compiler/test_gen/src/gen_list.rs index 2e0d767237..c9b84c7bc8 100644 --- a/crates/compiler/test_gen/src/gen_list.rs +++ b/crates/compiler/test_gen/src/gen_list.rs @@ -960,7 +960,7 @@ fn list_walk_implements_position() { r#" Option a : [Some a, None] - find : List a, a -> Option Nat | a implements Eq + find : List a, a -> Option Nat where a implements Eq find = \list, needle -> findHelp list needle |> .v @@ -3693,7 +3693,7 @@ fn list_walk_backwards_implements_position() { r#" Option a : [Some a, None] - find : List a, a -> Option Nat | a implements Eq + find : List a, a -> Option Nat where a implements Eq find = \list, needle -> findHelp list needle |> .v diff --git a/crates/compiler/test_gen/src/gen_num.rs b/crates/compiler/test_gen/src/gen_num.rs index 68df70a767..010657f9d5 100644 --- a/crates/compiler/test_gen/src/gen_num.rs +++ b/crates/compiler/test_gen/src/gen_num.rs @@ -891,7 +891,7 @@ fn gen_wrap_int_neq() { assert_evals_to!( indoc!( r#" - wrappedNotEq : a, a -> Bool | a implements Eq + wrappedNotEq : a, a -> Bool where a implements Eq wrappedNotEq = \num1, num2 -> num1 != num2 diff --git a/crates/compiler/test_mono/src/tests.rs b/crates/compiler/test_mono/src/tests.rs index 9632c7b4f2..18ae06ded4 100644 --- a/crates/compiler/test_mono/src/tests.rs +++ b/crates/compiler/test_mono/src/tests.rs @@ -1345,7 +1345,7 @@ fn specialize_ability_call() { app "test" provides [main] to "./platform" MHash implements - hash : a -> U64 | a implements MHash + hash : a -> U64 where a implements MHash Id := U64 implements [MHash {hash}] @@ -1380,13 +1380,13 @@ fn encode() { r#" app "test" provides [myU8Bytes] to "./platform" - MEncoder fmt := List U8, fmt -> List U8 | fmt implements Format + MEncoder fmt := List U8, fmt -> List U8 where fmt implements Format MEncoding implements - toEncoder : val -> MEncoder fmt | val implements MEncoding, fmt implements Format + toEncoder : val -> MEncoder fmt where val implements MEncoding, fmt implements Format Format implements - u8 : U8 -> MEncoder fmt | fmt implements Format + u8 : U8 -> MEncoder fmt where fmt implements Format Linear := {} implements [Format {u8}] @@ -2603,15 +2603,15 @@ fn unspecialized_lambda_set_unification_keeps_all_concrete_types_without_unifica r#" app "test" provides [main] to "./platform" - MEncoder fmt := List U8, fmt -> List U8 | fmt implements Format + MEncoder fmt := List U8, fmt -> List U8 where fmt implements Format MEncoding implements - toEncoder : val -> MEncoder fmt | val implements MEncoding, fmt implements Format + toEncoder : val -> MEncoder fmt where val implements MEncoding, fmt implements Format Format implements - u8 : {} -> MEncoder fmt | fmt implements Format - str : {} -> MEncoder fmt | fmt implements Format - tag : MEncoder fmt -> MEncoder fmt | fmt implements Format + u8 : {} -> MEncoder fmt where fmt implements Format + str : {} -> MEncoder fmt where fmt implements Format + tag : MEncoder fmt -> MEncoder fmt where fmt implements Format Linear := {} implements [Format {u8: lU8, str: lStr, tag: lTag}] diff --git a/crates/compiler/test_syntax/tests/snapshots/fail/ability_demand_value_has_args.expr.roc b/crates/compiler/test_syntax/tests/snapshots/fail/ability_demand_value_has_args.expr.roc index 3b411cb332..1ae763fa66 100644 --- a/crates/compiler/test_syntax/tests/snapshots/fail/ability_demand_value_has_args.expr.roc +++ b/crates/compiler/test_syntax/tests/snapshots/fail/ability_demand_value_has_args.expr.roc @@ -1,4 +1,4 @@ MEq implements - eq b c : a, a -> U64 | a implements MEq + eq b c : a, a -> U64 where a implements MEq 1 diff --git a/crates/compiler/test_syntax/tests/snapshots/fail/ability_demands_not_indented_with_first.expr.roc b/crates/compiler/test_syntax/tests/snapshots/fail/ability_demands_not_indented_with_first.expr.roc index 8d0aa047c9..d4b478df18 100644 --- a/crates/compiler/test_syntax/tests/snapshots/fail/ability_demands_not_indented_with_first.expr.roc +++ b/crates/compiler/test_syntax/tests/snapshots/fail/ability_demands_not_indented_with_first.expr.roc @@ -1,5 +1,5 @@ MEq implements - eq : a, a -> U64 | a implements MEq - neq : a, a -> U64 | a implements MEq + eq : a, a -> U64 where a implements MEq + neq : a, a -> U64 where a implements MEq 1 diff --git a/crates/compiler/test_syntax/tests/snapshots/fail/ability_first_demand_not_indented_enough.expr.roc b/crates/compiler/test_syntax/tests/snapshots/fail/ability_first_demand_not_indented_enough.expr.roc index 92086a5f15..fb55dc8219 100644 --- a/crates/compiler/test_syntax/tests/snapshots/fail/ability_first_demand_not_indented_enough.expr.roc +++ b/crates/compiler/test_syntax/tests/snapshots/fail/ability_first_demand_not_indented_enough.expr.roc @@ -1,4 +1,4 @@ MEq implements -eq : a, a -> U64 | a implements MEq +eq : a, a -> U64 where a implements MEq 1 diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/ability_single_line.expr.roc b/crates/compiler/test_syntax/tests/snapshots/pass/ability_single_line.expr.roc index 798560ef41..85870f77c6 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/ability_single_line.expr.roc +++ b/crates/compiler/test_syntax/tests/snapshots/pass/ability_single_line.expr.roc @@ -1,3 +1,3 @@ -Hash implements hash : a -> U64 | a implements Hash +Hash implements hash : a -> U64 where a implements Hash 1 diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/ability_two_in_a_row.expr.roc b/crates/compiler/test_syntax/tests/snapshots/pass/ability_two_in_a_row.expr.roc index 1c5fad72e5..4f6f9c75e0 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/ability_two_in_a_row.expr.roc +++ b/crates/compiler/test_syntax/tests/snapshots/pass/ability_two_in_a_row.expr.roc @@ -1,5 +1,5 @@ -Ab1 implements ab1 : a -> {} | a implements Ab1 +Ab1 implements ab1 : a -> {} where a implements Ab1 -Ab2 implements ab2 : a -> {} | a implements Ab2 +Ab2 implements ab2 : a -> {} where a implements Ab2 1 diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/opaque_has_abilities.expr.formatted.roc b/crates/compiler/test_syntax/tests/snapshots/pass/opaque_has_abilities.expr.formatted.roc index 32173c522a..e399dd7e0d 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/opaque_has_abilities.expr.formatted.roc +++ b/crates/compiler/test_syntax/tests/snapshots/pass/opaque_has_abilities.expr.formatted.roc @@ -1,9 +1,9 @@ A := U8 implements [Eq, Hash] -A := a | a implements Other +A := a where a implements Other implements [Eq, Hash] -A := a | a implements Other +A := a where a implements Other implements [Eq, Hash] A := U8 implements [Eq { eq }, Hash { hash }] @@ -16,7 +16,7 @@ A := U8 implements [Hash, Eq { eq, eq1 }] A := U8 implements [] -A := a | a implements Other +A := a where a implements Other implements [Eq { eq }, Hash { hash }] A := U8 implements [Eq {}] diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/opaque_has_abilities.expr.roc b/crates/compiler/test_syntax/tests/snapshots/pass/opaque_has_abilities.expr.roc index 3228574abc..0a329cbbdc 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/opaque_has_abilities.expr.roc +++ b/crates/compiler/test_syntax/tests/snapshots/pass/opaque_has_abilities.expr.roc @@ -1,8 +1,8 @@ A := U8 implements [Eq, Hash] -A := a | a implements Other implements [Eq, Hash] +A := a where a implements Other implements [Eq, Hash] -A := a | a implements Other +A := a where a implements Other implements [Eq, Hash] A := U8 implements [Eq {eq}, Hash {hash}] @@ -15,7 +15,7 @@ A := U8 implements [Hash, Eq {eq, eq1}] A := U8 implements [] -A := a | a implements Other +A := a where a implements Other implements [Eq {eq}, Hash {hash}] A := U8 implements [Eq {}] diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_function.expr.roc b/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_function.expr.roc index 6b11f13621..8406a9d704 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_function.expr.roc +++ b/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_function.expr.roc @@ -1,3 +1,3 @@ -f : a -> (b -> c) | a implements A +f : a -> (b -> c) where a implements A f diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_multiple_bound_abilities.expr.formatted.roc b/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_multiple_bound_abilities.expr.formatted.roc index 70a5869e41..15ab48af35 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_multiple_bound_abilities.expr.formatted.roc +++ b/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_multiple_bound_abilities.expr.formatted.roc @@ -1,5 +1,5 @@ -f : a -> b | a implements Hash & Eq, b implements Eq & Hash & Display +f : a -> b where a implements Hash & Eq, b implements Eq & Hash & Display -f : a -> b | a implements Hash & Eq, b implements Hash & Display & Eq +f : a -> b where a implements Hash & Eq, b implements Hash & Display & Eq f \ No newline at end of file diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_multiple_bound_abilities.expr.roc b/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_multiple_bound_abilities.expr.roc index 2a151bfd52..c77b4c76e5 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_multiple_bound_abilities.expr.roc +++ b/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_multiple_bound_abilities.expr.roc @@ -1,7 +1,7 @@ -f : a -> b | a implements Hash & Eq, b implements Eq & Hash & Display +f : a -> b where a implements Hash & Eq, b implements Eq & Hash & Display f : a -> b - | a implements Hash & Eq, + where a implements Hash & Eq, b implements Hash & Display & Eq f diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_multiple_has.expr.roc b/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_multiple_has.expr.roc index 4de00586ac..8122c5e15b 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_multiple_has.expr.roc +++ b/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_multiple_has.expr.roc @@ -1,3 +1,3 @@ -f : a -> (b -> c) | a implements A, b implements Eq, c implements Ord +f : a -> (b -> c) where a implements A, b implements Eq, c implements Ord f diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_multiple_has_across_newlines.expr.formatted.roc b/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_multiple_has_across_newlines.expr.formatted.roc index 0ebb9de5a0..d5d6c87616 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_multiple_has_across_newlines.expr.formatted.roc +++ b/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_multiple_has_across_newlines.expr.formatted.roc @@ -1,3 +1,3 @@ -f : a -> (b -> c) | a implements Hash, b has Eq, c implements Ord +f : a -> (b -> c) where a implements Hash, b has Eq, c implements Ord f \ No newline at end of file diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_multiple_has_across_newlines.expr.roc b/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_multiple_has_across_newlines.expr.roc index 98fd144541..8a999d8baa 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_multiple_has_across_newlines.expr.roc +++ b/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_multiple_has_across_newlines.expr.roc @@ -1,5 +1,5 @@ f : a -> (b -> c) - | a implements Hash, + where a implements Hash, b implements Eq, c implements Ord diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_non_function.expr.roc b/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_non_function.expr.roc index d60270f465..6fdaa51b78 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_non_function.expr.roc +++ b/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_non_function.expr.roc @@ -1,3 +1,3 @@ -f : a | a implements A +f : a where a implements A f diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_on_newline.expr.formatted.roc b/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_on_newline.expr.formatted.roc index bdef6cc7de..1b14b8c6b4 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_on_newline.expr.formatted.roc +++ b/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_on_newline.expr.formatted.roc @@ -1,3 +1,3 @@ -f : a -> U64 | a implements Hash +f : a -> U64 where a implements Hash f \ No newline at end of file diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_on_newline.expr.roc b/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_on_newline.expr.roc index 050ad46910..c147869078 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_on_newline.expr.roc +++ b/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_on_newline.expr.roc @@ -1,4 +1,4 @@ f : a -> U64 - | a implements Hash + where a implements Hash f diff --git a/crates/compiler/test_syntax/tests/test_fmt.rs b/crates/compiler/test_syntax/tests/test_fmt.rs index 4725aac92c..7a0feeb82c 100644 --- a/crates/compiler/test_syntax/tests/test_fmt.rs +++ b/crates/compiler/test_syntax/tests/test_fmt.rs @@ -5457,14 +5457,14 @@ mod test_fmt { expr_formats_to( indoc!( r#" - A := a | a implements Hash implements [ Eq, Hash ] + A := a where a implements Hash implements [ Eq, Hash ] 0 "# ), indoc!( r#" - A := a | a implements Hash + A := a where a implements Hash implements [Eq, Hash] 0 @@ -5568,7 +5568,7 @@ mod test_fmt { expr_formats_same(indoc!( r#" - A := a | a implements Other + A := a where a implements Other implements [Eq { eq }, Hash { hash }] 0 @@ -5625,7 +5625,7 @@ mod test_fmt { dataIndices : List Nat, data : List (T k v), size : Nat, - } | k implements Hash & Eq + } where k implements Hash & Eq a "# @@ -5839,10 +5839,10 @@ mod test_fmt { A implements ## This is member ab - ab : a -> a | a implements A + ab : a -> a where a implements A ## This is member de - de : a -> a | a implements A + de : a -> a where a implements A f = g "# @@ -5884,7 +5884,7 @@ mod test_fmt { fn clauses_with_multiple_abilities() { expr_formats_same(indoc!( r#" - f : {} -> a | a implements Eq & Hash & Decode + f : {} -> a where a implements Eq & Hash & Decode f "# @@ -5893,7 +5893,7 @@ mod test_fmt { expr_formats_to( indoc!( r#" - f : {} -> a | a implements Eq & Hash & Decode, + f : {} -> a where a implements Eq & Hash & Decode, b implements Eq & Hash f @@ -5902,10 +5902,10 @@ mod test_fmt { indoc!( // TODO: ideally, this would look a bit nicer - consider // f : {} -> a - // | a implements Eq & Hash & Decode, + // where a implements Eq & Hash & Decode, // b implements Eq & Hash r#" - f : {} -> a | a implements Eq & Hash & Decode, b implements Eq & Hash + f : {} -> a where a implements Eq & Hash & Decode, b implements Eq & Hash f "# diff --git a/crates/compiler/types/src/pretty_print.rs b/crates/compiler/types/src/pretty_print.rs index b132a0199e..6e8463aeb5 100644 --- a/crates/compiler/types/src/pretty_print.rs +++ b/crates/compiler/types/src/pretty_print.rs @@ -602,7 +602,13 @@ fn variable_to_string( ctx.able_variables.sort(); ctx.able_variables.dedup(); for (i, (var, abilities)) in ctx.able_variables.into_iter().enumerate() { - buf.push_str(if i == 0 { " | " } else { ", " }); + if i == 0 { + buf.push(' '); + buf.push_str(roc_parse::keyword::WHERE) + } else { + buf.push(','); + } + buf.push(' '); buf.push_str(var); buf.push(' '); buf.push_str(roc_parse::keyword::IMPLEMENTS); diff --git a/crates/compiler/types/src/types.rs b/crates/compiler/types/src/types.rs index efd49d2088..13a92447bb 100644 --- a/crates/compiler/types/src/types.rs +++ b/crates/compiler/types/src/types.rs @@ -1760,7 +1760,7 @@ pub enum Type { } /// A lambda set under an arrow in a ability member signature. For example, in -/// Default has default : {} -> a | a implements Default +/// Default has default : {} -> a where a implements Default /// the unspecialized lambda set for the arrow "{} -> a" would be `a:default:1`. /// /// Lambda sets in member signatures are never known until those members are specialized at a diff --git a/crates/compiler/uitest/tests/ability/bounds/expand_able_variables_in_type_alias.txt b/crates/compiler/uitest/tests/ability/bounds/expand_able_variables_in_type_alias.txt index 6cc44c9d8b..894ded1fa3 100644 --- a/crates/compiler/uitest/tests/ability/bounds/expand_able_variables_in_type_alias.txt +++ b/crates/compiler/uitest/tests/ability/bounds/expand_able_variables_in_type_alias.txt @@ -1,7 +1,7 @@ # +opt infer:print_only_under_alias app "test" provides [main] to "./platform" -F a : a | a implements Hash +F a : a where a implements Hash main : F a -> F a -#^^^^{-1} a -[[main(0)]]-> a | a implements Hash +#^^^^{-1} a -[[main(0)]]-> a where a implements Hash diff --git a/crates/compiler/uitest/tests/ability/bounds/multiple_variables_bound_to_an_ability_from_type_def.txt b/crates/compiler/uitest/tests/ability/bounds/multiple_variables_bound_to_an_ability_from_type_def.txt index 4d18952a60..32f23d7db0 100644 --- a/crates/compiler/uitest/tests/ability/bounds/multiple_variables_bound_to_an_ability_from_type_def.txt +++ b/crates/compiler/uitest/tests/ability/bounds/multiple_variables_bound_to_an_ability_from_type_def.txt @@ -1,7 +1,7 @@ # +opt infer:print_only_under_alias app "test" provides [main] to "./platform" -F a : a | a implements Hash & Eq & Decoding +F a : a where a implements Hash & Eq & Decoding main : F a -> F a -#^^^^{-1} a -[[main(0)]]-> a | a implements Hash & Decoding & Eq +#^^^^{-1} a -[[main(0)]]-> a where a implements Hash & Decoding & Eq diff --git a/crates/compiler/uitest/tests/ability/bounds/rigid_able_bounds_are_superset_of_flex_bounds_admitted.txt b/crates/compiler/uitest/tests/ability/bounds/rigid_able_bounds_are_superset_of_flex_bounds_admitted.txt index a06679108d..490c265512 100644 --- a/crates/compiler/uitest/tests/ability/bounds/rigid_able_bounds_are_superset_of_flex_bounds_admitted.txt +++ b/crates/compiler/uitest/tests/ability/bounds/rigid_able_bounds_are_superset_of_flex_bounds_admitted.txt @@ -1,8 +1,8 @@ app "test" provides [main] to "./platform" -f : x -> x | x implements Hash -g : x -> x | x implements Decoding & Encoding +f : x -> x where x implements Hash +g : x -> x where x implements Decoding & Encoding -main : x -> x | x implements Hash & Decoding & Encoding +main : x -> x where x implements Hash & Decoding & Encoding main = \x -> x |> f |> g -#^^^^{-1} x -[[main(0)]]-> x | x implements Hash & Encoding & Decoding +#^^^^{-1} x -[[main(0)]]-> x where x implements Hash & Encoding & Decoding diff --git a/crates/compiler/uitest/tests/ability/generalize_inferred_opaque_variable_bound_to_ability_issue_4408.txt b/crates/compiler/uitest/tests/ability/generalize_inferred_opaque_variable_bound_to_ability_issue_4408.txt index 3868cf4d17..4bb2874aa7 100644 --- a/crates/compiler/uitest/tests/ability/generalize_inferred_opaque_variable_bound_to_ability_issue_4408.txt +++ b/crates/compiler/uitest/tests/ability/generalize_inferred_opaque_variable_bound_to_ability_issue_4408.txt @@ -1,6 +1,6 @@ app "test" provides [top] to "./platform" -MDict u := (List u) | u implements Hash & Eq +MDict u := (List u) where u implements Hash & Eq bot : MDict k -> MDict k bot = \@MDict data -> @@ -9,4 +9,4 @@ bot = \@MDict data -> top : MDict v -> MDict v top = \x -> bot x -#^^^{-1} MDict v -[[top(0)]]-> MDict v | v implements Hash & Eq +#^^^{-1} MDict v -[[top(0)]]-> MDict v where v implements Hash & Eq diff --git a/crates/compiler/uitest/tests/ability/smoke/decoder.txt b/crates/compiler/uitest/tests/ability/smoke/decoder.txt index 77546828dd..1ceffa6ecc 100644 --- a/crates/compiler/uitest/tests/ability/smoke/decoder.txt +++ b/crates/compiler/uitest/tests/ability/smoke/decoder.txt @@ -2,19 +2,19 @@ app "test" provides [myU8] to "./platform" MDecodeError : [TooShort, Leftover (List U8)] -MDecoder val fmt := List U8, fmt -> { result: Result val MDecodeError, rest: List U8 } | fmt implements MDecoderFormatting +MDecoder val fmt := List U8, fmt -> { result: Result val MDecodeError, rest: List U8 } where fmt implements MDecoderFormatting MDecoding has - decoder : MDecoder val fmt | val implements MDecoding, fmt implements MDecoderFormatting + decoder : MDecoder val fmt where val implements MDecoding, fmt implements MDecoderFormatting MDecoderFormatting has - u8 : MDecoder U8 fmt | fmt implements MDecoderFormatting + u8 : MDecoder U8 fmt where fmt implements MDecoderFormatting -decodeWith : List U8, MDecoder val fmt, fmt -> { result: Result val MDecodeError, rest: List U8 } | fmt implements MDecoderFormatting +decodeWith : List U8, MDecoder val fmt, fmt -> { result: Result val MDecodeError, rest: List U8 } where fmt implements MDecoderFormatting decodeWith = \lst, (@MDecoder doDecode), fmt -> doDecode lst fmt fromBytes : List U8, fmt -> Result val MDecodeError - | fmt implements MDecoderFormatting, val implements MDecoding + where fmt implements MDecoderFormatting, val implements MDecoding fromBytes = \lst, fmt -> when decodeWith lst decoder fmt is { result, rest } -> @@ -34,7 +34,7 @@ u8 = @MDecoder \lst, @Linear {} -> MyU8 := U8 implements [MDecoding {decoder}] decoder = @MDecoder \lst, fmt -> -#^^^^^^^{-1} MyU8#decoder(12): MDecoder MyU8 fmt | fmt implements MDecoderFormatting +#^^^^^^^{-1} MyU8#decoder(12): MDecoder MyU8 fmt where fmt implements MDecoderFormatting when decodeWith lst u8 fmt is { result, rest } -> { result: Result.map result (\n -> @MyU8 n), rest } diff --git a/crates/compiler/uitest/tests/ability/smoke/encoder.txt b/crates/compiler/uitest/tests/ability/smoke/encoder.txt index f22517fb13..88dee647b4 100644 --- a/crates/compiler/uitest/tests/ability/smoke/encoder.txt +++ b/crates/compiler/uitest/tests/ability/smoke/encoder.txt @@ -1,17 +1,17 @@ app "test" provides [myU8Bytes] to "./platform" -MEncoder fmt := List U8, fmt -> List U8 | fmt implements Format +MEncoder fmt := List U8, fmt -> List U8 where fmt implements Format MEncoding has - toEncoder : val -> MEncoder fmt | val implements MEncoding, fmt implements Format + toEncoder : val -> MEncoder fmt where val implements MEncoding, fmt implements Format Format has - u8 : U8 -> MEncoder fmt | fmt implements Format + u8 : U8 -> MEncoder fmt where fmt implements Format -appendWith : List U8, MEncoder fmt, fmt -> List U8 | fmt implements Format +appendWith : List U8, MEncoder fmt, fmt -> List U8 where fmt implements Format appendWith = \lst, (@MEncoder doFormat), fmt -> doFormat lst fmt -toBytes : val, fmt -> List U8 | val implements MEncoding, fmt implements Format +toBytes : val, fmt -> List U8 where val implements MEncoding, fmt implements Format toBytes = \val, fmt -> appendWith [] (toEncoder val) fmt @@ -23,7 +23,7 @@ u8 = \n -> @MEncoder (\lst, @Linear {} -> List.append lst n) MyU8 := U8 implements [MEncoding {toEncoder}] toEncoder = \@MyU8 n -> u8 n -#^^^^^^^^^{-1} MyU8#toEncoder(11): MyU8 -[[toEncoder(11)]]-> MEncoder fmt | fmt implements Format +#^^^^^^^^^{-1} MyU8#toEncoder(11): MyU8 -[[toEncoder(11)]]-> MEncoder fmt where fmt implements Format myU8Bytes = toBytes (@MyU8 15) (@Linear {}) #^^^^^^^^^{-1} List U8 diff --git a/crates/compiler/uitest/tests/ability/specialize/bool_decoder.txt b/crates/compiler/uitest/tests/ability/specialize/bool_decoder.txt index 020da7aefc..0d66b5f47a 100644 --- a/crates/compiler/uitest/tests/ability/specialize/bool_decoder.txt +++ b/crates/compiler/uitest/tests/ability/specialize/bool_decoder.txt @@ -3,4 +3,4 @@ app "test" provides [main] to "./platform" main : Decoder Bool _ main = Decode.custom \bytes, fmt -> Decode.decodeWith bytes Decode.decoder fmt - # ^^^^^^^^^^^^^^ Decoding#Decode.decoder(4): Decoder Bool fmt | fmt implements DecoderFormatting + # ^^^^^^^^^^^^^^ Decoding#Decode.decoder(4): Decoder Bool fmt where fmt implements DecoderFormatting diff --git a/crates/compiler/uitest/tests/ability/specialize/bool_hash.txt b/crates/compiler/uitest/tests/ability/specialize/bool_hash.txt index fa6c3cccc0..00a42f8a7e 100644 --- a/crates/compiler/uitest/tests/ability/specialize/bool_hash.txt +++ b/crates/compiler/uitest/tests/ability/specialize/bool_hash.txt @@ -2,4 +2,4 @@ app "test" provides [main] to "./platform" main = \h -> Hash.hash h Bool.true - # ^^^^^^^^^ Hash#Hash.hash(1): a, Bool -[[Hash.hashBool(9)]]-> a | a implements Hasher + # ^^^^^^^^^ Hash#Hash.hash(1): a, Bool -[[Hash.hashBool(9)]]-> a where a implements Hasher diff --git a/crates/compiler/uitest/tests/ability/specialize/bool_to_encoder.txt b/crates/compiler/uitest/tests/ability/specialize/bool_to_encoder.txt index e2c6888373..72fd873b89 100644 --- a/crates/compiler/uitest/tests/ability/specialize/bool_to_encoder.txt +++ b/crates/compiler/uitest/tests/ability/specialize/bool_to_encoder.txt @@ -1,4 +1,4 @@ app "test" provides [main] to "./platform" main = Encode.toEncoder Bool.true -# ^^^^^^^^^^^^^^^^ Encoding#Encode.toEncoder(2): Bool -[[] + fmt:Encode.bool(17):1]-> Encoder fmt | fmt implements EncoderFormatting +# ^^^^^^^^^^^^^^^^ Encoding#Encode.toEncoder(2): Bool -[[] + fmt:Encode.bool(17):1]-> Encoder fmt where fmt implements EncoderFormatting diff --git a/crates/compiler/uitest/tests/ability/specialize/opaque_decoder_derive.txt b/crates/compiler/uitest/tests/ability/specialize/opaque_decoder_derive.txt index 13105803ad..9ea64135f1 100644 --- a/crates/compiler/uitest/tests/ability/specialize/opaque_decoder_derive.txt +++ b/crates/compiler/uitest/tests/ability/specialize/opaque_decoder_derive.txt @@ -6,4 +6,4 @@ N := U8 implements [Decoding] main : Decoder N _ main = Decode.custom \bytes, fmt -> Decode.decodeWith bytes Decode.decoder fmt -# ^^^^^^^^^^^^^^ N#Decode.decoder(3): List U8, fmt -[[7]]-> { rest : List U8, result : [Err [TooShort], Ok U8] } | fmt implements DecoderFormatting +# ^^^^^^^^^^^^^^ N#Decode.decoder(3): List U8, fmt -[[7]]-> { rest : List U8, result : [Err [TooShort], Ok U8] } where fmt implements DecoderFormatting diff --git a/crates/compiler/uitest/tests/ability/specialize/opaque_encoder_derive.txt b/crates/compiler/uitest/tests/ability/specialize/opaque_encoder_derive.txt index 71decfe129..6e1b247dc6 100644 --- a/crates/compiler/uitest/tests/ability/specialize/opaque_encoder_derive.txt +++ b/crates/compiler/uitest/tests/ability/specialize/opaque_encoder_derive.txt @@ -3,4 +3,4 @@ app "test" provides [main] to "./platform" N := U8 implements [Encoding] main = Encode.toEncoder (@N 15) -# ^^^^^^^^^^^^^^^^ N#Encode.toEncoder(3): N -[[#N_toEncoder(3)]]-> Encoder fmt | fmt implements EncoderFormatting +# ^^^^^^^^^^^^^^^^ N#Encode.toEncoder(3): N -[[#N_toEncoder(3)]]-> Encoder fmt where fmt implements EncoderFormatting diff --git a/crates/compiler/uitest/tests/ability/specialize/opaque_hash_custom.txt b/crates/compiler/uitest/tests/ability/specialize/opaque_hash_custom.txt index 957352040c..a1260a48fd 100644 --- a/crates/compiler/uitest/tests/ability/specialize/opaque_hash_custom.txt +++ b/crates/compiler/uitest/tests/ability/specialize/opaque_hash_custom.txt @@ -5,4 +5,4 @@ Noop := {} implements [Hash {hash}] hash = \hasher, @Noop {} -> hasher main = \hasher -> hash hasher (@Noop {}) -#^^^^{-1} hasher -[[main(0)]]-> hasher | hasher implements Hasher +#^^^^{-1} hasher -[[main(0)]]-> hasher where hasher implements Hasher diff --git a/crates/compiler/uitest/tests/ability/specialize/opaque_hash_derive.txt b/crates/compiler/uitest/tests/ability/specialize/opaque_hash_derive.txt index b9aabd1cc5..bf0f35a607 100644 --- a/crates/compiler/uitest/tests/ability/specialize/opaque_hash_derive.txt +++ b/crates/compiler/uitest/tests/ability/specialize/opaque_hash_derive.txt @@ -3,4 +3,4 @@ app "test" provides [main] to "./platform" N := U8 implements [Hash] main = \hasher, @N n -> Hash.hash hasher (@N n) -# ^^^^^^^^^ N#Hash.hash(3): a, N -[[#N_hash(3)]]-> a | a implements Hasher +# ^^^^^^^^^ N#Hash.hash(3): a, N -[[#N_hash(3)]]-> a where a implements Hasher diff --git a/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization.txt b/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization.txt index 333219f2a8..09856a4f4c 100644 --- a/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization.txt +++ b/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization.txt @@ -1,11 +1,11 @@ app "test" provides [main] to "./platform" -F has f : a -> (b -> {}) | a implements F, b implements G -G has g : b -> {} | b implements G +F has f : a -> (b -> {}) where a implements F, b implements G +G has g : b -> {} where b implements G Fo := {} implements [F {f}] f = \@Fo {} -> g -#^{-1} Fo#f(7): Fo -[[f(7)]]-> (b -[[] + b:g(4):1]-> {}) | b implements G +#^{-1} Fo#f(7): Fo -[[f(7)]]-> (b -[[] + b:g(4):1]-> {}) where b implements G Go := {} implements [G {g}] g = \@Go {} -> {} diff --git a/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_bound_output.txt b/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_bound_output.txt index ed7cc865d3..7cf1ab95b8 100644 --- a/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_bound_output.txt +++ b/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_bound_output.txt @@ -1,11 +1,11 @@ app "test" provides [main] to "./platform" -F has f : a -> ({} -> b) | a implements F, b implements G -G has g : {} -> b | b implements G +F has f : a -> ({} -> b) where a implements F, b implements G +G has g : {} -> b where b implements G Fo := {} implements [F {f}] f = \@Fo {} -> g -#^{-1} Fo#f(7): Fo -[[f(7)]]-> ({} -[[] + b:g(4):1]-> b) | b implements G +#^{-1} Fo#f(7): Fo -[[f(7)]]-> ({} -[[] + b:g(4):1]-> b) where b implements G Go := {} implements [G {g}] g = \{} -> @Go {} diff --git a/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_branching_over_single_variable.txt b/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_branching_over_single_variable.txt index 951c75103c..fd4340d36a 100644 --- a/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_branching_over_single_variable.txt +++ b/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_branching_over_single_variable.txt @@ -1,7 +1,7 @@ app "test" provides [f] to "./platform" -J has j : j -> (k -> {}) | j implements J, k implements K -K has k : k -> {} | k implements K +J has j : j -> (k -> {}) where j implements J, k implements K +K has k : k -> {} where k implements K C := {} implements [J {j: jC}] jC = \@C _ -> k @@ -18,5 +18,5 @@ f = \flag, a, c -> A -> j a B -> j a it c -# ^ k | k implements K -# ^^ k -[[] + j:j(2):2]-> {} | j implements J, k implements K +# ^ k where k implements K +# ^^ k -[[] + j:j(2):2]-> {} where j implements J, k implements K diff --git a/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_varying_over_multiple_variables.txt b/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_varying_over_multiple_variables.txt index 323d607f77..907ffcb1e1 100644 --- a/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_varying_over_multiple_variables.txt +++ b/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_varying_over_multiple_variables.txt @@ -1,32 +1,32 @@ app "test" provides [main] to "./platform" -J has j : j -> (k -> {}) | j implements J, k implements K -K has k : k -> {} | k implements K +J has j : j -> (k -> {}) where j implements J, k implements K +K has k : k -> {} where k implements K C := {} implements [J {j: jC}] jC = \@C _ -> k -#^^{-1} C -[[jC(8)]]-> (k -[[] + k:k(4):1]-> {}) | k implements K +#^^{-1} C -[[jC(8)]]-> (k -[[] + k:k(4):1]-> {}) where k implements K D := {} implements [J {j: jD}] jD = \@D _ -> k -#^^{-1} D -[[jD(9)]]-> (k -[[] + k:k(4):1]-> {}) | k implements K +#^^{-1} D -[[jD(9)]]-> (k -[[] + k:k(4):1]-> {}) where k implements K E := {} implements [K {k}] k = \@E _ -> {} #^{-1} E#k(10): E -[[k(10)]]-> {} f = \flag, a, b -> -# ^ j | j implements J -# ^ j | j implements J +# ^ j where j implements J +# ^ j where j implements J it = -# ^^ k -[[] + j:j(2):2 + j1:j(2):2]-> {} | j implements J, j1 has J, k implements K +# ^^ k -[[] + j:j(2):2 + j1:j(2):2]-> {} where j implements J, j1 has J, k implements K when flag is A -> j a - # ^ J#j(2): j -[[] + j:j(2):1]-> (k -[[] + j:j(2):2 + j1:j(2):2]-> {}) | j implements J, j1 has J, k implements K + # ^ J#j(2): j -[[] + j:j(2):1]-> (k -[[] + j:j(2):2 + j1:j(2):2]-> {}) where j implements J, j1 has J, k implements K B -> j b - # ^ J#j(2): j -[[] + j:j(2):1]-> (k -[[] + j1:j(2):2 + j:j(2):2]-> {}) | j implements J, j1 has J, k implements K + # ^ J#j(2): j -[[] + j:j(2):1]-> (k -[[] + j1:j(2):2 + j:j(2):2]-> {}) where j implements J, j1 has J, k implements K it -# ^^ k -[[] + j:j(2):2 + j1:j(2):2]-> {} | j implements J, j1 has J, k implements K +# ^^ k -[[] + j:j(2):2 + j1:j(2):2]-> {} where j implements J, j1 has J, k implements K main = (f A (@C {}) (@D {})) (@E {}) # ^ [A, B], C, D -[[f(11)]]-> (E -[[k(10)]]-> {}) diff --git a/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_varying_over_multiple_variables_two_results.txt b/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_varying_over_multiple_variables_two_results.txt index a6f436e4b1..27f1f4b11d 100644 --- a/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_varying_over_multiple_variables_two_results.txt +++ b/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_varying_over_multiple_variables_two_results.txt @@ -1,15 +1,15 @@ app "test" provides [main] to "./platform" -J has j : j -> (k -> {}) | j implements J, k implements K -K has k : k -> {} | k implements K +J has j : j -> (k -> {}) where j implements J, k implements K +K has k : k -> {} where k implements K C := {} implements [J {j: jC}] jC = \@C _ -> k -#^^{-1} C -[[jC(9)]]-> (k -[[] + k:k(4):1]-> {}) | k implements K +#^^{-1} C -[[jC(9)]]-> (k -[[] + k:k(4):1]-> {}) where k implements K D := {} implements [J {j: jD}] jD = \@D _ -> k -#^^{-1} D -[[jD(10)]]-> (k -[[] + k:k(4):1]-> {}) | k implements K +#^^{-1} D -[[jD(10)]]-> (k -[[] + k:k(4):1]-> {}) where k implements K E := {} implements [K {k: kE}] kE = \@E _ -> {} @@ -20,24 +20,24 @@ kF = \@F _ -> {} #^^{-1} F -[[kF(12)]]-> {} f = \flag, a, b -> -# ^ j | j implements J -# ^ j | j implements J +# ^ j where j implements J +# ^ j where j implements J it = -# ^^ k -[[] + j:j(2):2 + j1:j(2):2]-> {} | j implements J, j1 has J, k implements K +# ^^ k -[[] + j:j(2):2 + j1:j(2):2]-> {} where j implements J, j1 has J, k implements K when flag is A -> j a - # ^ J#j(2): j -[[] + j:j(2):1]-> (k -[[] + j:j(2):2 + j1:j(2):2]-> {}) | j implements J, j1 has J, k implements K + # ^ J#j(2): j -[[] + j:j(2):1]-> (k -[[] + j:j(2):2 + j1:j(2):2]-> {}) where j implements J, j1 has J, k implements K B -> j b - # ^ J#j(2): j -[[] + j:j(2):1]-> (k -[[] + j1:j(2):2 + j:j(2):2]-> {}) | j implements J, j1 has J, k implements K + # ^ J#j(2): j -[[] + j:j(2):1]-> (k -[[] + j1:j(2):2 + j:j(2):2]-> {}) where j implements J, j1 has J, k implements K it -# ^^ k -[[] + j:j(2):2 + j1:j(2):2]-> {} | j implements J, j1 has J, k implements K +# ^^ k -[[] + j:j(2):2 + j1:j(2):2]-> {} where j implements J, j1 has J, k implements K main = #^^^^{-1} {} it = \x -> -# ^^ k -[[it(21)]]-> {} | k implements K +# ^^ k -[[it(21)]]-> {} where k implements K (f A (@C {}) (@D {})) x -# ^ [A, B], C, D -[[f(13)]]-> (k -[[] + k:k(4):1]-> {}) | k implements K +# ^ [A, B], C, D -[[f(13)]]-> (k -[[] + k:k(4):1]-> {}) where k implements K if Bool.true then it (@E {}) # ^^ E -[[it(21)]]-> {} diff --git a/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_with_deep_specialization_and_capture.txt b/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_with_deep_specialization_and_capture.txt index 6c83ef6b6a..57331a3945 100644 --- a/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_with_deep_specialization_and_capture.txt +++ b/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_with_deep_specialization_and_capture.txt @@ -1,11 +1,11 @@ app "test" provides [main] to "./platform" -F has f : a, b -> ({} -> ({} -> {})) | a implements F, b implements G -G has g : b -> ({} -> {}) | b implements G +F has f : a, b -> ({} -> ({} -> {})) where a implements F, b implements G +G has g : b -> ({} -> {}) where b implements G Fo := {} implements [F {f}] f = \@Fo {}, b -> \{} -> g b -#^{-1} Fo#f(7): Fo, b -[[f(7)]]-> ({} -[[13 b]]-> ({} -[[] + b:g(4):2]-> {})) | b implements G +#^{-1} Fo#f(7): Fo, b -[[f(7)]]-> ({} -[[13 b]]-> ({} -[[] + b:g(4):2]-> {})) where b implements G Go := {} implements [G {g}] g = \@Go {} -> \{} -> {} diff --git a/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_with_let_weakened.txt b/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_with_let_weakened.txt index 618d29dcc3..56dd2e7478 100644 --- a/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_with_let_weakened.txt +++ b/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_with_let_weakened.txt @@ -1,11 +1,11 @@ app "test" provides [main] to "./platform" -F has f : a -> (b -> {}) | a implements F, b implements G -G has g : b -> {} | b implements G +F has f : a -> (b -> {}) where a implements F, b implements G +G has g : b -> {} where b implements G Fo := {} implements [F {f}] f = \@Fo {} -> g -#^{-1} Fo#f(7): Fo -[[f(7)]]-> (b -[[] + b:g(4):1]-> {}) | b implements G +#^{-1} Fo#f(7): Fo -[[f(7)]]-> (b -[[] + b:g(4):1]-> {}) where b implements G Go := {} implements [G {g}] g = \@Go {} -> {} diff --git a/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_with_let_weakened_unapplied.txt b/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_with_let_weakened_unapplied.txt index 71dc02b2cc..4cdda67509 100644 --- a/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_with_let_weakened_unapplied.txt +++ b/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_with_let_weakened_unapplied.txt @@ -1,19 +1,19 @@ app "test" provides [main] to "./platform" -F has f : a -> (b -> {}) | a implements F, b implements G -G has g : b -> {} | b implements G +F has f : a -> (b -> {}) where a implements F, b implements G +G has g : b -> {} where b implements G Fo := {} implements [F {f}] f = \@Fo {} -> g -#^{-1} Fo#f(7): Fo -[[f(7)]]-> (b -[[] + b:g(4):1]-> {}) | b implements G +#^{-1} Fo#f(7): Fo -[[f(7)]]-> (b -[[] + b:g(4):1]-> {}) where b implements G Go := {} implements [G {g}] g = \@Go {} -> {} #^{-1} Go#g(8): Go -[[g(8)]]-> {} main = -#^^^^{-1} b -[[] + b:g(4):1]-> {} | b implements G +#^^^^{-1} b -[[] + b:g(4):1]-> {} where b implements G h = f (@Fo {}) -# ^ Fo#f(7): Fo -[[f(7)]]-> (b -[[] + b:g(4):1]-> {}) | b implements G -# ^ b -[[] + b:g(4):1]-> {} | b implements G +# ^ Fo#f(7): Fo -[[f(7)]]-> (b -[[] + b:g(4):1]-> {}) where b implements G +# ^ b -[[] + b:g(4):1]-> {} where b implements G h diff --git a/crates/compiler/uitest/tests/ability/specialize/ranged_num_hash.txt b/crates/compiler/uitest/tests/ability/specialize/ranged_num_hash.txt index 8653bb77c7..0cfad58ac9 100644 --- a/crates/compiler/uitest/tests/ability/specialize/ranged_num_hash.txt +++ b/crates/compiler/uitest/tests/ability/specialize/ranged_num_hash.txt @@ -2,4 +2,4 @@ app "test" provides [main] to "./platform" main = \h -> Hash.hash h 7 - # ^^^^^^^^^ Hash#Hash.hash(1): a, I64 -[[Hash.hashI64(13)]]-> a | a implements Hasher + # ^^^^^^^^^ Hash#Hash.hash(1): a, I64 -[[Hash.hashI64(13)]]-> a where a implements Hasher diff --git a/crates/compiler/uitest/tests/ability/specialize/record_to_encoder.txt b/crates/compiler/uitest/tests/ability/specialize/record_to_encoder.txt index 390df75dfb..e3b4e8cdc8 100644 --- a/crates/compiler/uitest/tests/ability/specialize/record_to_encoder.txt +++ b/crates/compiler/uitest/tests/ability/specialize/record_to_encoder.txt @@ -3,4 +3,4 @@ app "test" provides [main] to "./platform" main = toEncoder { a: "" } - # ^^^^^^^^^ Encoding#toEncoder(2): { a : Str } -[[#Derived.toEncoder_{a}(0)]]-> Encoder fmt | fmt implements EncoderFormatting + # ^^^^^^^^^ Encoding#toEncoder(2): { a : Str } -[[#Derived.toEncoder_{a}(0)]]-> Encoder fmt where fmt implements EncoderFormatting diff --git a/crates/compiler/uitest/tests/ability/specialize/record_to_encoder_with_nested_custom_impl.txt b/crates/compiler/uitest/tests/ability/specialize/record_to_encoder_with_nested_custom_impl.txt index ba43f3905f..769296f3cf 100644 --- a/crates/compiler/uitest/tests/ability/specialize/record_to_encoder_with_nested_custom_impl.txt +++ b/crates/compiler/uitest/tests/ability/specialize/record_to_encoder_with_nested_custom_impl.txt @@ -6,4 +6,4 @@ A := {} implements [Encoding {toEncoder}] toEncoder = \@A _ -> custom \b, _ -> b main = toEncoder { a: @A {} } - # ^^^^^^^^^ Encoding#toEncoder(2): { a : A } -[[#Derived.toEncoder_{a}(0)]]-> Encoder fmt | fmt implements EncoderFormatting + # ^^^^^^^^^ Encoding#toEncoder(2): { a : A } -[[#Derived.toEncoder_{a}(0)]]-> Encoder fmt where fmt implements EncoderFormatting diff --git a/crates/compiler/uitest/tests/ability/specialize/resolve_lambda_set_ability_chain.txt b/crates/compiler/uitest/tests/ability/specialize/resolve_lambda_set_ability_chain.txt index 00439c028a..6903975585 100644 --- a/crates/compiler/uitest/tests/ability/specialize/resolve_lambda_set_ability_chain.txt +++ b/crates/compiler/uitest/tests/ability/specialize/resolve_lambda_set_ability_chain.txt @@ -1,7 +1,7 @@ app "test" provides [main] to "./platform" -Id1 has id1 : a -> a | a implements Id1 -Id2 has id2 : a -> a | a implements Id2 +Id1 has id1 : a -> a where a implements Id1 +Id2 has id2 : a -> a where a implements Id2 A := {} implements [Id1 {id1}, Id2 {id2}] id1 = \@A {} -> @A {} diff --git a/crates/compiler/uitest/tests/ability/specialize/resolve_lambda_set_branches_ability_vs_non_ability.txt b/crates/compiler/uitest/tests/ability/specialize/resolve_lambda_set_branches_ability_vs_non_ability.txt index 7fec6cf4b5..56fb6b5fed 100644 --- a/crates/compiler/uitest/tests/ability/specialize/resolve_lambda_set_branches_ability_vs_non_ability.txt +++ b/crates/compiler/uitest/tests/ability/specialize/resolve_lambda_set_branches_ability_vs_non_ability.txt @@ -1,6 +1,6 @@ app "test" provides [main] to "./platform" -Id has id : a -> a | a implements Id +Id has id : a -> a where a implements Id A := {} implements [Id {id}] id = \@A {} -> @A {} diff --git a/crates/compiler/uitest/tests/ability/specialize/resolve_lambda_set_branches_same_ability.txt b/crates/compiler/uitest/tests/ability/specialize/resolve_lambda_set_branches_same_ability.txt index 7fd08456e2..744dc8ed30 100644 --- a/crates/compiler/uitest/tests/ability/specialize/resolve_lambda_set_branches_same_ability.txt +++ b/crates/compiler/uitest/tests/ability/specialize/resolve_lambda_set_branches_same_ability.txt @@ -1,6 +1,6 @@ app "test" provides [main] to "./platform" -Id has id : a -> a | a implements Id +Id has id : a -> a where a implements Id A := {} implements [Id {id}] id = \@A {} -> @A {} diff --git a/crates/compiler/uitest/tests/ability/specialize/resolve_lambda_set_generalized_ability_alias.txt b/crates/compiler/uitest/tests/ability/specialize/resolve_lambda_set_generalized_ability_alias.txt index 172090ca5b..76b859f1de 100644 --- a/crates/compiler/uitest/tests/ability/specialize/resolve_lambda_set_generalized_ability_alias.txt +++ b/crates/compiler/uitest/tests/ability/specialize/resolve_lambda_set_generalized_ability_alias.txt @@ -1,6 +1,6 @@ app "test" provides [main] to "./platform" -Id has id : a -> a | a implements Id +Id has id : a -> a where a implements Id A := {} implements [Id {id}] id = \@A {} -> @A {} @@ -8,9 +8,9 @@ id = \@A {} -> @A {} main = alias1 = \x -> id x - # ^^ Id#id(2): a -[[] + a:id(2):1]-> a | a implements Id + # ^^ Id#id(2): a -[[] + a:id(2):1]-> a where a implements Id alias2 = \x -> alias1 x - # ^^^^^^ a -[[alias1(6)]]-> a | a implements Id + # ^^^^^^ a -[[alias1(6)]]-> a where a implements Id a : A a = alias2 (@A {}) diff --git a/crates/compiler/uitest/tests/ability/specialize/resolve_lambda_set_weakened_ability_alias.txt b/crates/compiler/uitest/tests/ability/specialize/resolve_lambda_set_weakened_ability_alias.txt index 004c1d70cb..6304b2434d 100644 --- a/crates/compiler/uitest/tests/ability/specialize/resolve_lambda_set_weakened_ability_alias.txt +++ b/crates/compiler/uitest/tests/ability/specialize/resolve_lambda_set_weakened_ability_alias.txt @@ -1,6 +1,6 @@ app "test" provides [main] to "./platform" -Id has id : a -> a | a implements Id +Id has id : a -> a where a implements Id A := {} implements [Id {id}] id = \@A {} -> @A {} diff --git a/crates/compiler/uitest/tests/ability/specialize/resolve_mutually_recursive_ability_lambda_sets.txt b/crates/compiler/uitest/tests/ability/specialize/resolve_mutually_recursive_ability_lambda_sets.txt index 91e20eb8f9..3c6fdc4f49 100644 --- a/crates/compiler/uitest/tests/ability/specialize/resolve_mutually_recursive_ability_lambda_sets.txt +++ b/crates/compiler/uitest/tests/ability/specialize/resolve_mutually_recursive_ability_lambda_sets.txt @@ -1,8 +1,8 @@ app "test" provides [main] to "./platform" Bounce has - ping : a -> a | a implements Bounce - pong : a -> a | a implements Bounce + ping : a -> a where a implements Bounce + pong : a -> a where a implements Bounce A := {} implements [Bounce {ping: pingA, pong: pongA}] diff --git a/crates/compiler/uitest/tests/ability/specialize/resolve_mutually_recursive_ability_lambda_sets_inferred.txt b/crates/compiler/uitest/tests/ability/specialize/resolve_mutually_recursive_ability_lambda_sets_inferred.txt index a6af367fe1..43a739a59a 100644 --- a/crates/compiler/uitest/tests/ability/specialize/resolve_mutually_recursive_ability_lambda_sets_inferred.txt +++ b/crates/compiler/uitest/tests/ability/specialize/resolve_mutually_recursive_ability_lambda_sets_inferred.txt @@ -1,8 +1,8 @@ app "test" provides [main] to "./platform" Bounce has - ping : a -> a | a implements Bounce - pong : a -> a | a implements Bounce + ping : a -> a where a implements Bounce + pong : a -> a where a implements Bounce A := {} implements [Bounce {ping, pong}] diff --git a/crates/compiler/uitest/tests/ability/specialize/resolve_recursive_ability_lambda_set.txt b/crates/compiler/uitest/tests/ability/specialize/resolve_recursive_ability_lambda_set.txt index db9090568e..a6373f7eaf 100644 --- a/crates/compiler/uitest/tests/ability/specialize/resolve_recursive_ability_lambda_set.txt +++ b/crates/compiler/uitest/tests/ability/specialize/resolve_recursive_ability_lambda_set.txt @@ -1,6 +1,6 @@ app "test" provides [main] to "./platform" -Diverge has diverge : a -> a | a implements Diverge +Diverge has diverge : a -> a where a implements Diverge A := {} implements [Diverge {diverge}] diff --git a/crates/compiler/uitest/tests/ability/specialize/resolve_two_unspecialized_lambda_sets_in_one_lambda_set.txt b/crates/compiler/uitest/tests/ability/specialize/resolve_two_unspecialized_lambda_sets_in_one_lambda_set.txt index 1b7828e9fe..8b572588f3 100644 --- a/crates/compiler/uitest/tests/ability/specialize/resolve_two_unspecialized_lambda_sets_in_one_lambda_set.txt +++ b/crates/compiler/uitest/tests/ability/specialize/resolve_two_unspecialized_lambda_sets_in_one_lambda_set.txt @@ -3,7 +3,7 @@ app "test" provides [main] to "./platform" Thunk a : {} -> a -Id has id : a -> Thunk a | a implements Id +Id has id : a -> Thunk a where a implements Id A := {} implements [Id {id}] id = \@A {} -> \{} -> @A {} diff --git a/crates/compiler/uitest/tests/ability/specialize/resolve_unspecialized_lambda_set_behind_alias.txt b/crates/compiler/uitest/tests/ability/specialize/resolve_unspecialized_lambda_set_behind_alias.txt index 2965caa4ad..5431c48b1a 100644 --- a/crates/compiler/uitest/tests/ability/specialize/resolve_unspecialized_lambda_set_behind_alias.txt +++ b/crates/compiler/uitest/tests/ability/specialize/resolve_unspecialized_lambda_set_behind_alias.txt @@ -3,7 +3,7 @@ app "test" provides [main] to "./platform" Thunk a : {} -> a -Id has id : a -> Thunk a | a implements Id +Id has id : a -> Thunk a where a implements Id A := {} implements [Id {id}] id = \@A {} -> \{} -> @A {} @@ -11,7 +11,7 @@ id = \@A {} -> \{} -> @A {} main = alias = \x -> id x - # ^^ Id#id(3): a -[[] + a:id(3):1]-> ({} -[[] + a:id(3):2]-> a) | a implements Id + # ^^ Id#id(3): a -[[] + a:id(3):1]-> ({} -[[] + a:id(3):2]-> a) where a implements Id a : A a = (alias (@A {})) {} diff --git a/crates/compiler/uitest/tests/ability/specialize/resolve_unspecialized_lambda_set_behind_opaque.txt b/crates/compiler/uitest/tests/ability/specialize/resolve_unspecialized_lambda_set_behind_opaque.txt index eec59f3109..25352cdabf 100644 --- a/crates/compiler/uitest/tests/ability/specialize/resolve_unspecialized_lambda_set_behind_opaque.txt +++ b/crates/compiler/uitest/tests/ability/specialize/resolve_unspecialized_lambda_set_behind_opaque.txt @@ -3,7 +3,7 @@ app "test" provides [main] to "./platform" Thunk a := {} -> a -Id has id : a -> Thunk a | a implements Id +Id has id : a -> Thunk a where a implements Id A := {} implements [Id {id}] id = \@A {} -> @Thunk (\{} -> @A {}) diff --git a/crates/compiler/uitest/tests/ability/specialize/static_specialization.txt b/crates/compiler/uitest/tests/ability/specialize/static_specialization.txt index 79f047465a..01dadc8d6f 100644 --- a/crates/compiler/uitest/tests/ability/specialize/static_specialization.txt +++ b/crates/compiler/uitest/tests/ability/specialize/static_specialization.txt @@ -1,6 +1,6 @@ app "test" provides [main] to "./platform" -Default has default : {} -> a | a implements Default +Default has default : {} -> a where a implements Default A := {} implements [Default {default}] default = \{} -> @A {} diff --git a/crates/compiler/uitest/tests/instantiate/call_generic_ability_member.txt b/crates/compiler/uitest/tests/instantiate/call_generic_ability_member.txt index 48a4646cf9..6e99d30a57 100644 --- a/crates/compiler/uitest/tests/instantiate/call_generic_ability_member.txt +++ b/crates/compiler/uitest/tests/instantiate/call_generic_ability_member.txt @@ -1,7 +1,7 @@ app "test" provides [main] to "./platform" X has - consume : a -> {} | a implements X + consume : a -> {} where a implements X O := {} implements [X {consume: consumeO}] @@ -12,8 +12,8 @@ P := {} implements [X {consume: consumeP}] consumeP = \@P {} -> {} caller = \x -> consume x -# ^ a | a implements X -# ^^^^^^^ X#consume(2): a -[[] + a:consume(2):1]-> {} | a implements X +# ^ a where a implements X +# ^^^^^^^ X#consume(2): a -[[] + a:consume(2):1]-> {} where a implements X main = { a: caller (@O {}), diff --git a/crates/compiler/uitest/tests/solve/ability_checked_specialization_with_annotation_only.txt b/crates/compiler/uitest/tests/solve/ability_checked_specialization_with_annotation_only.txt index b904dabe30..366d156d8b 100644 --- a/crates/compiler/uitest/tests/solve/ability_checked_specialization_with_annotation_only.txt +++ b/crates/compiler/uitest/tests/solve/ability_checked_specialization_with_annotation_only.txt @@ -1,7 +1,7 @@ app "test" provides [hash] to "./platform" MHash implements - hash : a -> U64 | a implements MHash + hash : a -> U64 where a implements MHash Id := U64 implements [MHash {hash}] diff --git a/crates/compiler/uitest/tests/solve/ability_checked_specialization_with_typed_body.txt b/crates/compiler/uitest/tests/solve/ability_checked_specialization_with_typed_body.txt index 19fba98d6f..db85fb9c61 100644 --- a/crates/compiler/uitest/tests/solve/ability_checked_specialization_with_typed_body.txt +++ b/crates/compiler/uitest/tests/solve/ability_checked_specialization_with_typed_body.txt @@ -1,7 +1,7 @@ app "test" provides [hash] to "./platform" MHash implements - hash : a -> U64 | a implements MHash + hash : a -> U64 where a implements MHash Id := U64 implements [MHash {hash}] diff --git a/crates/compiler/uitest/tests/solve/ability_constrained_in_non_member_check.txt b/crates/compiler/uitest/tests/solve/ability_constrained_in_non_member_check.txt index e8f330c0e3..72f5a2fe3d 100644 --- a/crates/compiler/uitest/tests/solve/ability_constrained_in_non_member_check.txt +++ b/crates/compiler/uitest/tests/solve/ability_constrained_in_non_member_check.txt @@ -1,8 +1,8 @@ app "test" provides [hashEq] to "./platform" MHash implements - hash : a -> U64 | a implements MHash + hash : a -> U64 where a implements MHash -hashEq : a, a -> Bool | a implements MHash +hashEq : a, a -> Bool where a implements MHash hashEq = \x, y -> hash x == hash y -#^^^^^^{-1} a, a -[[hashEq(0)]]-> Bool | a implements MHash +#^^^^^^{-1} a, a -[[hashEq(0)]]-> Bool where a implements MHash diff --git a/crates/compiler/uitest/tests/solve/ability_constrained_in_non_member_infer.txt b/crates/compiler/uitest/tests/solve/ability_constrained_in_non_member_infer.txt index 5130b11d44..2344a9922c 100644 --- a/crates/compiler/uitest/tests/solve/ability_constrained_in_non_member_infer.txt +++ b/crates/compiler/uitest/tests/solve/ability_constrained_in_non_member_infer.txt @@ -1,7 +1,7 @@ app "test" provides [hashEq] to "./platform" MHash implements - hash : a -> U64 | a implements MHash + hash : a -> U64 where a implements MHash hashEq = \x, y -> hash x == hash y -#^^^^^^{-1} a, a1 -[[hashEq(0)]]-> Bool | a implements MHash, a1 implements MHash +#^^^^^^{-1} a, a1 -[[hashEq(0)]]-> Bool where a implements MHash, a1 implements MHash diff --git a/crates/compiler/uitest/tests/solve/ability_constrained_in_non_member_infer_usage.txt b/crates/compiler/uitest/tests/solve/ability_constrained_in_non_member_infer_usage.txt index 30c0829af3..4e55a6ded3 100644 --- a/crates/compiler/uitest/tests/solve/ability_constrained_in_non_member_infer_usage.txt +++ b/crates/compiler/uitest/tests/solve/ability_constrained_in_non_member_infer_usage.txt @@ -1,7 +1,7 @@ app "test" provides [result] to "./platform" MHash implements - hash : a -> U64 | a implements MHash + hash : a -> U64 where a implements MHash hashEq = \x, y -> hash x == hash y diff --git a/crates/compiler/uitest/tests/solve/ability_constrained_in_non_member_multiple_specializations.txt b/crates/compiler/uitest/tests/solve/ability_constrained_in_non_member_multiple_specializations.txt index 552c80b60b..34e014097c 100644 --- a/crates/compiler/uitest/tests/solve/ability_constrained_in_non_member_multiple_specializations.txt +++ b/crates/compiler/uitest/tests/solve/ability_constrained_in_non_member_multiple_specializations.txt @@ -1,7 +1,7 @@ app "test" provides [result] to "./platform" MHash implements - hash : a -> U64 | a implements MHash + hash : a -> U64 where a implements MHash mulMHashes = \x, y -> hash x * hash y diff --git a/crates/compiler/uitest/tests/solve/ability_specialization_called.txt b/crates/compiler/uitest/tests/solve/ability_specialization_called.txt index 20b56e049b..632b5eac6c 100644 --- a/crates/compiler/uitest/tests/solve/ability_specialization_called.txt +++ b/crates/compiler/uitest/tests/solve/ability_specialization_called.txt @@ -1,7 +1,7 @@ app "test" provides [zero] to "./platform" MHash implements - hash : a -> U64 | a implements MHash + hash : a -> U64 where a implements MHash Id := U64 implements [MHash {hash}] diff --git a/crates/compiler/uitest/tests/solve/alias_ability_member.txt b/crates/compiler/uitest/tests/solve/alias_ability_member.txt index ab5f5d7e9c..550365d066 100644 --- a/crates/compiler/uitest/tests/solve/alias_ability_member.txt +++ b/crates/compiler/uitest/tests/solve/alias_ability_member.txt @@ -1,9 +1,9 @@ app "test" provides [thething] to "./platform" MHash implements - hash : a -> U64 | a implements MHash + hash : a -> U64 where a implements MHash thething = -#^^^^^^^^{-1} a -[[] + a:hash(2):1]-> U64 | a implements MHash +#^^^^^^^^{-1} a -[[] + a:hash(2):1]-> U64 where a implements MHash itis = hash itis diff --git a/crates/compiler/uitest/tests/solve/alias_propagates_able_var.txt b/crates/compiler/uitest/tests/solve/alias_propagates_able_var.txt index 01d4d57187..f4719ca9c7 100644 --- a/crates/compiler/uitest/tests/solve/alias_propagates_able_var.txt +++ b/crates/compiler/uitest/tests/solve/alias_propagates_able_var.txt @@ -1,8 +1,8 @@ app "test" provides [zeroEncoder] to "./platform" -MEncoder fmt := List U8, fmt -> List U8 | fmt implements Format +MEncoder fmt := List U8, fmt -> List U8 where fmt implements Format -Format implements it : fmt -> {} | fmt implements Format +Format implements it : fmt -> {} where fmt implements Format zeroEncoder = @MEncoder \lst, _ -> lst -#^^^^^^^^^^^{-1} MEncoder a | a implements Format +#^^^^^^^^^^^{-1} MEncoder a where a implements Format diff --git a/crates/compiler/uitest/tests/solve/exposed_ability_name.txt b/crates/compiler/uitest/tests/solve/exposed_ability_name.txt index 875af03cea..f22850b009 100644 --- a/crates/compiler/uitest/tests/solve/exposed_ability_name.txt +++ b/crates/compiler/uitest/tests/solve/exposed_ability_name.txt @@ -1,6 +1,6 @@ app "test" provides [main] to "./platform" -MHash implements hash : a -> U64 | a implements MHash +MHash implements hash : a -> U64 where a implements MHash main = hash -# ^^^^ MHash#hash(2): a -[[] + a:hash(2):1]-> U64 | a implements MHash +# ^^^^ MHash#hash(2): a -[[] + a:hash(2):1]-> U64 where a implements MHash diff --git a/crates/compiler/uitest/tests/solve/multiple_abilities_multiple_members_specializations.txt b/crates/compiler/uitest/tests/solve/multiple_abilities_multiple_members_specializations.txt index b572ce562c..adddd308cb 100644 --- a/crates/compiler/uitest/tests/solve/multiple_abilities_multiple_members_specializations.txt +++ b/crates/compiler/uitest/tests/solve/multiple_abilities_multiple_members_specializations.txt @@ -1,12 +1,12 @@ app "test" provides [hash, hash32, eq, le] to "./platform" MHash implements - hash : a -> U64 | a implements MHash - hash32 : a -> U32 | a implements MHash + hash : a -> U64 where a implements MHash + hash32 : a -> U32 where a implements MHash Ord implements - eq : a, a -> Bool | a implements Ord - le : a, a -> Bool | a implements Ord + eq : a, a -> Bool where a implements Ord + le : a, a -> Bool where a implements Ord Id := U64 implements [MHash {hash, hash32}, Ord {eq, le}] diff --git a/crates/compiler/uitest/tests/solve/single_ability_multiple_members_specializations.txt b/crates/compiler/uitest/tests/solve/single_ability_multiple_members_specializations.txt index 37b18653c0..5738eebcd6 100644 --- a/crates/compiler/uitest/tests/solve/single_ability_multiple_members_specializations.txt +++ b/crates/compiler/uitest/tests/solve/single_ability_multiple_members_specializations.txt @@ -1,8 +1,8 @@ app "test" provides [hash, hash32] to "./platform" MHash implements - hash : a -> U64 | a implements MHash - hash32 : a -> U32 | a implements MHash + hash : a -> U64 where a implements MHash + hash32 : a -> U32 where a implements MHash Id := U64 implements [MHash {hash, hash32}] diff --git a/crates/compiler/uitest/tests/solve/single_ability_single_member_specializations.txt b/crates/compiler/uitest/tests/solve/single_ability_single_member_specializations.txt index 190a4d2701..a49c763de5 100644 --- a/crates/compiler/uitest/tests/solve/single_ability_single_member_specializations.txt +++ b/crates/compiler/uitest/tests/solve/single_ability_single_member_specializations.txt @@ -1,6 +1,6 @@ app "test" provides [hash] to "./platform" -MHash implements hash : a -> U64 | a implements MHash +MHash implements hash : a -> U64 where a implements MHash Id := U64 implements [MHash {hash}] diff --git a/crates/reporting/src/error/type.rs b/crates/reporting/src/error/type.rs index 2223bbd825..378f6d902e 100644 --- a/crates/reporting/src/error/type.rs +++ b/crates/reporting/src/error/type.rs @@ -403,7 +403,8 @@ fn underivable_hint<'b>( alloc.keyword(roc_parse::keyword::IMPLEMENTS), alloc.reflow(" clause to bind the type variable, like "), alloc.inline_type_block(alloc.concat([ - alloc.string("| ".to_string()), + alloc.keyword(roc_parse::keyword::WHERE), + alloc.space(), alloc.type_variable(v.clone()), alloc.space(), alloc.keyword(roc_parse::keyword::IMPLEMENTS), @@ -2755,7 +2756,13 @@ fn type_with_able_vars<'b>( doc.push(typ); for (i, (var, abilities)) in able.into_iter().enumerate() { - doc.push(alloc.string(if i == 0 { " | " } else { ", " }.to_string())); + if i == 0 { + doc.push(alloc.space()); + doc.push(alloc.keyword(roc_parse::keyword::WHERE)); + } else { + doc.push(alloc.string(",".to_string())); + } + doc.push(alloc.space()); doc.push(alloc.type_variable(var)); doc.push(alloc.space()); doc.push(alloc.keyword(roc_parse::keyword::IMPLEMENTS)); diff --git a/crates/reporting/tests/test_reporting.rs b/crates/reporting/tests/test_reporting.rs index 6b3e7cd079..bebad3e4ab 100644 --- a/crates/reporting/tests/test_reporting.rs +++ b/crates/reporting/tests/test_reporting.rs @@ -6488,7 +6488,7 @@ In roc, functions are always written as a lambda, like{} inference_var_conflict_in_rigid_links, indoc!( r#" - f : a -> (_ -> b) | a implements Eq + f : a -> (_ -> b) where a implements Eq f = \x -> \y -> if x == y then x else y f "# @@ -6499,17 +6499,17 @@ In roc, functions are always written as a lambda, like{} Something is off with the body of the `f` definition: - 4│ f : a -> (_ -> b) | a implements Eq + 4│ f : a -> (_ -> b) where a implements Eq 5│ f = \x -> \y -> if x == y then x else y ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ The body is an anonymous function of type: - a -> a | a implements Eq, a implements Eq + a -> a where a implements Eq, a implements Eq But the type annotation on `f` says it should be: - a -> b | a implements Eq + a -> b where a implements Eq Tip: Your type annotation uses `b` and `a` as separate type variables. Your code seems to be saying they are the same though. Maybe they @@ -8207,7 +8207,7 @@ In roc, functions are always written as a lambda, like{} indoc!( r#" MEq implements - eq : a, a -> U64 | a implements MEq + eq : a, a -> U64 where a implements MEq 1 "# @@ -8219,7 +8219,7 @@ In roc, functions are always written as a lambda, like{} here: 4│ MEq implements - 5│ eq : a, a -> U64 | a implements MEq + 5│ eq : a, a -> U64 where a implements MEq ^ I suspect this line is not indented enough (by 1 spaces) @@ -8231,8 +8231,8 @@ In roc, functions are always written as a lambda, like{} indoc!( r#" MEq implements - eq : a, a -> U64 | a implements MEq - neq : a, a -> U64 | a implements MEq + eq : a, a -> U64 where a implements MEq + neq : a, a -> U64 where a implements MEq 1 "# @@ -8243,8 +8243,8 @@ In roc, functions are always written as a lambda, like{} I was partway through parsing an ability definition, but I got stuck here: - 5│ eq : a, a -> U64 | a implements MEq - 6│ neq : a, a -> U64 | a implements MEq + 5│ eq : a, a -> U64 where a implements MEq + 6│ neq : a, a -> U64 where a implements MEq ^ I suspect this line is indented too much (by 4 spaces)"# @@ -8255,7 +8255,7 @@ In roc, functions are always written as a lambda, like{} indoc!( r#" MEq implements - eq b c : a, a -> U64 | a implements MEq + eq b c : a, a -> U64 where a implements MEq 1 "# @@ -8267,7 +8267,7 @@ In roc, functions are always written as a lambda, like{} here: 4│ MEq implements - 5│ eq b c : a, a -> U64 | a implements MEq + 5│ eq b c : a, a -> U64 where a implements MEq ^ I was expecting to see a : annotating the signature of this value @@ -8417,7 +8417,7 @@ In roc, functions are always written as a lambda, like{} app "test" provides [] to "./platform" MHash a b c implements - hash : a -> U64 | a implements MHash + hash : a -> U64 where a implements MHash "# ), @r###" @@ -8449,7 +8449,7 @@ In roc, functions are always written as a lambda, like{} r#" app "test" provides [hash] to "./platform" - MHash implements hash : a, b -> Num.U64 | a implements MHash, b implements Bool.Bool + MHash implements hash : a, b -> Num.U64 where a implements MHash, b implements Bool.Bool "# ), @r###" @@ -8457,8 +8457,8 @@ In roc, functions are always written as a lambda, like{} The type referenced in this "implements" clause is not an ability: - 3│ MHash implements hash : a, b -> Num.U64 | a implements MHash, b implements Bool.Bool - ^^^^^^^^^ + 3│ MHash implements hash : a, b -> Num.U64 where a implements MHash, b implements Bool.Bool + ^^^^^^^^^ "### ); @@ -8468,7 +8468,7 @@ In roc, functions are always written as a lambda, like{} r#" app "test" provides [ab1] to "./platform" - Ab1 implements ab1 : a -> {} | a implements Ab1, a implements Ab1 + Ab1 implements ab1 : a -> {} where a implements Ab1, a implements Ab1 "# ), @r#" @@ -8476,13 +8476,13 @@ In roc, functions are always written as a lambda, like{} The `a` name is first defined here: - 3│ Ab1 implements ab1 : a -> {} | a implements Ab1, a implements Ab1 - ^^^^^^^^^^^^^^^^ + 3│ Ab1 implements ab1 : a -> {} where a implements Ab1, a implements Ab1 + ^^^^^^^^^^^^^^^^ But then it's defined a second time here: - 3│ Ab1 implements ab1 : a -> {} | a implements Ab1, a implements Ab1 - ^^^^^^^^^^^^^^^^ + 3│ Ab1 implements ab1 : a -> {} where a implements Ab1, a implements Ab1 + ^^^^^^^^^^^^^^^^ Since these variables have the same name, it's easy to use the wrong one by accident. Give one of them a new name. @@ -8495,9 +8495,9 @@ In roc, functions are always written as a lambda, like{} r#" app "test" provides [ab] to "./platform" - Ability implements ab : a -> U64 | a implements Ability + Ability implements ab : a -> U64 where a implements Ability - Ability implements ab1 : a -> U64 | a implements Ability + Ability implements ab1 : a -> U64 where a implements Ability "# ), @r#" @@ -8505,12 +8505,12 @@ In roc, functions are always written as a lambda, like{} The `Ability` name is first defined here: - 3│ Ability implements ab : a -> U64 | a implements Ability + 3│ Ability implements ab : a -> U64 where a implements Ability ^^^^^^^ But then it's defined a second time here: - 5│ Ability implements ab1 : a -> U64 | a implements Ability + 5│ Ability implements ab1 : a -> U64 where a implements Ability ^^^^^^^ Since these abilities have the same name, it's easy to use the wrong @@ -8561,7 +8561,7 @@ In roc, functions are always written as a lambda, like{} r#" app "test" provides [] to "./platform" - MEq implements eq : a, b -> Bool.Bool | a implements MEq, b implements MEq + MEq implements eq : a, b -> Bool.Bool where a implements MEq, b implements MEq "# ), @r#" @@ -8570,8 +8570,8 @@ In roc, functions are always written as a lambda, like{} The definition of the ability member `eq` includes multiple variables bound to the `MEq`` ability:` - 3│ MEq implements eq : a, b -> Bool.Bool | a implements MEq, b implements MEq - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + 3│ MEq implements eq : a, b -> Bool.Bool where a implements MEq, b implements MEq + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Ability members can only bind one type variable to their parent ability. Otherwise, I wouldn't know what type implements an ability by @@ -8587,9 +8587,9 @@ In roc, functions are always written as a lambda, like{} r#" app "test" provides [f] to "./platform" - MHash implements hash : (a | a implements MHash) -> Num.U64 + MHash implements hash : (a where a implements MHash) -> Num.U64 - f : a -> Num.U64 | a implements MHash + f : a -> Num.U64 where a implements MHash "# ), @r###" @@ -8597,8 +8597,8 @@ In roc, functions are always written as a lambda, like{} An `implements` clause is not allowed here: - 3│ MHash implements hash : (a | a implements MHash) -> Num.U64 - ^^^^^^^^^^^^^^^^^^ + 3│ MHash implements hash : (a where a implements MHash) -> Num.U64 + ^^^^^^^^^^^^^^^^^^ `implements` clauses can only be specified on the top-level type annotations. @@ -8608,7 +8608,7 @@ In roc, functions are always written as a lambda, like{} The definition of the ability member `hash` does not include an `implements` clause binding a type variable to the ability `MHash`: - 3│ MHash implements hash : (a | a implements MHash) -> Num.U64 + 3│ MHash implements hash : (a where a implements MHash) -> Num.U64 ^^^^ Ability members must include an `implements` clause binding a type @@ -8626,7 +8626,7 @@ In roc, functions are always written as a lambda, like{} r#" app "test" provides [hash] to "./platform" - MHash implements hash : a -> U64 | a implements MHash + MHash implements hash : a -> U64 where a implements MHash Id := U32 implements [MHash {hash}] @@ -8658,8 +8658,8 @@ In roc, functions are always written as a lambda, like{} app "test" provides [eq, le] to "./platform" MEq implements - eq : a, a -> Bool | a implements MEq - le : a, a -> Bool | a implements MEq + eq : a, a -> Bool where a implements MEq + le : a, a -> Bool where a implements MEq Id := U64 implements [MEq {eq}] @@ -8687,7 +8687,7 @@ In roc, functions are always written as a lambda, like{} app "test" provides [hash] to "./platform" MHash implements - hash : a -> U64 | a implements MHash + hash : a -> U64 where a implements MHash hash = \_ -> 0u64 "# @@ -8712,7 +8712,7 @@ In roc, functions are always written as a lambda, like{} app "test" provides [hash, One, Two] to "./platform" MHash implements - hash : a -> U64 | a implements MHash + hash : a -> U64 where a implements MHash One := {} implements [MHash {hash}] Two := {} implements [MHash {hash}] @@ -8748,7 +8748,7 @@ In roc, functions are always written as a lambda, like{} But the type annotation on `hash` says it must match: - a -> U64 | a implements MHash + a -> U64 where a implements MHash Note: The specialized type is too general, and does not provide a concrete type where a type variable is bound to an ability. @@ -8766,7 +8766,7 @@ In roc, functions are always written as a lambda, like{} app "test" provides [hash, One, Two] to "./platform" MHash implements - hash : a -> U64 | a implements MHash + hash : a -> U64 where a implements MHash One := {} implements [MHash {hash}] Two := {} implements [MHash {hash}] @@ -8797,7 +8797,7 @@ In roc, functions are always written as a lambda, like{} app "test" provides [eq] to "./platform" MEq implements - eq : a, a -> Bool | a implements MEq + eq : a, a -> Bool where a implements MEq You := {} implements [MEq {eq}] AndI := {} @@ -8832,7 +8832,7 @@ In roc, functions are always written as a lambda, like{} app "test" provides [hash] to "./platform" MHash implements - hash : a -> U64 | a implements MHash + hash : a -> U64 where a implements MHash Id := U64 implements [MHash {hash}] @@ -8866,7 +8866,7 @@ In roc, functions are always written as a lambda, like{} app "test" provides [noGoodVeryBadTerrible] to "./platform" MHash implements - hash : a -> U64 | a implements MHash + hash : a -> U64 where a implements MHash Id := U64 implements [MHash {hash}] @@ -8914,7 +8914,7 @@ In roc, functions are always written as a lambda, like{} main = MHash implements - hash : a -> U64 | a implements MHash + hash : a -> U64 where a implements MHash 123 "# @@ -8925,7 +8925,7 @@ In roc, functions are always written as a lambda, like{} This ability definition is not on the top-level of a module: 4│> MHash implements - 5│> hash : a -> U64 | a implements MHash + 5│> hash : a -> U64 where a implements MHash Abilities can only be defined on the top-level of a Roc module. "# @@ -8938,12 +8938,12 @@ In roc, functions are always written as a lambda, like{} app "test" provides [hash, hashable] to "./platform" MHash implements - hash : a -> U64 | a implements MHash + hash : a -> U64 where a implements MHash Id := U64 implements [MHash {hash}] hash = \@Id n -> n - hashable : a | a implements MHash + hashable : a where a implements MHash hashable = @Id 15 "# ), @@ -8952,7 +8952,7 @@ In roc, functions are always written as a lambda, like{} Something is off with the body of the `hashable` definition: - 9│ hashable : a | a implements MHash + 9│ hashable : a where a implements MHash 10│ hashable = @Id 15 ^^^^^^ @@ -8962,7 +8962,7 @@ In roc, functions are always written as a lambda, like{} But the type annotation on `hashable` says it should be: - a | a implements MHash + a where a implements MHash Note: The type variable `a` says it can take on any value that implements the ability `MHash`. @@ -8979,7 +8979,7 @@ In roc, functions are always written as a lambda, like{} app "test" provides [result] to "./platform" MHash implements - hash : a -> U64 | a implements MHash + hash : a -> U64 where a implements MHash mulMHashes : MHash, MHash -> U64 mulMHashes = \x, y -> hash x * hash y @@ -9154,7 +9154,7 @@ In roc, functions are always written as a lambda, like{} r#" app "test" provides [main] to "./platform" - Default implements default : {} -> a | a implements Default + Default implements default : {} -> a where a implements Default main = A := {} implements [Default {default}] @@ -9405,7 +9405,7 @@ In roc, functions are always written as a lambda, like{} r#" app "test" provides [A] to "./platform" - MEq implements eq : a, a -> U64 | a implements MEq + MEq implements eq : a, a -> U64 where a implements MEq A := U8 implements [MEq {eq}] "# @@ -9441,7 +9441,7 @@ In roc, functions are always written as a lambda, like{} r#" app "test" provides [A, myMEq] to "./platform" - MEq implements eq : a, a -> Bool | a implements MEq + MEq implements eq : a, a -> Bool where a implements MEq A := U8 implements [ MEq {eq: aMEq} ] @@ -9482,7 +9482,7 @@ In roc, functions are always written as a lambda, like{} r#" app "test" provides [A, myMEq] to "./platform" - MEq implements eq : a, a -> Bool | a implements MEq + MEq implements eq : a, a -> Bool where a implements MEq A := U8 implements [ MEq {eq ? aMEq} ] @@ -9560,7 +9560,7 @@ In roc, functions are always written as a lambda, like{} r#" app "test" provides [A] to "./platform" - MEq implements eq : a, a -> Bool | a implements MEq + MEq implements eq : a, a -> Bool where a implements MEq A := U8 implements [ MEq {eq : Bool.eq} ] "# @@ -9595,7 +9595,7 @@ In roc, functions are always written as a lambda, like{} r#" app "test" provides [A] to "./platform" - MEq implements eq : a, a -> Bool | a implements MEq + MEq implements eq : a, a -> Bool where a implements MEq A := U8 implements [ MEq {eq : \m, n -> m == n} ] "# @@ -9632,7 +9632,7 @@ In roc, functions are always written as a lambda, like{} r#" app "test" provides [A] to "./platform" - MEq implements eq : a, a -> Bool | a implements MEq + MEq implements eq : a, a -> Bool where a implements MEq A := U8 implements [ MEq {eq: eqA, eq: eqA} ] @@ -9685,7 +9685,7 @@ In roc, functions are always written as a lambda, like{} r#" app "test" provides [A] to "./platform" - Ab implements ab : a -> a | a implements Ab + Ab implements ab : a -> a where a implements Ab A := {} implements [Ab] "# @@ -9946,9 +9946,9 @@ In roc, functions are always written as a lambda, like{} r#" app "test" provides [x] to "./platform" - Foo implements foo : a -> a | a implements Foo + Foo implements foo : a -> a where a implements Foo - F a b := b | a implements Foo + F a b := b where a implements Foo MHash := {} @@ -10476,7 +10476,7 @@ I recommend using camelCase. It's the standard style in Roc code! r#" app "test" provides [hash, Id] to "./platform" - MHash implements hash : a -> U64 | a implements MHash + MHash implements hash : a -> U64 where a implements MHash Id := {} @@ -10502,7 +10502,7 @@ I recommend using camelCase. It's the standard style in Roc code! r#" app "test" provides [hash, Id, Id2] to "./platform" - MHash implements hash : a -> U64 | a implements MHash + MHash implements hash : a -> U64 where a implements MHash Id := {} implements [MHash {hash}] Id2 := {} @@ -10659,7 +10659,7 @@ I recommend using camelCase. It's the standard style in Roc code! app "test" imports [Decode.{decoder}] provides [main] to "./platform" main = - myDecoder : Decoder (a -> a) fmt | fmt implements DecoderFormatting + myDecoder : Decoder (a -> a) fmt where fmt implements DecoderFormatting myDecoder = decoder myDecoder @@ -10690,7 +10690,7 @@ I recommend using camelCase. It's the standard style in Roc code! A := {} main = - myDecoder : Decoder {x : A} fmt | fmt implements DecoderFormatting + myDecoder : Decoder {x : A} fmt where fmt implements DecoderFormatting myDecoder = decoder myDecoder @@ -10909,7 +10909,7 @@ I recommend using camelCase. It's the standard style in Roc code! app "test" imports [Decode.{decoder}] provides [main] to "./platform" main = - myDecoder : Decoder {x : Str, y ? Str} fmt | fmt implements DecoderFormatting + myDecoder : Decoder {x : Str, y ? Str} fmt where fmt implements DecoderFormatting myDecoder = decoder myDecoder @@ -11323,7 +11323,7 @@ I recommend using camelCase. It's the standard style in Roc code! r#" app "test" provides [main] to "./platform" - foo : a -> {} | a implements Hash + foo : a -> {} where a implements Hash main = foo {a: "", b: 1} "# @@ -11337,7 +11337,7 @@ I recommend using camelCase. It's the standard style in Roc code! r#" app "test" provides [main] to "./platform" - foo : a -> {} | a implements Hash + foo : a -> {} where a implements Hash t : [A {}, B U8 U64, C Str] @@ -11353,7 +11353,7 @@ I recommend using camelCase. It's the standard style in Roc code! r#" app "test" provides [main] to "./platform" - foo : a -> {} | a implements Hash + foo : a -> {} where a implements Hash main = foo (\x -> x) "# @@ -11380,7 +11380,7 @@ I recommend using camelCase. It's the standard style in Roc code! r#" app "test" provides [main] to "./platform" - foo : a -> {} | a implements Hash + foo : a -> {} where a implements Hash main = foo (A (\x -> x) B) "# @@ -11413,7 +11413,7 @@ I recommend using camelCase. It's the standard style in Roc code! r#" app "test" provides [main] to "./platform" - foo : a -> {} | a implements Hash + foo : a -> {} where a implements Hash main = foo ("", 1) "# @@ -11426,7 +11426,7 @@ I recommend using camelCase. It's the standard style in Roc code! r#" app "test" provides [main] to "./platform" - foo : a -> {} | a implements Hash + foo : a -> {} where a implements Hash main = foo ("", \{} -> {}) "# @@ -11709,7 +11709,7 @@ I recommend using camelCase. It's the standard style in Roc code! r#" app "test" provides [main] to "./platform" - foo : a -> {} | a implements Eq + foo : a -> {} where a implements Eq main = foo {a: "", b: 1} "# @@ -11723,7 +11723,7 @@ I recommend using camelCase. It's the standard style in Roc code! r#" app "test" provides [main] to "./platform" - foo : a -> {} | a implements Eq + foo : a -> {} where a implements Eq t : [A {}, B U8 U64, C Str] @@ -11739,7 +11739,7 @@ I recommend using camelCase. It's the standard style in Roc code! r#" app "test" provides [main] to "./platform" - foo : a -> {} | a implements Eq + foo : a -> {} where a implements Eq main = foo (\x -> x) "# @@ -11766,7 +11766,7 @@ I recommend using camelCase. It's the standard style in Roc code! r#" app "test" provides [main] to "./platform" - foo : a -> {} | a implements Eq + foo : a -> {} where a implements Eq main = foo (A (\x -> x) B) "# @@ -11845,7 +11845,7 @@ I recommend using camelCase. It's the standard style in Roc code! r#" app "test" provides [main] to "./platform" - foo : a -> {} | a implements Eq + foo : a -> {} where a implements Eq main = foo ("", 1) "# @@ -11858,7 +11858,7 @@ I recommend using camelCase. It's the standard style in Roc code! r#" app "test" provides [main] to "./platform" - foo : a -> {} | a implements Eq + foo : a -> {} where a implements Eq main = foo ("", 1.0f64) "# @@ -11938,7 +11938,7 @@ I recommend using camelCase. It's the standard style in Roc code! r#" app "test" provides [f] to "./platform" - F a : a | a implements Hash + F a : a where a implements Hash f : F ({} -> {}) "# @@ -12037,7 +12037,7 @@ I recommend using camelCase. It's the standard style in Roc code! duplicate_ability_in_has_clause, indoc!( r#" - f : a -> {} | a implements Hash & Hash + f : a -> {} where a implements Hash & Hash f "# @@ -12048,8 +12048,8 @@ I recommend using camelCase. It's the standard style in Roc code! I already saw that this type variable is bound to the `Hash` ability once before: - 4│ f : a -> {} | a implements Hash & Hash - ^^^^ + 4│ f : a -> {} where a implements Hash & Hash + ^^^^ Abilities only need to bound to a type variable once in an `implements` clause! @@ -12062,9 +12062,9 @@ I recommend using camelCase. It's the standard style in Roc code! r#" app "test" provides [main] to "./platform" - g : x -> x | x implements Decoding & Encoding + g : x -> x where x implements Decoding & Encoding - main : x -> x | x implements Encoding + main : x -> x where x implements Encoding main = \x -> g x "# ), @@ -12078,11 +12078,11 @@ I recommend using camelCase. It's the standard style in Roc code! This `x` value is a: - x | x implements Encoding + x where x implements Encoding But `g` needs its 1st argument to be: - x | x implements Encoding & Decoding + x where x implements Encoding & Decoding Note: The type variable `x` says it can take on any value that implements only the ability `Encoding`. @@ -12099,9 +12099,9 @@ I recommend using camelCase. It's the standard style in Roc code! r#" app "test" provides [main] to "./platform" - g : x -> x | x implements Decoding & Encoding & Hash + g : x -> x where x implements Decoding & Encoding & Hash - main : x -> x | x implements Encoding + main : x -> x where x implements Encoding main = \x -> g x "# ), @@ -12115,11 +12115,11 @@ I recommend using camelCase. It's the standard style in Roc code! This `x` value is a: - x | x implements Encoding + x where x implements Encoding But `g` needs its 1st argument to be: - x | x implements Hash & Encoding & Decoding + x where x implements Hash & Encoding & Decoding Note: The type variable `x` says it can take on any value that implements only the ability `Encoding`. @@ -12136,10 +12136,10 @@ I recommend using camelCase. It's the standard style in Roc code! r#" app "test" provides [main] to "./platform" - f : x -> x | x implements Hash - g : x -> x | x implements Decoding & Encoding + f : x -> x where x implements Hash + g : x -> x where x implements Decoding & Encoding - main : x -> x | x implements Hash & Encoding + main : x -> x where x implements Hash & Encoding main = \x -> g (f x) "# ), @@ -12153,11 +12153,11 @@ I recommend using camelCase. It's the standard style in Roc code! This `f` call produces: - x | x implements Hash & Encoding + x where x implements Hash & Encoding But `g` needs its 1st argument to be: - x | x implements Encoding & Decoding + x where x implements Encoding & Decoding Note: The type variable `x` says it can take on any value that implements only the abilities `Hash` and `Encoding`. @@ -12905,7 +12905,7 @@ I recommend using camelCase. It's the standard style in Roc code! Tip: This type variable is not bound to `Eq`. Consider adding an `implements` clause to bind the type variable, like - `| e implements Bool.Eq` + `where e implements Bool.Eq` "### ); @@ -13371,7 +13371,7 @@ I recommend using camelCase. It's the standard style in Roc code! app "test" imports [Decode.{decoder}] provides [main] to "./platform" main = - myDecoder : Decoder Nat fmt | fmt implements DecoderFormatting + myDecoder : Decoder Nat fmt where fmt implements DecoderFormatting myDecoder = decoder myDecoder @@ -13435,7 +13435,7 @@ I recommend using camelCase. It's the standard style in Roc code! app "test" imports [Decode.{decoder}] provides [main] to "./platform" main = - myDecoder : Decoder (U32, Str) fmt | fmt implements DecoderFormatting + myDecoder : Decoder (U32, Str) fmt where fmt implements DecoderFormatting myDecoder = decoder myDecoder @@ -13450,7 +13450,7 @@ I recommend using camelCase. It's the standard style in Roc code! app "test" imports [Decode.{decoder}] provides [main] to "./platform" main = - myDecoder : Decoder (U32, {} -> {}) fmt | fmt implements DecoderFormatting + myDecoder : Decoder (U32, {} -> {}) fmt where fmt implements DecoderFormatting myDecoder = decoder myDecoder diff --git a/examples/cli/cli-platform/Env.roc b/examples/cli/cli-platform/Env.roc index 061ab69b28..50af317d8c 100644 --- a/examples/cli/cli-platform/Env.roc +++ b/examples/cli/cli-platform/Env.roc @@ -65,7 +65,7 @@ var = \name -> ## - comma-separated lists (of either strings or numbers), as long as there are no spaces after the commas ## ## Trying to decode into any other types will always fail with a `DecodeErr`. -decode : Str -> Task val [VarNotFound, DecodeErr DecodeError] | val implements Decoding +decode : Str -> Task val [VarNotFound, DecodeErr DecodeError] where val implements Decoding decode = \name -> Effect.envVar name |> Effect.map @@ -120,4 +120,4 @@ dict = # decode all the required vars only, and then decode the optional ones separately some other way. # Alternatively, it could make sense to have some sort of tag union convention here, e.g. # if decoding into a tag union of [Present val, Missing], then it knows what to do. -# decodeAll : Task val [] [EnvDecodingFailed Str] [Env] | val implements Decoding +# decodeAll : Task val [] [EnvDecodingFailed Str] [Env] where val implements Decoding diff --git a/examples/cli/cli-platform/File.roc b/examples/cli/cli-platform/File.roc index 97d8841792..b5e367f889 100644 --- a/examples/cli/cli-platform/File.roc +++ b/examples/cli/cli-platform/File.roc @@ -26,7 +26,7 @@ WriteErr : InternalFile.WriteErr ## This opens the file first and closes it after writing to it. ## ## To write unformatted bytes to a file, you can use [File.writeBytes] instead. -write : Path, val, fmt -> Task {} [FileWriteErr Path WriteErr] | val implements Encode.Encoding, fmt implements Encode.EncoderFormatting +write : Path, val, fmt -> Task {} [FileWriteErr Path WriteErr] where val implements Encode.Encoding, fmt implements Encode.EncoderFormatting write = \path, val, fmt -> bytes = Encode.toBytes val fmt @@ -119,7 +119,7 @@ readUtf8 = \path -> # Str # [FileReadErr Path ReadErr, FileReadDecodeErr Path [Leftover (List U8)]Decode.DecodeError ] # [Read [File]] -# | val implements Decode.Decoding, fmt implements Decode.DecoderFormatting +# where val implements Decode.Decoding, fmt implements Decode.DecoderFormatting # read = \path, fmt -> # effect = Effect.map (Effect.fileReadBytes (InternalPath.toBytes path)) \result -> # when result is diff --git a/examples/cli/cli-platform/Http.roc b/examples/cli/cli-platform/Http.roc index 372d10a481..04c7132aee 100644 --- a/examples/cli/cli-platform/Http.roc +++ b/examples/cli/cli-platform/Http.roc @@ -56,7 +56,7 @@ stringBody : [MimeType Str], Str -> Body stringBody = \mimeType, str -> Body mimeType (Str.toUtf8 str) -# jsonBody : a -> Body | a implements Encoding +# jsonBody : a -> Body where a implements Encoding # jsonBody = \val -> # Body (MimeType "application/json") (Encode.toBytes val Json.format) # diff --git a/examples/python-interop/platform/main.roc b/examples/python-interop/platform/main.roc index 949cbe8dd2..5cfaa5f43b 100644 --- a/examples/python-interop/platform/main.roc +++ b/examples/python-interop/platform/main.roc @@ -1,5 +1,5 @@ platform "python-interop" - requires {} { main : arg -> ret | arg implements Decoding, ret implements Encoding } + requires {} { main : arg -> ret where arg implements Decoding, ret implements Encoding } exposes [] packages {} imports [Json] diff --git a/examples/ruby-interop/platform/main.roc b/examples/ruby-interop/platform/main.roc index 1cae530d89..c46ca8a0bf 100644 --- a/examples/ruby-interop/platform/main.roc +++ b/examples/ruby-interop/platform/main.roc @@ -1,5 +1,5 @@ platform "ruby-interop" - requires {} { main : arg -> ret | arg implements Decoding, ret implements Encoding } + requires {} { main : arg -> ret where arg implements Decoding, ret implements Encoding } exposes [] packages {} imports [Json] diff --git a/examples/virtual-dom-wip/platform/Html/Internal/Client.roc b/examples/virtual-dom-wip/platform/Html/Internal/Client.roc index bb2fab0712..d126741b2f 100644 --- a/examples/virtual-dom-wip/platform/Html/Internal/Client.roc +++ b/examples/virtual-dom-wip/platform/Html/Internal/Client.roc @@ -84,7 +84,7 @@ DiffState state : { rendered : RenderedTree state, patches : List Patch } # ------------------------------- # INITIALISATION # ------------------------------- -initClientApp : List U8, App state initData -> Effect (PlatformState state initData) | initData implements Decoding +initClientApp : List U8, App state initData -> Effect (PlatformState state initData) where initData implements Decoding initClientApp = \json, app -> # Initialise the Roc representation of the rendered DOM, and calculate patches (for event listeners) { state, rendered, patches } = @@ -100,7 +100,7 @@ initClientApp = \json, app -> } # Testable helper function to initialise the app -initClientAppHelp : List U8, App state initData -> { state, rendered : RenderedTree state, patches : List Patch } | initData implements Decoding +initClientAppHelp : List U8, App state initData -> { state, rendered : RenderedTree state, patches : List Patch } where initData implements Decoding initClientAppHelp = \json, app -> state = json @@ -200,7 +200,7 @@ JsEventResult state initData : { } ## Dispatch a JavaScript event to a Roc handler, given the handler ID and some JSON event data. -dispatchEvent : PlatformState state initData, List (List U8), HandlerId -> Effect (JsEventResult state initData) | initData implements Decoding +dispatchEvent : PlatformState state initData, List (List U8), HandlerId -> Effect (JsEventResult state initData) where initData implements Decoding dispatchEvent = \platformState, eventData, handlerId -> { app, state, rendered } = platformState diff --git a/examples/virtual-dom-wip/platform/Html/Internal/Server.roc b/examples/virtual-dom-wip/platform/Html/Internal/Server.roc index 05f1493d11..a9541197b2 100644 --- a/examples/virtual-dom-wip/platform/Html/Internal/Server.roc +++ b/examples/virtual-dom-wip/platform/Html/Internal/Server.roc @@ -57,7 +57,7 @@ appendRenderedStaticAttr = \{ buffer, styles }, attr -> # ------------------------------- # INITIALISATION # ------------------------------- -initServerApp : App state initData, initData, Str -> Result (Html []) [InvalidDocument] | initData implements Encoding +initServerApp : App state initData, initData, Str -> Result (Html []) [InvalidDocument] where initData implements Encoding initServerApp = \app, initData, hostJavaScript -> initData |> Ok @@ -66,7 +66,7 @@ initServerApp = \app, initData, hostJavaScript -> |> translateStatic |> insertRocScript initData app.wasmUrl hostJavaScript -insertRocScript : Html [], initData, Str, Str -> Result (Html []) [InvalidDocument] | initData implements Encoding +insertRocScript : Html [], initData, Str, Str -> Result (Html []) [InvalidDocument] where initData implements Encoding insertRocScript = \document, initData, wasmUrl, hostJavaScript -> encode = \value -> diff --git a/examples/virtual-dom-wip/platform/client-side.roc b/examples/virtual-dom-wip/platform/client-side.roc index 73e8603f53..bfa0c19fb8 100644 --- a/examples/virtual-dom-wip/platform/client-side.roc +++ b/examples/virtual-dom-wip/platform/client-side.roc @@ -26,7 +26,7 @@ ToHost state initData : { } # TODO: naming the type variables causes a type 'mismatch' -# main : FromHost state initData -> Effect (ToHost state initData) | initData implements Decoding & Encoding +# main : FromHost state initData -> Effect (ToHost state initData) where initData implements Decoding & Encoding main : FromHost _ _ -> Effect (ToHost _ _) main = \fromHost -> if fromHost.isInitEvent then diff --git a/www/generate_tutorial/src/tutorial.roc b/www/generate_tutorial/src/tutorial.roc index f8bc3117ef..d4f012045d 100644 --- a/www/generate_tutorial/src/tutorial.roc +++ b/www/generate_tutorial/src/tutorial.roc @@ -1,5 +1,5 @@ app "roc-tutorial" - packages { pf: "../../../examples/static-site-gen/platform/main.roc" } + packages { pf: "../../../examples/static-site-gen/platform/main.roc" } imports [ pf.Html.{ html, head, body, footer, script, div, main, p, section, h1, h2, label, ol, input, text, nav, a, li, link, meta }, pf.Html.Attributes.{ content, name, for, id, type, href, rel, lang, class, title, charset, src }, @@ -28,8 +28,8 @@ view = \htmlContent -> text htmlContent, ], footer [] [ - text "Made by people who like to make nice things. © 2022" - ] + text "Made by people who like to make nice things. © 2022", + ], ], script [src "/site.js"] [], ] @@ -62,26 +62,26 @@ viewTutorialStart = tocLinks = { tag, value } <- List.map [ - { tag: "#installation", value: "Installation" }, - { tag: "#strings-and-numbers", value: "Strings and Numbers" }, - { tag: "#building-an-application", value: "Building an Application" }, - { tag: "#defining-functions", value: "Defining Functions" }, - { tag: "#if-then-else", value: "if-then-else" }, - { tag: "#debugging", value: "Debugging" }, - { tag: "#records", value: "Records" }, - { tag: "#tags", value: "Tags & Pattern Matching" }, - { tag: "#booleans", value: "Booleans" }, - { tag: "#lists", value: "Lists" }, - { tag: "#types", value: "Types" }, - { tag: "#numeric-types", value: "Numeric Types" }, - { tag: "#crashing", value: "Crashing" }, - { tag: "#tests-and-expectations", value: "Tests and Expectations" }, - { tag: "#modules", value: "Modules" }, - { tag: "#tasks", value: "Tasks" }, - { tag: "#abilities", value: "Abilities" }, - { tag: "#appendix-advanced-concepts", value: "Advanced Concepts" }, - { tag: "#operator-desugaring-table", value: "Operator Desugaring Table" }, - ] + { tag: "#installation", value: "Installation" }, + { tag: "#strings-and-numbers", value: "Strings and Numbers" }, + { tag: "#building-an-application", value: "Building an Application" }, + { tag: "#defining-functions", value: "Defining Functions" }, + { tag: "#if-then-else", value: "if-then-else" }, + { tag: "#debugging", value: "Debugging" }, + { tag: "#records", value: "Records" }, + { tag: "#tags", value: "Tags & Pattern Matching" }, + { tag: "#booleans", value: "Booleans" }, + { tag: "#lists", value: "Lists" }, + { tag: "#types", value: "Types" }, + { tag: "#numeric-types", value: "Numeric Types" }, + { tag: "#crashing", value: "Crashing" }, + { tag: "#tests-and-expectations", value: "Tests and Expectations" }, + { tag: "#modules", value: "Modules" }, + { tag: "#tasks", value: "Tasks" }, + { tag: "#abilities", value: "Abilities" }, + { tag: "#appendix-advanced-concepts", value: "Advanced Concepts" }, + { tag: "#operator-desugaring-table", value: "Operator Desugaring Table" }, + ] li [] [ a [href tag] [text value], @@ -98,8 +98,8 @@ tutorialIntro = p [] [text "This tutorial will teach you how to build Roc applications. Along the way, you'll learn how to write tests, use the REPL, and more!"], ], section [] [ - h2 [ id "installation" ] [ - a [href "#installation"] [text "Installation"] + h2 [id "installation"] [ + a [href "#installation"] [text "Installation"], ], p [] [ text "Roc doesn’t have a numbered release or an installer yet, but you can follow the install instructions for your OS", @@ -108,7 +108,7 @@ tutorialIntro = a [href "https://roc.zulipchat.com/#narrow/stream/231634-beginners"] [text " #beginners "], text "on", a [href "https://roc.zulipchat.com/"] [text " Roc Zulip Chat "], - text "and ask for assistance!" - ] + text "and ask for assistance!", + ], ], ] From afa5aaba94519a7a3683f9cd6dc655ead951dd95 Mon Sep 17 00:00:00 2001 From: Bryce Miller Date: Sat, 10 Jun 2023 13:30:54 -0400 Subject: [PATCH 046/176] has -> implements --- crates/compiler/parse/src/ast.rs | 4 ++-- crates/compiler/parse/src/expr.rs | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/crates/compiler/parse/src/ast.rs b/crates/compiler/parse/src/ast.rs index 662d5de071..b3935ec35c 100644 --- a/crates/compiler/parse/src/ast.rs +++ b/crates/compiler/parse/src/ast.rs @@ -1681,11 +1681,11 @@ impl<'a> Malformed for TypeDef<'a> { } => header.is_malformed() || typ.is_malformed() || derived.is_malformed(), TypeDef::Ability { header, - loc_implements: loc_has, + loc_implements, members, } => { header.is_malformed() - || loc_has.is_malformed() + || loc_implements.is_malformed() || members.iter().any(|member| member.is_malformed()) } } diff --git a/crates/compiler/parse/src/expr.rs b/crates/compiler/parse/src/expr.rs index 6b279cef38..31bbc89290 100644 --- a/crates/compiler/parse/src/expr.rs +++ b/crates/compiler/parse/src/expr.rs @@ -617,14 +617,14 @@ pub fn parse_single_def<'a>( }; if let Some((name, name_region, args)) = opt_tag_and_args { - if let Ok((_, loc_has, state)) = + if let Ok((_, loc_implements, state)) = loc_implements_parser().parse(arena, state.clone(), min_indent) { let (_, (type_def, def_region), state) = finish_parsing_ability_def_help( min_indent, Loc::at(name_region, name), args, - loc_has, + loc_implements, arena, state, )?; @@ -1370,7 +1370,7 @@ fn finish_parsing_ability_def_help<'a>( start_column: u32, name: Loc<&'a str>, args: &'a [Loc>], - loc_has: Loc>, + loc_implements: Loc>, arena: &'a Bump, state: State<'a>, ) -> ParseResult<'a, (TypeDef<'a>, Region), EExpr<'a>> { @@ -1408,7 +1408,7 @@ fn finish_parsing_ability_def_help<'a>( let def_region = Region::span_across(&name.region, &demands.last().unwrap().typ.region); let type_def = TypeDef::Ability { header: TypeHeader { name, vars: args }, - loc_implements: loc_has, + loc_implements, members: demands.into_bump_slice(), }; From 5cbc389c44d7b5d45929df30ded2aaa64b8d44ff Mon Sep 17 00:00:00 2001 From: Brendan Hansknecht Date: Thu, 22 Jun 2023 08:18:58 -0700 Subject: [PATCH 047/176] add userland imple of inspect with some apps --- examples/GuiFormatter.roc | 210 ++++++++++++++++++++++++++ examples/Inspect.roc | 79 ++++++++++ examples/LogFormatter.roc | 220 +++++++++++++++++++++++++++ examples/Person.roc | 47 ++++++ examples/PrettyLogFormatter.roc | 255 ++++++++++++++++++++++++++++++++ examples/inspect-gui.roc | 22 +++ examples/inspect-logging.roc | 33 +++++ 7 files changed, 866 insertions(+) create mode 100644 examples/GuiFormatter.roc create mode 100644 examples/Inspect.roc create mode 100644 examples/LogFormatter.roc create mode 100644 examples/Person.roc create mode 100644 examples/PrettyLogFormatter.roc create mode 100644 examples/inspect-gui.roc create mode 100644 examples/inspect-logging.roc diff --git a/examples/GuiFormatter.roc b/examples/GuiFormatter.roc new file mode 100644 index 0000000000..3624187d71 --- /dev/null +++ b/examples/GuiFormatter.roc @@ -0,0 +1,210 @@ +interface GuiFormatter + exposes [ + GuiFormatter, + toGui, + ] + imports [ + Inspect.{ + Formatter, + Inspector, + }, + ] + +## This can't depend on the platform, so I just copied all of this. + +Rgba : { r : F32, g : F32, b : F32, a : F32 } +ButtonStyles : { bgColor : Rgba, borderColor : Rgba, borderWidth : F32, textColor : Rgba } +Elem : [Button Elem ButtonStyles, Col (List Elem), Row (List Elem), Text Str] + +GuiFormatter := { nodes : List Elem } + has [ + Formatter { + init: init, + list: list, + dict: dict, + tag: tag, + tuple: tuple, + record: record, + bool: bool, + str: str, + u8: u8, + i8: i8, + u16: u16, + i16: i16, + u32: u32, + i32: i32, + u64: u64, + i64: i64, + u128: u128, + i128: i128, + f32: f32, + f64: f64, + dec: dec, + + }, + ] + +init : {} -> GuiFormatter +init = \{} -> @GuiFormatter { nodes: [] } + +list : List elem, (elem -> Inspector GuiFormatter) -> Inspector GuiFormatter +list = \content, toInspector -> + f0 <- Inspect.custom + # Use a temporary buffer for the children nodes + (@GuiFormatter { nodes }) = + init {} + |> \f1 -> + f2, elem <- List.walk content f1 + elem + |> toInspector + |> Inspect.apply f2 + + addNode f0 (Col nodes) + +tag : Str, List (Inspector GuiFormatter) -> Inspector GuiFormatter +tag = \name, fields -> + f0 <- Inspect.custom + # Use a temporary buffer for the children nodes + (@GuiFormatter { nodes }) = + init {} + |> addNode (Text name) + |> \f1 -> + f2, fieldInspector <- List.walk fields f1 + Inspect.apply fieldInspector f2 + + addNode f0 (Row nodes) + +tuple : List (Inspector GuiFormatter) -> Inspector GuiFormatter +tuple = \fields -> + f0 <- Inspect.custom + # Use a temporary buffer for the children nodes + (@GuiFormatter { nodes }) = + init {} + |> \f1 -> + f2, fieldInspector <- List.walk fields f1 + Inspect.apply fieldInspector f2 + + addNode f0 (Row nodes) + +record : List { key : Str, value : Inspector GuiFormatter } -> Inspector GuiFormatter +record = \fields -> + f0 <- Inspect.custom + # Use a temporary buffer for the children nodes + (@GuiFormatter { nodes }) = + init {} + |> \f1 -> + f2, { key, value } <- List.walk fields f1 + (@GuiFormatter { nodes: innerNodes }) = + init {} + |> addNode (Text key) + |> addNode (Text ":") + |> \x -> Inspect.apply value x + + addNode f2 (Row innerNodes) + + addNode f0 (Col nodes) + +dict : dict, Inspect.DictWalkFn GuiFormatter dict key value, (key -> Inspector GuiFormatter), (value -> Inspector GuiFormatter) -> Inspector GuiFormatter +dict = \d, walkFn, keyToInspector, valueToInspector -> + f0 <- Inspect.custom + # Use a temporary buffer for the children nodes + (@GuiFormatter { nodes }) = + init {} + |> \f1 -> + f2, key, value <- walkFn d f1 + (@GuiFormatter { nodes: innerNodes }) = + init {} + |> \x -> Inspect.apply (keyToInspector key) x + |> addNode (Text ":") + |> \x -> Inspect.apply (valueToInspector value) x + + addNode f2 (Row innerNodes) + + addNode f0 (Col nodes) + +bool : Bool -> Inspector GuiFormatter +bool = \b -> + if b then + f0 <- Inspect.custom + addNode f0 (Text "true") + else + f0 <- Inspect.custom + addNode f0 (Text "false") + +str : Str -> Inspector GuiFormatter +str = \s -> + f0 <- Inspect.custom + addNode f0 (Text "\"\(s)\"") + +u8 : U8 -> Inspector GuiFormatter +u8 = \num -> + f0 <- Inspect.custom + addNode f0 (num |> Num.toStr |> Text) + +i8 : I8 -> Inspector GuiFormatter +i8 = \num -> + f0 <- Inspect.custom + addNode f0 (num |> Num.toStr |> Text) + +u16 : U16 -> Inspector GuiFormatter +u16 = \num -> + f0 <- Inspect.custom + addNode f0 (num |> Num.toStr |> Text) + +i16 : I16 -> Inspector GuiFormatter +i16 = \num -> + f0 <- Inspect.custom + addNode f0 (num |> Num.toStr |> Text) + +u32 : U32 -> Inspector GuiFormatter +u32 = \num -> + f0 <- Inspect.custom + addNode f0 (num |> Num.toStr |> Text) + +i32 : I32 -> Inspector GuiFormatter +i32 = \num -> + f0 <- Inspect.custom + addNode f0 (num |> Num.toStr |> Text) + +u64 : U64 -> Inspector GuiFormatter +u64 = \num -> + f0 <- Inspect.custom + addNode f0 (num |> Num.toStr |> Text) + +i64 : I64 -> Inspector GuiFormatter +i64 = \num -> + f0 <- Inspect.custom + addNode f0 (num |> Num.toStr |> Text) + +u128 : U128 -> Inspector GuiFormatter +u128 = \num -> + f0 <- Inspect.custom + addNode f0 (num |> Num.toStr |> Text) + +i128 : I128 -> Inspector GuiFormatter +i128 = \num -> + f0 <- Inspect.custom + addNode f0 (num |> Num.toStr |> Text) + +f32 : F32 -> Inspector GuiFormatter +f32 = \num -> + f0 <- Inspect.custom + addNode f0 (num |> Num.toStr |> Text) + +f64 : F64 -> Inspector GuiFormatter +f64 = \num -> + f0 <- Inspect.custom + addNode f0 (num |> Num.toStr |> Text) + +dec : Dec -> Inspector GuiFormatter +dec = \num -> + f0 <- Inspect.custom + addNode f0 (num |> Num.toStr |> Text) + +addNode : GuiFormatter, Elem -> GuiFormatter +addNode = \@GuiFormatter { nodes }, node -> + @GuiFormatter { nodes: List.append nodes node } + +toGui : GuiFormatter -> Elem +toGui = \@GuiFormatter { nodes } -> Col nodes + diff --git a/examples/Inspect.roc b/examples/Inspect.roc new file mode 100644 index 0000000000..31489ce03e --- /dev/null +++ b/examples/Inspect.roc @@ -0,0 +1,79 @@ +interface Inspect + exposes [ + Formatter, + init, + list, + dict, + tag, + tuple, + record, + bool, + str, + u8, + i8, + u16, + i16, + u32, + i32, + u64, + i64, + u128, + i128, + f32, + f64, + dec, + Inspector, + custom, + apply, + Inspect, + inspect, + toInspector, + DictWalkFn, + ] + imports [] + +DictWalkFn state dict key value : dict, state, (state, key, value -> state) -> state + +Formatter has + init : {} -> f | f has Formatter + + list : List elem, (elem -> Inspector f) -> Inspector f | f has Formatter + tag : Str, List (Inspector f) -> Inspector f | f has Formatter + tuple : List (Inspector f) -> Inspector f | f has Formatter + record : List { key : Str, value : Inspector f } -> Inspector f | f has Formatter + bool : Bool -> Inspector f | f has Formatter + str : Str -> Inspector f | f has Formatter + + # I am not yet sold on this function. Is there a better api. + # Specifying the walk function makes this feel very verbose. + # This is needed to make dicts special so that can print like giant records instead of lists of tuples. + dict : dict, DictWalkFn state dict key value, (key -> Inspector f), (value -> Inspector f) -> Inspector f | f has Formatter + + u8 : U8 -> Inspector f | f has Formatter + i8 : I8 -> Inspector f | f has Formatter + u16 : U16 -> Inspector f | f has Formatter + i16 : I16 -> Inspector f | f has Formatter + u32 : U32 -> Inspector f | f has Formatter + i32 : I32 -> Inspector f | f has Formatter + u64 : U64 -> Inspector f | f has Formatter + i64 : I64 -> Inspector f | f has Formatter + u128 : U128 -> Inspector f | f has Formatter + i128 : I128 -> Inspector f | f has Formatter + f32 : F32 -> Inspector f | f has Formatter + f64 : F64 -> Inspector f | f has Formatter + dec : Dec -> Inspector f | f has Formatter + +Inspector f := f -> f | f has Formatter + +custom = @Inspector + +apply : Inspector f, f -> f | f has Formatter +apply = \@Inspector fn, fmt -> fn fmt + +Inspect has + toInspector : val -> Inspector f | val has Inspect, f has Formatter + +inspect : val -> f | val has Inspect, f has Formatter +inspect = \val -> + (@Inspector valFn) = toInspector val + valFn (init {}) diff --git a/examples/LogFormatter.roc b/examples/LogFormatter.roc new file mode 100644 index 0000000000..b1940a6cee --- /dev/null +++ b/examples/LogFormatter.roc @@ -0,0 +1,220 @@ +interface LogFormatter + exposes [ + LogFormatter, + toBytes, + ] + imports [ + Inspect.{ + Formatter, + Inspector, + }, + ] + +LogFormatter := { bytes : List U8 } + has [ + Formatter { + init: init, + list: list, + dict: dict, + tag: tag, + tuple: tuple, + record: record, + bool: bool, + str: str, + u8: u8, + i8: i8, + u16: u16, + i16: i16, + u32: u32, + i32: i32, + u64: u64, + i64: i64, + u128: u128, + i128: i128, + f32: f32, + f64: f64, + dec: dec, + + }, + ] + +init : {} -> LogFormatter +init = \{} -> @LogFormatter { bytes: [] } + +list : List elem, (elem -> Inspector LogFormatter) -> Inspector LogFormatter +list = \content, toInspector -> + f0 <- Inspect.custom + write f0 (Str.toUtf8 "[") + |> \f1 -> + (f2, prependSep), elem <- List.walk content (f1, Bool.false) + f3 = + if prependSep then + write f2 (Str.toUtf8 ", ") + else + f2 + + elem + |> toInspector + |> Inspect.apply f3 + |> \f4 -> (f4, Bool.true) + |> .0 + |> write (Str.toUtf8 "]") + +tag : Str, List (Inspector LogFormatter) -> Inspector LogFormatter +tag = \name, fields -> + if List.isEmpty fields then + f0 <- Inspect.custom + write f0 (Str.toUtf8 name) + else + f0 <- Inspect.custom + write f0 (Str.toUtf8 "(") + |> write (Str.toUtf8 name) + |> \f1 -> + f2, inspector <- List.walk fields f1 + write f2 (Str.toUtf8 " ") + |> \x -> Inspect.apply inspector x + |> write (Str.toUtf8 ")") + +tuple : List (Inspector LogFormatter) -> Inspector LogFormatter +tuple = \fields -> + f0 <- Inspect.custom + write f0 (Str.toUtf8 "(") + |> \f1 -> + (f2, prependSep), inspector <- List.walk fields (f1, Bool.false) + f3 = + if prependSep then + write f2 (Str.toUtf8 ", ") + else + f2 + + Inspect.apply inspector f3 + |> \f4 -> (f4, Bool.true) + |> .0 + |> write (Str.toUtf8 ")") + +record : List { key : Str, value : Inspector LogFormatter } -> Inspector LogFormatter +record = \fields -> + f0 <- Inspect.custom + write f0 (Str.toUtf8 "{") + |> \f1 -> + (f2, prependSep), { key, value } <- List.walk fields (f1, Bool.false) + f3 = + if prependSep then + write f2 (Str.toUtf8 ", ") + else + f2 + + write f3 (Str.toUtf8 key) + |> write (Str.toUtf8 ": ") + |> \x -> Inspect.apply value x + |> \f4 -> (f4, Bool.true) + |> .0 + |> write (Str.toUtf8 "}") + +dict : dict, Inspect.DictWalkFn (LogFormatter, Bool) dict key value, (key -> Inspector LogFormatter), (value -> Inspector LogFormatter) -> Inspector LogFormatter +dict = \d, walkFn, keyToInspector, valueToInspector -> + f0 <- Inspect.custom + write f0 (Str.toUtf8 "{") + |> \f1 -> + (f2, prependSep), key, value <- walkFn d (f1, Bool.false) + f3 = + if prependSep then + write f2 (Str.toUtf8 ", ") + else + f2 + + Inspect.apply (keyToInspector key) f3 + |> write (Str.toUtf8 ": ") + |> \x -> Inspect.apply (valueToInspector value) x + |> \f4 -> (f4, Bool.true) + |> .0 + |> write (Str.toUtf8 "}") + +bool : Bool -> Inspector LogFormatter +bool = \b -> + if b then + f0 <- Inspect.custom + write f0 (Str.toUtf8 "true") + else + f0 <- Inspect.custom + write f0 (Str.toUtf8 "false") + +str : Str -> Inspector LogFormatter +str = \s -> + f0 <- Inspect.custom + f0 + |> write (Str.toUtf8 "\"") + |> write (Str.toUtf8 s) + |> write (Str.toUtf8 "\"") + +u8 : U8 -> Inspector LogFormatter +u8 = \num -> + f0 <- Inspect.custom + write f0 (num |> Num.toStr |> Str.toUtf8) + +i8 : I8 -> Inspector LogFormatter +i8 = \num -> + f0 <- Inspect.custom + write f0 (num |> Num.toStr |> Str.toUtf8) + +u16 : U16 -> Inspector LogFormatter +u16 = \num -> + f0 <- Inspect.custom + write f0 (num |> Num.toStr |> Str.toUtf8) + +i16 : I16 -> Inspector LogFormatter +i16 = \num -> + f0 <- Inspect.custom + write f0 (num |> Num.toStr |> Str.toUtf8) + +u32 : U32 -> Inspector LogFormatter +u32 = \num -> + f0 <- Inspect.custom + write f0 (num |> Num.toStr |> Str.toUtf8) + +i32 : I32 -> Inspector LogFormatter +i32 = \num -> + f0 <- Inspect.custom + write f0 (num |> Num.toStr |> Str.toUtf8) + +u64 : U64 -> Inspector LogFormatter +u64 = \num -> + f0 <- Inspect.custom + write f0 (num |> Num.toStr |> Str.toUtf8) + +i64 : I64 -> Inspector LogFormatter +i64 = \num -> + f0 <- Inspect.custom + write f0 (num |> Num.toStr |> Str.toUtf8) + +u128 : U128 -> Inspector LogFormatter +u128 = \num -> + f0 <- Inspect.custom + write f0 (num |> Num.toStr |> Str.toUtf8) + +i128 : I128 -> Inspector LogFormatter +i128 = \num -> + f0 <- Inspect.custom + write f0 (num |> Num.toStr |> Str.toUtf8) + +f32 : F32 -> Inspector LogFormatter +f32 = \num -> + f0 <- Inspect.custom + write f0 (num |> Num.toStr |> Str.toUtf8) + +f64 : F64 -> Inspector LogFormatter +f64 = \num -> + f0 <- Inspect.custom + write f0 (num |> Num.toStr |> Str.toUtf8) + +dec : Dec -> Inspector LogFormatter +dec = \num -> + f0 <- Inspect.custom + write f0 (num |> Num.toStr |> Str.toUtf8) + +write : LogFormatter, List U8 -> LogFormatter +write = \@LogFormatter { bytes }, added -> + @LogFormatter { bytes: List.concat bytes added } + +toBytes : LogFormatter -> List U8 +toBytes = \@LogFormatter { bytes } -> bytes diff --git a/examples/Person.roc b/examples/Person.roc new file mode 100644 index 0000000000..223f3018eb --- /dev/null +++ b/examples/Person.roc @@ -0,0 +1,47 @@ +interface Person + exposes [ + new, + ] + imports [ + Inspect.{ Formatter, Inspector, Inspect }, + ] + +Person := { + firstName : Str, + lastName : Str, + age : U8, + data: Dict Str [Stuff, Thing I32], + hasBeard: Bool, +} + has [ + Inspect { + toInspector: inspectPerson, + }, + ] + +new = @Person + +inspectPerson : Person -> Inspector f | f has Formatter +inspectPerson = \@Person { firstName, lastName, age, data, hasBeard } -> + # In practice, this would never be done manually due to autoderive. + # Instead you would just write: + # Inspect.inspect innerRecord + # This is what the auto-derive would generate. + + f0 <- Inspect.custom + [ + { key: "firstName", value: Inspect.str firstName }, + { key: "lastName", value: Inspect.str lastName }, + { key: "age", value: Inspect.u8 age }, + { key: "hasBeard", value: Inspect.bool hasBeard }, + { + key: "data", + value: Inspect.dict data Dict.walk Inspect.str \value -> + when value is + Thing i -> Inspect.tag "Thing" [Inspect.i32 i] + Stuff -> Inspect.tag "Stuff" [] + , + }, + ] + |> Inspect.record + |> Inspect.apply f0 diff --git a/examples/PrettyLogFormatter.roc b/examples/PrettyLogFormatter.roc new file mode 100644 index 0000000000..9c5064d051 --- /dev/null +++ b/examples/PrettyLogFormatter.roc @@ -0,0 +1,255 @@ +interface PrettyLogFormatter + exposes [ + PrettyLogFormatter, + toBytes, + ] + imports [ + Inspect.{ + Formatter, + Inspector, + }, + ] + +PrettyLogFormatter := { bytes : List U8, indents : List U8 } + has [ + Formatter { + init: init, + list: list, + dict: dict, + tag: tag, + tuple: tuple, + record: record, + bool: bool, + str: str, + u8: u8, + i8: i8, + u16: u16, + i16: i16, + u32: u32, + i32: i32, + u64: u64, + i64: i64, + u128: u128, + i128: i128, + f32: f32, + f64: f64, + dec: dec, + + }, + ] + +init : {} -> PrettyLogFormatter +init = \{} -> @PrettyLogFormatter { bytes: [], indents: [] } + +list : List elem, (elem -> Inspector PrettyLogFormatter) -> Inspector PrettyLogFormatter +list = \content, toInspector -> + f0 <- Inspect.custom + write f0 (Str.toUtf8 "[\n") + |> indent + |> \f1 -> + (f2, prependSep), elem <- List.walk content (f1, Bool.false) + f3 = + if prependSep then + write f2 (Str.toUtf8 ",\n") + else + f2 + + elemInspector = toInspector elem + f3 + |> writeIndent + |> \x -> Inspect.apply elemInspector x + |> \f4 -> (f4, Bool.true) + |> .0 + |> write (Str.toUtf8 "\n") + |> outdent + |> writeIndent + |> write (Str.toUtf8 "]") + +tag : Str, List (Inspector PrettyLogFormatter) -> Inspector PrettyLogFormatter +tag = \name, fields -> + if List.isEmpty fields then + f0 <- Inspect.custom + write f0 (Str.toUtf8 name) + else + f0 <- Inspect.custom + write f0 (Str.toUtf8 "(") + |> write (Str.toUtf8 name) + |> indent + |> \f1 -> + f2, inspector <- List.walk fields f1 + write f2 (Str.toUtf8 " ") + |> \x -> Inspect.apply inspector x + |> outdent + |> write (Str.toUtf8 ")") + +tuple : List (Inspector PrettyLogFormatter) -> Inspector PrettyLogFormatter +tuple = \fields -> + f0 <- Inspect.custom + write f0 (Str.toUtf8 "(\n") + |> indent + |> \f1 -> + (f2, prependSep), inspector <- List.walk fields (f1, Bool.false) + f3 = + if prependSep then + write f2 (Str.toUtf8 ",\n") + else + f2 + + f3 + |> writeIndent + |> \x -> Inspect.apply inspector x + |> \f4 -> (f4, Bool.true) + |> .0 + |> write (Str.toUtf8 "\n") + |> outdent + |> write (Str.toUtf8 ")") + +record : List { key : Str, value : Inspector PrettyLogFormatter } -> Inspector PrettyLogFormatter +record = \fields -> + f0 <- Inspect.custom + write f0 (Str.toUtf8 "{\n") + |> indent + |> \f1 -> + (f2, prependSep), { key, value } <- List.walk fields (f1, Bool.false) + f3 = + if prependSep then + write f2 (Str.toUtf8 ",\n") + else + f2 + + writeIndent f3 + |> write (Str.toUtf8 key) + |> write (Str.toUtf8 ": ") + |> \x -> Inspect.apply value x + |> \f4 -> (f4, Bool.true) + |> .0 + |> write (Str.toUtf8 "\n") + |> outdent + |> writeIndent + |> write (Str.toUtf8 "}") + +dict : dict, Inspect.DictWalkFn (PrettyLogFormatter, Bool) dict key value, (key -> Inspector PrettyLogFormatter), (value -> Inspector PrettyLogFormatter) -> Inspector PrettyLogFormatter +dict = \d, walkFn, keyToInspector, valueToInspector -> + f0 <- Inspect.custom + write f0 (Str.toUtf8 "{\n") + |> indent + |> \f1 -> + (f2, prependSep), key, value <- walkFn d (f1, Bool.false) + f3 = + if prependSep then + write f2 (Str.toUtf8 ",\n") + else + f2 + + writeIndent f3 + |> \x -> Inspect.apply (keyToInspector key) x + |> write (Str.toUtf8 ": ") + |> \x -> Inspect.apply (valueToInspector value) x + |> \f4 -> (f4, Bool.true) + |> .0 + |> write (Str.toUtf8 "\n") + |> outdent + |> writeIndent + |> write (Str.toUtf8 "}") + +bool : Bool -> Inspector PrettyLogFormatter +bool = \b -> + if b then + f0 <- Inspect.custom + write f0 (Str.toUtf8 "true") + else + f0 <- Inspect.custom + write f0 (Str.toUtf8 "false") + +str : Str -> Inspector PrettyLogFormatter +str = \s -> + f0 <- Inspect.custom + f0 + |> write (Str.toUtf8 "\"") + |> write (Str.toUtf8 s) + |> write (Str.toUtf8 "\"") + +u8 : U8 -> Inspector PrettyLogFormatter +u8 = \num -> + f0 <- Inspect.custom + write f0 (num |> Num.toStr |> Str.toUtf8) + +i8 : I8 -> Inspector PrettyLogFormatter +i8 = \num -> + f0 <- Inspect.custom + write f0 (num |> Num.toStr |> Str.toUtf8) + +u16 : U16 -> Inspector PrettyLogFormatter +u16 = \num -> + f0 <- Inspect.custom + write f0 (num |> Num.toStr |> Str.toUtf8) + +i16 : I16 -> Inspector PrettyLogFormatter +i16 = \num -> + f0 <- Inspect.custom + write f0 (num |> Num.toStr |> Str.toUtf8) + +u32 : U32 -> Inspector PrettyLogFormatter +u32 = \num -> + f0 <- Inspect.custom + write f0 (num |> Num.toStr |> Str.toUtf8) + +i32 : I32 -> Inspector PrettyLogFormatter +i32 = \num -> + f0 <- Inspect.custom + write f0 (num |> Num.toStr |> Str.toUtf8) + +u64 : U64 -> Inspector PrettyLogFormatter +u64 = \num -> + f0 <- Inspect.custom + write f0 (num |> Num.toStr |> Str.toUtf8) + +i64 : I64 -> Inspector PrettyLogFormatter +i64 = \num -> + f0 <- Inspect.custom + write f0 (num |> Num.toStr |> Str.toUtf8) + +u128 : U128 -> Inspector PrettyLogFormatter +u128 = \num -> + f0 <- Inspect.custom + write f0 (num |> Num.toStr |> Str.toUtf8) + +i128 : I128 -> Inspector PrettyLogFormatter +i128 = \num -> + f0 <- Inspect.custom + write f0 (num |> Num.toStr |> Str.toUtf8) + +f32 : F32 -> Inspector PrettyLogFormatter +f32 = \num -> + f0 <- Inspect.custom + write f0 (num |> Num.toStr |> Str.toUtf8) + +f64 : F64 -> Inspector PrettyLogFormatter +f64 = \num -> + f0 <- Inspect.custom + write f0 (num |> Num.toStr |> Str.toUtf8) + +dec : Dec -> Inspector PrettyLogFormatter +dec = \num -> + f0 <- Inspect.custom + write f0 (num |> Num.toStr |> Str.toUtf8) + +write : PrettyLogFormatter, List U8 -> PrettyLogFormatter +write = \@PrettyLogFormatter { bytes, indents }, added -> + @PrettyLogFormatter { bytes: List.concat bytes added, indents } + +writeIndent : PrettyLogFormatter -> PrettyLogFormatter +writeIndent = \@PrettyLogFormatter { bytes, indents } -> + @PrettyLogFormatter { bytes: List.concat bytes indents, indents } + +indent : PrettyLogFormatter -> PrettyLogFormatter +indent = \@PrettyLogFormatter { bytes, indents } -> + @PrettyLogFormatter { bytes, indents: indents |> List.append ' ' |> List.append ' ' } + +outdent : PrettyLogFormatter -> PrettyLogFormatter +outdent = \@PrettyLogFormatter { bytes, indents } -> + len = List.len indents + @PrettyLogFormatter { bytes, indents: List.takeFirst indents (len - 2) } + +toBytes : PrettyLogFormatter -> List U8 +toBytes = \@PrettyLogFormatter { bytes } -> bytes diff --git a/examples/inspect-gui.roc b/examples/inspect-gui.roc new file mode 100644 index 0000000000..1eac75f2af --- /dev/null +++ b/examples/inspect-gui.roc @@ -0,0 +1,22 @@ +app "inspect-gui" + packages { pf: "gui/platform/main.roc" } + imports [ + Inspect, + Person, + GuiFormatter, + ] + provides [render] to pf + +render = + person = Person.new { + firstName: "John", + lastName: "Smith", + age: 27, + hasBeard: Bool.true, + data: Dict.fromList [ + ("test", Thing 7), + ("stuff", Stuff), + ], + } + + Inspect.inspect person |> GuiFormatter.toGui diff --git a/examples/inspect-logging.roc b/examples/inspect-logging.roc new file mode 100644 index 0000000000..eb47a361b7 --- /dev/null +++ b/examples/inspect-logging.roc @@ -0,0 +1,33 @@ +app "inspect-logging" + packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.3.2/tE4xS_zLdmmxmHwHih9kHWQ7fsXtJr7W7h3425-eZFk.tar.br" } + imports [ + pf.Stdout, + Inspect.{ Formatter, Inspector, Inspect }, + LogFormatter, + Person, + ] + provides [main] to pf + +main = + person = Person.new { + firstName: "John", + lastName: "Smith", + age: 27, + hasBeard: Bool.true, + data: Dict.fromList [ + ("test", Thing 7), + ("stuff", Stuff), + ], + } + + Inspect.inspect person + |> LogFormatter.toBytes + |> Str.fromUtf8 + |> unwrapOrCrash + |> Stdout.line + +unwrapOrCrash : Result ok err -> ok +unwrapOrCrash = \res -> + when res is + Ok v -> v + Err _ -> crash "Hit an error in a result" From 7bf3dd2f42517b8e68b169e200442017ab6ea73b Mon Sep 17 00:00:00 2001 From: Brendan Hansknecht Date: Thu, 22 Jun 2023 18:29:02 -0700 Subject: [PATCH 048/176] add set function and make all collection functions generic --- examples/GuiFormatter.roc | 57 +++++++++++++++--------- examples/Inspect.roc | 17 ++++--- examples/LogFormatter.roc | 64 +++++++++++++++++--------- examples/PrettyLogFormatter.roc | 79 ++++++++++++++++++++++----------- 4 files changed, 140 insertions(+), 77 deletions(-) diff --git a/examples/GuiFormatter.roc b/examples/GuiFormatter.roc index 3624187d71..2dc268006e 100644 --- a/examples/GuiFormatter.roc +++ b/examples/GuiFormatter.roc @@ -21,6 +21,7 @@ GuiFormatter := { nodes : List Elem } Formatter { init: init, list: list, + set: set, dict: dict, tag: tag, tuple: tuple, @@ -47,20 +48,52 @@ GuiFormatter := { nodes : List Elem } init : {} -> GuiFormatter init = \{} -> @GuiFormatter { nodes: [] } -list : List elem, (elem -> Inspector GuiFormatter) -> Inspector GuiFormatter -list = \content, toInspector -> +list : list, Inspect.ElemWalkFn GuiFormatter list elem, (elem -> Inspector GuiFormatter) -> Inspector GuiFormatter +list = \content, walkFn, toInspector -> f0 <- Inspect.custom # Use a temporary buffer for the children nodes (@GuiFormatter { nodes }) = init {} |> \f1 -> - f2, elem <- List.walk content f1 + f2, elem <- walkFn content f1 elem |> toInspector |> Inspect.apply f2 addNode f0 (Col nodes) +set : set, Inspect.ElemWalkFn GuiFormatter set elem, (elem -> Inspector GuiFormatter) -> Inspector GuiFormatter +set = \content, walkFn, toInspector -> + f0 <- Inspect.custom + # Use a temporary buffer for the children nodes + (@GuiFormatter { nodes }) = + init {} + |> \f1 -> + f2, elem <- walkFn content f1 + elem + |> toInspector + |> Inspect.apply f2 + + addNode f0 (Col nodes) + +dict : dict, Inspect.KeyValWalkFn GuiFormatter dict key value, (key -> Inspector GuiFormatter), (value -> Inspector GuiFormatter) -> Inspector GuiFormatter +dict = \d, walkFn, keyToInspector, valueToInspector -> + f0 <- Inspect.custom + # Use a temporary buffer for the children nodes + (@GuiFormatter { nodes }) = + init {} + |> \f1 -> + f2, key, value <- walkFn d f1 + (@GuiFormatter { nodes: innerNodes }) = + init {} + |> \x -> Inspect.apply (keyToInspector key) x + |> addNode (Text ":") + |> \x -> Inspect.apply (valueToInspector value) x + + addNode f2 (Row innerNodes) + + addNode f0 (Col nodes) + tag : Str, List (Inspector GuiFormatter) -> Inspector GuiFormatter tag = \name, fields -> f0 <- Inspect.custom @@ -104,24 +137,6 @@ record = \fields -> addNode f0 (Col nodes) -dict : dict, Inspect.DictWalkFn GuiFormatter dict key value, (key -> Inspector GuiFormatter), (value -> Inspector GuiFormatter) -> Inspector GuiFormatter -dict = \d, walkFn, keyToInspector, valueToInspector -> - f0 <- Inspect.custom - # Use a temporary buffer for the children nodes - (@GuiFormatter { nodes }) = - init {} - |> \f1 -> - f2, key, value <- walkFn d f1 - (@GuiFormatter { nodes: innerNodes }) = - init {} - |> \x -> Inspect.apply (keyToInspector key) x - |> addNode (Text ":") - |> \x -> Inspect.apply (valueToInspector value) x - - addNode f2 (Row innerNodes) - - addNode f0 (Col nodes) - bool : Bool -> Inspector GuiFormatter bool = \b -> if b then diff --git a/examples/Inspect.roc b/examples/Inspect.roc index 31489ce03e..d685731167 100644 --- a/examples/Inspect.roc +++ b/examples/Inspect.roc @@ -3,6 +3,7 @@ interface Inspect Formatter, init, list, + set, dict, tag, tuple, @@ -28,26 +29,28 @@ interface Inspect Inspect, inspect, toInspector, - DictWalkFn, + KeyValWalkFn, + ElemWalkFn, ] imports [] -DictWalkFn state dict key value : dict, state, (state, key, value -> state) -> state +KeyValWalkFn state container key value : container, state, (state, key, value -> state) -> state +ElemWalkFn state container elem : container, state, (state, elem -> state) -> state Formatter has init : {} -> f | f has Formatter - list : List elem, (elem -> Inspector f) -> Inspector f | f has Formatter tag : Str, List (Inspector f) -> Inspector f | f has Formatter tuple : List (Inspector f) -> Inspector f | f has Formatter record : List { key : Str, value : Inspector f } -> Inspector f | f has Formatter bool : Bool -> Inspector f | f has Formatter str : Str -> Inspector f | f has Formatter - # I am not yet sold on this function. Is there a better api. - # Specifying the walk function makes this feel very verbose. - # This is needed to make dicts special so that can print like giant records instead of lists of tuples. - dict : dict, DictWalkFn state dict key value, (key -> Inspector f), (value -> Inspector f) -> Inspector f | f has Formatter + # TODO: is there a clear/better way to make the following apis. + # Including the walk fn just makes this look verbose. + list : list, ElemWalkFn state list elem, (elem -> Inspector f) -> Inspector f | f has Formatter + set : set, ElemWalkFn state set elem, (elem -> Inspector f) -> Inspector f | f has Formatter + dict : dict, KeyValWalkFn state dict key value, (key -> Inspector f), (value -> Inspector f) -> Inspector f | f has Formatter u8 : U8 -> Inspector f | f has Formatter i8 : I8 -> Inspector f | f has Formatter diff --git a/examples/LogFormatter.roc b/examples/LogFormatter.roc index b1940a6cee..61b1a098aa 100644 --- a/examples/LogFormatter.roc +++ b/examples/LogFormatter.roc @@ -15,6 +15,7 @@ LogFormatter := { bytes : List U8 } Formatter { init: init, list: list, + set: set, dict: dict, tag: tag, tuple: tuple, @@ -41,12 +42,12 @@ LogFormatter := { bytes : List U8 } init : {} -> LogFormatter init = \{} -> @LogFormatter { bytes: [] } -list : List elem, (elem -> Inspector LogFormatter) -> Inspector LogFormatter -list = \content, toInspector -> +list : list, Inspect.ElemWalkFn (LogFormatter, Bool) list elem, (elem -> Inspector LogFormatter) -> Inspector LogFormatter +list = \content, walkFn, toInspector -> f0 <- Inspect.custom write f0 (Str.toUtf8 "[") |> \f1 -> - (f2, prependSep), elem <- List.walk content (f1, Bool.false) + (f2, prependSep), elem <- walkFn content (f1, Bool.false) f3 = if prependSep then write f2 (Str.toUtf8 ", ") @@ -60,6 +61,44 @@ list = \content, toInspector -> |> .0 |> write (Str.toUtf8 "]") +set : set, Inspect.ElemWalkFn (LogFormatter, Bool) set elem, (elem -> Inspector LogFormatter) -> Inspector LogFormatter +set = \content, walkFn, toInspector -> + f0 <- Inspect.custom + write f0 (Str.toUtf8 "{") + |> \f1 -> + (f2, prependSep), elem <- walkFn content (f1, Bool.false) + f3 = + if prependSep then + write f2 (Str.toUtf8 ", ") + else + f2 + + elem + |> toInspector + |> Inspect.apply f3 + |> \f4 -> (f4, Bool.true) + |> .0 + |> write (Str.toUtf8 "}") + +dict : dict, Inspect.KeyValWalkFn (LogFormatter, Bool) dict key value, (key -> Inspector LogFormatter), (value -> Inspector LogFormatter) -> Inspector LogFormatter +dict = \d, walkFn, keyToInspector, valueToInspector -> + f0 <- Inspect.custom + write f0 (Str.toUtf8 "{") + |> \f1 -> + (f2, prependSep), key, value <- walkFn d (f1, Bool.false) + f3 = + if prependSep then + write f2 (Str.toUtf8 ", ") + else + f2 + + Inspect.apply (keyToInspector key) f3 + |> write (Str.toUtf8 ": ") + |> \x -> Inspect.apply (valueToInspector value) x + |> \f4 -> (f4, Bool.true) + |> .0 + |> write (Str.toUtf8 "}") + tag : Str, List (Inspector LogFormatter) -> Inspector LogFormatter tag = \name, fields -> if List.isEmpty fields then @@ -111,25 +150,6 @@ record = \fields -> |> .0 |> write (Str.toUtf8 "}") -dict : dict, Inspect.DictWalkFn (LogFormatter, Bool) dict key value, (key -> Inspector LogFormatter), (value -> Inspector LogFormatter) -> Inspector LogFormatter -dict = \d, walkFn, keyToInspector, valueToInspector -> - f0 <- Inspect.custom - write f0 (Str.toUtf8 "{") - |> \f1 -> - (f2, prependSep), key, value <- walkFn d (f1, Bool.false) - f3 = - if prependSep then - write f2 (Str.toUtf8 ", ") - else - f2 - - Inspect.apply (keyToInspector key) f3 - |> write (Str.toUtf8 ": ") - |> \x -> Inspect.apply (valueToInspector value) x - |> \f4 -> (f4, Bool.true) - |> .0 - |> write (Str.toUtf8 "}") - bool : Bool -> Inspector LogFormatter bool = \b -> if b then diff --git a/examples/PrettyLogFormatter.roc b/examples/PrettyLogFormatter.roc index 9c5064d051..1656ae0913 100644 --- a/examples/PrettyLogFormatter.roc +++ b/examples/PrettyLogFormatter.roc @@ -15,6 +15,7 @@ PrettyLogFormatter := { bytes : List U8, indents : List U8 } Formatter { init: init, list: list, + set: set, dict: dict, tag: tag, tuple: tuple, @@ -41,13 +42,13 @@ PrettyLogFormatter := { bytes : List U8, indents : List U8 } init : {} -> PrettyLogFormatter init = \{} -> @PrettyLogFormatter { bytes: [], indents: [] } -list : List elem, (elem -> Inspector PrettyLogFormatter) -> Inspector PrettyLogFormatter -list = \content, toInspector -> +list : list, Inspect.ElemWalkFn (PrettyLogFormatter, Bool) list elem, (elem -> Inspector PrettyLogFormatter) -> Inspector PrettyLogFormatter +list = \content, walkFn, toInspector -> f0 <- Inspect.custom write f0 (Str.toUtf8 "[\n") |> indent |> \f1 -> - (f2, prependSep), elem <- List.walk content (f1, Bool.false) + (f2, prependSep), elem <- walkFn content (f1, Bool.false) f3 = if prependSep then write f2 (Str.toUtf8 ",\n") @@ -65,6 +66,54 @@ list = \content, toInspector -> |> writeIndent |> write (Str.toUtf8 "]") +set : set, Inspect.ElemWalkFn (PrettyLogFormatter, Bool) set elem, (elem -> Inspector PrettyLogFormatter) -> Inspector PrettyLogFormatter +set = \content, walkFn, toInspector -> + f0 <- Inspect.custom + write f0 (Str.toUtf8 "{\n") + |> indent + |> \f1 -> + (f2, prependSep), elem <- walkFn content (f1, Bool.false) + f3 = + if prependSep then + write f2 (Str.toUtf8 ",\n") + else + f2 + + elemInspector = toInspector elem + f3 + |> writeIndent + |> \x -> Inspect.apply elemInspector x + |> \f4 -> (f4, Bool.true) + |> .0 + |> write (Str.toUtf8 "\n") + |> outdent + |> writeIndent + |> write (Str.toUtf8 "}") + +dict : dict, Inspect.KeyValWalkFn (PrettyLogFormatter, Bool) dict key value, (key -> Inspector PrettyLogFormatter), (value -> Inspector PrettyLogFormatter) -> Inspector PrettyLogFormatter +dict = \d, walkFn, keyToInspector, valueToInspector -> + f0 <- Inspect.custom + write f0 (Str.toUtf8 "{\n") + |> indent + |> \f1 -> + (f2, prependSep), key, value <- walkFn d (f1, Bool.false) + f3 = + if prependSep then + write f2 (Str.toUtf8 ",\n") + else + f2 + + writeIndent f3 + |> \x -> Inspect.apply (keyToInspector key) x + |> write (Str.toUtf8 ": ") + |> \x -> Inspect.apply (valueToInspector value) x + |> \f4 -> (f4, Bool.true) + |> .0 + |> write (Str.toUtf8 "\n") + |> outdent + |> writeIndent + |> write (Str.toUtf8 "}") + tag : Str, List (Inspector PrettyLogFormatter) -> Inspector PrettyLogFormatter tag = \name, fields -> if List.isEmpty fields then @@ -128,30 +177,6 @@ record = \fields -> |> writeIndent |> write (Str.toUtf8 "}") -dict : dict, Inspect.DictWalkFn (PrettyLogFormatter, Bool) dict key value, (key -> Inspector PrettyLogFormatter), (value -> Inspector PrettyLogFormatter) -> Inspector PrettyLogFormatter -dict = \d, walkFn, keyToInspector, valueToInspector -> - f0 <- Inspect.custom - write f0 (Str.toUtf8 "{\n") - |> indent - |> \f1 -> - (f2, prependSep), key, value <- walkFn d (f1, Bool.false) - f3 = - if prependSep then - write f2 (Str.toUtf8 ",\n") - else - f2 - - writeIndent f3 - |> \x -> Inspect.apply (keyToInspector key) x - |> write (Str.toUtf8 ": ") - |> \x -> Inspect.apply (valueToInspector value) x - |> \f4 -> (f4, Bool.true) - |> .0 - |> write (Str.toUtf8 "\n") - |> outdent - |> writeIndent - |> write (Str.toUtf8 "}") - bool : Bool -> Inspector PrettyLogFormatter bool = \b -> if b then From 2e7343e857f6ab73793cef2ad6c8e4a20dba30cb Mon Sep 17 00:00:00 2001 From: Brendan Hansknecht Date: Thu, 22 Jun 2023 19:26:42 -0700 Subject: [PATCH 049/176] change to community instead of person --- examples/Community.roc | 147 +++++++++++++++++++++++++++++++++++ examples/Inspect.roc | 2 - examples/Person.roc | 47 ----------- examples/inspect-gui.roc | 30 +++++-- examples/inspect-logging.roc | 29 +++++-- 5 files changed, 190 insertions(+), 65 deletions(-) create mode 100644 examples/Community.roc delete mode 100644 examples/Person.roc diff --git a/examples/Community.roc b/examples/Community.roc new file mode 100644 index 0000000000..0cb4522fdf --- /dev/null +++ b/examples/Community.roc @@ -0,0 +1,147 @@ +interface Community + exposes [ + Community, + empty, + addPerson, + addFriend, + Person, + walkFriendNames, + ] + imports [ + Inspect.{ Formatter, Inspector, Inspect }, + ] + +Community := { + people : List Person, + friends : List (Set Nat), +} + has [ + Inspect { + toInspector: inspectCommunity, + }, + ] + +Person := { + firstName : Str, + lastName : Str, + age : U8, + hasBeard : Bool, + favoriteColor: Color, +} + has [ + Inspect { + toInspector: inspectPerson, + }, + ] + +Color : [ + Red, + Green, + Blue, + RGB (U8, U8, U8), +] + +empty = @Community { people: [], friends: [] } + +addPerson = \@Community { people, friends }, person -> + @Community { + people: List.append people (@Person person), + friends: List.append friends (Set.empty {}), + } + +addFriend = \@Community { people, friends }, from, to -> + when (List.get friends from, List.get friends to) is + (Ok fromSet, Ok toSet) -> + @Community { + people, + friends: friends + |> List.set from (Set.insert fromSet to) + |> List.set to (Set.insert toSet from), + } + + _ -> + @Community { people, friends } + +walkFriendNames : Community, state, (state, Str, Set Str -> state) -> state +walkFriendNames = \@Community { people, friends }, s0, nextFn -> + (out, _) = + (s1, id), friendSet <- List.walk friends (s0, 0) + (@Person person) = + when List.get people id is + Ok v -> v + Err _ -> crash "Unknown Person" + personName = + person.firstName + |> Str.concat " " + |> Str.concat person.lastName + + friendNames = + friendsSet, friendId <- Set.walk friendSet (Set.empty {}) + (@Person friend) = + when List.get people friendId is + Ok v -> v + Err _ -> crash "Unknown Person" + friendName = + friend.firstName + |> Str.concat " " + |> Str.concat friend.lastName + Set.insert friendsSet friendName + + (nextFn s1 personName friendNames, id + 1) + out + +inspectCommunity : Community -> Inspector f | f has Formatter +inspectCommunity = \@Community { people, friends } -> + f0 <- Inspect.custom + [ + { key: "people", value: Inspect.list people List.walk Inspect.toInspector }, + { + key: "friends", + value: Inspect.list + friends + List.walk + (\s -> Inspect.set + s + Set.walk + (\num -> num |> Num.toU64 |> Inspect.u64) + ), + # value: Inspect.dict + # (@Community { people, friends }) + # walkFriendNames + # Inspect.str + # (\s -> Inspect.set s Set.walk Inspect.str), + }, + ] + |> Inspect.record + |> Inspect.apply f0 + +inspectPerson : Person -> Inspector f | f has Formatter +inspectPerson = \@Person { firstName, lastName, age, hasBeard, favoriteColor } -> + # In practice, this would never be done manually due to autoderive. + # Instead you would just write: + # Inspect.inspect innerRecord + # This is what the auto-derive would generate. + + f0 <- Inspect.custom + [ + { key: "firstName", value: Inspect.str firstName }, + { key: "lastName", value: Inspect.str lastName }, + { key: "age", value: Inspect.u8 age }, + { key: "hasBeard", value: Inspect.bool hasBeard }, + { + key: "favoriteColor", + value: + when favoriteColor is + Red -> + Inspect.tag "Red" [] + Green -> + Inspect.tag "Green" [] + Blue -> + Inspect.tag "Blue" [] + RGB (r, g, b) -> + Inspect.tag "RGB" [Inspect.tuple [Inspect.u8 r, Inspect.u8 g, Inspect.u8 b]] + , + }, + ] + |> Inspect.record + |> Inspect.apply f0 diff --git a/examples/Inspect.roc b/examples/Inspect.roc index d685731167..9cbfe02276 100644 --- a/examples/Inspect.roc +++ b/examples/Inspect.roc @@ -46,8 +46,6 @@ Formatter has bool : Bool -> Inspector f | f has Formatter str : Str -> Inspector f | f has Formatter - # TODO: is there a clear/better way to make the following apis. - # Including the walk fn just makes this look verbose. list : list, ElemWalkFn state list elem, (elem -> Inspector f) -> Inspector f | f has Formatter set : set, ElemWalkFn state set elem, (elem -> Inspector f) -> Inspector f | f has Formatter dict : dict, KeyValWalkFn state dict key value, (key -> Inspector f), (value -> Inspector f) -> Inspector f | f has Formatter diff --git a/examples/Person.roc b/examples/Person.roc deleted file mode 100644 index 223f3018eb..0000000000 --- a/examples/Person.roc +++ /dev/null @@ -1,47 +0,0 @@ -interface Person - exposes [ - new, - ] - imports [ - Inspect.{ Formatter, Inspector, Inspect }, - ] - -Person := { - firstName : Str, - lastName : Str, - age : U8, - data: Dict Str [Stuff, Thing I32], - hasBeard: Bool, -} - has [ - Inspect { - toInspector: inspectPerson, - }, - ] - -new = @Person - -inspectPerson : Person -> Inspector f | f has Formatter -inspectPerson = \@Person { firstName, lastName, age, data, hasBeard } -> - # In practice, this would never be done manually due to autoderive. - # Instead you would just write: - # Inspect.inspect innerRecord - # This is what the auto-derive would generate. - - f0 <- Inspect.custom - [ - { key: "firstName", value: Inspect.str firstName }, - { key: "lastName", value: Inspect.str lastName }, - { key: "age", value: Inspect.u8 age }, - { key: "hasBeard", value: Inspect.bool hasBeard }, - { - key: "data", - value: Inspect.dict data Dict.walk Inspect.str \value -> - when value is - Thing i -> Inspect.tag "Thing" [Inspect.i32 i] - Stuff -> Inspect.tag "Stuff" [] - , - }, - ] - |> Inspect.record - |> Inspect.apply f0 diff --git a/examples/inspect-gui.roc b/examples/inspect-gui.roc index 1eac75f2af..e3ca09d7a4 100644 --- a/examples/inspect-gui.roc +++ b/examples/inspect-gui.roc @@ -2,21 +2,35 @@ app "inspect-gui" packages { pf: "gui/platform/main.roc" } imports [ Inspect, - Person, + Community, GuiFormatter, ] provides [render] to pf render = - person = Person.new { + Community.empty + |> Community.addPerson { firstName: "John", lastName: "Smith", age: 27, hasBeard: Bool.true, - data: Dict.fromList [ - ("test", Thing 7), - ("stuff", Stuff), - ], + favoriteColor: Blue, } - - Inspect.inspect person |> GuiFormatter.toGui + |> Community.addPerson { + firstName: "Debby", + lastName: "Johnson", + age: 47, + hasBeard: Bool.false, + favoriteColor: Green, + } + |> Community.addPerson { + firstName: "Jane", + lastName: "Doe", + age: 33, + hasBeard: Bool.false, + favoriteColor: RGB (255, 255, 0), + } + |> Community.addFriend 0 2 + |> Community.addFriend 1 2 + |> Inspect.inspect + |> GuiFormatter.toGui diff --git a/examples/inspect-logging.roc b/examples/inspect-logging.roc index eb47a361b7..9661b840f4 100644 --- a/examples/inspect-logging.roc +++ b/examples/inspect-logging.roc @@ -4,23 +4,36 @@ app "inspect-logging" pf.Stdout, Inspect.{ Formatter, Inspector, Inspect }, LogFormatter, - Person, + Community, ] provides [main] to pf main = - person = Person.new { + Community.empty + |> Community.addPerson { firstName: "John", lastName: "Smith", age: 27, hasBeard: Bool.true, - data: Dict.fromList [ - ("test", Thing 7), - ("stuff", Stuff), - ], + favoriteColor: Blue, } - - Inspect.inspect person + |> Community.addPerson { + firstName: "Debby", + lastName: "Johnson", + age: 47, + hasBeard: Bool.false, + favoriteColor: Green, + } + |> Community.addPerson { + firstName: "Jane", + lastName: "Doe", + age: 33, + hasBeard: Bool.false, + favoriteColor: RGB (255, 255, 0), + } + |> Community.addFriend 0 2 + |> Community.addFriend 1 2 + |> Inspect.inspect |> LogFormatter.toBytes |> Str.fromUtf8 |> unwrapOrCrash From 17f68aaf127a2ee44fdd4b2ceedea4941acb9c31 Mon Sep 17 00:00:00 2001 From: Brendan Hansknecht Date: Thu, 22 Jun 2023 21:19:07 -0700 Subject: [PATCH 050/176] fix pretty printing --- examples/PrettyLogFormatter.roc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/examples/PrettyLogFormatter.roc b/examples/PrettyLogFormatter.roc index 1656ae0913..42198f0835 100644 --- a/examples/PrettyLogFormatter.roc +++ b/examples/PrettyLogFormatter.roc @@ -123,12 +123,10 @@ tag = \name, fields -> f0 <- Inspect.custom write f0 (Str.toUtf8 "(") |> write (Str.toUtf8 name) - |> indent |> \f1 -> f2, inspector <- List.walk fields f1 write f2 (Str.toUtf8 " ") |> \x -> Inspect.apply inspector x - |> outdent |> write (Str.toUtf8 ")") tuple : List (Inspector PrettyLogFormatter) -> Inspector PrettyLogFormatter @@ -151,6 +149,7 @@ tuple = \fields -> |> .0 |> write (Str.toUtf8 "\n") |> outdent + |> writeIndent |> write (Str.toUtf8 ")") record : List { key : Str, value : Inspector PrettyLogFormatter } -> Inspector PrettyLogFormatter From 5379aef1046428d842e2c6dc1f7efa7bb314612d Mon Sep 17 00:00:00 2001 From: Brendan Hansknecht Date: Wed, 5 Jul 2023 10:07:42 -0700 Subject: [PATCH 051/176] add opaque type support to formatters --- examples/GuiFormatter.roc | 6 ++++++ examples/Inspect.roc | 8 ++++++++ examples/LogFormatter.roc | 9 +++++++++ examples/PrettyLogFormatter.roc | 9 +++++++++ 4 files changed, 32 insertions(+) diff --git a/examples/GuiFormatter.roc b/examples/GuiFormatter.roc index 2dc268006e..6933f12f20 100644 --- a/examples/GuiFormatter.roc +++ b/examples/GuiFormatter.roc @@ -28,6 +28,7 @@ GuiFormatter := { nodes : List Elem } record: record, bool: bool, str: str, + opaque: opaque, u8: u8, i8: i8, u16: u16, @@ -151,6 +152,11 @@ str = \s -> f0 <- Inspect.custom addNode f0 (Text "\"\(s)\"") +opaque : Str -> Inspector GuiFormatter +opaque = \s -> + f0 <- Inspect.custom + addNode f0 (Text "<\(s)>") + u8 : U8 -> Inspector GuiFormatter u8 = \num -> f0 <- Inspect.custom diff --git a/examples/Inspect.roc b/examples/Inspect.roc index 9cbfe02276..08accb4090 100644 --- a/examples/Inspect.roc +++ b/examples/Inspect.roc @@ -10,6 +10,7 @@ interface Inspect record, bool, str, + opaque, u8, i8, u16, @@ -50,6 +51,13 @@ Formatter has set : set, ElemWalkFn state set elem, (elem -> Inspector f) -> Inspector f | f has Formatter dict : dict, KeyValWalkFn state dict key value, (key -> Inspector f), (value -> Inspector f) -> Inspector f | f has Formatter + # Note opaque is used for both opaque types and functions. + # The auto deriver for functions probably could put the function type. + # For regular opaque types, I think we can use the type name, though that may lead to some reflection related issues that still need to be discussed. + # As a simple baseline, it can just use the exact words `opaque` and `function` for now. + # In text, this would render as ``, ``, etc + opaque : Str -> Inspector f | f has Formatter + u8 : U8 -> Inspector f | f has Formatter i8 : I8 -> Inspector f | f has Formatter u16 : U16 -> Inspector f | f has Formatter diff --git a/examples/LogFormatter.roc b/examples/LogFormatter.roc index 61b1a098aa..97ccefb29f 100644 --- a/examples/LogFormatter.roc +++ b/examples/LogFormatter.roc @@ -22,6 +22,7 @@ LogFormatter := { bytes : List U8 } record: record, bool: bool, str: str, + opaque: opaque, u8: u8, i8: i8, u16: u16, @@ -167,6 +168,14 @@ str = \s -> |> write (Str.toUtf8 s) |> write (Str.toUtf8 "\"") +opaque : Str -> Inspector LogFormatter +opaque = \s -> + f0 <- Inspect.custom + f0 + |> write (Str.toUtf8 "<") + |> write (Str.toUtf8 s) + |> write (Str.toUtf8 ">") + u8 : U8 -> Inspector LogFormatter u8 = \num -> f0 <- Inspect.custom diff --git a/examples/PrettyLogFormatter.roc b/examples/PrettyLogFormatter.roc index 42198f0835..9a41d7a94c 100644 --- a/examples/PrettyLogFormatter.roc +++ b/examples/PrettyLogFormatter.roc @@ -22,6 +22,7 @@ PrettyLogFormatter := { bytes : List U8, indents : List U8 } record: record, bool: bool, str: str, + opaque: opaque, u8: u8, i8: i8, u16: u16, @@ -193,6 +194,14 @@ str = \s -> |> write (Str.toUtf8 s) |> write (Str.toUtf8 "\"") +opaque : Str -> Inspector PrettyLogFormatter +opaque = \s -> + f0 <- Inspect.custom + f0 + |> write (Str.toUtf8 "<") + |> write (Str.toUtf8 s) + |> write (Str.toUtf8 ">") + u8 : U8 -> Inspector PrettyLogFormatter u8 = \num -> f0 <- Inspect.custom From 77e8b134c4ce10f1d8e80c8814f57a4a5b597aff Mon Sep 17 00:00:00 2001 From: Brendan Hansknecht Date: Wed, 5 Jul 2023 10:18:46 -0700 Subject: [PATCH 052/176] switch LogFormatter to use a Str as the base type --- examples/LogFormatter.roc | 104 ++++++------ examples/PrettyLogFormatter.roc | 288 -------------------------------- examples/inspect-logging.roc | 10 +- 3 files changed, 53 insertions(+), 349 deletions(-) delete mode 100644 examples/PrettyLogFormatter.roc diff --git a/examples/LogFormatter.roc b/examples/LogFormatter.roc index 97ccefb29f..808689f884 100644 --- a/examples/LogFormatter.roc +++ b/examples/LogFormatter.roc @@ -1,7 +1,7 @@ interface LogFormatter exposes [ LogFormatter, - toBytes, + toStr, ] imports [ Inspect.{ @@ -10,7 +10,7 @@ interface LogFormatter }, ] -LogFormatter := { bytes : List U8 } +LogFormatter := { data : Str } has [ Formatter { init: init, @@ -41,17 +41,17 @@ LogFormatter := { bytes : List U8 } ] init : {} -> LogFormatter -init = \{} -> @LogFormatter { bytes: [] } +init = \{} -> @LogFormatter { data: "" } list : list, Inspect.ElemWalkFn (LogFormatter, Bool) list elem, (elem -> Inspector LogFormatter) -> Inspector LogFormatter list = \content, walkFn, toInspector -> f0 <- Inspect.custom - write f0 (Str.toUtf8 "[") + write f0 "[" |> \f1 -> (f2, prependSep), elem <- walkFn content (f1, Bool.false) f3 = if prependSep then - write f2 (Str.toUtf8 ", ") + write f2 ", " else f2 @@ -60,17 +60,17 @@ list = \content, walkFn, toInspector -> |> Inspect.apply f3 |> \f4 -> (f4, Bool.true) |> .0 - |> write (Str.toUtf8 "]") + |> write "]" set : set, Inspect.ElemWalkFn (LogFormatter, Bool) set elem, (elem -> Inspector LogFormatter) -> Inspector LogFormatter set = \content, walkFn, toInspector -> f0 <- Inspect.custom - write f0 (Str.toUtf8 "{") + write f0 "{" |> \f1 -> (f2, prependSep), elem <- walkFn content (f1, Bool.false) f3 = if prependSep then - write f2 (Str.toUtf8 ", ") + write f2 ", " else f2 @@ -79,171 +79,171 @@ set = \content, walkFn, toInspector -> |> Inspect.apply f3 |> \f4 -> (f4, Bool.true) |> .0 - |> write (Str.toUtf8 "}") + |> write "}" dict : dict, Inspect.KeyValWalkFn (LogFormatter, Bool) dict key value, (key -> Inspector LogFormatter), (value -> Inspector LogFormatter) -> Inspector LogFormatter dict = \d, walkFn, keyToInspector, valueToInspector -> f0 <- Inspect.custom - write f0 (Str.toUtf8 "{") + write f0 "{" |> \f1 -> (f2, prependSep), key, value <- walkFn d (f1, Bool.false) f3 = if prependSep then - write f2 (Str.toUtf8 ", ") + write f2 ", " else f2 Inspect.apply (keyToInspector key) f3 - |> write (Str.toUtf8 ": ") + |> write ": " |> \x -> Inspect.apply (valueToInspector value) x |> \f4 -> (f4, Bool.true) |> .0 - |> write (Str.toUtf8 "}") + |> write "}" tag : Str, List (Inspector LogFormatter) -> Inspector LogFormatter tag = \name, fields -> if List.isEmpty fields then f0 <- Inspect.custom - write f0 (Str.toUtf8 name) + write f0 name else f0 <- Inspect.custom - write f0 (Str.toUtf8 "(") - |> write (Str.toUtf8 name) + write f0 "(" + |> write name |> \f1 -> f2, inspector <- List.walk fields f1 - write f2 (Str.toUtf8 " ") + write f2 " " |> \x -> Inspect.apply inspector x - |> write (Str.toUtf8 ")") + |> write ")" tuple : List (Inspector LogFormatter) -> Inspector LogFormatter tuple = \fields -> f0 <- Inspect.custom - write f0 (Str.toUtf8 "(") + write f0 "(" |> \f1 -> (f2, prependSep), inspector <- List.walk fields (f1, Bool.false) f3 = if prependSep then - write f2 (Str.toUtf8 ", ") + write f2 ", " else f2 Inspect.apply inspector f3 |> \f4 -> (f4, Bool.true) |> .0 - |> write (Str.toUtf8 ")") + |> write ")" record : List { key : Str, value : Inspector LogFormatter } -> Inspector LogFormatter record = \fields -> f0 <- Inspect.custom - write f0 (Str.toUtf8 "{") + write f0 "{" |> \f1 -> (f2, prependSep), { key, value } <- List.walk fields (f1, Bool.false) f3 = if prependSep then - write f2 (Str.toUtf8 ", ") + write f2 ", " else f2 - write f3 (Str.toUtf8 key) - |> write (Str.toUtf8 ": ") + write f3 key + |> write ": " |> \x -> Inspect.apply value x |> \f4 -> (f4, Bool.true) |> .0 - |> write (Str.toUtf8 "}") + |> write "}" bool : Bool -> Inspector LogFormatter bool = \b -> if b then f0 <- Inspect.custom - write f0 (Str.toUtf8 "true") + write f0 "true" else f0 <- Inspect.custom - write f0 (Str.toUtf8 "false") + write f0 "false" str : Str -> Inspector LogFormatter str = \s -> f0 <- Inspect.custom f0 - |> write (Str.toUtf8 "\"") - |> write (Str.toUtf8 s) - |> write (Str.toUtf8 "\"") + |> write "\"" + |> write s + |> write "\"" opaque : Str -> Inspector LogFormatter opaque = \s -> f0 <- Inspect.custom f0 - |> write (Str.toUtf8 "<") - |> write (Str.toUtf8 s) - |> write (Str.toUtf8 ">") + |> write "<" + |> write s + |> write ">" u8 : U8 -> Inspector LogFormatter u8 = \num -> f0 <- Inspect.custom - write f0 (num |> Num.toStr |> Str.toUtf8) + write f0 (num |> Num.toStr) i8 : I8 -> Inspector LogFormatter i8 = \num -> f0 <- Inspect.custom - write f0 (num |> Num.toStr |> Str.toUtf8) + write f0 (num |> Num.toStr) u16 : U16 -> Inspector LogFormatter u16 = \num -> f0 <- Inspect.custom - write f0 (num |> Num.toStr |> Str.toUtf8) + write f0 (num |> Num.toStr) i16 : I16 -> Inspector LogFormatter i16 = \num -> f0 <- Inspect.custom - write f0 (num |> Num.toStr |> Str.toUtf8) + write f0 (num |> Num.toStr) u32 : U32 -> Inspector LogFormatter u32 = \num -> f0 <- Inspect.custom - write f0 (num |> Num.toStr |> Str.toUtf8) + write f0 (num |> Num.toStr) i32 : I32 -> Inspector LogFormatter i32 = \num -> f0 <- Inspect.custom - write f0 (num |> Num.toStr |> Str.toUtf8) + write f0 (num |> Num.toStr) u64 : U64 -> Inspector LogFormatter u64 = \num -> f0 <- Inspect.custom - write f0 (num |> Num.toStr |> Str.toUtf8) + write f0 (num |> Num.toStr) i64 : I64 -> Inspector LogFormatter i64 = \num -> f0 <- Inspect.custom - write f0 (num |> Num.toStr |> Str.toUtf8) + write f0 (num |> Num.toStr) u128 : U128 -> Inspector LogFormatter u128 = \num -> f0 <- Inspect.custom - write f0 (num |> Num.toStr |> Str.toUtf8) + write f0 (num |> Num.toStr) i128 : I128 -> Inspector LogFormatter i128 = \num -> f0 <- Inspect.custom - write f0 (num |> Num.toStr |> Str.toUtf8) + write f0 (num |> Num.toStr) f32 : F32 -> Inspector LogFormatter f32 = \num -> f0 <- Inspect.custom - write f0 (num |> Num.toStr |> Str.toUtf8) + write f0 (num |> Num.toStr) f64 : F64 -> Inspector LogFormatter f64 = \num -> f0 <- Inspect.custom - write f0 (num |> Num.toStr |> Str.toUtf8) + write f0 (num |> Num.toStr) dec : Dec -> Inspector LogFormatter dec = \num -> f0 <- Inspect.custom - write f0 (num |> Num.toStr |> Str.toUtf8) + write f0 (num |> Num.toStr) -write : LogFormatter, List U8 -> LogFormatter -write = \@LogFormatter { bytes }, added -> - @LogFormatter { bytes: List.concat bytes added } +write : LogFormatter, Str -> LogFormatter +write = \@LogFormatter { data }, added -> + @LogFormatter { data: Str.concat data added } -toBytes : LogFormatter -> List U8 -toBytes = \@LogFormatter { bytes } -> bytes +toStr : LogFormatter -> Str +toStr = \@LogFormatter { data } -> data diff --git a/examples/PrettyLogFormatter.roc b/examples/PrettyLogFormatter.roc deleted file mode 100644 index 9a41d7a94c..0000000000 --- a/examples/PrettyLogFormatter.roc +++ /dev/null @@ -1,288 +0,0 @@ -interface PrettyLogFormatter - exposes [ - PrettyLogFormatter, - toBytes, - ] - imports [ - Inspect.{ - Formatter, - Inspector, - }, - ] - -PrettyLogFormatter := { bytes : List U8, indents : List U8 } - has [ - Formatter { - init: init, - list: list, - set: set, - dict: dict, - tag: tag, - tuple: tuple, - record: record, - bool: bool, - str: str, - opaque: opaque, - u8: u8, - i8: i8, - u16: u16, - i16: i16, - u32: u32, - i32: i32, - u64: u64, - i64: i64, - u128: u128, - i128: i128, - f32: f32, - f64: f64, - dec: dec, - - }, - ] - -init : {} -> PrettyLogFormatter -init = \{} -> @PrettyLogFormatter { bytes: [], indents: [] } - -list : list, Inspect.ElemWalkFn (PrettyLogFormatter, Bool) list elem, (elem -> Inspector PrettyLogFormatter) -> Inspector PrettyLogFormatter -list = \content, walkFn, toInspector -> - f0 <- Inspect.custom - write f0 (Str.toUtf8 "[\n") - |> indent - |> \f1 -> - (f2, prependSep), elem <- walkFn content (f1, Bool.false) - f3 = - if prependSep then - write f2 (Str.toUtf8 ",\n") - else - f2 - - elemInspector = toInspector elem - f3 - |> writeIndent - |> \x -> Inspect.apply elemInspector x - |> \f4 -> (f4, Bool.true) - |> .0 - |> write (Str.toUtf8 "\n") - |> outdent - |> writeIndent - |> write (Str.toUtf8 "]") - -set : set, Inspect.ElemWalkFn (PrettyLogFormatter, Bool) set elem, (elem -> Inspector PrettyLogFormatter) -> Inspector PrettyLogFormatter -set = \content, walkFn, toInspector -> - f0 <- Inspect.custom - write f0 (Str.toUtf8 "{\n") - |> indent - |> \f1 -> - (f2, prependSep), elem <- walkFn content (f1, Bool.false) - f3 = - if prependSep then - write f2 (Str.toUtf8 ",\n") - else - f2 - - elemInspector = toInspector elem - f3 - |> writeIndent - |> \x -> Inspect.apply elemInspector x - |> \f4 -> (f4, Bool.true) - |> .0 - |> write (Str.toUtf8 "\n") - |> outdent - |> writeIndent - |> write (Str.toUtf8 "}") - -dict : dict, Inspect.KeyValWalkFn (PrettyLogFormatter, Bool) dict key value, (key -> Inspector PrettyLogFormatter), (value -> Inspector PrettyLogFormatter) -> Inspector PrettyLogFormatter -dict = \d, walkFn, keyToInspector, valueToInspector -> - f0 <- Inspect.custom - write f0 (Str.toUtf8 "{\n") - |> indent - |> \f1 -> - (f2, prependSep), key, value <- walkFn d (f1, Bool.false) - f3 = - if prependSep then - write f2 (Str.toUtf8 ",\n") - else - f2 - - writeIndent f3 - |> \x -> Inspect.apply (keyToInspector key) x - |> write (Str.toUtf8 ": ") - |> \x -> Inspect.apply (valueToInspector value) x - |> \f4 -> (f4, Bool.true) - |> .0 - |> write (Str.toUtf8 "\n") - |> outdent - |> writeIndent - |> write (Str.toUtf8 "}") - -tag : Str, List (Inspector PrettyLogFormatter) -> Inspector PrettyLogFormatter -tag = \name, fields -> - if List.isEmpty fields then - f0 <- Inspect.custom - write f0 (Str.toUtf8 name) - else - f0 <- Inspect.custom - write f0 (Str.toUtf8 "(") - |> write (Str.toUtf8 name) - |> \f1 -> - f2, inspector <- List.walk fields f1 - write f2 (Str.toUtf8 " ") - |> \x -> Inspect.apply inspector x - |> write (Str.toUtf8 ")") - -tuple : List (Inspector PrettyLogFormatter) -> Inspector PrettyLogFormatter -tuple = \fields -> - f0 <- Inspect.custom - write f0 (Str.toUtf8 "(\n") - |> indent - |> \f1 -> - (f2, prependSep), inspector <- List.walk fields (f1, Bool.false) - f3 = - if prependSep then - write f2 (Str.toUtf8 ",\n") - else - f2 - - f3 - |> writeIndent - |> \x -> Inspect.apply inspector x - |> \f4 -> (f4, Bool.true) - |> .0 - |> write (Str.toUtf8 "\n") - |> outdent - |> writeIndent - |> write (Str.toUtf8 ")") - -record : List { key : Str, value : Inspector PrettyLogFormatter } -> Inspector PrettyLogFormatter -record = \fields -> - f0 <- Inspect.custom - write f0 (Str.toUtf8 "{\n") - |> indent - |> \f1 -> - (f2, prependSep), { key, value } <- List.walk fields (f1, Bool.false) - f3 = - if prependSep then - write f2 (Str.toUtf8 ",\n") - else - f2 - - writeIndent f3 - |> write (Str.toUtf8 key) - |> write (Str.toUtf8 ": ") - |> \x -> Inspect.apply value x - |> \f4 -> (f4, Bool.true) - |> .0 - |> write (Str.toUtf8 "\n") - |> outdent - |> writeIndent - |> write (Str.toUtf8 "}") - -bool : Bool -> Inspector PrettyLogFormatter -bool = \b -> - if b then - f0 <- Inspect.custom - write f0 (Str.toUtf8 "true") - else - f0 <- Inspect.custom - write f0 (Str.toUtf8 "false") - -str : Str -> Inspector PrettyLogFormatter -str = \s -> - f0 <- Inspect.custom - f0 - |> write (Str.toUtf8 "\"") - |> write (Str.toUtf8 s) - |> write (Str.toUtf8 "\"") - -opaque : Str -> Inspector PrettyLogFormatter -opaque = \s -> - f0 <- Inspect.custom - f0 - |> write (Str.toUtf8 "<") - |> write (Str.toUtf8 s) - |> write (Str.toUtf8 ">") - -u8 : U8 -> Inspector PrettyLogFormatter -u8 = \num -> - f0 <- Inspect.custom - write f0 (num |> Num.toStr |> Str.toUtf8) - -i8 : I8 -> Inspector PrettyLogFormatter -i8 = \num -> - f0 <- Inspect.custom - write f0 (num |> Num.toStr |> Str.toUtf8) - -u16 : U16 -> Inspector PrettyLogFormatter -u16 = \num -> - f0 <- Inspect.custom - write f0 (num |> Num.toStr |> Str.toUtf8) - -i16 : I16 -> Inspector PrettyLogFormatter -i16 = \num -> - f0 <- Inspect.custom - write f0 (num |> Num.toStr |> Str.toUtf8) - -u32 : U32 -> Inspector PrettyLogFormatter -u32 = \num -> - f0 <- Inspect.custom - write f0 (num |> Num.toStr |> Str.toUtf8) - -i32 : I32 -> Inspector PrettyLogFormatter -i32 = \num -> - f0 <- Inspect.custom - write f0 (num |> Num.toStr |> Str.toUtf8) - -u64 : U64 -> Inspector PrettyLogFormatter -u64 = \num -> - f0 <- Inspect.custom - write f0 (num |> Num.toStr |> Str.toUtf8) - -i64 : I64 -> Inspector PrettyLogFormatter -i64 = \num -> - f0 <- Inspect.custom - write f0 (num |> Num.toStr |> Str.toUtf8) - -u128 : U128 -> Inspector PrettyLogFormatter -u128 = \num -> - f0 <- Inspect.custom - write f0 (num |> Num.toStr |> Str.toUtf8) - -i128 : I128 -> Inspector PrettyLogFormatter -i128 = \num -> - f0 <- Inspect.custom - write f0 (num |> Num.toStr |> Str.toUtf8) - -f32 : F32 -> Inspector PrettyLogFormatter -f32 = \num -> - f0 <- Inspect.custom - write f0 (num |> Num.toStr |> Str.toUtf8) - -f64 : F64 -> Inspector PrettyLogFormatter -f64 = \num -> - f0 <- Inspect.custom - write f0 (num |> Num.toStr |> Str.toUtf8) - -dec : Dec -> Inspector PrettyLogFormatter -dec = \num -> - f0 <- Inspect.custom - write f0 (num |> Num.toStr |> Str.toUtf8) - -write : PrettyLogFormatter, List U8 -> PrettyLogFormatter -write = \@PrettyLogFormatter { bytes, indents }, added -> - @PrettyLogFormatter { bytes: List.concat bytes added, indents } - -writeIndent : PrettyLogFormatter -> PrettyLogFormatter -writeIndent = \@PrettyLogFormatter { bytes, indents } -> - @PrettyLogFormatter { bytes: List.concat bytes indents, indents } - -indent : PrettyLogFormatter -> PrettyLogFormatter -indent = \@PrettyLogFormatter { bytes, indents } -> - @PrettyLogFormatter { bytes, indents: indents |> List.append ' ' |> List.append ' ' } - -outdent : PrettyLogFormatter -> PrettyLogFormatter -outdent = \@PrettyLogFormatter { bytes, indents } -> - len = List.len indents - @PrettyLogFormatter { bytes, indents: List.takeFirst indents (len - 2) } - -toBytes : PrettyLogFormatter -> List U8 -toBytes = \@PrettyLogFormatter { bytes } -> bytes diff --git a/examples/inspect-logging.roc b/examples/inspect-logging.roc index 9661b840f4..31e39d43e9 100644 --- a/examples/inspect-logging.roc +++ b/examples/inspect-logging.roc @@ -34,13 +34,5 @@ main = |> Community.addFriend 0 2 |> Community.addFriend 1 2 |> Inspect.inspect - |> LogFormatter.toBytes - |> Str.fromUtf8 - |> unwrapOrCrash + |> LogFormatter.toStr |> Stdout.line - -unwrapOrCrash : Result ok err -> ok -unwrapOrCrash = \res -> - when res is - Ok v -> v - Err _ -> crash "Hit an error in a result" From 0f5ea7eeb81a5b7bcbb9fc01196d27ca6caebe89 Mon Sep 17 00:00:00 2001 From: Luke Boswell Date: Sat, 5 Aug 2023 20:28:26 +1000 Subject: [PATCH 053/176] fix float callee convention for Windows --- .../compiler/gen_dev/src/generic64/x86_64.rs | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/crates/compiler/gen_dev/src/generic64/x86_64.rs b/crates/compiler/gen_dev/src/generic64/x86_64.rs index 918330fc58..eea8c390ac 100644 --- a/crates/compiler/gen_dev/src/generic64/x86_64.rs +++ b/crates/compiler/gen_dev/src/generic64/x86_64.rs @@ -1130,6 +1130,9 @@ impl CallConv for X86_64Windo ]; const SHADOW_SPACE_SIZE: u8 = 32; + // Refer https://learn.microsoft.com/en-us/cpp/build/x64-calling-convention?view=msvc-170#callercallee-saved-registers + // > The x64 ABI considers registers RBX, RBP, RDI, RSI, RSP, R12, R13, R14, R15, and XMM6-XMM15 nonvolatile. + // > They must be saved and restored by a function that uses them. #[inline(always)] fn general_callee_saved(reg: &X86_64GeneralReg) -> bool { matches!( @@ -1146,16 +1149,23 @@ impl CallConv for X86_64Windo ) } + // Refer https://learn.microsoft.com/en-us/cpp/build/x64-calling-convention?view=msvc-170#callercallee-saved-registers + // > The x64 ABI considers registers RBX, RBP, RDI, RSI, RSP, R12, R13, R14, R15, and XMM6-XMM15 nonvolatile. + // > They must be saved and restored by a function that uses them. #[inline(always)] fn float_callee_saved(reg: &X86_64FloatReg) -> bool { matches!( reg, - X86_64FloatReg::XMM0 - | X86_64FloatReg::XMM1 - | X86_64FloatReg::XMM2 - | X86_64FloatReg::XMM3 - | X86_64FloatReg::XMM4 - | X86_64FloatReg::XMM5 + X86_64FloatReg::XMM6 + | X86_64FloatReg::XMM7 + | X86_64FloatReg::XMM8 + | X86_64FloatReg::XMM9 + | X86_64FloatReg::XMM10 + | X86_64FloatReg::XMM11 + | X86_64FloatReg::XMM12 + | X86_64FloatReg::XMM13 + | X86_64FloatReg::XMM14 + | X86_64FloatReg::XMM15 ) } From 5cff9ac981dd6f167a30eb477ce22f8cf0b96b38 Mon Sep 17 00:00:00 2001 From: Luke Boswell Date: Sat, 5 Aug 2023 21:48:53 +1000 Subject: [PATCH 054/176] windows & zig returning of 128bit values --- crates/compiler/gen_dev/src/generic64/mod.rs | 3 ++- .../compiler/gen_dev/src/generic64/x86_64.rs | 25 +++++++++++++++++-- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/crates/compiler/gen_dev/src/generic64/mod.rs b/crates/compiler/gen_dev/src/generic64/mod.rs index 98a9dfc5ca..918302e383 100644 --- a/crates/compiler/gen_dev/src/generic64/mod.rs +++ b/crates/compiler/gen_dev/src/generic64/mod.rs @@ -985,7 +985,8 @@ impl< let dst_reg = self.storage_manager.claim_float_reg(&mut self.buf, dst); ASM::mov_freg64_freg64(&mut self.buf, dst_reg, CC::FLOAT_RETURN_REGS[0]); } - LayoutRepr::I128 | LayoutRepr::U128 => { + // Note that on windows there is only 1 general return register so we can't use this optimisation + LayoutRepr::I128 | LayoutRepr::U128 if CC::GENERAL_RETURN_REGS.len() > 1 => { let offset = self.storage_manager.claim_stack_area(dst, 16); ASM::mov_base32_reg64(&mut self.buf, offset, CC::GENERAL_RETURN_REGS[0]); diff --git a/crates/compiler/gen_dev/src/generic64/x86_64.rs b/crates/compiler/gen_dev/src/generic64/x86_64.rs index eea8c390ac..42434ee786 100644 --- a/crates/compiler/gen_dev/src/generic64/x86_64.rs +++ b/crates/compiler/gen_dev/src/generic64/x86_64.rs @@ -8,7 +8,7 @@ use roc_builtins::bitcode::{FloatWidth, IntWidth}; use roc_error_macros::internal_error; use roc_module::symbol::Symbol; use roc_mono::layout::{ - Builtin, InLayout, LayoutInterner, LayoutRepr, STLayoutInterner, UnionLayout, + Builtin, InLayout, Layout, LayoutInterner, LayoutRepr, STLayoutInterner, UnionLayout, }; use super::{CompareOperation, RegisterWidth}; @@ -1296,6 +1296,16 @@ impl CallConv for X86_64Windo single_register_layouts!() => { internal_error!("single register layouts are not complex symbols"); } + // For windows (and zig 0.9 changes in zig 0.10) we need to match what zig does, + // in this case uses RAX & RDX to return the value + LayoutRepr::I128 | LayoutRepr::U128 => { + let (base_offset, size) = storage_manager.stack_offset_and_size(sym); + debug_assert_eq!(base_offset % 8, 0); + debug_assert_eq!(size, 16); + + X86_64Assembler::mov_reg64_base32(buf, X86_64GeneralReg::RAX, base_offset + 0x00); + X86_64Assembler::mov_reg64_base32(buf, X86_64GeneralReg::RDX, base_offset + 0x08); + } _ if layout_interner.stack_size(*layout) == 0 => {} _ if !Self::returns_via_arg_pointer(layout_interner, layout) => { let (base_offset, size) = storage_manager.stack_offset_and_size(sym); @@ -1343,6 +1353,14 @@ impl CallConv for X86_64Windo single_register_layouts!() => { internal_error!("single register layouts are not complex symbols"); } + // For windows (and zig 0.9 changes in zig 0.10) we need to match what zig does, + // in this case uses RAX & RDX to return the value + LayoutRepr::I128 | LayoutRepr::U128 => { + let size = layout_interner.stack_size(*layout); + let offset = storage_manager.claim_stack_area(sym, size); + X86_64Assembler::mov_base32_reg64(buf, offset + 0x00, X86_64GeneralReg::RAX); + X86_64Assembler::mov_base32_reg64(buf, offset + 0x08, X86_64GeneralReg::RDX); + } _ if layout_interner.stack_size(*layout) == 0 => { storage_manager.no_data(sym); } @@ -1518,7 +1536,10 @@ impl X86_64WindowsFastcall { ) -> bool { // TODO: This is not fully correct there are some exceptions for "vector" types. // details here: https://docs.microsoft.com/en-us/cpp/build/x64-calling-convention?view=msvc-160#return-values - interner.stack_size(*ret_layout) > 8 + match *ret_layout { + Layout::I128 | Layout::U128 => false, + _ => interner.stack_size(*ret_layout) > 8, + } } } From fe38d5656972c424353cd12627d45f90d5e7fef6 Mon Sep 17 00:00:00 2001 From: Folkert Date: Sat, 5 Aug 2023 17:19:59 +0200 Subject: [PATCH 055/176] cleanup --- crates/compiler/gen_dev/src/generic64/x86_64.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/compiler/gen_dev/src/generic64/x86_64.rs b/crates/compiler/gen_dev/src/generic64/x86_64.rs index 42434ee786..e9de5194a4 100644 --- a/crates/compiler/gen_dev/src/generic64/x86_64.rs +++ b/crates/compiler/gen_dev/src/generic64/x86_64.rs @@ -1303,7 +1303,7 @@ impl CallConv for X86_64Windo debug_assert_eq!(base_offset % 8, 0); debug_assert_eq!(size, 16); - X86_64Assembler::mov_reg64_base32(buf, X86_64GeneralReg::RAX, base_offset + 0x00); + X86_64Assembler::mov_reg64_base32(buf, X86_64GeneralReg::RAX, base_offset); X86_64Assembler::mov_reg64_base32(buf, X86_64GeneralReg::RDX, base_offset + 0x08); } _ if layout_interner.stack_size(*layout) == 0 => {} @@ -1358,7 +1358,7 @@ impl CallConv for X86_64Windo LayoutRepr::I128 | LayoutRepr::U128 => { let size = layout_interner.stack_size(*layout); let offset = storage_manager.claim_stack_area(sym, size); - X86_64Assembler::mov_base32_reg64(buf, offset + 0x00, X86_64GeneralReg::RAX); + X86_64Assembler::mov_base32_reg64(buf, offset, X86_64GeneralReg::RAX); X86_64Assembler::mov_base32_reg64(buf, offset + 0x08, X86_64GeneralReg::RDX); } _ if layout_interner.stack_size(*layout) == 0 => { From 9271d761a65054b412a5bd119aa03fe44ea14e2a Mon Sep 17 00:00:00 2001 From: Folkert Date: Sat, 5 Aug 2023 17:20:38 +0200 Subject: [PATCH 056/176] make llvm an optional dependency of test_gen --- Cargo.lock | 1 - crates/compiler/test_gen/Cargo.toml | 13 +++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0562d973a6..e8c6e11bef 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4784,7 +4784,6 @@ dependencies = [ "criterion", "indoc", "inkwell", - "lazy_static", "libc", "libloading", "roc_bitcode", diff --git a/crates/compiler/test_gen/Cargo.toml b/crates/compiler/test_gen/Cargo.toml index 3abd9974b1..cc323c814b 100644 --- a/crates/compiler/test_gen/Cargo.toml +++ b/crates/compiler/test_gen/Cargo.toml @@ -18,7 +18,13 @@ wasi_libc_sys = { path = "../../wasi-libc-sys" } tempfile.workspace = true +[dependencies] +roc_gen_llvm = { path = "../gen_llvm", optional = true } +inkwell = { workspace = true, optional = true } + [dev-dependencies] +roc_gen_dev = { path = "../gen_dev" } +roc_gen_wasm = { path = "../gen_wasm" } roc_bitcode = { path = "../builtins/bitcode" } roc_build = { path = "../build", features = ["target-aarch64", "target-x86_64", "target-wasm32"] } roc_builtins = { path = "../builtins" } @@ -28,9 +34,6 @@ roc_command_utils = { path = "../../utils/command" } roc_constrain = { path = "../constrain" } roc_debug_flags = { path = "../debug_flags" } roc_error_macros = { path = "../../error_macros" } -roc_gen_dev = { path = "../gen_dev" } -roc_gen_llvm = { path = "../gen_llvm" } -roc_gen_wasm = { path = "../gen_wasm" } roc_load = { path = "../load" } roc_module = { path = "../module" } roc_mono = { path = "../mono" } @@ -50,8 +53,6 @@ roc_wasm_module = { path = "../../wasm_module" } bumpalo.workspace = true criterion.workspace = true indoc.workspace = true -inkwell.workspace = true -lazy_static.workspace = true libc.workspace = true libloading.workspace = true target-lexicon.workspace = true @@ -61,7 +62,7 @@ tempfile.workspace = true [features] default = ["gen-llvm"] gen-dev = [] -gen-llvm = [] +gen-llvm = ["roc_gen_llvm", "inkwell"] gen-llvm-wasm = ["gen-llvm"] gen-wasm = [] From 8d4e83c3bb455cdbf526397b9c405016faeebdca Mon Sep 17 00:00:00 2001 From: Folkert Date: Sat, 5 Aug 2023 18:37:37 +0200 Subject: [PATCH 057/176] remove lazy_static dependency in test_gen --- crates/compiler/test_gen/src/helpers/llvm.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/crates/compiler/test_gen/src/helpers/llvm.rs b/crates/compiler/test_gen/src/helpers/llvm.rs index ba5e129c04..18eebb4c93 100644 --- a/crates/compiler/test_gen/src/helpers/llvm.rs +++ b/crates/compiler/test_gen/src/helpers/llvm.rs @@ -1,5 +1,6 @@ use std::mem::MaybeUninit; use std::path::PathBuf; +use std::sync::OnceLock; use inkwell::module::Module; use libloading::Library; @@ -414,10 +415,6 @@ fn write_final_wasm() -> bool { false } -lazy_static::lazy_static! { - static ref TEMP_DIR: tempfile::TempDir = tempfile::tempdir().unwrap(); -} - #[allow(dead_code)] fn compile_to_wasm_bytes<'a>( arena: &'a bumpalo::Bump, @@ -426,13 +423,17 @@ fn compile_to_wasm_bytes<'a>( context: &'a inkwell::context::Context, function_kind: FunctionKind, ) -> Vec { + // globally cache the temporary directory + static TEMP_DIR: OnceLock = OnceLock::new(); + let temp_dir = TEMP_DIR.get_or_init(|| tempfile::tempdir().unwrap()); + let target = wasm32_target_tripple(); let (_main_fn_name, _delayed_errors, llvm_module) = create_llvm_module(arena, src, config, context, &target, function_kind); let content_hash = crate::helpers::src_hash(src); - let wasm_file = llvm_module_to_wasm_file(&TEMP_DIR, content_hash, llvm_module); + let wasm_file = llvm_module_to_wasm_file(temp_dir, content_hash, llvm_module); let compiled_bytes = std::fs::read(wasm_file).unwrap(); if write_final_wasm() { From dcc71bc102bfa1d8d6402165b5a7fdeb895f5da6 Mon Sep 17 00:00:00 2001 From: Folkert Date: Mon, 7 Aug 2023 20:20:10 +0200 Subject: [PATCH 058/176] remove unused logic --- crates/compiler/load_internal/src/file.rs | 51 +---------------------- 1 file changed, 1 insertion(+), 50 deletions(-) diff --git a/crates/compiler/load_internal/src/file.rs b/crates/compiler/load_internal/src/file.rs index bf79445f92..076221a424 100644 --- a/crates/compiler/load_internal/src/file.rs +++ b/crates/compiler/load_internal/src/file.rs @@ -3101,53 +3101,6 @@ fn finish_specialization<'a>( .collect(); let module_id = state.root_id; - let mut glue_getters = Vec::new(); - - // the REPL does not have any platform data - if let ( - EntryPoint::Executable { - exposed_to_host: exposed_top_levels, - .. - }, - Some(platform_data), - ) = (&entry_point, platform_data.as_ref()) - { - // Expose glue for the platform, not for the app module! - let module_id = platform_data.module_id; - - for (_name, proc_layout) in exposed_top_levels.iter() { - let ret = &proc_layout.result; - for in_layout in proc_layout.arguments.iter().chain([ret]) { - let layout = layout_interner.get(*in_layout); - let ident_ids = interns.all_ident_ids.get_mut(&module_id).unwrap(); - let all_glue_procs = roc_mono::ir::generate_glue_procs( - module_id, - ident_ids, - arena, - &mut layout_interner, - arena.alloc(layout), - ); - - let lambda_set_names = all_glue_procs - .legacy_layout_based_extern_names - .iter() - .map(|(lambda_set_id, _)| (*_name, *lambda_set_id)); - exposed_to_host.lambda_sets.extend(lambda_set_names); - - let getter_names = all_glue_procs - .getters - .iter() - .flat_map(|(_, glue_procs)| glue_procs.iter().map(|glue_proc| glue_proc.name)); - exposed_to_host.getters.extend(getter_names); - - glue_getters.extend(all_glue_procs.getters.iter().flat_map(|(_, glue_procs)| { - glue_procs - .iter() - .map(|glue_proc| (glue_proc.name, glue_proc.proc_layout)) - })); - } - } - } let output_path = match output_path { Some(path_str) => Path::new(path_str).into(), @@ -3176,9 +3129,7 @@ fn finish_specialization<'a>( sources, timings: state.timings, toplevel_expects, - glue_layouts: GlueLayouts { - getters: glue_getters, - }, + glue_layouts: GlueLayouts { getters: vec![] }, uses_prebuilt_platform, }) } From f23120078a7866a47d580430da37768a57ab4e5e Mon Sep 17 00:00:00 2001 From: Folkert Date: Mon, 7 Aug 2023 21:58:57 +0200 Subject: [PATCH 059/176] cleanup --- crates/compiler/load_internal/src/file.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/crates/compiler/load_internal/src/file.rs b/crates/compiler/load_internal/src/file.rs index 076221a424..f49098070b 100644 --- a/crates/compiler/load_internal/src/file.rs +++ b/crates/compiler/load_internal/src/file.rs @@ -41,7 +41,6 @@ use roc_mono::ir::{ CapturedSymbols, ExternalSpecializations, GlueLayouts, PartialProc, Proc, ProcLayout, Procs, ProcsBase, UpdateModeIds, UsageTrackingMap, }; -use roc_mono::layout::LayoutInterner; use roc_mono::layout::{ GlobalLayoutInterner, LambdaName, Layout, LayoutCache, LayoutProblem, Niche, STLayoutInterner, }; @@ -2982,8 +2981,8 @@ fn finish_specialization<'a>( arena: &'a Bump, state: State<'a>, subs: Subs, - mut layout_interner: STLayoutInterner<'a>, - mut exposed_to_host: ExposedToHost, + layout_interner: STLayoutInterner<'a>, + exposed_to_host: ExposedToHost, module_expectations: VecMap, ) -> Result, LoadingProblem<'a>> { if false { From 3d86ccf1670a1b999c68d497cf095daaf71c2b54 Mon Sep 17 00:00:00 2001 From: Folkert Date: Tue, 8 Aug 2023 16:37:47 +0200 Subject: [PATCH 060/176] remove `as Fx` from platform types --- .../benchmarks/platform/main.roc | 2 +- crates/compiler/mono/src/ir.rs | 28 ++++++++----------- examples/cli/cli-platform/main.roc | 2 +- examples/cli/effects-platform/main.roc | 2 +- .../cli/false-interpreter/platform/main.roc | 2 +- 5 files changed, 15 insertions(+), 21 deletions(-) diff --git a/crates/cli_testing_examples/benchmarks/platform/main.roc b/crates/cli_testing_examples/benchmarks/platform/main.roc index 0b86055696..e4802e2503 100644 --- a/crates/cli_testing_examples/benchmarks/platform/main.roc +++ b/crates/cli_testing_examples/benchmarks/platform/main.roc @@ -5,5 +5,5 @@ platform "benchmarks" imports [Task.{ Task }] provides [mainForHost] -mainForHost : Task {} [] as Fx +mainForHost : Task {} [] mainForHost = main diff --git a/crates/compiler/mono/src/ir.rs b/crates/compiler/mono/src/ir.rs index 284dd2d588..58884bbad6 100644 --- a/crates/compiler/mono/src/ir.rs +++ b/crates/compiler/mono/src/ir.rs @@ -3099,10 +3099,18 @@ fn specialize_host_specializations<'a>( let mut aliases = BumpMap::default(); - for (id, _, raw_function_layout) in hels { + for (var, id) in hels { let symbol = env.unique_symbol(); let lambda_name = LambdaName::no_niche(symbol); + let mut layout_env = + layout::Env::from_components(layout_cache, env.subs, env.arena, env.target_info); + let lambda_set = env.subs.get_lambda_set(var); + let raw_function_layout = + RawFunctionLayout::from_var(&mut layout_env, lambda_set.ambient_function) + .value() + .unwrap(); + let (key, (top_level, proc)) = generate_host_exposed_function( env, procs, @@ -10004,7 +10012,7 @@ impl LambdaSetId { fn find_lambda_sets<'a>( env: &mut crate::layout::Env<'a, '_>, initial: Variable, -) -> Vec<'a, (LambdaSetId, Variable, RawFunctionLayout<'a>)> { +) -> MutMap { let mut stack = bumpalo::collections::Vec::new_in(env.arena); // ignore the lambda set of top-level functions @@ -10020,21 +10028,7 @@ fn find_lambda_sets<'a>( } } - let lambda_set_variables = find_lambda_sets_help(env.subs, stack); - let mut answer = - bumpalo::collections::Vec::with_capacity_in(lambda_set_variables.len(), env.arena); - - for (variable, lambda_set_id) in lambda_set_variables { - let lambda_set = env.subs.get_lambda_set(variable); - let raw_function_layout = RawFunctionLayout::from_var(env, lambda_set.ambient_function) - .value() - .unwrap(); - - let key = (lambda_set_id, variable, raw_function_layout); - answer.push(key); - } - - answer + find_lambda_sets_help(env.subs, stack) } pub fn find_lambda_sets_help( diff --git a/examples/cli/cli-platform/main.roc b/examples/cli/cli-platform/main.roc index 8e185a6db1..c8f90a9191 100644 --- a/examples/cli/cli-platform/main.roc +++ b/examples/cli/cli-platform/main.roc @@ -5,5 +5,5 @@ platform "cli" imports [Task.{ Task }] provides [mainForHost] -mainForHost : Task {} [] as Fx +mainForHost : Task {} [] mainForHost = main diff --git a/examples/cli/effects-platform/main.roc b/examples/cli/effects-platform/main.roc index 5e718ffc47..e2092147f7 100644 --- a/examples/cli/effects-platform/main.roc +++ b/examples/cli/effects-platform/main.roc @@ -5,5 +5,5 @@ platform "effects" imports [pf.Effect] provides [mainForHost] -mainForHost : Effect.Effect {} as Fx +mainForHost : Effect.Effect {} mainForHost = main diff --git a/examples/cli/false-interpreter/platform/main.roc b/examples/cli/false-interpreter/platform/main.roc index 2d737816a5..cf97352ce4 100644 --- a/examples/cli/false-interpreter/platform/main.roc +++ b/examples/cli/false-interpreter/platform/main.roc @@ -5,5 +5,5 @@ platform "false-interpreter" imports [Task.{ Task }] provides [mainForHost] -mainForHost : Str -> Task {} [] as Fx +mainForHost : Str -> Task {} [] mainForHost = \file -> main file From 4c17caa90dfe7a9a13b057e6df6fb4adc03e3d6f Mon Sep 17 00:00:00 2001 From: Folkert Date: Tue, 8 Aug 2023 18:39:54 +0200 Subject: [PATCH 061/176] update mono tests --- .../generated/capture_void_layout_task.txt | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/crates/compiler/test_mono/generated/capture_void_layout_task.txt b/crates/compiler/test_mono/generated/capture_void_layout_task.txt index a1ccd5b8d3..bad0f8684c 100644 --- a/crates/compiler/test_mono/generated/capture_void_layout_task.txt +++ b/crates/compiler/test_mono/generated/capture_void_layout_task.txt @@ -14,7 +14,7 @@ procedure List.66 (#Attr.2, #Attr.3): let List.537 : [] = lowlevel ListGetUnsafe #Attr.2 #Attr.3; ret List.537; -procedure List.80 (#Derived_gen.11, #Derived_gen.12, #Derived_gen.13, #Derived_gen.14, #Derived_gen.15): +procedure List.80 (#Derived_gen.13, #Derived_gen.14, #Derived_gen.15, #Derived_gen.16, #Derived_gen.17): joinpoint List.527 List.439 List.440 List.441 List.442 List.443: let List.529 : Int1 = CallByName Num.22 List.442 List.443; if List.529 then @@ -27,7 +27,7 @@ procedure List.80 (#Derived_gen.11, #Derived_gen.12, #Derived_gen.13, #Derived_g dec List.439; ret List.440; in - jump List.527 #Derived_gen.11 #Derived_gen.12 #Derived_gen.13 #Derived_gen.14 #Derived_gen.15; + jump List.527 #Derived_gen.13 #Derived_gen.14 #Derived_gen.15 #Derived_gen.16 #Derived_gen.17; procedure List.93 (List.436, List.437, List.438): let List.525 : U64 = 0i64; @@ -156,8 +156,16 @@ procedure Test.80 (Test.81): ret Test.83; procedure Test.84 (Test.86, #Attr.12): - let Test.87 : Str = "a Lambda Set is empty. Most likely there is a type error in your program."; - Crash Test.87 + let Test.87 : U8 = GetTagId #Attr.12; + switch Test.87: + case 0: + let Test.85 : {} = CallByName Test.10 Test.86 #Attr.12; + ret Test.85; + + default: + let Test.85 : {} = CallByName Test.14 Test.86 #Attr.12; + ret Test.85; + procedure Test.0 (): let Test.35 : List [] = Array []; From 387b6927d518de5d3419e26a83ed25dbe0010e96 Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Tue, 8 Aug 2023 19:55:38 +0200 Subject: [PATCH 062/176] libgcc_s.so.1 fix #5732 --- crates/compiler/build/src/link.rs | 106 +++++++++--------- crates/compiler/test_gen/benches/list_map.rs | 2 +- crates/compiler/test_gen/benches/quicksort.rs | 2 +- flake.nix | 6 + 4 files changed, 63 insertions(+), 53 deletions(-) diff --git a/crates/compiler/build/src/link.rs b/crates/compiler/build/src/link.rs index 7d8e800f30..9231aee0ae 100644 --- a/crates/compiler/build/src/link.rs +++ b/crates/compiler/build/src/link.rs @@ -4,6 +4,7 @@ use roc_command_utils::{cargo, clang, rustup, zig}; use roc_error_macros::internal_error; use roc_mono::ir::OptLevel; use std::collections::HashMap; +use std::ffi::OsString; use std::fs::DirEntry; use std::io; use std::path::{Path, PathBuf}; @@ -785,11 +786,25 @@ fn get_target_str(target: &Triple) -> &str { } } -fn nix_path_opt() -> Option { - env::var_os("NIX_GLIBC_PATH").map(|path| path.into_string().unwrap()) +fn nix_paths() -> Vec { + let mut paths = vec![]; + + if let Some(nix_libgcc_s_path) = env::var_os("NIX_LIBGCC_S_PATH") { + paths.push(nix_libgcc_s_path.into_string().unwrap()) + } + + if let Some(nix_glibc_path) = nix_glibc_path_opt() { + paths.push(nix_glibc_path.into_string().unwrap()) + } + + paths } -fn library_path(segments: [&str; N]) -> Option { +fn nix_glibc_path_opt() -> Option { + env::var_os("NIX_GLIBC_PATH") +} + +fn build_path(segments: [&str; N]) -> Option { let mut guess_path = PathBuf::new(); for s in segments { guess_path.push(s); @@ -812,22 +827,21 @@ fn library_path(segments: [&str; N]) -> Option { /// match will be returned. /// /// If there are no matches, [`None`] will be returned. -fn look_for_library(lib_dirs: &[&[&str]], lib_filename: &str) -> Option { +fn look_for_library(lib_dirs: &[PathBuf], lib_filename: &str) -> Option { lib_dirs .iter() - .map(|lib_dir| { - lib_dir.iter().fold(PathBuf::new(), |mut path, segment| { - path.push(segment); - path - }) - }) - .map(|mut path| { - path.push(lib_filename); - path + .map(|path| { + let mut path_cl = path.clone(); + path_cl.push(lib_filename); + path_cl }) .find(|path| path.exists()) } +fn strs_to_path(strs: &[&str]) -> PathBuf { + strs.iter().collect() +} + fn link_linux( target: &Triple, output_path: PathBuf, @@ -863,49 +877,39 @@ fn link_linux( } // Some things we'll need to build a list of dirs to check for libraries - let maybe_nix_path = nix_path_opt(); - let usr_lib_arch = ["/usr", "lib", &architecture]; - let lib_arch = ["/lib", &architecture]; - let nix_path_segments; - let lib_dirs_if_nix: [&[&str]; 5]; - let lib_dirs_if_nonix: [&[&str]; 4]; + //env::var_os("NIX_GLIBC_PATH").map(|path| path.into_string().unwrap()), + //env::var_os("NIX_LIBGCC_S_PATH").map(|path| path.into_string().unwrap()) + let nix_paths_vec_string = nix_paths(); + let nix_paths_vec: Vec = nix_paths_vec_string.iter().map(|path_string| PathBuf::from(path_string)).collect(); + let usr_lib_arch_path = strs_to_path(&["/usr", "lib", &architecture]); + let lib_arch_path = strs_to_path(&["/lib", &architecture]); - // Build the aformentioned list - let lib_dirs: &[&[&str]] = - // give preference to nix_path if it's defined, this prevents bugs - if let Some(nix_path) = &maybe_nix_path { - nix_path_segments = [nix_path.as_str()]; - lib_dirs_if_nix = [ - &nix_path_segments, - &usr_lib_arch, - &lib_arch, - &["/usr", "lib"], - &["/usr", "lib64"], - ]; - &lib_dirs_if_nix - } else { - lib_dirs_if_nonix = [ - &usr_lib_arch, - &lib_arch, - &["/usr", "lib"], - &["/usr", "lib64"], - ]; - &lib_dirs_if_nonix - }; + let mut lib_dirs: Vec = vec![]; + + // start with nix paths, this prevents bugs + if !nix_paths_vec.is_empty() { + lib_dirs.extend(nix_paths_vec) + } + + lib_dirs.extend( [ + usr_lib_arch_path, + lib_arch_path, + strs_to_path(&["/usr", "lib"]), + strs_to_path(&["/usr", "lib64"]), + ]); // Look for the libraries we'll need - let libgcc_name = "libgcc_s.so.1"; - let libgcc_path = look_for_library(lib_dirs, libgcc_name); + let libgcc_path = look_for_library(&lib_dirs, libgcc_name); let crti_name = "crti.o"; - let crti_path = look_for_library(lib_dirs, crti_name); + let crti_path = look_for_library(&lib_dirs, crti_name); let crtn_name = "crtn.o"; - let crtn_path = look_for_library(lib_dirs, crtn_name); + let crtn_path = look_for_library(&lib_dirs, crtn_name); let scrt1_name = "Scrt1.o"; - let scrt1_path = look_for_library(lib_dirs, scrt1_name); + let scrt1_path = look_for_library(&lib_dirs, scrt1_name); // Unwrap all the paths at once so we can inform the user of all missing libs at once let (libgcc_path, crti_path, crtn_path, scrt1_path) = @@ -925,7 +929,7 @@ fn link_linux( let dirs = lib_dirs .iter() - .map(|segments| segments.join("/")) + .map(|path_buf| path_buf.as_path().to_str().unwrap_or("FAILED TO CONVERT PATH TO STR").to_string()) .collect::>() .join("\n"); eprintln!("We looked in the following directories:\n{dirs}"); @@ -936,13 +940,13 @@ fn link_linux( let ld_linux = match target.architecture { Architecture::X86_64 => { // give preference to nix_path if it's defined, this prevents bugs - if let Some(nix_path) = nix_path_opt() { - library_path([&nix_path, "ld-linux-x86-64.so.2"]) + if let Some(nix_glibc_path) = nix_glibc_path_opt() { + build_path([&nix_glibc_path.into_string().unwrap(), "ld-linux-x86-64.so.2"]) } else { - library_path(["/lib64", "ld-linux-x86-64.so.2"]) + build_path(["/lib64", "ld-linux-x86-64.so.2"]) } } - Architecture::Aarch64(_) => library_path(["/lib", "ld-linux-aarch64.so.1"]), + Architecture::Aarch64(_) => build_path(["/lib", "ld-linux-aarch64.so.1"]), _ => internal_error!( "TODO gracefully handle unsupported linux architecture: {:?}", target.architecture diff --git a/crates/compiler/test_gen/benches/list_map.rs b/crates/compiler/test_gen/benches/list_map.rs index 877957322b..ff8951cb05 100644 --- a/crates/compiler/test_gen/benches/list_map.rs +++ b/crates/compiler/test_gen/benches/list_map.rs @@ -63,7 +63,7 @@ fn roc_function<'a, 'b>( let context = inkwell::context::Context::create(); let (main_fn_name, errors, lib) = - helpers::llvm::helper(arena, config, source, arena.alloc(context)); + helpers::llvm::helper(arena, config, source, arena.alloc(context), roc_load::FunctionKind::LambdaSet); assert!(errors.is_empty(), "Encountered errors:\n{errors}"); diff --git a/crates/compiler/test_gen/benches/quicksort.rs b/crates/compiler/test_gen/benches/quicksort.rs index 2c02646b49..ba8b2cf21b 100644 --- a/crates/compiler/test_gen/benches/quicksort.rs +++ b/crates/compiler/test_gen/benches/quicksort.rs @@ -92,7 +92,7 @@ fn roc_function<'a>( let context = inkwell::context::Context::create(); let (main_fn_name, errors, lib) = - helpers::llvm::helper(arena, config, source, arena.alloc(context)); + helpers::llvm::helper(arena, config, source, arena.alloc(context), roc_load::FunctionKind::LambdaSet); assert!(errors.is_empty(), "Encountered errors:\n{errors}"); diff --git a/flake.nix b/flake.nix index a8be3b40e1..40d9d6b77e 100644 --- a/flake.nix +++ b/flake.nix @@ -125,9 +125,15 @@ [ ]); LLVM_SYS_130_PREFIX = "${llvmPkgs.llvm.dev}"; + # nix does not store libs in /usr/lib or /lib + # for libgcc_s.so.1 + NIX_LIBGCC_S_PATH = + if pkgs.stdenv.isLinux then "${pkgs.stdenv.cc.cc.lib}/lib" else ""; + # for crti.o, crtn.o, and Scrt1.o NIX_GLIBC_PATH = if pkgs.stdenv.isLinux then "${pkgs.glibc.out}/lib" else ""; + LD_LIBRARY_PATH = with pkgs; lib.makeLibraryPath ([ pkg-config stdenv.cc.cc.lib libffi ncurses zlib ] From bec0e52f1eb961eae868132b70ff84a10f72bd10 Mon Sep 17 00:00:00 2001 From: Folkert Date: Tue, 8 Aug 2023 19:55:10 +0200 Subject: [PATCH 063/176] make glue and mono look at the same type --- crates/compiler/mono/src/ir.rs | 19 +++++++++---------- crates/glue/src/types.rs | 15 +++++++++------ 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/crates/compiler/mono/src/ir.rs b/crates/compiler/mono/src/ir.rs index 58884bbad6..db98654e6b 100644 --- a/crates/compiler/mono/src/ir.rs +++ b/crates/compiler/mono/src/ir.rs @@ -3069,9 +3069,7 @@ fn specialize_host_specializations<'a>( let Some(from_platform) = opt_from_platform else { continue }; // now run the lambda set numbering scheme - let mut layout_env = - layout::Env::from_components(layout_cache, env.subs, env.arena, env.target_info); - let hels = find_lambda_sets(&mut layout_env, from_platform); + let hels = find_lambda_sets(env.arena, env.subs, from_platform); // now unify let mut unify_env = roc_unify::Env::new( @@ -10009,16 +10007,17 @@ impl LambdaSetId { } } -fn find_lambda_sets<'a>( - env: &mut crate::layout::Env<'a, '_>, +pub fn find_lambda_sets( + arena: &Bump, + subs: &Subs, initial: Variable, ) -> MutMap { - let mut stack = bumpalo::collections::Vec::new_in(env.arena); + let mut stack = bumpalo::collections::Vec::new_in(arena); // ignore the lambda set of top-level functions - match env.subs.get_without_compacting(initial).content { + match subs.get_without_compacting(initial).content { Content::Structure(FlatType::Func(arguments, _, result)) => { - let arguments = &env.subs.variables[arguments.indices()]; + let arguments = &subs.variables[arguments.indices()]; stack.extend(arguments.iter().copied()); stack.push(result); @@ -10028,10 +10027,10 @@ fn find_lambda_sets<'a>( } } - find_lambda_sets_help(env.subs, stack) + find_lambda_sets_help(subs, stack) } -pub fn find_lambda_sets_help( +fn find_lambda_sets_help( subs: &Subs, mut stack: Vec<'_, Variable>, ) -> MutMap { diff --git a/crates/glue/src/types.rs b/crates/glue/src/types.rs index d1580b123d..2a030f4203 100644 --- a/crates/glue/src/types.rs +++ b/crates/glue/src/types.rs @@ -111,8 +111,7 @@ impl Types { target, ); - let variables: Vec<_> = entry_points.values().copied().collect(); - for var in variables { + for (_symbol, var) in entry_points.clone() { env.lambda_set_ids = env.find_lambda_sets(var); let id = env.add_toplevel_type(var, &mut types); @@ -1223,8 +1222,7 @@ impl<'a> Env<'a> { } fn find_lambda_sets(&self, root: Variable) -> MutMap { - let stack = bumpalo::vec![in self.arena; root]; - roc_mono::ir::find_lambda_sets_help(self.subs, stack) + roc_mono::ir::find_lambda_sets(self.arena, self.subs, root) } fn add_toplevel_type(&mut self, var: Variable, types: &mut Types) -> TypeId { @@ -1268,8 +1266,13 @@ fn add_function_type<'a>( let name = format!("RocFunction_{closure_var:?}"); - let id = env.lambda_set_ids.get(&closure_var).unwrap(); - let extern_name = format!("roc__mainForHost_{}_caller", id.0); + let extern_name = match env.lambda_set_ids.get(&closure_var) { + Some(id) => format!("roc__mainForHost_{}_caller", id.0), + None => { + debug_assert!(is_toplevel); + String::from("this_extern_should_not_be_used_this_is_a_bug") + } + }; for arg_var in args { let arg_layout = env From ec3bcb33f60721375483a319b1f8ed79425d14f9 Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Tue, 8 Aug 2023 20:03:21 +0200 Subject: [PATCH 064/176] fmt, clippy, nix aliases fix --- crates/compiler/build/src/link.rs | 17 +++++++++++++---- crates/compiler/test_gen/benches/list_map.rs | 9 +++++++-- crates/compiler/test_gen/benches/quicksort.rs | 9 +++++++-- flake.nix | 2 +- 4 files changed, 28 insertions(+), 9 deletions(-) diff --git a/crates/compiler/build/src/link.rs b/crates/compiler/build/src/link.rs index 9231aee0ae..a9240a916a 100644 --- a/crates/compiler/build/src/link.rs +++ b/crates/compiler/build/src/link.rs @@ -880,7 +880,7 @@ fn link_linux( //env::var_os("NIX_GLIBC_PATH").map(|path| path.into_string().unwrap()), //env::var_os("NIX_LIBGCC_S_PATH").map(|path| path.into_string().unwrap()) let nix_paths_vec_string = nix_paths(); - let nix_paths_vec: Vec = nix_paths_vec_string.iter().map(|path_string| PathBuf::from(path_string)).collect(); + let nix_paths_vec: Vec = nix_paths_vec_string.iter().map(PathBuf::from).collect(); let usr_lib_arch_path = strs_to_path(&["/usr", "lib", &architecture]); let lib_arch_path = strs_to_path(&["/lib", &architecture]); @@ -891,7 +891,7 @@ fn link_linux( lib_dirs.extend(nix_paths_vec) } - lib_dirs.extend( [ + lib_dirs.extend([ usr_lib_arch_path, lib_arch_path, strs_to_path(&["/usr", "lib"]), @@ -929,7 +929,13 @@ fn link_linux( let dirs = lib_dirs .iter() - .map(|path_buf| path_buf.as_path().to_str().unwrap_or("FAILED TO CONVERT PATH TO STR").to_string()) + .map(|path_buf| { + path_buf + .as_path() + .to_str() + .unwrap_or("FAILED TO CONVERT PATH TO STR") + .to_string() + }) .collect::>() .join("\n"); eprintln!("We looked in the following directories:\n{dirs}"); @@ -941,7 +947,10 @@ fn link_linux( Architecture::X86_64 => { // give preference to nix_path if it's defined, this prevents bugs if let Some(nix_glibc_path) = nix_glibc_path_opt() { - build_path([&nix_glibc_path.into_string().unwrap(), "ld-linux-x86-64.so.2"]) + build_path([ + &nix_glibc_path.into_string().unwrap(), + "ld-linux-x86-64.so.2", + ]) } else { build_path(["/lib64", "ld-linux-x86-64.so.2"]) } diff --git a/crates/compiler/test_gen/benches/list_map.rs b/crates/compiler/test_gen/benches/list_map.rs index ff8951cb05..2aa8243bfd 100644 --- a/crates/compiler/test_gen/benches/list_map.rs +++ b/crates/compiler/test_gen/benches/list_map.rs @@ -62,8 +62,13 @@ fn roc_function<'a, 'b>( }; let context = inkwell::context::Context::create(); - let (main_fn_name, errors, lib) = - helpers::llvm::helper(arena, config, source, arena.alloc(context), roc_load::FunctionKind::LambdaSet); + let (main_fn_name, errors, lib) = helpers::llvm::helper( + arena, + config, + source, + arena.alloc(context), + roc_load::FunctionKind::LambdaSet, + ); assert!(errors.is_empty(), "Encountered errors:\n{errors}"); diff --git a/crates/compiler/test_gen/benches/quicksort.rs b/crates/compiler/test_gen/benches/quicksort.rs index ba8b2cf21b..2b786ac8dd 100644 --- a/crates/compiler/test_gen/benches/quicksort.rs +++ b/crates/compiler/test_gen/benches/quicksort.rs @@ -91,8 +91,13 @@ fn roc_function<'a>( }; let context = inkwell::context::Context::create(); - let (main_fn_name, errors, lib) = - helpers::llvm::helper(arena, config, source, arena.alloc(context), roc_load::FunctionKind::LambdaSet); + let (main_fn_name, errors, lib) = helpers::llvm::helper( + arena, + config, + source, + arena.alloc(context), + roc_load::FunctionKind::LambdaSet, + ); assert!(errors.is_empty(), "Encountered errors:\n{errors}"); diff --git a/flake.nix b/flake.nix index 40d9d6b77e..4493103d8f 100644 --- a/flake.nix +++ b/flake.nix @@ -142,7 +142,7 @@ 1; # to run the editor with NVIDIA's closed source drivers shellHook = '' - source <(echo "${aliases}") + ${aliases} ''; }; From cb9a348871956de6ed9c11aae22fae5ad8c47369 Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Tue, 8 Aug 2023 20:09:15 +0200 Subject: [PATCH 065/176] cleanup --- crates/compiler/build/src/link.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/crates/compiler/build/src/link.rs b/crates/compiler/build/src/link.rs index a9240a916a..03c55f767f 100644 --- a/crates/compiler/build/src/link.rs +++ b/crates/compiler/build/src/link.rs @@ -876,9 +876,6 @@ fn link_linux( )); } - // Some things we'll need to build a list of dirs to check for libraries - //env::var_os("NIX_GLIBC_PATH").map(|path| path.into_string().unwrap()), - //env::var_os("NIX_LIBGCC_S_PATH").map(|path| path.into_string().unwrap()) let nix_paths_vec_string = nix_paths(); let nix_paths_vec: Vec = nix_paths_vec_string.iter().map(PathBuf::from).collect(); let usr_lib_arch_path = strs_to_path(&["/usr", "lib", &architecture]); @@ -886,7 +883,7 @@ fn link_linux( let mut lib_dirs: Vec = vec![]; - // start with nix paths, this prevents bugs + // start with nix paths, this prevents version incompatibility if !nix_paths_vec.is_empty() { lib_dirs.extend(nix_paths_vec) } From 5d3c7a93635760cfd459878a135debc843a986e7 Mon Sep 17 00:00:00 2001 From: Folkert Date: Wed, 9 Aug 2023 14:06:07 +0200 Subject: [PATCH 066/176] remove HostExposedAlias --- crates/compiler/can/src/annotation.rs | 34 ++--- crates/compiler/solve/src/to_var.rs | 89 +----------- crates/compiler/types/src/types.rs | 200 +------------------------- 3 files changed, 13 insertions(+), 310 deletions(-) diff --git a/crates/compiler/can/src/annotation.rs b/crates/compiler/can/src/annotation.rs index 6866cfa3ff..7fe637466f 100644 --- a/crates/compiler/can/src/annotation.rs +++ b/crates/compiler/can/src/annotation.rs @@ -847,29 +847,17 @@ fn can_annotation_help( let alias = scope.lookup_alias(symbol).unwrap(); local_aliases.insert(symbol, alias.clone()); - if vars.is_empty() && env.home == symbol.module_id() { - let actual_var = var_store.fresh(); - introduced_variables.insert_host_exposed_alias(symbol, actual_var); - Type::HostExposedAlias { - name: symbol, - type_arguments: vars, - lambda_set_variables: alias.lambda_set_variables.clone(), - actual: Box::new(alias.typ.clone()), - actual_var, - } - } else { - Type::Alias { - symbol, - type_arguments: vars.into_iter().map(OptAbleType::unbound).collect(), - lambda_set_variables: alias.lambda_set_variables.clone(), - infer_ext_in_output_types: alias - .infer_ext_in_output_variables - .iter() - .map(|v| Type::Variable(*v)) - .collect(), - actual: Box::new(alias.typ.clone()), - kind: alias.kind, - } + Type::Alias { + symbol, + type_arguments: vars.into_iter().map(OptAbleType::unbound).collect(), + lambda_set_variables: alias.lambda_set_variables.clone(), + infer_ext_in_output_types: alias + .infer_ext_in_output_variables + .iter() + .map(|v| Type::Variable(*v)) + .collect(), + actual: Box::new(alias.typ.clone()), + kind: alias.kind, } } diff --git a/crates/compiler/solve/src/to_var.rs b/crates/compiler/solve/src/to_var.rs index 102aa63dac..86e4dc9cfa 100644 --- a/crates/compiler/solve/src/to_var.rs +++ b/crates/compiler/solve/src/to_var.rs @@ -142,8 +142,7 @@ impl RegisterVariable { TypeTag::EmptyTagUnion => Direct(Variable::EMPTY_TAG_UNION), TypeTag::DelayedAlias { shared } | TypeTag::StructuralAlias { shared, .. } - | TypeTag::OpaqueAlias { shared, .. } - | TypeTag::HostExposedAlias { shared, .. } => { + | TypeTag::OpaqueAlias { shared, .. } => { let AliasShared { symbol, .. } = types[shared]; if let Some(reserved) = Variable::get_reserved(symbol) { let direct_var = if rank.is_generalized() { @@ -752,92 +751,6 @@ pub(crate) fn type_to_var_help( env.register_with_known_var(destination, rank, content) } - HostExposedAlias { - shared, - actual_type: alias_type, - actual_variable: actual_var, - } => { - let AliasShared { - symbol, - type_argument_abilities: _, - type_argument_regions: _, - lambda_set_variables, - infer_ext_in_output_variables: _, // TODO - } = types[shared]; - - let type_arguments = types.get_type_arguments(typ_index); - - let alias_variables = { - let length = type_arguments.len() + lambda_set_variables.len(); - let new_variables = VariableSubsSlice::reserve_into_subs(env.subs, length); - - for (target_index, arg_type) in - (new_variables.indices()).zip(type_arguments.into_iter()) - { - let copy_var = helper!(arg_type); - env.subs.variables[target_index] = copy_var; - } - let it = (new_variables.indices().skip(type_arguments.len())) - .zip(lambda_set_variables.into_iter()); - for (target_index, ls) in it { - // We MUST do this now, otherwise when linking the ambient function during - // instantiation of the real var, there will be nothing to link against. - let copy_var = type_to_var_help( - env, - rank, - problems, - abilities_store, - obligation_cache, - arena, - aliases, - types, - ls, - true, - ); - env.subs.variables[target_index] = copy_var; - } - - AliasVariables { - variables_start: new_variables.start, - type_variables_len: type_arguments.len() as _, - lambda_set_variables_len: lambda_set_variables.len() as _, - all_variables_len: length as _, - } - }; - - // cannot use helper! here because this variable may be involved in unification below - let alias_variable = type_to_var_help( - env, - rank, - problems, - abilities_store, - obligation_cache, - arena, - aliases, - types, - alias_type, - false, - ); - // TODO(opaques): I think host-exposed aliases should always be structural - // (when does it make sense to give a host an opaque type?) - let content = Content::Alias( - symbol, - alias_variables, - alias_variable, - AliasKind::Structural, - ); - let result = env.register_with_known_var(destination, rank, content); - - // We only want to unify the actual_var with the alias once - // if it's already redirected (and therefore, redundant) - // don't do it again - if !env.subs.redundant(actual_var) { - let descriptor = env.subs.get(result); - env.subs.union(result, actual_var, descriptor); - } - - result - } Error => { let content = Content::Error; diff --git a/crates/compiler/types/src/types.rs b/crates/compiler/types/src/types.rs index f01837bbd6..7ce596e000 100644 --- a/crates/compiler/types/src/types.rs +++ b/crates/compiler/types/src/types.rs @@ -398,11 +398,6 @@ pub enum TypeTag { shared: Index, actual: Index, }, - HostExposedAlias { - shared: Index, - actual_type: Index, - actual_variable: Variable, - }, Apply { symbol: Symbol, @@ -998,41 +993,6 @@ impl Types { self.set_type_tag(index, tag, type_arguments_slice) } - Type::HostExposedAlias { - name, - type_arguments, - lambda_set_variables, - actual_var, - actual, - } => { - let type_arguments_slice = self.from_old_type_slice(type_arguments.iter()); - - let lambda_set_slice = { - let slice = self.reserve_type_tags(lambda_set_variables.len()); - - for (index, argument) in slice.into_iter().zip(lambda_set_variables) { - self.from_old_type_at(index, &argument.0); - } - - Slice::new(slice.start() as _, slice.len() as _) - }; - - let alias_shared = AliasShared { - symbol: *name, - type_argument_abilities: Slice::default(), - type_argument_regions: Slice::default(), - lambda_set_variables: lambda_set_slice, - infer_ext_in_output_variables: Slice::default(), - }; - - let tag = TypeTag::HostExposedAlias { - shared: Index::push_new(&mut self.aliases, alias_shared), - actual_type: self.from_old_type(actual), - actual_variable: *actual_var, - }; - - self.set_type_tag(index, tag, type_arguments_slice) - } Type::Variable(var) => { self.set_type_tag(index, TypeTag::Variable(*var), Slice::default()) } @@ -1217,27 +1177,6 @@ impl Types { new_type_arguments, ) } - HostExposedAlias { - shared, - actual_type, - actual_variable, - } => { - let type_arguments = self.get_type_arguments(typ); - - let new_type_arguments = defer_slice!(type_arguments); - let new_shared = do_shared!(shared); - let new_actual_type = defer!(actual_type); - let new_actual_variable = subst!(actual_variable); - - ( - HostExposedAlias { - shared: new_shared, - actual_type: new_actual_type, - actual_variable: new_actual_variable, - }, - new_type_arguments, - ) - } Apply { symbol, type_argument_regions, @@ -1432,12 +1371,7 @@ mod debug_types { maybe_paren!(Free, p, alias(types, f, tag, shared)) } TypeTag::StructuralAlias { shared, actual } - | TypeTag::OpaqueAlias { shared, actual } - | TypeTag::HostExposedAlias { - shared, - actual_type: actual, - actual_variable: _, - } => maybe_paren!( + | TypeTag::OpaqueAlias { shared, actual } => maybe_paren!( Free, p, alias(types, f, tag, shared) @@ -1743,13 +1677,6 @@ pub enum Type { actual: Box, kind: AliasKind, }, - HostExposedAlias { - name: Symbol, - type_arguments: Vec, - lambda_set_variables: Vec, - actual_var: Variable, - actual: Box, - }, RecursiveTagUnion(Variable, Vec<(TagName, Vec)>, TypeExtension), /// Applying a type to some arguments (e.g. Dict.Dict String Int) Apply(Symbol, Vec>, Region), @@ -1836,19 +1763,6 @@ impl Clone for Type { actual: actual.clone(), kind: *kind, }, - Self::HostExposedAlias { - name, - type_arguments, - lambda_set_variables, - actual_var, - actual, - } => Self::HostExposedAlias { - name: *name, - type_arguments: type_arguments.clone(), - lambda_set_variables: lambda_set_variables.clone(), - actual_var: *actual_var, - actual: actual.clone(), - }, Self::RecursiveTagUnion(arg0, arg1, arg2) => { Self::RecursiveTagUnion(*arg0, arg1.clone(), arg2.clone()) } @@ -2054,22 +1968,6 @@ impl fmt::Debug for Type { Ok(()) } - Type::HostExposedAlias { - name, - type_arguments: arguments, - .. - } => { - write!(f, "HostExposedAlias {name:?}")?; - - for arg in arguments { - write!(f, " {arg:?}")?; - } - - // Sometimes it's useful to see the expansion of the alias - // write!(f, "[ but actually {:?} ]", _actual)?; - - Ok(()) - } Type::Record(fields, ext) => { write!(f, "{{")?; @@ -2384,22 +2282,6 @@ impl Type { stack.push(actual); } - HostExposedAlias { - type_arguments, - lambda_set_variables, - actual: actual_type, - .. - } => { - for value in type_arguments.iter_mut() { - stack.push(value); - } - - for lambda_set in lambda_set_variables.iter_mut() { - stack.push(lambda_set.as_inner_mut()); - } - - stack.push(actual_type); - } Apply(_, args, _) => { stack.extend(args.iter_mut().map(|t| &mut t.value)); } @@ -2522,22 +2404,6 @@ impl Type { stack.push(actual); } - HostExposedAlias { - type_arguments, - lambda_set_variables, - actual: actual_type, - .. - } => { - for value in type_arguments.iter_mut() { - stack.push(value); - } - - for lambda_set in lambda_set_variables.iter_mut() { - stack.push(lambda_set.as_inner_mut()); - } - - stack.push(actual_type); - } Apply(_, args, _) => { stack.extend(args.iter_mut().map(|t| &mut t.value)); } @@ -2640,10 +2506,6 @@ impl Type { } alias_actual.substitute_alias(rep_symbol, rep_args, actual) } - HostExposedAlias { - actual: actual_type, - .. - } => actual_type.substitute_alias(rep_symbol, rep_args, actual), Apply(symbol, args, region) if *symbol == rep_symbol => { if args.len() == rep_args.len() && args @@ -2727,9 +2589,6 @@ impl Type { actual: actual_type, .. } => alias_symbol == &rep_symbol || actual_type.contains_symbol(rep_symbol), - HostExposedAlias { name, actual, .. } => { - name == &rep_symbol || actual.contains_symbol(rep_symbol) - } Apply(symbol, _, _) if *symbol == rep_symbol => true, Apply(_, args, _) => args.iter().any(|arg| arg.value.contains_symbol(rep_symbol)), RangedNumber(_) => false, @@ -2793,7 +2652,6 @@ impl Type { actual: actual_type, .. } => actual_type.contains_variable(rep_variable), - HostExposedAlias { actual, .. } => actual.contains_variable(rep_variable), Apply(_, args, _) => args .iter() .any(|arg| arg.value.contains_variable(rep_variable)), @@ -2996,22 +2854,6 @@ fn instantiate_aliases<'a, F>( .iter_mut() .for_each(|t| instantiate_aliases(&mut t.value.typ, region, aliases, ctx)); } - HostExposedAlias { - type_arguments: type_args, - lambda_set_variables, - actual: actual_type, - .. - } => { - for arg in type_args { - instantiate_aliases(arg, region, aliases, ctx); - } - - for arg in lambda_set_variables { - arg.instantiate_aliases(region, aliases, ctx); - } - - instantiate_aliases(&mut *actual_type, region, aliases, ctx); - } Alias { type_arguments: type_args, lambda_set_variables, @@ -3170,12 +3012,6 @@ fn symbols_help(initial: &Type) -> Vec { output.push(*alias_symbol); stack.push(actual_type); } - HostExposedAlias { name, actual, .. } => { - // because the type parameters are inlined in the actual type, we don't need to look - // at the type parameters here - output.push(*name); - stack.push(actual); - } Apply(symbol, args, _) => { output.push(*symbol); stack.extend(args.iter().map(|t| &t.value)); @@ -3301,16 +3137,6 @@ fn variables_help(tipe: &Type, accum: &mut ImSet) { } variables_help(actual, accum); } - HostExposedAlias { - type_arguments: arguments, - actual, - .. - } => { - for arg in arguments { - variables_help(arg, accum); - } - variables_help(actual, accum); - } RangedNumber(_) => {} Apply(_, args, _) => { for x in args { @@ -3453,16 +3279,6 @@ fn variables_help_detailed(tipe: &Type, accum: &mut VariableDetail) { } variables_help_detailed(actual, accum); } - HostExposedAlias { - type_arguments: arguments, - actual, - .. - } => { - for arg in arguments { - variables_help_detailed(arg, accum); - } - variables_help_detailed(actual, accum); - } RangedNumber(_) => {} Apply(_, args, _) => { for x in args { @@ -4653,20 +4469,6 @@ fn instantiate_lambda_sets_as_unspecialized( stack.push(actual); stack.extend(type_arguments.iter_mut().rev().map(|t| &mut t.typ)); } - Type::HostExposedAlias { - name: _, - type_arguments, - lambda_set_variables, - actual_var: _, - actual, - } => { - for lambda_set in lambda_set_variables.iter_mut() { - debug_assert!(matches!(lambda_set.0, Type::Variable(_))); - lambda_set.0 = new_uls(); - } - stack.push(actual); - stack.extend(type_arguments.iter_mut().rev()); - } Type::Apply(_sym, args, _region) => { stack.extend(args.iter_mut().rev().map(|t| &mut t.value)); } From 7fb4b60b218c5ab83dd6672c1cb66ca818686c6b Mon Sep 17 00:00:00 2001 From: Folkert Date: Wed, 9 Aug 2023 15:09:03 +0200 Subject: [PATCH 067/176] move around hostexposedalias logic --- crates/compiler/alias_analysis/src/lib.rs | 74 ++++++++----------- crates/compiler/build/src/program.rs | 1 + crates/compiler/gen_dev/src/object_builder.rs | 4 +- crates/compiler/gen_llvm/src/llvm/build.rs | 67 ++++++++--------- crates/compiler/load_internal/src/file.rs | 17 ++++- crates/compiler/load_internal/src/module.rs | 3 +- crates/compiler/mono/src/code_gen_help/mod.rs | 13 ++-- crates/compiler/mono/src/ir.rs | 58 +++++++-------- crates/compiler/mono/src/tail_recursion.rs | 2 +- crates/compiler/test_gen/src/helpers/llvm.rs | 2 + crates/repl_cli/src/cli_gen.rs | 2 + 11 files changed, 120 insertions(+), 123 deletions(-) diff --git a/crates/compiler/alias_analysis/src/lib.rs b/crates/compiler/alias_analysis/src/lib.rs index 598406dffb..77902fc496 100644 --- a/crates/compiler/alias_analysis/src/lib.rs +++ b/crates/compiler/alias_analysis/src/lib.rs @@ -14,7 +14,7 @@ use roc_module::low_level::LowLevel; use roc_module::symbol::Symbol; use roc_mono::ir::{ - Call, CallType, EntryPoint, ErasedField, Expr, HigherOrderLowLevel, HostExposedLayouts, + Call, CallType, EntryPoint, ErasedField, Expr, HigherOrderLowLevel, HostExposedLambdaSet, ListLiteralElement, Literal, ModifyRc, OptLevel, Proc, ProcLayout, SingleEntryPoint, Stmt, }; use roc_mono::layout::{ @@ -137,15 +137,17 @@ fn bytes_as_ascii(bytes: &[u8]) -> String { buf } -pub fn spec_program<'a, 'r, I>( +pub fn spec_program<'a, 'r, I1, I2>( arena: &'a Bump, interner: &'r STLayoutInterner<'a>, opt_level: OptLevel, entry_point: roc_mono::ir::EntryPoint<'a>, - procs: I, + procs: I1, + hels: I2, ) -> Result where - I: Iterator>, + I1: Iterator>, + I2: Iterator>, { let main_module = { let mut m = ModDefBuilder::new(); @@ -183,50 +185,36 @@ where let mut host_exposed_functions = Vec::new(); let mut erased_functions = Vec::new(); + for hels in hels { + match hels.raw_function_layout { + RawFunctionLayout::Function(_, _, _) => { + let it = hels.proc_layout.arguments.iter().copied(); + let bytes = + func_name_bytes_help(hels.symbol, it, Niche::NONE, hels.proc_layout.result); + + host_exposed_functions.push((bytes, hels.proc_layout.arguments)); + } + RawFunctionLayout::ErasedFunction(..) => { + let it = hels.proc_layout.arguments.iter().copied(); + let bytes = + func_name_bytes_help(hels.symbol, it, Niche::NONE, hels.proc_layout.result); + + host_exposed_functions.push((bytes, hels.proc_layout.arguments)); + } + RawFunctionLayout::ZeroArgumentThunk(_) => { + let bytes = + func_name_bytes_help(hels.symbol, [], Niche::NONE, hels.proc_layout.result); + + host_exposed_functions.push((bytes, hels.proc_layout.arguments)); + } + } + } + // all other functions for proc in procs { let bytes = func_name_bytes(proc); let func_name = FuncName(&bytes); - if let HostExposedLayouts::HostExposed { aliases, .. } = &proc.host_exposed_layouts { - for (_, hels) in aliases { - match hels.raw_function_layout { - RawFunctionLayout::Function(_, _, _) => { - let it = hels.proc_layout.arguments.iter().copied(); - let bytes = func_name_bytes_help( - hels.symbol, - it, - Niche::NONE, - hels.proc_layout.result, - ); - - host_exposed_functions.push((bytes, hels.proc_layout.arguments)); - } - RawFunctionLayout::ErasedFunction(..) => { - let it = hels.proc_layout.arguments.iter().copied(); - let bytes = func_name_bytes_help( - hels.symbol, - it, - Niche::NONE, - hels.proc_layout.result, - ); - - host_exposed_functions.push((bytes, hels.proc_layout.arguments)); - } - RawFunctionLayout::ZeroArgumentThunk(_) => { - let bytes = func_name_bytes_help( - hels.symbol, - [], - Niche::NONE, - hels.proc_layout.result, - ); - - host_exposed_functions.push((bytes, hels.proc_layout.arguments)); - } - } - } - } - if debug() { eprintln!( "{:?}: {:?} with {:?} args", diff --git a/crates/compiler/build/src/program.rs b/crates/compiler/build/src/program.rs index 839b029116..c8e6fd2496 100644 --- a/crates/compiler/build/src/program.rs +++ b/crates/compiler/build/src/program.rs @@ -235,6 +235,7 @@ fn gen_from_mono_module_llvm<'a>( &loaded.layout_interner, opt_level, loaded.procedures, + loaded.host_exposed_lambda_sets, entry_point, Some(&app_ll_file), &loaded.glue_layouts, diff --git a/crates/compiler/gen_dev/src/object_builder.rs b/crates/compiler/gen_dev/src/object_builder.rs index 62acda1cb5..a000fbf537 100644 --- a/crates/compiler/gen_dev/src/object_builder.rs +++ b/crates/compiler/gen_dev/src/object_builder.rs @@ -599,7 +599,7 @@ fn build_exposed_proc<'a, B: Backend<'a>>(backend: &mut B, proc: &Proc<'a>) -> P closure_data_layout: None, ret_layout: proc.ret_layout, is_self_recursive: roc_mono::ir::SelfRecursive::NotSelfRecursive, - host_exposed_layouts: roc_mono::ir::HostExposedLayouts::NotHostExposed, + is_host_exposed: false, is_erased: proc.is_erased, } } @@ -681,7 +681,7 @@ fn build_exposed_generic_proc<'a, B: Backend<'a>>(backend: &mut B, proc: &Proc<' closure_data_layout: None, ret_layout: roc_mono::layout::Layout::UNIT, is_self_recursive: roc_mono::ir::SelfRecursive::NotSelfRecursive, - host_exposed_layouts: roc_mono::ir::HostExposedLayouts::NotHostExposed, + is_host_exposed: false, is_erased: proc.is_erased, } } diff --git a/crates/compiler/gen_llvm/src/llvm/build.rs b/crates/compiler/gen_llvm/src/llvm/build.rs index 92649bc5a1..c840b5712f 100644 --- a/crates/compiler/gen_llvm/src/llvm/build.rs +++ b/crates/compiler/gen_llvm/src/llvm/build.rs @@ -43,7 +43,7 @@ use roc_error_macros::{internal_error, todo_lambda_erasure}; use roc_module::symbol::{Interns, Symbol}; use roc_mono::ir::{ BranchInfo, CallType, CrashTag, EntryPoint, GlueLayouts, HostExposedLambdaSet, - ListLiteralElement, ModifyRc, OptLevel, ProcLayout, SingleEntryPoint, + HostExposedLambdaSets, ListLiteralElement, ModifyRc, OptLevel, ProcLayout, SingleEntryPoint, }; use roc_mono::layout::{ Builtin, InLayout, LambdaName, LambdaSet, Layout, LayoutIds, LayoutInterner, LayoutRepr, Niche, @@ -4920,6 +4920,7 @@ pub fn build_procedures<'a>( layout_interner: &STLayoutInterner<'a>, opt_level: OptLevel, procedures: MutMap<(Symbol, ProcLayout<'a>), roc_mono::ir::Proc<'a>>, + host_exposed_lambda_sets: HostExposedLambdaSets<'a>, entry_point: EntryPoint<'a>, debug_output_file: Option<&Path>, glue_layouts: &GlueLayouts<'a>, @@ -4929,6 +4930,7 @@ pub fn build_procedures<'a>( layout_interner, opt_level, procedures, + host_exposed_lambda_sets, entry_point, debug_output_file, ); @@ -4982,6 +4984,7 @@ pub fn build_wasm_test_wrapper<'a, 'ctx>( layout_interner, opt_level, procedures, + vec![], EntryPoint::Single(entry_point), Some(&std::env::temp_dir().join("test.ll")), ); @@ -5000,6 +5003,7 @@ pub fn build_procedures_return_main<'a, 'ctx>( layout_interner: &STLayoutInterner<'a>, opt_level: OptLevel, procedures: MutMap<(Symbol, ProcLayout<'a>), roc_mono::ir::Proc<'a>>, + host_exposed_lambda_sets: HostExposedLambdaSets<'a>, entry_point: SingleEntryPoint<'a>, ) -> (&'static str, FunctionValue<'ctx>) { let mod_solutions = build_procedures_help( @@ -5007,6 +5011,7 @@ pub fn build_procedures_return_main<'a, 'ctx>( layout_interner, opt_level, procedures, + host_exposed_lambda_sets, EntryPoint::Single(entry_point), Some(&std::env::temp_dir().join("test.ll")), ); @@ -5034,6 +5039,7 @@ pub fn build_procedures_expose_expects<'a>( layout_interner, opt_level, procedures, + vec![], entry_point, Some(&std::env::temp_dir().join("test.ll")), ); @@ -5096,20 +5102,23 @@ fn build_procedures_help<'a>( layout_interner: &STLayoutInterner<'a>, opt_level: OptLevel, procedures: MutMap<(Symbol, ProcLayout<'a>), roc_mono::ir::Proc<'a>>, + host_exposed_lambda_sets: HostExposedLambdaSets<'a>, entry_point: EntryPoint<'a>, debug_output_file: Option<&Path>, ) -> &'a ModSolutions { let mut layout_ids = roc_mono::layout::LayoutIds::default(); let mut scope = Scope::default(); - let it = procedures.iter().map(|x| x.1); + let it1 = procedures.iter().map(|x| x.1); + let it2 = host_exposed_lambda_sets.iter().map(|(_, _, hels)| hels); let solutions = match roc_alias_analysis::spec_program( env.arena, layout_interner, opt_level, entry_point, - it, + it1, + it2, ) { Err(e) => panic!("Error in alias analysis: {e}"), Ok(solutions) => solutions, @@ -5147,7 +5156,6 @@ fn build_procedures_help<'a>( build_proc( env, layout_interner, - mod_solutions, &mut layout_ids, func_spec_solutions, scope.clone(), @@ -5192,6 +5200,26 @@ fn build_procedures_help<'a>( } } + use LlvmBackendMode::*; + match env.mode { + GenTest | WasmGenTest | CliTest => { /* no host, or exposing types is not supported */ } + Binary | BinaryDev | BinaryGlue => { + for (proc_name, alias_name, hels) in host_exposed_lambda_sets.iter() { + let ident_string = proc_name.name().as_str(&env.interns); + let fn_name: String = format!("{}_{}", ident_string, hels.id.0); + + expose_alias_to_host( + env, + layout_interner, + mod_solutions, + &fn_name, + *alias_name, + hels, + ) + } + } + } + mod_solutions } @@ -5558,43 +5586,12 @@ fn build_host_exposed_alias_size_help<'a, 'ctx>( fn build_proc<'a, 'ctx>( env: &Env<'a, 'ctx, '_>, layout_interner: &STLayoutInterner<'a>, - mod_solutions: &'a ModSolutions, layout_ids: &mut LayoutIds<'a>, func_spec_solutions: &FuncSpecSolutions, mut scope: Scope<'a, 'ctx>, proc: &roc_mono::ir::Proc<'a>, fn_val: FunctionValue<'ctx>, ) { - use roc_mono::ir::HostExposedLayouts; - - match &proc.host_exposed_layouts { - HostExposedLayouts::NotHostExposed => {} - HostExposedLayouts::HostExposed { aliases, .. } => { - use LlvmBackendMode::*; - - match env.mode { - GenTest | WasmGenTest | CliTest => { - /* no host, or exposing types is not supported */ - } - Binary | BinaryDev | BinaryGlue => { - for (alias_name, hels) in aliases.iter() { - let ident_string = proc.name.name().as_str(&env.interns); - let fn_name: String = format!("{}_{}", ident_string, hels.id.0); - - expose_alias_to_host( - env, - layout_interner, - mod_solutions, - &fn_name, - *alias_name, - hels, - ) - } - } - } - } - }; - let args = proc.args; let context = &env.context; diff --git a/crates/compiler/load_internal/src/file.rs b/crates/compiler/load_internal/src/file.rs index f49098070b..2e4ad911bb 100644 --- a/crates/compiler/load_internal/src/file.rs +++ b/crates/compiler/load_internal/src/file.rs @@ -38,8 +38,8 @@ use roc_module::symbol::{ PackageQualified, Symbol, }; use roc_mono::ir::{ - CapturedSymbols, ExternalSpecializations, GlueLayouts, PartialProc, Proc, ProcLayout, Procs, - ProcsBase, UpdateModeIds, UsageTrackingMap, + CapturedSymbols, ExternalSpecializations, GlueLayouts, HostExposedLambdaSets, PartialProc, + Proc, ProcLayout, Procs, ProcsBase, UpdateModeIds, UsageTrackingMap, }; use roc_mono::layout::{ GlobalLayoutInterner, LambdaName, Layout, LayoutCache, LayoutProblem, Niche, STLayoutInterner, @@ -613,6 +613,7 @@ enum Msg<'a> { external_specializations_requested: BumpMap>, procs_base: ProcsBase<'a>, procedures: MutMap<(Symbol, ProcLayout<'a>), Proc<'a>>, + host_exposed_lambda_sets: HostExposedLambdaSets<'a>, update_mode_ids: UpdateModeIds, module_timing: ModuleTiming, subs: Subs, @@ -708,6 +709,7 @@ struct State<'a> { pub module_cache: ModuleCache<'a>, pub dependencies: Dependencies<'a>, pub procedures: MutMap<(Symbol, ProcLayout<'a>), Proc<'a>>, + pub host_exposed_lambda_sets: HostExposedLambdaSets<'a>, pub toplevel_expects: ToplevelExpects, pub exposed_to_host: ExposedToHost, @@ -788,6 +790,7 @@ impl<'a> State<'a> { module_cache: ModuleCache::default(), dependencies, procedures: MutMap::default(), + host_exposed_lambda_sets: std::vec::Vec::new(), toplevel_expects: ToplevelExpects::default(), exposed_to_host: ExposedToHost::default(), exposed_modules: &[], @@ -2649,6 +2652,7 @@ fn update<'a>( subs, procs_base, procedures, + host_exposed_lambda_sets, external_specializations_requested, module_timing, layout_cache, @@ -2666,6 +2670,9 @@ fn update<'a>( let _ = layout_cache; state.procedures.extend(procedures); + state + .host_exposed_lambda_sets + .extend(host_exposed_lambda_sets); state.module_cache.late_specializations.insert( module_id, LateSpecializationsModule { @@ -3081,6 +3088,7 @@ fn finish_specialization<'a>( let State { toplevel_expects, procedures, + host_exposed_lambda_sets, module_cache, output_path, platform_data, @@ -3124,6 +3132,7 @@ fn finish_specialization<'a>( interns, layout_interner, procedures, + host_exposed_lambda_sets, entry_point, sources, timings: state.timings, @@ -5513,7 +5522,8 @@ fn make_specializations<'a>( ); let external_specializations_requested = procs.externals_we_need.clone(); - let (procedures, restored_procs_base) = procs.get_specialized_procs_without_rc(); + let (procedures, host_exposed_lambda_sets, restored_procs_base) = + procs.get_specialized_procs_without_rc(); // Turn `Bytes.Decode.IdentId(238)` into `Bytes.Decode.238`, we rely on this in mono tests mono_env.home.register_debug_idents(mono_env.ident_ids); @@ -5529,6 +5539,7 @@ fn make_specializations<'a>( layout_cache, procs_base: restored_procs_base, procedures, + host_exposed_lambda_sets, update_mode_ids, subs, expectations, diff --git a/crates/compiler/load_internal/src/module.rs b/crates/compiler/load_internal/src/module.rs index a84b60cb29..089c22a409 100644 --- a/crates/compiler/load_internal/src/module.rs +++ b/crates/compiler/load_internal/src/module.rs @@ -11,7 +11,7 @@ use roc_module::ident::Ident; use roc_module::symbol::{ IdentIds, IdentIdsByModule, Interns, ModuleId, PQModuleName, PackageQualified, Symbol, }; -use roc_mono::ir::{GlueLayouts, LambdaSetId, Proc, ProcLayout, ProcsBase}; +use roc_mono::ir::{GlueLayouts, HostExposedLambdaSets, LambdaSetId, Proc, ProcLayout, ProcsBase}; use roc_mono::layout::{LayoutCache, STLayoutInterner}; use roc_parse::ast::{CommentOrNewline, Defs, TypeAnnotation, ValueDef}; use roc_parse::header::{HeaderType, PackageName}; @@ -167,6 +167,7 @@ pub struct MonomorphizedModule<'a> { pub can_problems: MutMap>, pub type_problems: MutMap>, pub procedures: MutMap<(Symbol, ProcLayout<'a>), Proc<'a>>, + pub host_exposed_lambda_sets: HostExposedLambdaSets<'a>, pub toplevel_expects: ToplevelExpects, pub entry_point: EntryPoint<'a>, pub exposed_to_host: ExposedToHost, diff --git a/crates/compiler/mono/src/code_gen_help/mod.rs b/crates/compiler/mono/src/code_gen_help/mod.rs index f0587fa70d..34285d4a3b 100644 --- a/crates/compiler/mono/src/code_gen_help/mod.rs +++ b/crates/compiler/mono/src/code_gen_help/mod.rs @@ -6,8 +6,8 @@ use roc_module::symbol::{IdentIds, ModuleId, Symbol}; use roc_target::TargetInfo; use crate::ir::{ - BranchInfo, Call, CallSpecId, CallType, Expr, HostExposedLayouts, JoinPointId, Literal, - ModifyRc, PassedFunction, Proc, ProcLayout, SelfRecursive, Stmt, UpdateModeId, + BranchInfo, Call, CallSpecId, CallType, Expr, JoinPointId, Literal, ModifyRc, PassedFunction, + Proc, ProcLayout, SelfRecursive, Stmt, UpdateModeId, }; use crate::layout::{ Builtin, InLayout, LambdaName, Layout, LayoutInterner, LayoutRepr, LayoutWrapper, Niche, @@ -452,7 +452,7 @@ impl<'a> CodeGenHelp<'a> { closure_data_layout: None, ret_layout, is_self_recursive: SelfRecursive::NotSelfRecursive, - host_exposed_layouts: HostExposedLayouts::NotHostExposed, + is_host_exposed: false, is_erased: false, }); @@ -772,7 +772,7 @@ impl<'a> CallerProc<'a> { closure_data_layout: None, ret_layout: Layout::UNIT, is_self_recursive: SelfRecursive::NotSelfRecursive, - host_exposed_layouts: HostExposedLayouts::NotHostExposed, + is_host_exposed: false, is_erased: false, }; @@ -888,10 +888,7 @@ pub fn test_helper<'a>( closure_data_layout: None, ret_layout: output_layout, is_self_recursive: main_proc.is_self_recursive, - host_exposed_layouts: HostExposedLayouts::HostExposed { - rigids: Default::default(), - aliases: Default::default(), - }, + is_host_exposed: true, is_erased: false, } } diff --git a/crates/compiler/mono/src/ir.rs b/crates/compiler/mono/src/ir.rs index db98654e6b..a473e9df8a 100644 --- a/crates/compiler/mono/src/ir.rs +++ b/crates/compiler/mono/src/ir.rs @@ -307,7 +307,7 @@ pub struct Proc<'a> { pub closure_data_layout: Option>, pub ret_layout: InLayout<'a>, pub is_self_recursive: SelfRecursive, - pub host_exposed_layouts: HostExposedLayouts<'a>, + pub is_host_exposed: bool, pub is_erased: bool, } @@ -905,12 +905,16 @@ impl<'a> SpecializationStack<'a> { } } +pub type HostExposedLambdaSets<'a> = + std::vec::Vec<(LambdaName<'a>, Symbol, HostExposedLambdaSet<'a>)>; + #[derive(Clone, Debug)] pub struct Procs<'a> { pub partial_procs: PartialProcs<'a>, ability_member_aliases: AbilityAliases, pending_specializations: PendingSpecializations<'a>, specialized: Specialized<'a>, + host_exposed_lambda_sets: HostExposedLambdaSets<'a>, pub runtime_errors: BumpMap, pub externals_we_need: BumpMap>, symbol_specializations: SymbolSpecializations<'a>, @@ -930,6 +934,7 @@ impl<'a> Procs<'a> { specialized: Specialized::default(), runtime_errors: BumpMap::new_in(arena), externals_we_need: BumpMap::new_in(arena), + host_exposed_lambda_sets: std::vec::Vec::new(), symbol_specializations: Default::default(), specialization_stack: SpecializationStack(Vec::with_capacity_in(16, arena)), @@ -995,7 +1000,11 @@ impl<'a> Procs<'a> { pub fn get_specialized_procs_without_rc( self, - ) -> (MutMap<(Symbol, ProcLayout<'a>), Proc<'a>>, ProcsBase<'a>) { + ) -> ( + MutMap<(Symbol, ProcLayout<'a>), Proc<'a>>, + HostExposedLambdaSets<'a>, + ProcsBase<'a>, + ) { let mut specialized_procs = MutMap::with_capacity_and_hasher(self.specialized.len(), default_hasher()); @@ -1013,7 +1022,11 @@ impl<'a> Procs<'a> { imported_module_thunks: self.imported_module_thunks, }; - (specialized_procs, restored_procs_base) + ( + specialized_procs, + self.host_exposed_lambda_sets, + restored_procs_base, + ) } // TODO trim these down @@ -3062,9 +3075,9 @@ fn specialize_host_specializations<'a>( let offset_variable = StorageSubs::merge_into(store, env.subs); - for (symbol, from_app, opt_from_platform) in it { + for (lambda_name, from_app, opt_from_platform) in it { let from_app = offset_variable(from_app); - let index = specialize_external_help(env, procs, layout_cache, symbol, from_app); + let index = specialize_external_help(env, procs, layout_cache, lambda_name, from_app); let Some(from_platform) = opt_from_platform else { continue }; @@ -3095,8 +3108,6 @@ fn specialize_host_specializations<'a>( } } - let mut aliases = BumpMap::default(); - for (var, id) in hels { let symbol = env.unique_symbol(); let lambda_name = LambdaName::no_niche(symbol); @@ -3128,20 +3139,10 @@ fn specialize_host_specializations<'a>( raw_function_layout, }; - aliases.insert(key, hels); - } + let in_progress = &mut procs.specialized.procedures[index.0]; + let InProgressProc::Done(proc) = in_progress else { unreachable!() }; - let in_progress = &mut procs.specialized.procedures[index.0]; - let InProgressProc::Done(proc) = in_progress else { unreachable!() }; - - match &mut proc.host_exposed_layouts { - HostExposedLayouts::HostExposed { aliases: old, .. } => old.extend(aliases), - hep @ HostExposedLayouts::NotHostExposed => { - *hep = HostExposedLayouts::HostExposed { - aliases, - rigids: Default::default(), - }; - } + procs.host_exposed_lambda_sets.push((proc.name, key, hels)); } } } @@ -3308,7 +3309,7 @@ fn generate_runtime_error_function<'a>( closure_data_layout: None, ret_layout, is_self_recursive: SelfRecursive::NotSelfRecursive, - host_exposed_layouts: HostExposedLayouts::NotHostExposed, + is_host_exposed: false, is_erased, } } @@ -3404,7 +3405,7 @@ fn generate_host_exposed_function<'a>( closure_data_layout: None, ret_layout: result, is_self_recursive: SelfRecursive::NotSelfRecursive, - host_exposed_layouts: HostExposedLayouts::NotHostExposed, + is_host_exposed: false, is_erased: false, }; @@ -3469,7 +3470,7 @@ fn generate_host_exposed_lambda_set<'a>( closure_data_layout: None, ret_layout: return_layout, is_self_recursive: SelfRecursive::NotSelfRecursive, - host_exposed_layouts: HostExposedLayouts::NotHostExposed, + is_host_exposed: false, is_erased: false, }; @@ -3533,9 +3534,6 @@ fn specialize_proc_help<'a>( let body = partial_proc.body.clone(); let body_var = partial_proc.body_var; - // host-exposed functions are tagged on later - let host_exposed_layouts = HostExposedLayouts::NotHostExposed; - let mut specialized_body = from_can(env, body_var, body, procs, layout_cache); let specialized_proc = match specialized { @@ -3567,7 +3565,7 @@ fn specialize_proc_help<'a>( closure_data_layout: Some(closure_data_layout), ret_layout, is_self_recursive: recursivity, - host_exposed_layouts, + is_host_exposed: false, is_erased, } } @@ -3770,7 +3768,7 @@ fn specialize_proc_help<'a>( closure_data_layout, ret_layout, is_self_recursive: recursivity, - host_exposed_layouts, + is_host_exposed: false, is_erased, } } @@ -10330,7 +10328,7 @@ where closure_data_layout: None, ret_layout: *field, is_self_recursive: SelfRecursive::NotSelfRecursive, - host_exposed_layouts: HostExposedLayouts::NotHostExposed, + is_host_exposed: false, is_erased: false, }; @@ -10426,7 +10424,7 @@ where closure_data_layout: None, ret_layout: *field, is_self_recursive: SelfRecursive::NotSelfRecursive, - host_exposed_layouts: HostExposedLayouts::NotHostExposed, + is_host_exposed: false, is_erased: false, }; diff --git a/crates/compiler/mono/src/tail_recursion.rs b/crates/compiler/mono/src/tail_recursion.rs index cd3346401e..6b726d3039 100644 --- a/crates/compiler/mono/src/tail_recursion.rs +++ b/crates/compiler/mono/src/tail_recursion.rs @@ -802,7 +802,7 @@ impl<'a> TrmcEnv<'a> { closure_data_layout: proc.closure_data_layout, ret_layout: proc.ret_layout, is_self_recursive: SelfRecursive::NotSelfRecursive, - host_exposed_layouts: proc.host_exposed_layouts.clone(), + is_host_exposed: proc.is_host_exposed, is_erased: proc.is_erased, } } diff --git a/crates/compiler/test_gen/src/helpers/llvm.rs b/crates/compiler/test_gen/src/helpers/llvm.rs index 18eebb4c93..34bc8dc9fc 100644 --- a/crates/compiler/test_gen/src/helpers/llvm.rs +++ b/crates/compiler/test_gen/src/helpers/llvm.rs @@ -102,6 +102,7 @@ fn create_llvm_module<'a>( use roc_load::MonomorphizedModule; let MonomorphizedModule { procedures, + host_exposed_lambda_sets, interns, layout_interner, .. @@ -271,6 +272,7 @@ fn create_llvm_module<'a>( &layout_interner, config.opt_level, procedures, + host_exposed_lambda_sets, entry_point, ), }; diff --git a/crates/repl_cli/src/cli_gen.rs b/crates/repl_cli/src/cli_gen.rs index accd1359d9..0b8c322ca7 100644 --- a/crates/repl_cli/src/cli_gen.rs +++ b/crates/repl_cli/src/cli_gen.rs @@ -199,6 +199,7 @@ fn mono_module_to_dylib<'a>( let MonomorphizedModule { procedures, + host_exposed_lambda_sets, entry_point, interns, subs, @@ -258,6 +259,7 @@ fn mono_module_to_dylib<'a>( &layout_interner, opt_level, procedures, + host_exposed_lambda_sets, entry_point, ); From 0f3da32d9d611bf9e8ab7b1b6658213fb35f4cd5 Mon Sep 17 00:00:00 2001 From: Folkert Date: Wed, 9 Aug 2023 15:11:02 +0200 Subject: [PATCH 068/176] remove unused field --- crates/compiler/gen_dev/src/object_builder.rs | 2 -- crates/compiler/mono/src/code_gen_help/mod.rs | 3 --- crates/compiler/mono/src/ir.rs | 8 -------- crates/compiler/mono/src/tail_recursion.rs | 1 - 4 files changed, 14 deletions(-) diff --git a/crates/compiler/gen_dev/src/object_builder.rs b/crates/compiler/gen_dev/src/object_builder.rs index a000fbf537..d3b79d14c8 100644 --- a/crates/compiler/gen_dev/src/object_builder.rs +++ b/crates/compiler/gen_dev/src/object_builder.rs @@ -599,7 +599,6 @@ fn build_exposed_proc<'a, B: Backend<'a>>(backend: &mut B, proc: &Proc<'a>) -> P closure_data_layout: None, ret_layout: proc.ret_layout, is_self_recursive: roc_mono::ir::SelfRecursive::NotSelfRecursive, - is_host_exposed: false, is_erased: proc.is_erased, } } @@ -681,7 +680,6 @@ fn build_exposed_generic_proc<'a, B: Backend<'a>>(backend: &mut B, proc: &Proc<' closure_data_layout: None, ret_layout: roc_mono::layout::Layout::UNIT, is_self_recursive: roc_mono::ir::SelfRecursive::NotSelfRecursive, - is_host_exposed: false, is_erased: proc.is_erased, } } diff --git a/crates/compiler/mono/src/code_gen_help/mod.rs b/crates/compiler/mono/src/code_gen_help/mod.rs index 34285d4a3b..9e29a126c0 100644 --- a/crates/compiler/mono/src/code_gen_help/mod.rs +++ b/crates/compiler/mono/src/code_gen_help/mod.rs @@ -452,7 +452,6 @@ impl<'a> CodeGenHelp<'a> { closure_data_layout: None, ret_layout, is_self_recursive: SelfRecursive::NotSelfRecursive, - is_host_exposed: false, is_erased: false, }); @@ -772,7 +771,6 @@ impl<'a> CallerProc<'a> { closure_data_layout: None, ret_layout: Layout::UNIT, is_self_recursive: SelfRecursive::NotSelfRecursive, - is_host_exposed: false, is_erased: false, }; @@ -888,7 +886,6 @@ pub fn test_helper<'a>( closure_data_layout: None, ret_layout: output_layout, is_self_recursive: main_proc.is_self_recursive, - is_host_exposed: true, is_erased: false, } } diff --git a/crates/compiler/mono/src/ir.rs b/crates/compiler/mono/src/ir.rs index a473e9df8a..d13afb88c7 100644 --- a/crates/compiler/mono/src/ir.rs +++ b/crates/compiler/mono/src/ir.rs @@ -307,7 +307,6 @@ pub struct Proc<'a> { pub closure_data_layout: Option>, pub ret_layout: InLayout<'a>, pub is_self_recursive: SelfRecursive, - pub is_host_exposed: bool, pub is_erased: bool, } @@ -3309,7 +3308,6 @@ fn generate_runtime_error_function<'a>( closure_data_layout: None, ret_layout, is_self_recursive: SelfRecursive::NotSelfRecursive, - is_host_exposed: false, is_erased, } } @@ -3405,7 +3403,6 @@ fn generate_host_exposed_function<'a>( closure_data_layout: None, ret_layout: result, is_self_recursive: SelfRecursive::NotSelfRecursive, - is_host_exposed: false, is_erased: false, }; @@ -3470,7 +3467,6 @@ fn generate_host_exposed_lambda_set<'a>( closure_data_layout: None, ret_layout: return_layout, is_self_recursive: SelfRecursive::NotSelfRecursive, - is_host_exposed: false, is_erased: false, }; @@ -3565,7 +3561,6 @@ fn specialize_proc_help<'a>( closure_data_layout: Some(closure_data_layout), ret_layout, is_self_recursive: recursivity, - is_host_exposed: false, is_erased, } } @@ -3768,7 +3763,6 @@ fn specialize_proc_help<'a>( closure_data_layout, ret_layout, is_self_recursive: recursivity, - is_host_exposed: false, is_erased, } } @@ -10328,7 +10322,6 @@ where closure_data_layout: None, ret_layout: *field, is_self_recursive: SelfRecursive::NotSelfRecursive, - is_host_exposed: false, is_erased: false, }; @@ -10424,7 +10417,6 @@ where closure_data_layout: None, ret_layout: *field, is_self_recursive: SelfRecursive::NotSelfRecursive, - is_host_exposed: false, is_erased: false, }; diff --git a/crates/compiler/mono/src/tail_recursion.rs b/crates/compiler/mono/src/tail_recursion.rs index 6b726d3039..bd419d02c5 100644 --- a/crates/compiler/mono/src/tail_recursion.rs +++ b/crates/compiler/mono/src/tail_recursion.rs @@ -802,7 +802,6 @@ impl<'a> TrmcEnv<'a> { closure_data_layout: proc.closure_data_layout, ret_layout: proc.ret_layout, is_self_recursive: SelfRecursive::NotSelfRecursive, - is_host_exposed: proc.is_host_exposed, is_erased: proc.is_erased, } } From 64ab5cb7f67695f4a1dd5aa0fb90538c8e015e6b Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Wed, 9 Aug 2023 15:57:10 +0200 Subject: [PATCH 069/176] added README for wip website --- www/wip_new_website/README.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 www/wip_new_website/README.md diff --git a/www/wip_new_website/README.md b/www/wip_new_website/README.md new file mode 100644 index 0000000000..bef0305d16 --- /dev/null +++ b/www/wip_new_website/README.md @@ -0,0 +1,30 @@ + +# Getting Started + +## Prerequisites + +- Linux or MacOS operating system, Windows users can use linux through WSL. +- Install [git](https://chat.openai.com/share/71fb3ae6-80d7-478c-8a27-a36aaa5ba921) +- Install [nix](https://nixos.org/download.html) + +## Building the website from scratch + +```bash +git clone https://github.com/roc-lang/roc.git +cd roc +nix develop +./www/build.sh +# make the roc command available +export PATH="$(pwd)/target/release/:$PATH" +cd www/wip_new_website +roc build.roc +``` + +Open http://0.0.0.0:8080/wip in your browser. + +## After you've made a change + +In the terminal where `roc build.roc` is running: +1. kill the server with Ctrl+C +2. run `roc build.roc` +3. refresh the page in your browser \ No newline at end of file From 69588a3b76c14f38c973baf4d7b3f40664de86e2 Mon Sep 17 00:00:00 2001 From: Folkert Date: Wed, 9 Aug 2023 16:04:48 +0200 Subject: [PATCH 070/176] fix wasm tests --- crates/compiler/mono/src/ir.rs | 9 --------- crates/compiler/test_gen/src/wasm_linking.rs | 4 +--- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/crates/compiler/mono/src/ir.rs b/crates/compiler/mono/src/ir.rs index d13afb88c7..2a4df79103 100644 --- a/crates/compiler/mono/src/ir.rs +++ b/crates/compiler/mono/src/ir.rs @@ -319,15 +319,6 @@ pub struct HostExposedLambdaSet<'a> { pub raw_function_layout: RawFunctionLayout<'a>, } -#[derive(Clone, Debug, PartialEq, Eq)] -pub enum HostExposedLayouts<'a> { - NotHostExposed, - HostExposed { - rigids: BumpMap>, - aliases: BumpMap>, - }, -} - #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum SelfRecursive { NotSelfRecursive, diff --git a/crates/compiler/test_gen/src/wasm_linking.rs b/crates/compiler/test_gen/src/wasm_linking.rs index fd6597cd9e..97b1688a99 100644 --- a/crates/compiler/test_gen/src/wasm_linking.rs +++ b/crates/compiler/test_gen/src/wasm_linking.rs @@ -14,8 +14,7 @@ use roc_module::symbol::{ Symbol, }; use roc_mono::ir::{ - Call, CallType, Expr, HostExposedLayouts, Literal, Proc, ProcLayout, SelfRecursive, Stmt, - UpdateModeId, + Call, CallType, Expr, Literal, Proc, ProcLayout, SelfRecursive, Stmt, UpdateModeId, }; use roc_mono::layout::{LambdaName, Layout, Niche, STLayoutInterner}; use roc_wasm_interp::{wasi, ImportDispatcher, Instance, WasiDispatcher}; @@ -116,7 +115,6 @@ fn build_app_mono<'a>( closure_data_layout: None, ret_layout: int_layout, is_self_recursive: SelfRecursive::NotSelfRecursive, - host_exposed_layouts: HostExposedLayouts::NotHostExposed, is_erased: false, }; From aed1c26e726aa50b0a0f14ac95a3f56fa14a99a4 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Thu, 10 Aug 2023 12:50:07 -0400 Subject: [PATCH 071/176] Situationally gen Eq/Ord/Hash glue for tag unions --- crates/glue/src/RustGlue.roc | 270 +++++++++++++++++++---------------- 1 file changed, 145 insertions(+), 125 deletions(-) diff --git a/crates/glue/src/RustGlue.roc b/crates/glue/src/RustGlue.roc index 482e3a9047..8c5d6a4718 100644 --- a/crates/glue/src/RustGlue.roc +++ b/crates/glue/src/RustGlue.roc @@ -426,107 +426,122 @@ deriveDebugTagUnion = \buf, types, tagUnionType, tags -> } """ -deriveEqTagUnion : Str, Str -> Str -deriveEqTagUnion = \buf, tagUnionType -> - """ - \(buf) +deriveEqTagUnion : Str, Types, Shape, Str -> Str +deriveEqTagUnion = \buf, types, shape, tagUnionType -> + if canSupportEqHashOrd types shape then + """ + \(buf) - impl Eq for \(tagUnionType) {} - """ + impl Eq for \(tagUnionType) {} + """ + else + buf -derivePartialEqTagUnion : Str, Str, List { name : Str, payload : [Some TypeId, None] } -> Str -derivePartialEqTagUnion = \buf, tagUnionType, tags -> - checks = - List.walk tags "" \accum, { name: tagName } -> - """ - \(accum) - \(tagName) => self.payload.\(tagName) == other.payload.\(tagName), - """ +derivePartialEqTagUnion : Str, Types, Shape, Str, List { name : Str, payload : [Some TypeId, None] } -> Str +derivePartialEqTagUnion = \buf, types, shape, tagUnionType, tags -> + if canSupportPartialEqOrd types shape then + checks = + List.walk tags "" \accum, { name: tagName } -> + """ + \(accum) + \(tagName) => self.payload.\(tagName) == other.payload.\(tagName), + """ - """ - \(buf) + """ + \(buf) - impl PartialEq for \(tagUnionType) { - fn eq(&self, other: &Self) -> bool { - use discriminant_\(tagUnionType)::*; + impl PartialEq for \(tagUnionType) { + fn eq(&self, other: &Self) -> bool { + use discriminant_\(tagUnionType)::*; - if self.discriminant != other.discriminant { - return false; - } - - unsafe { - match self.discriminant {\(checks) + if self.discriminant != other.discriminant { + return false; } - } - } - } - """ -deriveOrdTagUnion : Str, Str -> Str -deriveOrdTagUnion = \buf, tagUnionType -> - """ - \(buf) - - impl Ord for \(tagUnionType) { - fn cmp(&self, other: &Self) -> std::cmp::Ordering { - self.partial_cmp(other).unwrap() - } - } - """ - -derivePartialOrdTagUnion : Str, Str, List { name : Str, payload : [Some TypeId, None] } -> Str -derivePartialOrdTagUnion = \buf, tagUnionType, tags -> - checks = - List.walk tags "" \accum, { name: tagName } -> - """ - \(accum) - \(tagName) => self.payload.\(tagName).partial_cmp(&other.payload.\(tagName)), - """ - - """ - \(buf) - - impl PartialOrd for \(tagUnionType) { - fn partial_cmp(&self, other: &Self) -> Option { - use discriminant_\(tagUnionType)::*; - - use std::cmp::Ordering::*; - - match self.discriminant.cmp(&other.discriminant) { - Less => Option::Some(Less), - Greater => Option::Some(Greater), - Equal => unsafe { + unsafe { match self.discriminant {\(checks) } - }, - } - } - } - """ - -deriveHashTagUnion : Str, Str, List { name : Str, payload : [Some TypeId, None] } -> Str -deriveHashTagUnion = \buf, tagUnionType, tags -> - checks = - List.walk tags "" \accum, { name: tagName } -> - """ - \(accum) - \(tagName) => self.payload.\(tagName).hash(state), - """ - - """ - \(buf) - - impl core::hash::Hash for \(tagUnionType) { - fn hash(&self, state: &mut H) { - use discriminant_\(tagUnionType)::*; - - unsafe { - match self.discriminant {\(checks) } } } - } - """ + """ + else + buf + +deriveOrdTagUnion : Str, Types, Shape, Str -> Str +deriveOrdTagUnion = \buf, types, shape, tagUnionType -> + if canSupportEqHashOrd types shape then + """ + \(buf) + + impl Ord for \(tagUnionType) { + fn cmp(&self, other: &Self) -> std::cmp::Ordering { + self.partial_cmp(other).unwrap() + } + } + """ + else + buf + +derivePartialOrdTagUnion : Str, Types, Shape, Str, List { name : Str, payload : [Some TypeId, None] } -> Str +derivePartialOrdTagUnion = \buf, types, shape, tagUnionType, tags -> + if canSupportPartialEqOrd types shape then + checks = + List.walk tags "" \accum, { name: tagName } -> + """ + \(accum) + \(tagName) => self.payload.\(tagName).partial_cmp(&other.payload.\(tagName)), + """ + + """ + \(buf) + + impl PartialOrd for \(tagUnionType) { + fn partial_cmp(&self, other: &Self) -> Option { + use discriminant_\(tagUnionType)::*; + + use std::cmp::Ordering::*; + + match self.discriminant.cmp(&other.discriminant) { + Less => Option::Some(Less), + Greater => Option::Some(Greater), + Equal => unsafe { + match self.discriminant {\(checks) + } + }, + } + } + } + """ + else + buf + +deriveHashTagUnion : Str, Types, Shape, Str, List { name : Str, payload : [Some TypeId, None] } -> Str +deriveHashTagUnion = \buf, types, shape, tagUnionType, tags -> + if canSupportEqHashOrd types shape then + checks = + List.walk tags "" \accum, { name: tagName } -> + """ + \(accum) + \(tagName) => self.payload.\(tagName).hash(state), + """ + + """ + \(buf) + + impl core::hash::Hash for \(tagUnionType) { + fn hash(&self, state: &mut H) { + use discriminant_\(tagUnionType)::*; + + unsafe { + match self.discriminant {\(checks) + } + } + } + } + """ + else + buf generateConstructorFunctions : Str, Types, Str, List { name : Str, payload : [Some TypeId, None] } -> Str generateConstructorFunctions = \buf, types, tagUnionType, tags -> @@ -646,6 +661,7 @@ generateNonRecursiveTagUnion = \buf, types, id, name, tags, discriminantSize, di sizeOfSelf = Num.toStr (Types.size types id) alignOfSelf = Num.toStr (Types.alignment types id) + shape = Types.shape types id # TODO: this value can be different than the alignment of `id` align = @@ -701,16 +717,16 @@ generateNonRecursiveTagUnion = \buf, types, id, name, tags, discriminantSize, di """ |> deriveCloneTagUnion escapedName tags |> deriveDebugTagUnion types escapedName tags - |> deriveEqTagUnion escapedName - |> derivePartialEqTagUnion escapedName tags - |> deriveOrdTagUnion escapedName - |> derivePartialOrdTagUnion escapedName tags - |> deriveHashTagUnion escapedName tags + |> deriveEqTagUnion types shape escapedName + |> derivePartialEqTagUnion types shape escapedName tags + |> deriveOrdTagUnion types shape escapedName + |> derivePartialOrdTagUnion types shape escapedName tags + |> deriveHashTagUnion types shape escapedName tags |> generateDestructorFunctions types escapedName tags |> generateConstructorFunctions types escapedName tags |> \b -> type = Types.shape types id - if cannotDeriveCopy types type then + if cannotSupportCopy types type then # A custom drop impl is only needed when we can't derive copy. b |> Str.concat @@ -942,7 +958,7 @@ generateRecursiveTagUnion = \buf, types, id, tagUnionName, tags, discriminantSiz |> Str.joinWith "\n" partialEqImpl = - if canDerivePartialEq types (Types.shape types id) then + if canSupportPartialEqOrd types (Types.shape types id) then """ impl PartialEq for \(escapedName) { fn eq(&self, other: &Self) -> bool { @@ -1027,7 +1043,7 @@ generateRecursiveTagUnion = \buf, types, id, tagUnionName, tags, discriminantSiz hashImpl = - if canDerivePartialEq types (Types.shape types id) then + if canSupportPartialEqOrd types (Types.shape types id) then """ impl core::hash::Hash for \(escapedName) { fn hash(&self, state: &mut H) { @@ -1067,7 +1083,7 @@ generateRecursiveTagUnion = \buf, types, id, tagUnionName, tags, discriminantSiz |> Str.joinWith "\n" partialOrdImpl = - if canDerivePartialEq types (Types.shape types id) then + if canSupportPartialEqOrd types (Types.shape types id) then """ impl PartialOrd for \(escapedName) { fn partial_cmp(&self, other: &Self) -> Option { @@ -1198,7 +1214,7 @@ generateTagUnionDropPayload = \buf, types, selfMut, tags, discriminantName, disc buf |> writeTagImpls tags discriminantName indents \name, payload -> when payload is - Some id if cannotDeriveCopy types (Types.shape types id) -> + Some id if cannotSupportCopy types (Types.shape types id) -> "unsafe { core::mem::ManuallyDrop::drop(&mut \(selfMut).payload.\(name)) }," _ -> @@ -1272,7 +1288,7 @@ generateUnionField = \types -> type = Types.shape types id fullTypeStr = - if cannotDeriveCopy types type then + if cannotSupportCopy types type then # types with pointers need ManuallyDrop # because rust unions don't (and can't) # know how to drop them automatically! @@ -1673,54 +1689,58 @@ generateDeriveStr = \buf, types, type, includeDebug -> buf |> Str.concat "#[derive(Clone, " - |> condWrite (!(cannotDeriveCopy types type)) "Copy, " - |> condWrite (!(cannotDeriveDefault types type)) "Default, " + |> condWrite (!(cannotSupportCopy types type)) "Copy, " + |> condWrite (!(cannotSupportDefault types type)) "Default, " |> condWrite deriveDebug "Debug, " - |> condWrite (canDerivePartialEq types type) "PartialEq, PartialOrd, " - |> condWrite (!(hasFloat types type) && (canDerivePartialEq types type)) "Eq, Ord, Hash, " + |> condWrite (canSupportPartialEqOrd types type) "PartialEq, PartialOrd, " + |> condWrite (canSupportEqHashOrd types type) "Eq, Ord, Hash, " |> Str.concat ")]\n" -canDerivePartialEq : Types, Shape -> Bool -canDerivePartialEq = \types, type -> +canSupportEqHashOrd : Types, Shape -> Bool +canSupportEqHashOrd = \types, type -> + !(hasFloat types type) && (canSupportPartialEqOrd types type) + +canSupportPartialEqOrd : Types, Shape -> Bool +canSupportPartialEqOrd = \types, type -> when type is Function rocFn -> runtimeRepresentation = Types.shape types rocFn.lambdaSet - canDerivePartialEq types runtimeRepresentation + canSupportPartialEqOrd types runtimeRepresentation Unsized -> Bool.false Unit | EmptyTagUnion | Bool | Num _ | TagUnion (Enumeration _) -> Bool.true RocStr -> Bool.true RocList inner | RocSet inner | RocBox inner -> innerType = Types.shape types inner - canDerivePartialEq types innerType + canSupportPartialEqOrd types innerType RocDict k v -> kType = Types.shape types k vType = Types.shape types v - canDerivePartialEq types kType && canDerivePartialEq types vType + canSupportPartialEqOrd types kType && canSupportPartialEqOrd types vType TagUnion (Recursive { tags }) -> List.all tags \{ payload } -> when payload is None -> Bool.true - Some id -> canDerivePartialEq types (Types.shape types id) + Some id -> canSupportPartialEqOrd types (Types.shape types id) TagUnion (NullableWrapped { tags }) -> List.all tags \{ payload } -> when payload is None -> Bool.true - Some id -> canDerivePartialEq types (Types.shape types id) + Some id -> canSupportPartialEqOrd types (Types.shape types id) TagUnion (NonNullableUnwrapped { payload }) -> - canDerivePartialEq types (Types.shape types payload) + canSupportPartialEqOrd types (Types.shape types payload) TagUnion (NullableUnwrapped { nonNullPayload }) -> - canDerivePartialEq types (Types.shape types nonNullPayload) + canSupportPartialEqOrd types (Types.shape types nonNullPayload) RecursivePointer _ -> Bool.true TagUnion (SingleTagStruct { payload: HasNoClosure fields }) -> - List.all fields \{ id } -> canDerivePartialEq types (Types.shape types id) + List.all fields \{ id } -> canSupportPartialEqOrd types (Types.shape types id) TagUnion (SingleTagStruct { payload: HasClosure _ }) -> Bool.false @@ -1728,23 +1748,23 @@ canDerivePartialEq = \types, type -> TagUnion (NonRecursive { tags }) -> List.all tags \{ payload } -> when payload is - Some id -> canDerivePartialEq types (Types.shape types id) + Some id -> canSupportPartialEqOrd types (Types.shape types id) None -> Bool.true RocResult okId errId -> okShape = Types.shape types okId errShape = Types.shape types errId - canDerivePartialEq types okShape && canDerivePartialEq types errShape + canSupportPartialEqOrd types okShape && canSupportPartialEqOrd types errShape Struct { fields: HasNoClosure fields } | TagUnionPayload { fields: HasNoClosure fields } -> - List.all fields \{ id } -> canDerivePartialEq types (Types.shape types id) + List.all fields \{ id } -> canSupportPartialEqOrd types (Types.shape types id) Struct { fields: HasClosure fields } | TagUnionPayload { fields: HasClosure fields } -> - List.all fields \{ id } -> canDerivePartialEq types (Types.shape types id) + List.all fields \{ id } -> canSupportPartialEqOrd types (Types.shape types id) -cannotDeriveCopy : Types, Shape -> Bool -cannotDeriveCopy = \types, type -> +cannotSupportCopy : Types, Shape -> Bool +cannotSupportCopy = \types, type -> !(canDeriveCopy types type) canDeriveCopy : Types, Shape -> Bool @@ -1780,22 +1800,22 @@ canDeriveCopy = \types, type -> Struct { fields: HasClosure fields } | TagUnionPayload { fields: HasClosure fields } -> List.all fields \{ id } -> canDeriveCopy types (Types.shape types id) -cannotDeriveDefault = \types, type -> +cannotSupportDefault = \types, type -> when type is Unit | Unsized | EmptyTagUnion | TagUnion _ | RocResult _ _ | RecursivePointer _ | Function _ -> Bool.true RocStr | Bool | Num _ -> Bool.false RocList id | RocSet id | RocBox id -> - cannotDeriveDefault types (Types.shape types id) + cannotSupportDefault types (Types.shape types id) TagUnionPayload { fields: HasClosure _ } -> Bool.true RocDict keyId valId -> - cannotDeriveCopy types (Types.shape types keyId) - || cannotDeriveCopy types (Types.shape types valId) + cannotSupportCopy types (Types.shape types keyId) + || cannotSupportCopy types (Types.shape types valId) Struct { fields: HasClosure _ } -> Bool.true Struct { fields: HasNoClosure fields } | TagUnionPayload { fields: HasNoClosure fields } -> - List.any fields \{ id } -> cannotDeriveDefault types (Types.shape types id) + List.any fields \{ id } -> cannotSupportDefault types (Types.shape types id) hasFloat = \types, type -> hasFloatHelp types type (Set.empty {}) From 841cf8c74e768bbc047d37bf73d5de62dead4f98 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Thu, 10 Aug 2023 20:20:55 -0400 Subject: [PATCH 072/176] Drop redundant import --- crates/compiler/test_gen/src/gen_tags.rs | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/crates/compiler/test_gen/src/gen_tags.rs b/crates/compiler/test_gen/src/gen_tags.rs index b273461464..67be643771 100644 --- a/crates/compiler/test_gen/src/gen_tags.rs +++ b/crates/compiler/test_gen/src/gen_tags.rs @@ -17,8 +17,6 @@ use roc_mono::layout::{LayoutRepr, STLayoutInterner}; #[cfg(test)] use roc_std::{RocList, RocStr, U128}; -use crate::helpers::with_larger_debug_stack; - #[test] fn width_and_alignment_u8_u8() { use roc_mono::layout::Layout; @@ -2257,15 +2255,15 @@ fn recursive_tag_id_in_allocation_basic() { main = when x is - A _ -> "A" - B _ -> "B" - C _ -> "C" - D _ -> "D" - E _ -> "E" - F _ -> "F" - G _ -> "G" - H _ -> "H" - I _ -> "I" + A _ -> "A" + B _ -> "B" + C _ -> "C" + D _ -> "D" + E _ -> "E" + F _ -> "F" + G _ -> "G" + H _ -> "H" + I _ -> "I" "### ), RocStr::from("H"), From 6c05307a7bc1d73606b85d1cc2d8ec2f22e26c0e Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Thu, 10 Aug 2023 20:36:14 -0400 Subject: [PATCH 073/176] Drop redundant import --- crates/compiler/test_gen/src/gen_list.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/crates/compiler/test_gen/src/gen_list.rs b/crates/compiler/test_gen/src/gen_list.rs index 52a57d48e5..25f89869b7 100644 --- a/crates/compiler/test_gen/src/gen_list.rs +++ b/crates/compiler/test_gen/src/gen_list.rs @@ -3822,8 +3822,6 @@ mod pattern_match { #[cfg(feature = "gen-dev")] use crate::helpers::dev::assert_evals_to; - use crate::helpers::with_larger_debug_stack; - use super::RocList; #[test] From b983010fb16ff2e5ad27b560a99c0c3ecc4d96d0 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Thu, 10 Aug 2023 20:50:55 -0400 Subject: [PATCH 074/176] Add type annotation to Inspect.custom --- examples/Inspect.roc | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/Inspect.roc b/examples/Inspect.roc index 08accb4090..2afe3f397a 100644 --- a/examples/Inspect.roc +++ b/examples/Inspect.roc @@ -74,6 +74,7 @@ Formatter has Inspector f := f -> f | f has Formatter +custom : (f -> f) -> Inspector f | f has Formatter custom = @Inspector apply : Inspector f, f -> f | f has Formatter From 6ba4aebb3ba2079b53ef85e84066d365849de49a Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Thu, 10 Aug 2023 20:54:35 -0400 Subject: [PATCH 075/176] roc format --- crates/compiler/builtins/roc/Dict.roc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/crates/compiler/builtins/roc/Dict.roc b/crates/compiler/builtins/roc/Dict.roc index 91e08bef32..593e37d139 100644 --- a/crates/compiler/builtins/roc/Dict.roc +++ b/crates/compiler/builtins/roc/Dict.roc @@ -241,8 +241,7 @@ clear = \@Dict { metadata, dataIndices, data } -> ## Convert each value in the dictionary to something new, by calling a conversion ## function on each of them which receives both the key and the old value. Then return a ## new dictionary containing the same keys and the converted values. -map : Dict k a, (k, a -> b) -> Dict k b - where k implements Hash & Eq, b implements Hash & Eq +map : Dict k a, (k, a -> b) -> Dict k b where k implements Hash & Eq, b implements Hash & Eq map = \dict, transform -> init = withCapacity (capacity dict) @@ -254,8 +253,7 @@ map = \dict, transform -> ## (using [Dict.insertAll]) into one dictionary. ## ## You may know a similar function named `concatMap` in other languages. -joinMap : Dict a b, (a, b -> Dict x y) -> Dict x y - where a implements Hash & Eq, x implements Hash & Eq +joinMap : Dict a b, (a, b -> Dict x y) -> Dict x y where a implements Hash & Eq, x implements Hash & Eq joinMap = \dict, transform -> init = withCapacity (capacity dict) # Might be a pessimization From 390b5fee77ae910b2ddf0789765fd2ee7b53fe49 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Thu, 10 Aug 2023 21:10:47 -0400 Subject: [PATCH 076/176] Rename Formatter to InspectFormatter --- examples/Community.roc | 6 ++-- examples/Inspect.roc | 64 +++++++++++++++++++-------------------- examples/LogFormatter.roc | 4 +-- 3 files changed, 37 insertions(+), 37 deletions(-) diff --git a/examples/Community.roc b/examples/Community.roc index 0cb4522fdf..719d1449c8 100644 --- a/examples/Community.roc +++ b/examples/Community.roc @@ -8,7 +8,7 @@ interface Community walkFriendNames, ] imports [ - Inspect.{ Formatter, Inspector, Inspect }, + Inspect.{ InspectFormatter, Inspector, Inspect }, ] Community := { @@ -90,7 +90,7 @@ walkFriendNames = \@Community { people, friends }, s0, nextFn -> (nextFn s1 personName friendNames, id + 1) out -inspectCommunity : Community -> Inspector f | f has Formatter +inspectCommunity : Community -> Inspector f | f has InspectFormatter inspectCommunity = \@Community { people, friends } -> f0 <- Inspect.custom [ @@ -115,7 +115,7 @@ inspectCommunity = \@Community { people, friends } -> |> Inspect.record |> Inspect.apply f0 -inspectPerson : Person -> Inspector f | f has Formatter +inspectPerson : Person -> Inspector f | f has InspectFormatter inspectPerson = \@Person { firstName, lastName, age, hasBeard, favoriteColor } -> # In practice, this would never be done manually due to autoderive. # Instead you would just write: diff --git a/examples/Inspect.roc b/examples/Inspect.roc index 2afe3f397a..aa2aedb2b7 100644 --- a/examples/Inspect.roc +++ b/examples/Inspect.roc @@ -1,6 +1,8 @@ interface Inspect exposes [ - Formatter, + Inspect, + InspectFormatter, + Inspector, init, list, set, @@ -24,10 +26,8 @@ interface Inspect f32, f64, dec, - Inspector, custom, apply, - Inspect, inspect, toInspector, KeyValWalkFn, @@ -38,52 +38,52 @@ interface Inspect KeyValWalkFn state container key value : container, state, (state, key, value -> state) -> state ElemWalkFn state container elem : container, state, (state, elem -> state) -> state -Formatter has - init : {} -> f | f has Formatter +InspectFormatter has + init : {} -> f | f has InspectFormatter - tag : Str, List (Inspector f) -> Inspector f | f has Formatter - tuple : List (Inspector f) -> Inspector f | f has Formatter - record : List { key : Str, value : Inspector f } -> Inspector f | f has Formatter - bool : Bool -> Inspector f | f has Formatter - str : Str -> Inspector f | f has Formatter + tag : Str, List (Inspector f) -> Inspector f | f has InspectFormatter + tuple : List (Inspector f) -> Inspector f | f has InspectFormatter + record : List { key : Str, value : Inspector f } -> Inspector f | f has InspectFormatter + bool : Bool -> Inspector f | f has InspectFormatter + str : Str -> Inspector f | f has InspectFormatter - list : list, ElemWalkFn state list elem, (elem -> Inspector f) -> Inspector f | f has Formatter - set : set, ElemWalkFn state set elem, (elem -> Inspector f) -> Inspector f | f has Formatter - dict : dict, KeyValWalkFn state dict key value, (key -> Inspector f), (value -> Inspector f) -> Inspector f | f has Formatter + list : list, ElemWalkFn state list elem, (elem -> Inspector f) -> Inspector f | f has InspectFormatter + set : set, ElemWalkFn state set elem, (elem -> Inspector f) -> Inspector f | f has InspectFormatter + dict : dict, KeyValWalkFn state dict key value, (key -> Inspector f), (value -> Inspector f) -> Inspector f | f has InspectFormatter # Note opaque is used for both opaque types and functions. # The auto deriver for functions probably could put the function type. # For regular opaque types, I think we can use the type name, though that may lead to some reflection related issues that still need to be discussed. # As a simple baseline, it can just use the exact words `opaque` and `function` for now. # In text, this would render as ``, ``, etc - opaque : Str -> Inspector f | f has Formatter + opaque : Str -> Inspector f | f has InspectFormatter - u8 : U8 -> Inspector f | f has Formatter - i8 : I8 -> Inspector f | f has Formatter - u16 : U16 -> Inspector f | f has Formatter - i16 : I16 -> Inspector f | f has Formatter - u32 : U32 -> Inspector f | f has Formatter - i32 : I32 -> Inspector f | f has Formatter - u64 : U64 -> Inspector f | f has Formatter - i64 : I64 -> Inspector f | f has Formatter - u128 : U128 -> Inspector f | f has Formatter - i128 : I128 -> Inspector f | f has Formatter - f32 : F32 -> Inspector f | f has Formatter - f64 : F64 -> Inspector f | f has Formatter - dec : Dec -> Inspector f | f has Formatter + u8 : U8 -> Inspector f | f has InspectFormatter + i8 : I8 -> Inspector f | f has InspectFormatter + u16 : U16 -> Inspector f | f has InspectFormatter + i16 : I16 -> Inspector f | f has InspectFormatter + u32 : U32 -> Inspector f | f has InspectFormatter + i32 : I32 -> Inspector f | f has InspectFormatter + u64 : U64 -> Inspector f | f has InspectFormatter + i64 : I64 -> Inspector f | f has InspectFormatter + u128 : U128 -> Inspector f | f has InspectFormatter + i128 : I128 -> Inspector f | f has InspectFormatter + f32 : F32 -> Inspector f | f has InspectFormatter + f64 : F64 -> Inspector f | f has InspectFormatter + dec : Dec -> Inspector f | f has InspectFormatter -Inspector f := f -> f | f has Formatter +Inspector f := f -> f | f has InspectFormatter -custom : (f -> f) -> Inspector f | f has Formatter +custom : (f -> f) -> Inspector f | f has InspectFormatter custom = @Inspector -apply : Inspector f, f -> f | f has Formatter +apply : Inspector f, f -> f | f has InspectFormatter apply = \@Inspector fn, fmt -> fn fmt Inspect has - toInspector : val -> Inspector f | val has Inspect, f has Formatter + toInspector : val -> Inspector f | val has Inspect, f has InspectFormatter -inspect : val -> f | val has Inspect, f has Formatter +inspect : val -> f | val has Inspect, f has InspectFormatter inspect = \val -> (@Inspector valFn) = toInspector val valFn (init {}) diff --git a/examples/LogFormatter.roc b/examples/LogFormatter.roc index 808689f884..fe56223860 100644 --- a/examples/LogFormatter.roc +++ b/examples/LogFormatter.roc @@ -5,14 +5,14 @@ interface LogFormatter ] imports [ Inspect.{ - Formatter, + InspectFormatter, Inspector, }, ] LogFormatter := { data : Str } has [ - Formatter { + InspectFormatter { init: init, list: list, set: set, From 315d185b2b0b446c3a21dbb327f6615631b2c1f9 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Thu, 10 Aug 2023 21:17:16 -0400 Subject: [PATCH 077/176] Fix test --- crates/compiler/test_syntax/tests/test_fmt.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/compiler/test_syntax/tests/test_fmt.rs b/crates/compiler/test_syntax/tests/test_fmt.rs index d5bd7ad1f3..f824a22065 100644 --- a/crates/compiler/test_syntax/tests/test_fmt.rs +++ b/crates/compiler/test_syntax/tests/test_fmt.rs @@ -5565,7 +5565,7 @@ mod test_fmt { expr_formats_same(indoc!( r#" A := a where a implements Other - has [Eq { eq }, Hash { hash }] + implements [Eq { eq }, Hash { hash }] 0 "# From 24806fa4171f3c5878319c2ec825f9471c29a238 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Thu, 10 Aug 2023 21:14:40 -0400 Subject: [PATCH 078/176] Rename Inspect WalkFn aliases --- examples/GuiFormatter.roc | 7 +++---- examples/Inspect.roc | 14 +++++++------- examples/LogFormatter.roc | 6 +++--- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/examples/GuiFormatter.roc b/examples/GuiFormatter.roc index 6933f12f20..b333cc4c96 100644 --- a/examples/GuiFormatter.roc +++ b/examples/GuiFormatter.roc @@ -49,7 +49,7 @@ GuiFormatter := { nodes : List Elem } init : {} -> GuiFormatter init = \{} -> @GuiFormatter { nodes: [] } -list : list, Inspect.ElemWalkFn GuiFormatter list elem, (elem -> Inspector GuiFormatter) -> Inspector GuiFormatter +list : list, Inspect.ElemWalker GuiFormatter list elem, (elem -> Inspector GuiFormatter) -> Inspector GuiFormatter list = \content, walkFn, toInspector -> f0 <- Inspect.custom # Use a temporary buffer for the children nodes @@ -63,7 +63,7 @@ list = \content, walkFn, toInspector -> addNode f0 (Col nodes) -set : set, Inspect.ElemWalkFn GuiFormatter set elem, (elem -> Inspector GuiFormatter) -> Inspector GuiFormatter +set : set, Inspect.ElemWalker GuiFormatter set elem, (elem -> Inspector GuiFormatter) -> Inspector GuiFormatter set = \content, walkFn, toInspector -> f0 <- Inspect.custom # Use a temporary buffer for the children nodes @@ -77,7 +77,7 @@ set = \content, walkFn, toInspector -> addNode f0 (Col nodes) -dict : dict, Inspect.KeyValWalkFn GuiFormatter dict key value, (key -> Inspector GuiFormatter), (value -> Inspector GuiFormatter) -> Inspector GuiFormatter +dict : dict, Inspect.KeyValWalker GuiFormatter dict key value, (key -> Inspector GuiFormatter), (value -> Inspector GuiFormatter) -> Inspector GuiFormatter dict = \d, walkFn, keyToInspector, valueToInspector -> f0 <- Inspect.custom # Use a temporary buffer for the children nodes @@ -228,4 +228,3 @@ addNode = \@GuiFormatter { nodes }, node -> toGui : GuiFormatter -> Elem toGui = \@GuiFormatter { nodes } -> Col nodes - diff --git a/examples/Inspect.roc b/examples/Inspect.roc index aa2aedb2b7..84fec2e086 100644 --- a/examples/Inspect.roc +++ b/examples/Inspect.roc @@ -3,6 +3,8 @@ interface Inspect Inspect, InspectFormatter, Inspector, + KeyValWalker, + ElemWalker, init, list, set, @@ -30,13 +32,11 @@ interface Inspect apply, inspect, toInspector, - KeyValWalkFn, - ElemWalkFn, ] imports [] -KeyValWalkFn state container key value : container, state, (state, key, value -> state) -> state -ElemWalkFn state container elem : container, state, (state, elem -> state) -> state +KeyValWalker state collection key val : collection, state, (state, key, val -> state) -> state +ElemWalker state collection elem : collection, state, (state, elem -> state) -> state InspectFormatter has init : {} -> f | f has InspectFormatter @@ -47,9 +47,9 @@ InspectFormatter has bool : Bool -> Inspector f | f has InspectFormatter str : Str -> Inspector f | f has InspectFormatter - list : list, ElemWalkFn state list elem, (elem -> Inspector f) -> Inspector f | f has InspectFormatter - set : set, ElemWalkFn state set elem, (elem -> Inspector f) -> Inspector f | f has InspectFormatter - dict : dict, KeyValWalkFn state dict key value, (key -> Inspector f), (value -> Inspector f) -> Inspector f | f has InspectFormatter + list : list, ElemWalker state list elem, (elem -> Inspector f) -> Inspector f | f has InspectFormatter + set : set, ElemWalker state set elem, (elem -> Inspector f) -> Inspector f | f has InspectFormatter + dict : dict, KeyValWalker state dict key value, (key -> Inspector f), (value -> Inspector f) -> Inspector f | f has InspectFormatter # Note opaque is used for both opaque types and functions. # The auto deriver for functions probably could put the function type. diff --git a/examples/LogFormatter.roc b/examples/LogFormatter.roc index fe56223860..5e3f63855c 100644 --- a/examples/LogFormatter.roc +++ b/examples/LogFormatter.roc @@ -43,7 +43,7 @@ LogFormatter := { data : Str } init : {} -> LogFormatter init = \{} -> @LogFormatter { data: "" } -list : list, Inspect.ElemWalkFn (LogFormatter, Bool) list elem, (elem -> Inspector LogFormatter) -> Inspector LogFormatter +list : list, Inspect.ElemWalker (LogFormatter, Bool) list elem, (elem -> Inspector LogFormatter) -> Inspector LogFormatter list = \content, walkFn, toInspector -> f0 <- Inspect.custom write f0 "[" @@ -62,7 +62,7 @@ list = \content, walkFn, toInspector -> |> .0 |> write "]" -set : set, Inspect.ElemWalkFn (LogFormatter, Bool) set elem, (elem -> Inspector LogFormatter) -> Inspector LogFormatter +set : set, Inspect.ElemWalker (LogFormatter, Bool) set elem, (elem -> Inspector LogFormatter) -> Inspector LogFormatter set = \content, walkFn, toInspector -> f0 <- Inspect.custom write f0 "{" @@ -81,7 +81,7 @@ set = \content, walkFn, toInspector -> |> .0 |> write "}" -dict : dict, Inspect.KeyValWalkFn (LogFormatter, Bool) dict key value, (key -> Inspector LogFormatter), (value -> Inspector LogFormatter) -> Inspector LogFormatter +dict : dict, Inspect.KeyValWalker (LogFormatter, Bool) dict key value, (key -> Inspector LogFormatter), (value -> Inspector LogFormatter) -> Inspector LogFormatter dict = \d, walkFn, keyToInspector, valueToInspector -> f0 <- Inspect.custom write f0 "{" From 700776fad7e36d4459af088b3fede50bddd783c7 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Thu, 10 Aug 2023 21:23:52 -0400 Subject: [PATCH 079/176] Make Inspect a builtin --- .../compiler/builtins/roc}/Inspect.roc | 11 ++++-- crates/compiler/builtins/src/roc.rs | 2 + crates/compiler/load/build.rs | 1 + crates/compiler/load/src/lib.rs | 2 + crates/compiler/load_internal/src/file.rs | 3 ++ crates/compiler/load_internal/src/lib.rs | 1 + .../load_internal/src/module_cache.rs | 1 + crates/compiler/module/src/ident.rs | 1 + crates/compiler/module/src/symbol.rs | 38 ++++++++++++++++++- examples/Community.roc | 4 +- examples/GuiFormatter.roc | 13 ++----- examples/LogFormatter.roc | 13 ++----- examples/inspect-gui.roc | 1 - examples/inspect-logging.roc | 1 - 14 files changed, 63 insertions(+), 29 deletions(-) rename {examples => crates/compiler/builtins/roc}/Inspect.roc (96%) diff --git a/examples/Inspect.roc b/crates/compiler/builtins/roc/Inspect.roc similarity index 96% rename from examples/Inspect.roc rename to crates/compiler/builtins/roc/Inspect.roc index 84fec2e086..9c2521712c 100644 --- a/examples/Inspect.roc +++ b/crates/compiler/builtins/roc/Inspect.roc @@ -1,10 +1,11 @@ interface Inspect exposes [ Inspect, - InspectFormatter, Inspector, - KeyValWalker, + InspectFormatter, ElemWalker, + KeyValWalker, + inspect, init, list, set, @@ -30,10 +31,12 @@ interface Inspect dec, custom, apply, - inspect, toInspector, ] - imports [] + imports [ + Bool.{ Bool }, + Num.{ U8, U16, U32, U64, U128, I8, I16, I32, I64, I128, F32, F64, Dec }, + ] KeyValWalker state collection key val : collection, state, (state, key, val -> state) -> state ElemWalker state collection elem : collection, state, (state, elem -> state) -> state diff --git a/crates/compiler/builtins/src/roc.rs b/crates/compiler/builtins/src/roc.rs index 22c7dc9325..158c698de2 100644 --- a/crates/compiler/builtins/src/roc.rs +++ b/crates/compiler/builtins/src/roc.rs @@ -15,6 +15,7 @@ pub fn module_source(module_id: ModuleId) -> &'static str { ModuleId::ENCODE => ENCODE, ModuleId::DECODE => DECODE, ModuleId::HASH => HASH, + ModuleId::INSPECT => INSPECT, ModuleId::JSON => JSON, _ => internal_error!( "ModuleId {:?} is not part of the standard library", @@ -34,4 +35,5 @@ const BOOL: &str = include_str!("../roc/Bool.roc"); const ENCODE: &str = include_str!("../roc/Encode.roc"); const DECODE: &str = include_str!("../roc/Decode.roc"); const HASH: &str = include_str!("../roc/Hash.roc"); +const INSPECT: &str = include_str!("../roc/Inspect.roc"); const JSON: &str = include_str!("../roc/TotallyNotJson.roc"); diff --git a/crates/compiler/load/build.rs b/crates/compiler/load/build.rs index 5119007da6..6655800ad3 100644 --- a/crates/compiler/load/build.rs +++ b/crates/compiler/load/build.rs @@ -25,6 +25,7 @@ const MODULES: &[(ModuleId, &str)] = &[ (ModuleId::ENCODE, "Encode.roc"), (ModuleId::DECODE, "Decode.roc"), (ModuleId::HASH, "Hash.roc"), + (ModuleId::INSPECT, "Inspect.roc"), (ModuleId::JSON, "TotallyNotJson.roc"), ]; diff --git a/crates/compiler/load/src/lib.rs b/crates/compiler/load/src/lib.rs index 0777b01f2a..75cc9bf1b3 100644 --- a/crates/compiler/load/src/lib.rs +++ b/crates/compiler/load/src/lib.rs @@ -212,6 +212,7 @@ const BOX: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/Box.dat")) as &[_]; const ENCODE: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/Encode.dat")) as &[_]; const DECODE: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/Decode.dat")) as &[_]; const HASH: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/Hash.dat")) as &[_]; +const INSPECT: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/Inspect.dat")) as &[_]; fn deserialize_help(bytes: &[u8]) -> TypeState { let (state, _offset) = TypeState::deserialize(bytes); @@ -242,6 +243,7 @@ fn read_cached_types() -> MutMap { output.insert(ModuleId::DECODE, deserialize_help(DECODE)); output.insert(ModuleId::HASH, deserialize_help(HASH)); + output.insert(ModuleId::INSPECT, deserialize_help(INSPECT)); } output diff --git a/crates/compiler/load_internal/src/file.rs b/crates/compiler/load_internal/src/file.rs index 2e4ad911bb..8bc264d321 100644 --- a/crates/compiler/load_internal/src/file.rs +++ b/crates/compiler/load_internal/src/file.rs @@ -2290,6 +2290,7 @@ fn update<'a>( extend_header_with_builtin(header, ModuleId::ENCODE); extend_header_with_builtin(header, ModuleId::DECODE); extend_header_with_builtin(header, ModuleId::HASH); + extend_header_with_builtin(header, ModuleId::INSPECT); } state @@ -3494,6 +3495,7 @@ fn load_module<'a>( "Encode", ModuleId::ENCODE "Decode", ModuleId::DECODE "Hash", ModuleId::HASH + "Inspect", ModuleId::INSPECT "TotallyNotJson", ModuleId::JSON } @@ -5257,6 +5259,7 @@ fn canonicalize_and_constrain<'a>( | ModuleId::DICT | ModuleId::SET | ModuleId::HASH + | ModuleId::INSPECT ); if !name.is_builtin() || should_include_builtin { diff --git a/crates/compiler/load_internal/src/lib.rs b/crates/compiler/load_internal/src/lib.rs index 6bdb0cabbd..24226d4c6b 100644 --- a/crates/compiler/load_internal/src/lib.rs +++ b/crates/compiler/load_internal/src/lib.rs @@ -25,5 +25,6 @@ pub const BUILTIN_MODULES: &[(ModuleId, &str)] = &[ (ModuleId::ENCODE, "Encode"), (ModuleId::DECODE, "Decode"), (ModuleId::HASH, "Hash"), + (ModuleId::INSPECT, "Inspect"), (ModuleId::JSON, "TotallyNotJson"), ]; diff --git a/crates/compiler/load_internal/src/module_cache.rs b/crates/compiler/load_internal/src/module_cache.rs index ec2bea79f7..299528bf66 100644 --- a/crates/compiler/load_internal/src/module_cache.rs +++ b/crates/compiler/load_internal/src/module_cache.rs @@ -85,6 +85,7 @@ impl Default for ModuleCache<'_> { ENCODE, DECODE, HASH, + INSPECT, JSON, } diff --git a/crates/compiler/module/src/ident.rs b/crates/compiler/module/src/ident.rs index 6265698b22..558846915b 100644 --- a/crates/compiler/module/src/ident.rs +++ b/crates/compiler/module/src/ident.rs @@ -113,6 +113,7 @@ impl ModuleName { pub const ENCODE: &'static str = "Encode"; pub const DECODE: &'static str = "Decode"; pub const HASH: &'static str = "Hash"; + pub const INSPECT: &'static str = "Inspect"; pub const JSON: &'static str = "TotallyNotJson"; pub fn as_str(&self) -> &str { diff --git a/crates/compiler/module/src/symbol.rs b/crates/compiler/module/src/symbol.rs index 868a7fb7f2..3d52c928a5 100644 --- a/crates/compiler/module/src/symbol.rs +++ b/crates/compiler/module/src/symbol.rs @@ -1588,9 +1588,43 @@ define_builtins! { 20 HASH_HASH_LIST: "hashList" 21 HASH_HASH_UNORDERED: "hashUnordered" } - 14 JSON: "TotallyNotJson" => { + 14 INSPECT: "Inspect" => { + 0 INSPECT_INSPECT_ABILITY: "Inspect" exposed_type=true + 1 INSPECT_INSPECTOR: "Inspector" exposed_type=true + 2 INSPECT_INSPECT_FORMATTER: "InspectFormatter" exposed_type=true + 3 INSPECT_ELEM_WALKER: "ElemWalker" exposed_type=true + 4 INSPECT_KEY_VAL_WALKER: "KeyValWalker" exposed_type=true + 5 INSPECT_INSPECT: "inspect" + 6 INSPECT_INIT: "init" + 7 INSPECT_LIST: "list" + 8 INSPECT_SET: "set" + 9 INSPECT_DICT: "dict" + 10 INSPECT_TAG: "tag" + 11 INSPECT_TUPLE: "tuple" + 12 INSPECT_RECORD: "record" + 13 INSPECT_BOOL: "bool" + 14 INSPECT_STR: "str" + 15 INSPECT_OPAQUE: "opaque" + 16 INSPECT_U8: "u8" + 17 INSPECT_I8: "i8" + 18 INSPECT_U16: "u16" + 19 INSPECT_I16: "i16" + 20 INSPECT_U32: "u32" + 21 INSPECT_I32: "i32" + 22 INSPECT_U64: "u64" + 23 INSPECT_I64: "i64" + 24 INSPECT_U128: "u128" + 25 INSPECT_I128: "i128" + 26 INSPECT_F32: "f32" + 27 INSPECT_F64: "f64" + 28 INSPECT_DEC: "dec" + 29 INSPECT_CUSTOM: "custom" + 30 INSPECT_APPLY: "apply" + 31 INSPECT_TO_INSPECTOR: "toInspector" + } + 15 JSON: "TotallyNotJson" => { 0 JSON_JSON: "TotallyNotJson" } - num_modules: 15 // Keep this count up to date by hand! (TODO: see the mut_map! macro for how we could determine this count correctly in the macro) + num_modules: 16 // Keep this count up to date by hand! (TODO: see the mut_map! macro for how we could determine this count correctly in the macro) } diff --git a/examples/Community.roc b/examples/Community.roc index 719d1449c8..66918e22a9 100644 --- a/examples/Community.roc +++ b/examples/Community.roc @@ -7,9 +7,7 @@ interface Community Person, walkFriendNames, ] - imports [ - Inspect.{ InspectFormatter, Inspector, Inspect }, - ] + imports [] Community := { people : List Person, diff --git a/examples/GuiFormatter.roc b/examples/GuiFormatter.roc index b333cc4c96..22266a1ea4 100644 --- a/examples/GuiFormatter.roc +++ b/examples/GuiFormatter.roc @@ -3,12 +3,7 @@ interface GuiFormatter GuiFormatter, toGui, ] - imports [ - Inspect.{ - Formatter, - Inspector, - }, - ] + imports [] ## This can't depend on the platform, so I just copied all of this. @@ -49,7 +44,7 @@ GuiFormatter := { nodes : List Elem } init : {} -> GuiFormatter init = \{} -> @GuiFormatter { nodes: [] } -list : list, Inspect.ElemWalker GuiFormatter list elem, (elem -> Inspector GuiFormatter) -> Inspector GuiFormatter +list : list, ElemWalker GuiFormatter list elem, (elem -> Inspector GuiFormatter) -> Inspector GuiFormatter list = \content, walkFn, toInspector -> f0 <- Inspect.custom # Use a temporary buffer for the children nodes @@ -63,7 +58,7 @@ list = \content, walkFn, toInspector -> addNode f0 (Col nodes) -set : set, Inspect.ElemWalker GuiFormatter set elem, (elem -> Inspector GuiFormatter) -> Inspector GuiFormatter +set : set, ElemWalker GuiFormatter set elem, (elem -> Inspector GuiFormatter) -> Inspector GuiFormatter set = \content, walkFn, toInspector -> f0 <- Inspect.custom # Use a temporary buffer for the children nodes @@ -77,7 +72,7 @@ set = \content, walkFn, toInspector -> addNode f0 (Col nodes) -dict : dict, Inspect.KeyValWalker GuiFormatter dict key value, (key -> Inspector GuiFormatter), (value -> Inspector GuiFormatter) -> Inspector GuiFormatter +dict : dict, KeyValWalker GuiFormatter dict key value, (key -> Inspector GuiFormatter), (value -> Inspector GuiFormatter) -> Inspector GuiFormatter dict = \d, walkFn, keyToInspector, valueToInspector -> f0 <- Inspect.custom # Use a temporary buffer for the children nodes diff --git a/examples/LogFormatter.roc b/examples/LogFormatter.roc index 5e3f63855c..2e2a0308a2 100644 --- a/examples/LogFormatter.roc +++ b/examples/LogFormatter.roc @@ -3,12 +3,7 @@ interface LogFormatter LogFormatter, toStr, ] - imports [ - Inspect.{ - InspectFormatter, - Inspector, - }, - ] + imports [] LogFormatter := { data : Str } has [ @@ -43,7 +38,7 @@ LogFormatter := { data : Str } init : {} -> LogFormatter init = \{} -> @LogFormatter { data: "" } -list : list, Inspect.ElemWalker (LogFormatter, Bool) list elem, (elem -> Inspector LogFormatter) -> Inspector LogFormatter +list : list, ElemWalker (LogFormatter, Bool) list elem, (elem -> Inspector LogFormatter) -> Inspector LogFormatter list = \content, walkFn, toInspector -> f0 <- Inspect.custom write f0 "[" @@ -62,7 +57,7 @@ list = \content, walkFn, toInspector -> |> .0 |> write "]" -set : set, Inspect.ElemWalker (LogFormatter, Bool) set elem, (elem -> Inspector LogFormatter) -> Inspector LogFormatter +set : set, ElemWalker (LogFormatter, Bool) set elem, (elem -> Inspector LogFormatter) -> Inspector LogFormatter set = \content, walkFn, toInspector -> f0 <- Inspect.custom write f0 "{" @@ -81,7 +76,7 @@ set = \content, walkFn, toInspector -> |> .0 |> write "}" -dict : dict, Inspect.KeyValWalker (LogFormatter, Bool) dict key value, (key -> Inspector LogFormatter), (value -> Inspector LogFormatter) -> Inspector LogFormatter +dict : dict, KeyValWalker (LogFormatter, Bool) dict key value, (key -> Inspector LogFormatter), (value -> Inspector LogFormatter) -> Inspector LogFormatter dict = \d, walkFn, keyToInspector, valueToInspector -> f0 <- Inspect.custom write f0 "{" diff --git a/examples/inspect-gui.roc b/examples/inspect-gui.roc index e3ca09d7a4..bd15a57119 100644 --- a/examples/inspect-gui.roc +++ b/examples/inspect-gui.roc @@ -1,7 +1,6 @@ app "inspect-gui" packages { pf: "gui/platform/main.roc" } imports [ - Inspect, Community, GuiFormatter, ] diff --git a/examples/inspect-logging.roc b/examples/inspect-logging.roc index 31e39d43e9..ea9b8cbc29 100644 --- a/examples/inspect-logging.roc +++ b/examples/inspect-logging.roc @@ -2,7 +2,6 @@ app "inspect-logging" packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.3.2/tE4xS_zLdmmxmHwHih9kHWQ7fsXtJr7W7h3425-eZFk.tar.br" } imports [ pf.Stdout, - Inspect.{ Formatter, Inspector, Inspect }, LogFormatter, Community, ] From 0176b9310d22b801d046da01d7d9330655d2f0e8 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Thu, 10 Aug 2023 21:51:01 -0400 Subject: [PATCH 080/176] Update snapshot tests --- ...lity_demand_value_has_args.expr.result-ast | 2 +- ...ds_not_indented_with_first.expr.result-ast | 2 +- ...demand_not_indented_enough.expr.result-ast | 2 +- ...y_non_signature_expression.expr.result-ast | 2 +- ...and_signature_is_multiline.expr.result-ast | 14 +- .../pass/ability_multi_line.expr.result-ast | 22 +- .../pass/ability_single_line.expr.result-ast | 22 +- .../pass/ability_two_in_a_row.expr.result-ast | 44 ++-- .../opaque_has_abilities.expr.formatted.roc | 8 +- .../pass/opaque_has_abilities.expr.result-ast | 224 +++++++++--------- .../where_clause_function.expr.result-ast | 12 +- ...e_multiple_bound_abilities.expr.result-ast | 54 ++--- .../where_clause_multiple_has.expr.result-ast | 24 +- ...ple_has_across_newlines.expr.formatted.roc | 2 +- ...ltiple_has_across_newlines.expr.result-ast | 24 +- .../where_clause_non_function.expr.result-ast | 12 +- .../where_clause_on_newline.expr.result-ast | 12 +- 17 files changed, 241 insertions(+), 241 deletions(-) diff --git a/crates/compiler/test_syntax/tests/snapshots/fail/ability_demand_value_has_args.expr.result-ast b/crates/compiler/test_syntax/tests/snapshots/fail/ability_demand_value_has_args.expr.result-ast index 3cb44e1fdf..1e781bb579 100644 --- a/crates/compiler/test_syntax/tests/snapshots/fail/ability_demand_value_has_args.expr.result-ast +++ b/crates/compiler/test_syntax/tests/snapshots/fail/ability_demand_value_has_args.expr.result-ast @@ -1 +1 @@ -Expr(Ability(DemandColon(@15), @7), @0) \ No newline at end of file +Expr(Ability(DemandColon(@22), @14), @0) \ No newline at end of file diff --git a/crates/compiler/test_syntax/tests/snapshots/fail/ability_demands_not_indented_with_first.expr.result-ast b/crates/compiler/test_syntax/tests/snapshots/fail/ability_demands_not_indented_with_first.expr.result-ast index b4df5acd38..4d5187ee9f 100644 --- a/crates/compiler/test_syntax/tests/snapshots/fail/ability_demands_not_indented_with_first.expr.result-ast +++ b/crates/compiler/test_syntax/tests/snapshots/fail/ability_demands_not_indented_with_first.expr.result-ast @@ -1 +1 @@ -Expr(Ability(DemandAlignment(4, @49), @40), @0) \ No newline at end of file +Expr(Ability(DemandAlignment(4, @67), @58), @0) \ No newline at end of file diff --git a/crates/compiler/test_syntax/tests/snapshots/fail/ability_first_demand_not_indented_enough.expr.result-ast b/crates/compiler/test_syntax/tests/snapshots/fail/ability_first_demand_not_indented_enough.expr.result-ast index f069010c69..d3fb65ba18 100644 --- a/crates/compiler/test_syntax/tests/snapshots/fail/ability_first_demand_not_indented_enough.expr.result-ast +++ b/crates/compiler/test_syntax/tests/snapshots/fail/ability_first_demand_not_indented_enough.expr.result-ast @@ -1 +1 @@ -Expr(Ability(DemandAlignment(-1, @8), @7), @0) \ No newline at end of file +Expr(Ability(DemandAlignment(-1, @15), @14), @0) \ No newline at end of file diff --git a/crates/compiler/test_syntax/tests/snapshots/fail/ability_non_signature_expression.expr.result-ast b/crates/compiler/test_syntax/tests/snapshots/fail/ability_non_signature_expression.expr.result-ast index a66a3a05e5..08763b5ffb 100644 --- a/crates/compiler/test_syntax/tests/snapshots/fail/ability_non_signature_expression.expr.result-ast +++ b/crates/compiler/test_syntax/tests/snapshots/fail/ability_non_signature_expression.expr.result-ast @@ -1 +1 @@ -Expr(Ability(DemandName(@12), @7), @0) \ No newline at end of file +Expr(Ability(DemandName(@19), @14), @0) \ No newline at end of file diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/ability_demand_signature_is_multiline.expr.result-ast b/crates/compiler/test_syntax/tests/snapshots/pass/ability_demand_signature_is_multiline.expr.result-ast index 7f97d78500..03168073e5 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/ability_demand_signature_is_multiline.expr.result-ast +++ b/crates/compiler/test_syntax/tests/snapshots/pass/ability_demand_signature_is_multiline.expr.result-ast @@ -4,7 +4,7 @@ Defs( Index(0), ], regions: [ - @0-36, + @0-43, ], space_before: [ Slice(start = 0, length = 0), @@ -19,18 +19,18 @@ Defs( name: @0-4 "Hash", vars: [], }, - loc_has: @5-8 Has, + loc_implements: @5-15 Implements, members: [ AbilityMember { - name: @11-15 SpaceBefore( + name: @18-22 SpaceBefore( "hash", [ Newline, ], ), - typ: @18-36 Function( + typ: @25-43 Function( [ - @18-19 SpaceAfter( + @25-26 SpaceAfter( BoundVariable( "a", ), @@ -39,7 +39,7 @@ Defs( ], ), ], - @33-36 Apply( + @40-43 Apply( "", "U64", [], @@ -51,7 +51,7 @@ Defs( ], value_defs: [], }, - @38-39 SpaceBefore( + @45-46 SpaceBefore( Num( "1", ), diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/ability_multi_line.expr.result-ast b/crates/compiler/test_syntax/tests/snapshots/pass/ability_multi_line.expr.result-ast index 35bbb58f04..9203211925 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/ability_multi_line.expr.result-ast +++ b/crates/compiler/test_syntax/tests/snapshots/pass/ability_multi_line.expr.result-ast @@ -4,7 +4,7 @@ Defs( Index(0), ], regions: [ - @0-45, + @0-52, ], space_before: [ Slice(start = 0, length = 0), @@ -19,22 +19,22 @@ Defs( name: @0-4 "Hash", vars: [], }, - loc_has: @5-8 Has, + loc_implements: @5-15 Implements, members: [ AbilityMember { - name: @11-15 SpaceBefore( + name: @18-22 SpaceBefore( "hash", [ Newline, ], ), - typ: @18-26 Function( + typ: @25-33 Function( [ - @18-19 BoundVariable( + @25-26 BoundVariable( "a", ), ], - @23-26 Apply( + @30-33 Apply( "", "U64", [], @@ -42,19 +42,19 @@ Defs( ), }, AbilityMember { - name: @29-34 SpaceBefore( + name: @36-41 SpaceBefore( "hash2", [ Newline, ], ), - typ: @37-45 Function( + typ: @44-52 Function( [ - @37-38 BoundVariable( + @44-45 BoundVariable( "a", ), ], - @42-45 Apply( + @49-52 Apply( "", "U64", [], @@ -66,7 +66,7 @@ Defs( ], value_defs: [], }, - @47-48 SpaceBefore( + @54-55 SpaceBefore( Num( "1", ), diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/ability_single_line.expr.result-ast b/crates/compiler/test_syntax/tests/snapshots/pass/ability_single_line.expr.result-ast index e450865a13..2847f04b1d 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/ability_single_line.expr.result-ast +++ b/crates/compiler/test_syntax/tests/snapshots/pass/ability_single_line.expr.result-ast @@ -4,7 +4,7 @@ Defs( Index(0), ], regions: [ - @0-37, + @0-55, ], space_before: [ Slice(start = 0, length = 0), @@ -19,28 +19,28 @@ Defs( name: @0-4 "Hash", vars: [], }, - loc_has: @5-8 Has, + loc_implements: @5-15 Implements, members: [ AbilityMember { - name: @9-13 "hash", - typ: @16-37 Where( - @16-24 Function( + name: @16-20 "hash", + typ: @23-55 Where( + @23-31 Function( [ - @16-17 BoundVariable( + @23-24 BoundVariable( "a", ), ], - @21-24 Apply( + @28-31 Apply( "", "U64", [], ), ), [ - @27-37 HasClause { - var: @27-28 "a", + @38-55 ImplementsClause { + var: @38-39 "a", abilities: [ - @33-37 Apply( + @51-55 Apply( "", "Hash", [], @@ -55,7 +55,7 @@ Defs( ], value_defs: [], }, - @39-40 SpaceBefore( + @57-58 SpaceBefore( Num( "1", ), diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/ability_two_in_a_row.expr.result-ast b/crates/compiler/test_syntax/tests/snapshots/pass/ability_two_in_a_row.expr.result-ast index cce2f989e2..d4285ec53d 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/ability_two_in_a_row.expr.result-ast +++ b/crates/compiler/test_syntax/tests/snapshots/pass/ability_two_in_a_row.expr.result-ast @@ -5,8 +5,8 @@ Defs( Index(1), ], regions: [ - @0-33, - @35-68, + @0-51, + @53-104, ], space_before: [ Slice(start = 0, length = 0), @@ -26,27 +26,27 @@ Defs( name: @0-3 "Ab1", vars: [], }, - loc_has: @4-7 Has, + loc_implements: @4-14 Implements, members: [ AbilityMember { - name: @8-11 "ab1", - typ: @14-33 Where( - @14-21 Function( + name: @15-18 "ab1", + typ: @21-51 Where( + @21-28 Function( [ - @14-15 BoundVariable( + @21-22 BoundVariable( "a", ), ], - @19-21 Record { + @26-28 Record { fields: [], ext: None, }, ), [ - @24-33 HasClause { - var: @24-25 "a", + @35-51 ImplementsClause { + var: @35-36 "a", abilities: [ - @30-33 Apply( + @48-51 Apply( "", "Ab1", [], @@ -60,30 +60,30 @@ Defs( }, Ability { header: TypeHeader { - name: @35-38 "Ab2", + name: @53-56 "Ab2", vars: [], }, - loc_has: @39-42 Has, + loc_implements: @57-67 Implements, members: [ AbilityMember { - name: @43-46 "ab2", - typ: @49-68 Where( - @49-56 Function( + name: @68-71 "ab2", + typ: @74-104 Where( + @74-81 Function( [ - @49-50 BoundVariable( + @74-75 BoundVariable( "a", ), ], - @54-56 Record { + @79-81 Record { fields: [], ext: None, }, ), [ - @59-68 HasClause { - var: @59-60 "a", + @88-104 ImplementsClause { + var: @88-89 "a", abilities: [ - @65-68 Apply( + @101-104 Apply( "", "Ab2", [], @@ -98,7 +98,7 @@ Defs( ], value_defs: [], }, - @70-71 SpaceBefore( + @106-107 SpaceBefore( Num( "1", ), diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/opaque_has_abilities.expr.formatted.roc b/crates/compiler/test_syntax/tests/snapshots/pass/opaque_has_abilities.expr.formatted.roc index ce68feedbf..bc1b9655e7 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/opaque_has_abilities.expr.formatted.roc +++ b/crates/compiler/test_syntax/tests/snapshots/pass/opaque_has_abilities.expr.formatted.roc @@ -1,10 +1,10 @@ A := U8 implements [Eq, Hash] A := a where a implements Other - implements [Eq, Hash] + implements [Eq, Hash] A := a where a implements Other - implements [Eq, Hash] + implements [Eq, Hash] A := U8 implements [Eq { eq }, Hash { hash }] @@ -17,8 +17,8 @@ A := U8 implements [Hash, Eq { eq, eq1 }] A := U8 implements [] A := a where a implements Other - implements [Eq { eq }, Hash { hash }] + implements [Eq { eq }, Hash { hash }] A := U8 implements [Eq {}] -0 +0 \ No newline at end of file diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/opaque_has_abilities.expr.result-ast b/crates/compiler/test_syntax/tests/snapshots/pass/opaque_has_abilities.expr.result-ast index b9a9bf4520..6426fd40e6 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/opaque_has_abilities.expr.result-ast +++ b/crates/compiler/test_syntax/tests/snapshots/pass/opaque_has_abilities.expr.result-ast @@ -14,15 +14,15 @@ Defs( ], regions: [ @0-7, - @24-44, - @61-81, - @103-110, - @139-146, - @167-174, - @201-208, - @235-242, - @251-271, - @305-312, + @31-62, + @86-117, + @146-153, + @189-196, + @224-231, + @265-272, + @306-313, + @329-360, + @401-408, ], space_before: [ Slice(start = 0, length = 0), @@ -80,18 +80,18 @@ Defs( [], ), derived: Some( - @12-22 Has( + @19-29 Implements( [ - @13-15 HasAbility { - ability: @13-15 Apply( + @20-22 ImplementsAbility { + ability: @20-22 Apply( "", "Eq", [], ), impls: None, }, - @17-21 HasAbility { - ability: @17-21 Apply( + @24-28 ImplementsAbility { + ability: @24-28 Apply( "", "Hash", [], @@ -104,18 +104,18 @@ Defs( }, Opaque { header: TypeHeader { - name: @24-25 "A", + name: @31-32 "A", vars: [], }, - typ: @29-44 Where( - @29-30 BoundVariable( + typ: @36-62 Where( + @36-37 BoundVariable( "a", ), [ - @33-44 HasClause { - var: @33-34 "a", + @44-62 ImplementsClause { + var: @44-45 "a", abilities: [ - @39-44 Apply( + @57-62 Apply( "", "Other", [], @@ -125,18 +125,18 @@ Defs( ], ), derived: Some( - @49-59 Has( + @74-84 Implements( [ - @50-52 HasAbility { - ability: @50-52 Apply( + @75-77 ImplementsAbility { + ability: @75-77 Apply( "", "Eq", [], ), impls: None, }, - @54-58 HasAbility { - ability: @54-58 Apply( + @79-83 ImplementsAbility { + ability: @79-83 Apply( "", "Hash", [], @@ -149,18 +149,18 @@ Defs( }, Opaque { header: TypeHeader { - name: @61-62 "A", + name: @86-87 "A", vars: [], }, - typ: @66-81 Where( - @66-67 BoundVariable( + typ: @91-117 Where( + @91-92 BoundVariable( "a", ), [ - @70-81 HasClause { - var: @70-71 "a", + @99-117 ImplementsClause { + var: @99-100 "a", abilities: [ - @76-81 Apply( + @112-117 Apply( "", "Other", [], @@ -170,19 +170,19 @@ Defs( ], ), derived: Some( - @91-101 SpaceBefore( - Has( + @134-144 SpaceBefore( + Implements( [ - @92-94 HasAbility { - ability: @92-94 Apply( + @135-137 ImplementsAbility { + ability: @135-137 Apply( "", "Eq", [], ), impls: None, }, - @96-100 HasAbility { - ability: @96-100 Apply( + @139-143 ImplementsAbility { + ability: @139-143 Apply( "", "Hash", [], @@ -199,44 +199,44 @@ Defs( }, Opaque { header: TypeHeader { - name: @103-104 "A", + name: @146-147 "A", vars: [], }, - typ: @108-110 Apply( + typ: @151-153 Apply( "", "U8", [], ), derived: Some( - @115-137 Has( + @165-187 Implements( [ - @116-123 HasAbility { - ability: @116-118 Apply( + @166-173 ImplementsAbility { + ability: @166-168 Apply( "", "Eq", [], ), impls: Some( - @119-123 HasImpls( + @169-173 AbilityImpls( [ - @120-122 LabelOnly( - @120-122 "eq", + @170-172 LabelOnly( + @170-172 "eq", ), ], ), ), }, - @125-136 HasAbility { - ability: @125-129 Apply( + @175-186 ImplementsAbility { + ability: @175-179 Apply( "", "Hash", [], ), impls: Some( - @130-136 HasImpls( + @180-186 AbilityImpls( [ - @131-135 LabelOnly( - @131-135 "hash", + @181-185 LabelOnly( + @181-185 "hash", ), ], ), @@ -248,31 +248,31 @@ Defs( }, Opaque { header: TypeHeader { - name: @139-140 "A", + name: @189-190 "A", vars: [], }, - typ: @144-146 Apply( + typ: @194-196 Apply( "", "U8", [], ), derived: Some( - @151-165 Has( + @208-222 Implements( [ - @152-164 HasAbility { - ability: @152-154 Apply( + @209-221 ImplementsAbility { + ability: @209-211 Apply( "", "Eq", [], ), impls: Some( - @155-164 HasImpls( + @212-221 AbilityImpls( [ - @156-158 LabelOnly( - @156-158 "eq", + @213-215 LabelOnly( + @213-215 "eq", ), - @160-163 LabelOnly( - @160-163 "eq1", + @217-220 LabelOnly( + @217-220 "eq1", ), ], ), @@ -284,38 +284,38 @@ Defs( }, Opaque { header: TypeHeader { - name: @167-168 "A", + name: @224-225 "A", vars: [], }, - typ: @172-174 Apply( + typ: @229-231 Apply( "", "U8", [], ), derived: Some( - @179-199 Has( + @243-263 Implements( [ - @180-192 HasAbility { - ability: @180-182 Apply( + @244-256 ImplementsAbility { + ability: @244-246 Apply( "", "Eq", [], ), impls: Some( - @183-192 HasImpls( + @247-256 AbilityImpls( [ - @184-186 LabelOnly( - @184-186 "eq", + @248-250 LabelOnly( + @248-250 "eq", ), - @188-191 LabelOnly( - @188-191 "eq1", + @252-255 LabelOnly( + @252-255 "eq1", ), ], ), ), }, - @194-198 HasAbility { - ability: @194-198 Apply( + @258-262 ImplementsAbility { + ability: @258-262 Apply( "", "Hash", [], @@ -328,39 +328,39 @@ Defs( }, Opaque { header: TypeHeader { - name: @201-202 "A", + name: @265-266 "A", vars: [], }, - typ: @206-208 Apply( + typ: @270-272 Apply( "", "U8", [], ), derived: Some( - @213-233 Has( + @284-304 Implements( [ - @214-218 HasAbility { - ability: @214-218 Apply( + @285-289 ImplementsAbility { + ability: @285-289 Apply( "", "Hash", [], ), impls: None, }, - @220-232 HasAbility { - ability: @220-222 Apply( + @291-303 ImplementsAbility { + ability: @291-293 Apply( "", "Eq", [], ), impls: Some( - @223-232 HasImpls( + @294-303 AbilityImpls( [ - @224-226 LabelOnly( - @224-226 "eq", + @295-297 LabelOnly( + @295-297 "eq", ), - @228-231 LabelOnly( - @228-231 "eq1", + @299-302 LabelOnly( + @299-302 "eq1", ), ], ), @@ -372,34 +372,34 @@ Defs( }, Opaque { header: TypeHeader { - name: @235-236 "A", + name: @306-307 "A", vars: [], }, - typ: @240-242 Apply( + typ: @311-313 Apply( "", "U8", [], ), derived: Some( - @247-249 Has( + @325-327 Implements( [], ), ), }, Opaque { header: TypeHeader { - name: @251-252 "A", + name: @329-330 "A", vars: [], }, - typ: @256-271 Where( - @256-257 BoundVariable( + typ: @334-360 Where( + @334-335 BoundVariable( "a", ), [ - @260-271 HasClause { - var: @260-261 "a", + @342-360 ImplementsClause { + var: @342-343 "a", abilities: [ - @266-271 Apply( + @355-360 Apply( "", "Other", [], @@ -409,36 +409,36 @@ Defs( ], ), derived: Some( - @281-303 SpaceBefore( - Has( + @377-399 SpaceBefore( + Implements( [ - @282-289 HasAbility { - ability: @282-284 Apply( + @378-385 ImplementsAbility { + ability: @378-380 Apply( "", "Eq", [], ), impls: Some( - @285-289 HasImpls( + @381-385 AbilityImpls( [ - @286-288 LabelOnly( - @286-288 "eq", + @382-384 LabelOnly( + @382-384 "eq", ), ], ), ), }, - @291-302 HasAbility { - ability: @291-295 Apply( + @387-398 ImplementsAbility { + ability: @387-391 Apply( "", "Hash", [], ), impls: Some( - @296-302 HasImpls( + @392-398 AbilityImpls( [ - @297-301 LabelOnly( - @297-301 "hash", + @393-397 LabelOnly( + @393-397 "hash", ), ], ), @@ -454,25 +454,25 @@ Defs( }, Opaque { header: TypeHeader { - name: @305-306 "A", + name: @401-402 "A", vars: [], }, - typ: @310-312 Apply( + typ: @406-408 Apply( "", "U8", [], ), derived: Some( - @317-324 Has( + @420-427 Implements( [ - @318-323 HasAbility { - ability: @318-320 Apply( + @421-426 ImplementsAbility { + ability: @421-423 Apply( "", "Eq", [], ), impls: Some( - @321-323 HasImpls( + @424-426 AbilityImpls( [], ), ), @@ -484,7 +484,7 @@ Defs( ], value_defs: [], }, - @326-327 SpaceBefore( + @429-430 SpaceBefore( Num( "0", ), diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_function.expr.result-ast b/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_function.expr.result-ast index f06dab0871..02f717dfdf 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_function.expr.result-ast +++ b/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_function.expr.result-ast @@ -4,7 +4,7 @@ Defs( Index(2147483648), ], regions: [ - @0-27, + @0-38, ], space_before: [ Slice(start = 0, length = 0), @@ -19,7 +19,7 @@ Defs( @0-1 Identifier( "f", ), - @4-27 Where( + @4-38 Where( @4-16 Function( [ @4-5 BoundVariable( @@ -38,10 +38,10 @@ Defs( ), ), [ - @20-27 HasClause { - var: @20-21 "a", + @24-38 ImplementsClause { + var: @24-25 "a", abilities: [ - @26-27 Apply( + @37-38 Apply( "", "A", [], @@ -53,7 +53,7 @@ Defs( ), ], }, - @29-30 SpaceBefore( + @40-41 SpaceBefore( Var { module_name: "", ident: "f", diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_multiple_bound_abilities.expr.result-ast b/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_multiple_bound_abilities.expr.result-ast index c68f1217e9..fd2cc42467 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_multiple_bound_abilities.expr.result-ast +++ b/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_multiple_bound_abilities.expr.result-ast @@ -5,8 +5,8 @@ Defs( Index(2147483649), ], regions: [ - @0-55, - @57-118, + @0-73, + @75-154, ], space_before: [ Slice(start = 0, length = 0), @@ -26,7 +26,7 @@ Defs( @0-1 Identifier( "f", ), - @4-55 Where( + @4-73 Where( @4-10 Function( [ @4-5 BoundVariable( @@ -38,35 +38,35 @@ Defs( ), ), [ - @13-28 HasClause { - var: @13-14 "a", + @17-39 ImplementsClause { + var: @17-18 "a", abilities: [ - @19-23 Apply( + @30-34 Apply( "", "Hash", [], ), - @26-28 Apply( + @37-39 Apply( "", "Eq", [], ), ], }, - @30-55 HasClause { - var: @30-31 "b", + @41-73 ImplementsClause { + var: @41-42 "b", abilities: [ - @36-38 Apply( + @54-56 Apply( "", "Eq", [], ), - @41-45 Apply( + @59-63 Apply( "", "Hash", [], ), - @48-55 Apply( + @66-73 Apply( "", "Display", [], @@ -77,18 +77,18 @@ Defs( ), ), Annotation( - @57-58 Identifier( + @75-76 Identifier( "f", ), - @61-118 Where( - @61-67 SpaceAfter( + @79-154 Where( + @79-85 SpaceAfter( Function( [ - @61-62 BoundVariable( + @79-80 BoundVariable( "a", ), ], - @66-67 BoundVariable( + @84-85 BoundVariable( "b", ), ), @@ -97,40 +97,40 @@ Defs( ], ), [ - @72-87 HasClause { - var: @72-73 "a", + @94-116 ImplementsClause { + var: @94-95 "a", abilities: [ - @78-82 Apply( + @107-111 Apply( "", "Hash", [], ), - @85-87 Apply( + @114-116 Apply( "", "Eq", [], ), ], }, - @93-118 HasClause { - var: @93-94 SpaceBefore( + @122-154 ImplementsClause { + var: @122-123 SpaceBefore( "b", [ Newline, ], ), abilities: [ - @99-103 Apply( + @135-139 Apply( "", "Hash", [], ), - @106-113 Apply( + @142-149 Apply( "", "Display", [], ), - @116-118 Apply( + @152-154 Apply( "", "Eq", [], @@ -142,7 +142,7 @@ Defs( ), ], }, - @120-121 SpaceBefore( + @156-157 SpaceBefore( Var { module_name: "", ident: "f", diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_multiple_has.expr.result-ast b/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_multiple_has.expr.result-ast index 05f6b2b66d..e252c64ff9 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_multiple_has.expr.result-ast +++ b/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_multiple_has.expr.result-ast @@ -4,7 +4,7 @@ Defs( Index(2147483648), ], regions: [ - @0-48, + @0-73, ], space_before: [ Slice(start = 0, length = 0), @@ -19,7 +19,7 @@ Defs( @0-1 Identifier( "f", ), - @4-48 Where( + @4-73 Where( @4-16 Function( [ @4-5 BoundVariable( @@ -38,30 +38,30 @@ Defs( ), ), [ - @20-27 HasClause { - var: @20-21 "a", + @24-38 ImplementsClause { + var: @24-25 "a", abilities: [ - @26-27 Apply( + @37-38 Apply( "", "A", [], ), ], }, - @29-37 HasClause { - var: @29-30 "b", + @40-55 ImplementsClause { + var: @40-41 "b", abilities: [ - @35-37 Apply( + @53-55 Apply( "", "Eq", [], ), ], }, - @39-48 HasClause { - var: @39-40 "c", + @57-73 ImplementsClause { + var: @57-58 "c", abilities: [ - @45-48 Apply( + @70-73 Apply( "", "Ord", [], @@ -73,7 +73,7 @@ Defs( ), ], }, - @50-51 SpaceBefore( + @75-76 SpaceBefore( Var { module_name: "", ident: "f", diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_multiple_has_across_newlines.expr.formatted.roc b/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_multiple_has_across_newlines.expr.formatted.roc index d5d6c87616..9076cc336a 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_multiple_has_across_newlines.expr.formatted.roc +++ b/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_multiple_has_across_newlines.expr.formatted.roc @@ -1,3 +1,3 @@ -f : a -> (b -> c) where a implements Hash, b has Eq, c implements Ord +f : a -> (b -> c) where a implements Hash, b implements Eq, c implements Ord f \ No newline at end of file diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_multiple_has_across_newlines.expr.result-ast b/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_multiple_has_across_newlines.expr.result-ast index 8ea27a6af7..d29d1e2569 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_multiple_has_across_newlines.expr.result-ast +++ b/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_multiple_has_across_newlines.expr.result-ast @@ -4,7 +4,7 @@ Defs( Index(2147483648), ], regions: [ - @0-67, + @0-92, ], space_before: [ Slice(start = 0, length = 0), @@ -19,7 +19,7 @@ Defs( @0-1 Identifier( "f", ), - @4-67 Where( + @4-92 Where( @4-16 SpaceAfter( Function( [ @@ -43,40 +43,40 @@ Defs( ], ), [ - @24-34 HasClause { - var: @24-25 "a", + @28-45 ImplementsClause { + var: @28-29 "a", abilities: [ - @30-34 Apply( + @41-45 Apply( "", "Hash", [], ), ], }, - @42-50 HasClause { - var: @42-43 SpaceBefore( + @53-68 ImplementsClause { + var: @53-54 SpaceBefore( "b", [ Newline, ], ), abilities: [ - @48-50 Apply( + @66-68 Apply( "", "Eq", [], ), ], }, - @58-67 HasClause { - var: @58-59 SpaceBefore( + @76-92 ImplementsClause { + var: @76-77 SpaceBefore( "c", [ Newline, ], ), abilities: [ - @64-67 Apply( + @89-92 Apply( "", "Ord", [], @@ -88,7 +88,7 @@ Defs( ), ], }, - @69-70 SpaceBefore( + @94-95 SpaceBefore( Var { module_name: "", ident: "f", diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_non_function.expr.result-ast b/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_non_function.expr.result-ast index 862b258bf8..30486cee67 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_non_function.expr.result-ast +++ b/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_non_function.expr.result-ast @@ -4,7 +4,7 @@ Defs( Index(2147483648), ], regions: [ - @0-15, + @0-26, ], space_before: [ Slice(start = 0, length = 0), @@ -19,15 +19,15 @@ Defs( @0-1 Identifier( "f", ), - @4-15 Where( + @4-26 Where( @4-5 BoundVariable( "a", ), [ - @8-15 HasClause { - var: @8-9 "a", + @12-26 ImplementsClause { + var: @12-13 "a", abilities: [ - @14-15 Apply( + @25-26 Apply( "", "A", [], @@ -39,7 +39,7 @@ Defs( ), ], }, - @17-18 SpaceBefore( + @28-29 SpaceBefore( Var { module_name: "", ident: "f", diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_on_newline.expr.result-ast b/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_on_newline.expr.result-ast index ad552875ed..ca97aea704 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_on_newline.expr.result-ast +++ b/crates/compiler/test_syntax/tests/snapshots/pass/where_clause_on_newline.expr.result-ast @@ -4,7 +4,7 @@ Defs( Index(2147483648), ], regions: [ - @0-29, + @0-40, ], space_before: [ Slice(start = 0, length = 0), @@ -19,7 +19,7 @@ Defs( @0-1 Identifier( "f", ), - @4-29 Where( + @4-40 Where( @4-12 SpaceAfter( Function( [ @@ -38,10 +38,10 @@ Defs( ], ), [ - @19-29 HasClause { - var: @19-20 "a", + @23-40 ImplementsClause { + var: @23-24 "a", abilities: [ - @25-29 Apply( + @36-40 Apply( "", "Hash", [], @@ -53,7 +53,7 @@ Defs( ), ], }, - @31-32 SpaceBefore( + @42-43 SpaceBefore( Var { module_name: "", ident: "f", From 79086458950894ef84dc8e53ce782c114a35ed07 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Thu, 10 Aug 2023 22:24:24 -0400 Subject: [PATCH 081/176] Fix more tests --- .../compiler/uitest/tests/ability/smoke/decoder.txt | 4 ++-- .../compiler/uitest/tests/ability/smoke/encoder.txt | 4 ++-- .../uitest/tests/ability/specialize/dec_hash.txt | 2 +- .../polymorphic_lambda_set_specialization.txt | 4 ++-- ...orphic_lambda_set_specialization_bound_output.txt | 4 ++-- ...specialization_branching_over_single_variable.txt | 4 ++-- ...pecialization_varying_over_multiple_variables.txt | 12 ++++++------ ...n_varying_over_multiple_variables_two_results.txt | 12 ++++++------ ...lization_with_deep_specialization_and_capture.txt | 4 ++-- ...c_lambda_set_specialization_with_let_weakened.txt | 4 ++-- ...et_specialization_with_let_weakened_unapplied.txt | 4 ++-- .../specialize/resolve_lambda_set_ability_chain.txt | 4 ++-- ...ve_lambda_set_branches_ability_vs_non_ability.txt | 2 +- .../resolve_lambda_set_branches_same_ability.txt | 2 +- .../resolve_lambda_set_generalized_ability_alias.txt | 2 +- .../resolve_lambda_set_weakened_ability_alias.txt | 2 +- ...esolve_mutually_recursive_ability_lambda_sets.txt | 2 +- ...tually_recursive_ability_lambda_sets_inferred.txt | 2 +- .../resolve_recursive_ability_lambda_set.txt | 2 +- ...o_unspecialized_lambda_sets_in_one_lambda_set.txt | 2 +- ...resolve_unspecialized_lambda_set_behind_alias.txt | 2 +- ...esolve_unspecialized_lambda_set_behind_opaque.txt | 2 +- .../ability/specialize/static_specialization.txt | 2 +- .../instantiate/call_generic_ability_member.txt | 2 +- 24 files changed, 43 insertions(+), 43 deletions(-) diff --git a/crates/compiler/uitest/tests/ability/smoke/decoder.txt b/crates/compiler/uitest/tests/ability/smoke/decoder.txt index 1ceffa6ecc..085d98c493 100644 --- a/crates/compiler/uitest/tests/ability/smoke/decoder.txt +++ b/crates/compiler/uitest/tests/ability/smoke/decoder.txt @@ -4,10 +4,10 @@ MDecodeError : [TooShort, Leftover (List U8)] MDecoder val fmt := List U8, fmt -> { result: Result val MDecodeError, rest: List U8 } where fmt implements MDecoderFormatting -MDecoding has +MDecoding implements decoder : MDecoder val fmt where val implements MDecoding, fmt implements MDecoderFormatting -MDecoderFormatting has +MDecoderFormatting implements u8 : MDecoder U8 fmt where fmt implements MDecoderFormatting decodeWith : List U8, MDecoder val fmt, fmt -> { result: Result val MDecodeError, rest: List U8 } where fmt implements MDecoderFormatting diff --git a/crates/compiler/uitest/tests/ability/smoke/encoder.txt b/crates/compiler/uitest/tests/ability/smoke/encoder.txt index 88dee647b4..12f639bf02 100644 --- a/crates/compiler/uitest/tests/ability/smoke/encoder.txt +++ b/crates/compiler/uitest/tests/ability/smoke/encoder.txt @@ -2,10 +2,10 @@ app "test" provides [myU8Bytes] to "./platform" MEncoder fmt := List U8, fmt -> List U8 where fmt implements Format -MEncoding has +MEncoding implements toEncoder : val -> MEncoder fmt where val implements MEncoding, fmt implements Format -Format has +Format implements u8 : U8 -> MEncoder fmt where fmt implements Format appendWith : List U8, MEncoder fmt, fmt -> List U8 where fmt implements Format diff --git a/crates/compiler/uitest/tests/ability/specialize/dec_hash.txt b/crates/compiler/uitest/tests/ability/specialize/dec_hash.txt index facc13c6ae..a69b5c6722 100644 --- a/crates/compiler/uitest/tests/ability/specialize/dec_hash.txt +++ b/crates/compiler/uitest/tests/ability/specialize/dec_hash.txt @@ -2,4 +2,4 @@ app "test" provides [main] to "./platform" main = \h -> Hash.hash h 1.1dec - # ^^^^^^^^^ Hash#Hash.hash(1): a, Dec -[[Hash.hashDec(17)]]-> a | a has Hasher + # ^^^^^^^^^ Hash#Hash.hash(1): a, Dec -[[Hash.hashDec(17)]]-> a where a implements Hasher diff --git a/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization.txt b/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization.txt index 09856a4f4c..a9b7ba5ceb 100644 --- a/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization.txt +++ b/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization.txt @@ -1,7 +1,7 @@ app "test" provides [main] to "./platform" -F has f : a -> (b -> {}) where a implements F, b implements G -G has g : b -> {} where b implements G +F implements f : a -> (b -> {}) where a implements F, b implements G +G implements g : b -> {} where b implements G Fo := {} implements [F {f}] f = \@Fo {} -> g diff --git a/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_bound_output.txt b/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_bound_output.txt index 7cf1ab95b8..fcedaca3cf 100644 --- a/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_bound_output.txt +++ b/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_bound_output.txt @@ -1,7 +1,7 @@ app "test" provides [main] to "./platform" -F has f : a -> ({} -> b) where a implements F, b implements G -G has g : {} -> b where b implements G +F implements f : a -> ({} -> b) where a implements F, b implements G +G implements g : {} -> b where b implements G Fo := {} implements [F {f}] f = \@Fo {} -> g diff --git a/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_branching_over_single_variable.txt b/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_branching_over_single_variable.txt index fd4340d36a..abc75f0c2e 100644 --- a/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_branching_over_single_variable.txt +++ b/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_branching_over_single_variable.txt @@ -1,7 +1,7 @@ app "test" provides [f] to "./platform" -J has j : j -> (k -> {}) where j implements J, k implements K -K has k : k -> {} where k implements K +J implements j : j -> (k -> {}) where j implements J, k implements K +K implements k : k -> {} where k implements K C := {} implements [J {j: jC}] jC = \@C _ -> k diff --git a/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_varying_over_multiple_variables.txt b/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_varying_over_multiple_variables.txt index 907ffcb1e1..1d3192d532 100644 --- a/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_varying_over_multiple_variables.txt +++ b/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_varying_over_multiple_variables.txt @@ -1,7 +1,7 @@ app "test" provides [main] to "./platform" -J has j : j -> (k -> {}) where j implements J, k implements K -K has k : k -> {} where k implements K +J implements j : j -> (k -> {}) where j implements J, k implements K +K implements k : k -> {} where k implements K C := {} implements [J {j: jC}] jC = \@C _ -> k @@ -19,14 +19,14 @@ f = \flag, a, b -> # ^ j where j implements J # ^ j where j implements J it = -# ^^ k -[[] + j:j(2):2 + j1:j(2):2]-> {} where j implements J, j1 has J, k implements K +# ^^ k -[[] + j:j(2):2 + j1:j(2):2]-> {} where j implements J, j1 implements J, k implements K when flag is A -> j a - # ^ J#j(2): j -[[] + j:j(2):1]-> (k -[[] + j:j(2):2 + j1:j(2):2]-> {}) where j implements J, j1 has J, k implements K + # ^ J#j(2): j -[[] + j:j(2):1]-> (k -[[] + j:j(2):2 + j1:j(2):2]-> {}) where j implements J, j1 implements J, k implements K B -> j b - # ^ J#j(2): j -[[] + j:j(2):1]-> (k -[[] + j1:j(2):2 + j:j(2):2]-> {}) where j implements J, j1 has J, k implements K + # ^ J#j(2): j -[[] + j:j(2):1]-> (k -[[] + j1:j(2):2 + j:j(2):2]-> {}) where j implements J, j1 implements J, k implements K it -# ^^ k -[[] + j:j(2):2 + j1:j(2):2]-> {} where j implements J, j1 has J, k implements K +# ^^ k -[[] + j:j(2):2 + j1:j(2):2]-> {} where j implements J, j1 implements J, k implements K main = (f A (@C {}) (@D {})) (@E {}) # ^ [A, B], C, D -[[f(11)]]-> (E -[[k(10)]]-> {}) diff --git a/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_varying_over_multiple_variables_two_results.txt b/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_varying_over_multiple_variables_two_results.txt index 27f1f4b11d..5cf0feadae 100644 --- a/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_varying_over_multiple_variables_two_results.txt +++ b/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_varying_over_multiple_variables_two_results.txt @@ -1,7 +1,7 @@ app "test" provides [main] to "./platform" -J has j : j -> (k -> {}) where j implements J, k implements K -K has k : k -> {} where k implements K +J implements j : j -> (k -> {}) where j implements J, k implements K +K implements k : k -> {} where k implements K C := {} implements [J {j: jC}] jC = \@C _ -> k @@ -23,14 +23,14 @@ f = \flag, a, b -> # ^ j where j implements J # ^ j where j implements J it = -# ^^ k -[[] + j:j(2):2 + j1:j(2):2]-> {} where j implements J, j1 has J, k implements K +# ^^ k -[[] + j:j(2):2 + j1:j(2):2]-> {} where j implements J, j1 implements J, k implements K when flag is A -> j a - # ^ J#j(2): j -[[] + j:j(2):1]-> (k -[[] + j:j(2):2 + j1:j(2):2]-> {}) where j implements J, j1 has J, k implements K + # ^ J#j(2): j -[[] + j:j(2):1]-> (k -[[] + j:j(2):2 + j1:j(2):2]-> {}) where j implements J, j1 implements J, k implements K B -> j b - # ^ J#j(2): j -[[] + j:j(2):1]-> (k -[[] + j1:j(2):2 + j:j(2):2]-> {}) where j implements J, j1 has J, k implements K + # ^ J#j(2): j -[[] + j:j(2):1]-> (k -[[] + j1:j(2):2 + j:j(2):2]-> {}) where j implements J, j1 implements J, k implements K it -# ^^ k -[[] + j:j(2):2 + j1:j(2):2]-> {} where j implements J, j1 has J, k implements K +# ^^ k -[[] + j:j(2):2 + j1:j(2):2]-> {} where j implements J, j1 implements J, k implements K main = #^^^^{-1} {} diff --git a/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_with_deep_specialization_and_capture.txt b/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_with_deep_specialization_and_capture.txt index 57331a3945..3040768282 100644 --- a/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_with_deep_specialization_and_capture.txt +++ b/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_with_deep_specialization_and_capture.txt @@ -1,7 +1,7 @@ app "test" provides [main] to "./platform" -F has f : a, b -> ({} -> ({} -> {})) where a implements F, b implements G -G has g : b -> ({} -> {}) where b implements G +F implements f : a, b -> ({} -> ({} -> {})) where a implements F, b implements G +G implements g : b -> ({} -> {}) where b implements G Fo := {} implements [F {f}] f = \@Fo {}, b -> \{} -> g b diff --git a/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_with_let_weakened.txt b/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_with_let_weakened.txt index 56dd2e7478..d52dd50232 100644 --- a/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_with_let_weakened.txt +++ b/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_with_let_weakened.txt @@ -1,7 +1,7 @@ app "test" provides [main] to "./platform" -F has f : a -> (b -> {}) where a implements F, b implements G -G has g : b -> {} where b implements G +F implements f : a -> (b -> {}) where a implements F, b implements G +G implements g : b -> {} where b implements G Fo := {} implements [F {f}] f = \@Fo {} -> g diff --git a/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_with_let_weakened_unapplied.txt b/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_with_let_weakened_unapplied.txt index 4cdda67509..6a0e2b3e98 100644 --- a/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_with_let_weakened_unapplied.txt +++ b/crates/compiler/uitest/tests/ability/specialize/polymorphic_lambda_set_specialization_with_let_weakened_unapplied.txt @@ -1,7 +1,7 @@ app "test" provides [main] to "./platform" -F has f : a -> (b -> {}) where a implements F, b implements G -G has g : b -> {} where b implements G +F implements f : a -> (b -> {}) where a implements F, b implements G +G implements g : b -> {} where b implements G Fo := {} implements [F {f}] f = \@Fo {} -> g diff --git a/crates/compiler/uitest/tests/ability/specialize/resolve_lambda_set_ability_chain.txt b/crates/compiler/uitest/tests/ability/specialize/resolve_lambda_set_ability_chain.txt index 6903975585..23705beb8e 100644 --- a/crates/compiler/uitest/tests/ability/specialize/resolve_lambda_set_ability_chain.txt +++ b/crates/compiler/uitest/tests/ability/specialize/resolve_lambda_set_ability_chain.txt @@ -1,7 +1,7 @@ app "test" provides [main] to "./platform" -Id1 has id1 : a -> a where a implements Id1 -Id2 has id2 : a -> a where a implements Id2 +Id1 implements id1 : a -> a where a implements Id1 +Id2 implements id2 : a -> a where a implements Id2 A := {} implements [Id1 {id1}, Id2 {id2}] id1 = \@A {} -> @A {} diff --git a/crates/compiler/uitest/tests/ability/specialize/resolve_lambda_set_branches_ability_vs_non_ability.txt b/crates/compiler/uitest/tests/ability/specialize/resolve_lambda_set_branches_ability_vs_non_ability.txt index 56fb6b5fed..d7c226d7d2 100644 --- a/crates/compiler/uitest/tests/ability/specialize/resolve_lambda_set_branches_ability_vs_non_ability.txt +++ b/crates/compiler/uitest/tests/ability/specialize/resolve_lambda_set_branches_ability_vs_non_ability.txt @@ -1,6 +1,6 @@ app "test" provides [main] to "./platform" -Id has id : a -> a where a implements Id +Id implements id : a -> a where a implements Id A := {} implements [Id {id}] id = \@A {} -> @A {} diff --git a/crates/compiler/uitest/tests/ability/specialize/resolve_lambda_set_branches_same_ability.txt b/crates/compiler/uitest/tests/ability/specialize/resolve_lambda_set_branches_same_ability.txt index 744dc8ed30..ecaef311f1 100644 --- a/crates/compiler/uitest/tests/ability/specialize/resolve_lambda_set_branches_same_ability.txt +++ b/crates/compiler/uitest/tests/ability/specialize/resolve_lambda_set_branches_same_ability.txt @@ -1,6 +1,6 @@ app "test" provides [main] to "./platform" -Id has id : a -> a where a implements Id +Id implements id : a -> a where a implements Id A := {} implements [Id {id}] id = \@A {} -> @A {} diff --git a/crates/compiler/uitest/tests/ability/specialize/resolve_lambda_set_generalized_ability_alias.txt b/crates/compiler/uitest/tests/ability/specialize/resolve_lambda_set_generalized_ability_alias.txt index 76b859f1de..90a6ab84fe 100644 --- a/crates/compiler/uitest/tests/ability/specialize/resolve_lambda_set_generalized_ability_alias.txt +++ b/crates/compiler/uitest/tests/ability/specialize/resolve_lambda_set_generalized_ability_alias.txt @@ -1,6 +1,6 @@ app "test" provides [main] to "./platform" -Id has id : a -> a where a implements Id +Id implements id : a -> a where a implements Id A := {} implements [Id {id}] id = \@A {} -> @A {} diff --git a/crates/compiler/uitest/tests/ability/specialize/resolve_lambda_set_weakened_ability_alias.txt b/crates/compiler/uitest/tests/ability/specialize/resolve_lambda_set_weakened_ability_alias.txt index 6304b2434d..e90cf3ebae 100644 --- a/crates/compiler/uitest/tests/ability/specialize/resolve_lambda_set_weakened_ability_alias.txt +++ b/crates/compiler/uitest/tests/ability/specialize/resolve_lambda_set_weakened_ability_alias.txt @@ -1,6 +1,6 @@ app "test" provides [main] to "./platform" -Id has id : a -> a where a implements Id +Id implements id : a -> a where a implements Id A := {} implements [Id {id}] id = \@A {} -> @A {} diff --git a/crates/compiler/uitest/tests/ability/specialize/resolve_mutually_recursive_ability_lambda_sets.txt b/crates/compiler/uitest/tests/ability/specialize/resolve_mutually_recursive_ability_lambda_sets.txt index 3c6fdc4f49..3daf251c37 100644 --- a/crates/compiler/uitest/tests/ability/specialize/resolve_mutually_recursive_ability_lambda_sets.txt +++ b/crates/compiler/uitest/tests/ability/specialize/resolve_mutually_recursive_ability_lambda_sets.txt @@ -1,6 +1,6 @@ app "test" provides [main] to "./platform" -Bounce has +Bounce implements ping : a -> a where a implements Bounce pong : a -> a where a implements Bounce diff --git a/crates/compiler/uitest/tests/ability/specialize/resolve_mutually_recursive_ability_lambda_sets_inferred.txt b/crates/compiler/uitest/tests/ability/specialize/resolve_mutually_recursive_ability_lambda_sets_inferred.txt index 43a739a59a..560ead417c 100644 --- a/crates/compiler/uitest/tests/ability/specialize/resolve_mutually_recursive_ability_lambda_sets_inferred.txt +++ b/crates/compiler/uitest/tests/ability/specialize/resolve_mutually_recursive_ability_lambda_sets_inferred.txt @@ -1,6 +1,6 @@ app "test" provides [main] to "./platform" -Bounce has +Bounce implements ping : a -> a where a implements Bounce pong : a -> a where a implements Bounce diff --git a/crates/compiler/uitest/tests/ability/specialize/resolve_recursive_ability_lambda_set.txt b/crates/compiler/uitest/tests/ability/specialize/resolve_recursive_ability_lambda_set.txt index a6373f7eaf..993454a1b6 100644 --- a/crates/compiler/uitest/tests/ability/specialize/resolve_recursive_ability_lambda_set.txt +++ b/crates/compiler/uitest/tests/ability/specialize/resolve_recursive_ability_lambda_set.txt @@ -1,6 +1,6 @@ app "test" provides [main] to "./platform" -Diverge has diverge : a -> a where a implements Diverge +Diverge implements diverge : a -> a where a implements Diverge A := {} implements [Diverge {diverge}] diff --git a/crates/compiler/uitest/tests/ability/specialize/resolve_two_unspecialized_lambda_sets_in_one_lambda_set.txt b/crates/compiler/uitest/tests/ability/specialize/resolve_two_unspecialized_lambda_sets_in_one_lambda_set.txt index 8b572588f3..3d6991faa9 100644 --- a/crates/compiler/uitest/tests/ability/specialize/resolve_two_unspecialized_lambda_sets_in_one_lambda_set.txt +++ b/crates/compiler/uitest/tests/ability/specialize/resolve_two_unspecialized_lambda_sets_in_one_lambda_set.txt @@ -3,7 +3,7 @@ app "test" provides [main] to "./platform" Thunk a : {} -> a -Id has id : a -> Thunk a where a implements Id +Id implements id : a -> Thunk a where a implements Id A := {} implements [Id {id}] id = \@A {} -> \{} -> @A {} diff --git a/crates/compiler/uitest/tests/ability/specialize/resolve_unspecialized_lambda_set_behind_alias.txt b/crates/compiler/uitest/tests/ability/specialize/resolve_unspecialized_lambda_set_behind_alias.txt index 5431c48b1a..e8056b8340 100644 --- a/crates/compiler/uitest/tests/ability/specialize/resolve_unspecialized_lambda_set_behind_alias.txt +++ b/crates/compiler/uitest/tests/ability/specialize/resolve_unspecialized_lambda_set_behind_alias.txt @@ -3,7 +3,7 @@ app "test" provides [main] to "./platform" Thunk a : {} -> a -Id has id : a -> Thunk a where a implements Id +Id implements id : a -> Thunk a where a implements Id A := {} implements [Id {id}] id = \@A {} -> \{} -> @A {} diff --git a/crates/compiler/uitest/tests/ability/specialize/resolve_unspecialized_lambda_set_behind_opaque.txt b/crates/compiler/uitest/tests/ability/specialize/resolve_unspecialized_lambda_set_behind_opaque.txt index 25352cdabf..aa7ff8e6a7 100644 --- a/crates/compiler/uitest/tests/ability/specialize/resolve_unspecialized_lambda_set_behind_opaque.txt +++ b/crates/compiler/uitest/tests/ability/specialize/resolve_unspecialized_lambda_set_behind_opaque.txt @@ -3,7 +3,7 @@ app "test" provides [main] to "./platform" Thunk a := {} -> a -Id has id : a -> Thunk a where a implements Id +Id implements id : a -> Thunk a where a implements Id A := {} implements [Id {id}] id = \@A {} -> @Thunk (\{} -> @A {}) diff --git a/crates/compiler/uitest/tests/ability/specialize/static_specialization.txt b/crates/compiler/uitest/tests/ability/specialize/static_specialization.txt index 01dadc8d6f..ab53585cf3 100644 --- a/crates/compiler/uitest/tests/ability/specialize/static_specialization.txt +++ b/crates/compiler/uitest/tests/ability/specialize/static_specialization.txt @@ -1,6 +1,6 @@ app "test" provides [main] to "./platform" -Default has default : {} -> a where a implements Default +Default implements default : {} -> a where a implements Default A := {} implements [Default {default}] default = \{} -> @A {} diff --git a/crates/compiler/uitest/tests/instantiate/call_generic_ability_member.txt b/crates/compiler/uitest/tests/instantiate/call_generic_ability_member.txt index 6e99d30a57..e1cdbcce81 100644 --- a/crates/compiler/uitest/tests/instantiate/call_generic_ability_member.txt +++ b/crates/compiler/uitest/tests/instantiate/call_generic_ability_member.txt @@ -1,6 +1,6 @@ app "test" provides [main] to "./platform" -X has +X implements consume : a -> {} where a implements X O := {} implements [X {consume: consumeO}] From 545c07157d4017430f696f47672b75ef10a7a659 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Thu, 10 Aug 2023 22:33:29 -0400 Subject: [PATCH 082/176] Fix a test --- crates/compiler/load_internal/tests/test_load.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/compiler/load_internal/tests/test_load.rs b/crates/compiler/load_internal/tests/test_load.rs index c52ee7a674..97da9c600f 100644 --- a/crates/compiler/load_internal/tests/test_load.rs +++ b/crates/compiler/load_internal/tests/test_load.rs @@ -940,8 +940,8 @@ fn issue_2863_module_type_does_not_exist() { Did you mean one of these? Decoding - Result Dict + Result DecodeError " ) From 6b9592aefda4d8cc15658d7cd3a41eba691a82e2 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Thu, 10 Aug 2023 22:48:31 -0400 Subject: [PATCH 083/176] Update some insta tests --- crates/reporting/tests/test_reporting.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/reporting/tests/test_reporting.rs b/crates/reporting/tests/test_reporting.rs index 9146b28cb2..bfbd9e6cc0 100644 --- a/crates/reporting/tests/test_reporting.rs +++ b/crates/reporting/tests/test_reporting.rs @@ -658,9 +658,9 @@ mod test_reporting { Did you mean one of these? - Str Frac Num + Str Err "### ); @@ -8201,8 +8201,8 @@ In roc, functions are always written as a lambda, like{} Type Unsigned8 - Unsigned32 Unsigned16 + Unsigned64 ── UNRECOGNIZED NAME ───────────────────────────────────── /code/proj/Main.roc ─ @@ -8215,8 +8215,8 @@ In roc, functions are always written as a lambda, like{} Type Unsigned8 - Unsigned32 Unsigned16 + Unsigned64 "### ); From 2ca3c420a322de7b9673577967fcbe07dfcd0cb6 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Thu, 10 Aug 2023 23:04:02 -0400 Subject: [PATCH 084/176] Delete some trailing spaces --- www/build.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/www/build.sh b/www/build.sh index a5581ce069..ff1b92f33d 100755 --- a/www/build.sh +++ b/www/build.sh @@ -23,7 +23,7 @@ DESIGN_ASSETS_COMMIT="4d949642ebc56ca455cf270b288382788bce5873" DESIGN_ASSETS_TARFILE="roc-lang-design-assets-4d94964.tar.gz" DESIGN_ASSETS_DIR="roc-lang-design-assets-4d94964" -curl -fLJO https://github.com/roc-lang/design-assets/tarball/$DESIGN_ASSETS_COMMIT +curl -fLJO https://github.com/roc-lang/design-assets/tarball/$DESIGN_ASSETS_COMMIT tar -xzf $DESIGN_ASSETS_TARFILE mv $DESIGN_ASSETS_DIR/fonts build/ rm -rf $DESIGN_ASSETS_TARFILE $DESIGN_ASSETS_DIR @@ -71,7 +71,7 @@ if ! [ -v GITHUB_TOKEN_READ_ONLY ]; then roc=target/release/roc else echo 'Fetching latest roc nightly...' - + # get roc release archive curl -fOL https://github.com/roc-lang/roc/releases/download/nightly/roc_nightly-linux_x86_64-latest.tar.gz # extract archive @@ -124,7 +124,7 @@ if [ -v GITHUB_TOKEN_READ_ONLY ]; then curl -v -H "Authorization: $GITHUB_TOKEN_READ_ONLY" -fL -o basic_cli_releases.json "https://api.github.com/repos/roc-lang/basic-cli/releases" DOCS_LINKS=$(cat basic_cli_releases.json | jq -r '.[] | .assets[] | select(.name=="docs.tar.gz") | .browser_download_url') - + rm basic_cli_releases.json VERSION_NUMBERS=$(echo "$DOCS_LINKS" | grep -oP '(?<=/download/)[^/]+(?=/docs.tar.gz)') From 254226f0674e60c78f1f1e2f807c3818c7790979 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Thu, 10 Aug 2023 23:04:10 -0400 Subject: [PATCH 085/176] Use abilities-syntax branch of basic-cli for now --- www/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/build.sh b/www/build.sh index ff1b92f33d..79ed5d67e6 100755 --- a/www/build.sh +++ b/www/build.sh @@ -107,7 +107,7 @@ export ROC_DOCS_URL_ROOT=/packages/basic-cli rm -rf ./downloaded-basic-cli -git clone --depth 1 https://github.com/roc-lang/basic-cli.git downloaded-basic-cli +git clone --branch new-abilities-syntax --depth 1 https://github.com/roc-lang/basic-cli.git downloaded-basic-cli cargo run --bin roc-docs downloaded-basic-cli/src/main.roc From 08e7b52ddcac6e588ea7f20a043c78c281d4faa3 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Thu, 10 Aug 2023 23:34:23 -0400 Subject: [PATCH 086/176] Update mono tests --- .../generated/capture_void_layout_task.txt | 14 ++-- ...lambda_set_productive_nullable_wrapped.txt | 28 ++++---- .../encode_derived_nested_record_string.txt | 68 +++++++++---------- ...encode_derived_record_one_field_string.txt | 26 +++---- ...ncode_derived_record_two_field_strings.txt | 26 +++---- .../generated/encode_derived_string.txt | 4 +- .../encode_derived_tag_one_field_string.txt | 4 +- ...encode_derived_tag_two_payloads_string.txt | 4 +- ..._return_joinpoints_in_union_lambda_set.txt | 4 +- .../test_mono/generated/issue_4749.txt | 22 +++--- ..._4772_weakened_monomorphic_destructure.txt | 14 ++-- ...ist_map_take_capturing_or_noncapturing.txt | 2 +- .../generated/pattern_as_toplevel.txt | 2 +- ...function_and_union_with_inference_hole.txt | 4 +- ..._set_resolved_only_upon_specialization.txt | 8 +-- .../generated/recursively_build_effect.txt | 18 ++--- .../generated/specialize_after_match.txt | 24 +++---- ...not_duplicate_identical_concrete_types.txt | 4 +- 18 files changed, 138 insertions(+), 138 deletions(-) diff --git a/crates/compiler/test_mono/generated/capture_void_layout_task.txt b/crates/compiler/test_mono/generated/capture_void_layout_task.txt index bad0f8684c..a84c395f9e 100644 --- a/crates/compiler/test_mono/generated/capture_void_layout_task.txt +++ b/crates/compiler/test_mono/generated/capture_void_layout_task.txt @@ -45,8 +45,8 @@ procedure Num.22 (#Attr.2, #Attr.3): procedure Test.10 (Test.66, #Attr.12): let Test.9 : {} = UnionAtIndex (Id 0) (Index 0) #Attr.12; - let #Derived_gen.18 : Int1 = lowlevel RefCountIsUnique #Attr.12; - if #Derived_gen.18 then + let #Derived_gen.20 : Int1 = lowlevel RefCountIsUnique #Attr.12; + if #Derived_gen.20 then free #Attr.12; ret Test.9; else @@ -60,7 +60,7 @@ procedure Test.10 (Test.66, #Attr.12): procedure Test.14 (Test.45, #Attr.12): let Test.13 : {{}, []} = UnionAtIndex (Id 1) (Index 1) #Attr.12; let Test.12 : [C {}, C *self {{}, []}] = UnionAtIndex (Id 1) (Index 0) #Attr.12; - joinpoint #Derived_gen.19: + joinpoint #Derived_gen.18: let Test.50 : {} = Struct {}; let Test.51 : U8 = GetTagId Test.12; joinpoint Test.52 Test.15: @@ -87,14 +87,14 @@ procedure Test.14 (Test.45, #Attr.12): jump Test.52 Test.53; in - let #Derived_gen.20 : Int1 = lowlevel RefCountIsUnique #Attr.12; - if #Derived_gen.20 then + let #Derived_gen.19 : Int1 = lowlevel RefCountIsUnique #Attr.12; + if #Derived_gen.19 then free #Attr.12; - jump #Derived_gen.19; + jump #Derived_gen.18; else inc Test.12; decref #Attr.12; - jump #Derived_gen.19; + jump #Derived_gen.18; procedure Test.20 (Test.21, Test.18): let Test.23 : [C {}, C []] = CallByName Test.32 Test.21 Test.18; diff --git a/crates/compiler/test_mono/generated/compose_recursive_lambda_set_productive_nullable_wrapped.txt b/crates/compiler/test_mono/generated/compose_recursive_lambda_set_productive_nullable_wrapped.txt index cbd51527e7..0e96162fcb 100644 --- a/crates/compiler/test_mono/generated/compose_recursive_lambda_set_productive_nullable_wrapped.txt +++ b/crates/compiler/test_mono/generated/compose_recursive_lambda_set_productive_nullable_wrapped.txt @@ -18,7 +18,7 @@ procedure List.66 (#Attr.2, #Attr.3): let List.537 : Int1 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; ret List.537; -procedure List.80 (#Derived_gen.3, #Derived_gen.4, #Derived_gen.5, #Derived_gen.6, #Derived_gen.7): +procedure List.80 (#Derived_gen.0, #Derived_gen.1, #Derived_gen.2, #Derived_gen.3, #Derived_gen.4): joinpoint List.527 List.439 List.440 List.441 List.442 List.443: let List.529 : Int1 = CallByName Num.22 List.442 List.443; if List.529 then @@ -31,7 +31,7 @@ procedure List.80 (#Derived_gen.3, #Derived_gen.4, #Derived_gen.5, #Derived_gen. dec List.439; ret List.440; in - jump List.527 #Derived_gen.3 #Derived_gen.4 #Derived_gen.5 #Derived_gen.6 #Derived_gen.7; + jump List.527 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4; procedure List.93 (List.436, List.437, List.438): let List.525 : U64 = 0i64; @@ -54,11 +54,11 @@ procedure Str.3 (#Attr.2, #Attr.3): procedure Test.1 (Test.5): ret Test.5; -procedure Test.11 (#Derived_gen.10, #Derived_gen.11): +procedure Test.11 (#Derived_gen.8, #Derived_gen.9): joinpoint Test.27 Test.12 #Attr.12: let Test.8 : Int1 = UnionAtIndex (Id 2) (Index 1) #Attr.12; let Test.7 : [, C *self Int1, C *self Int1] = UnionAtIndex (Id 2) (Index 0) #Attr.12; - joinpoint #Derived_gen.14: + joinpoint #Derived_gen.12: joinpoint Test.31 Test.29: let Test.30 : U8 = GetTagId Test.7; switch Test.30: @@ -85,16 +85,16 @@ procedure Test.11 (#Derived_gen.10, #Derived_gen.11): jump Test.31 Test.32; in - let #Derived_gen.15 : Int1 = lowlevel RefCountIsUnique #Attr.12; - if #Derived_gen.15 then + let #Derived_gen.13 : Int1 = lowlevel RefCountIsUnique #Attr.12; + if #Derived_gen.13 then free #Attr.12; - jump #Derived_gen.14; + jump #Derived_gen.12; else inc Test.7; decref #Attr.12; - jump #Derived_gen.14; + jump #Derived_gen.12; in - jump Test.27 #Derived_gen.10 #Derived_gen.11; + jump Test.27 #Derived_gen.8 #Derived_gen.9; procedure Test.2 (Test.13): ret Test.13; @@ -125,7 +125,7 @@ procedure Test.6 (Test.7, Test.8, Test.5): procedure Test.9 (Test.10, #Attr.12): let Test.8 : Int1 = UnionAtIndex (Id 1) (Index 1) #Attr.12; let Test.7 : [, C *self Int1, C *self Int1] = UnionAtIndex (Id 1) (Index 0) #Attr.12; - joinpoint #Derived_gen.12: + joinpoint #Derived_gen.14: let Test.37 : U8 = GetTagId Test.7; joinpoint Test.38 Test.36: switch Test.8: @@ -153,14 +153,14 @@ procedure Test.9 (Test.10, #Attr.12): jump Test.38 Test.39; in - let #Derived_gen.13 : Int1 = lowlevel RefCountIsUnique #Attr.12; - if #Derived_gen.13 then + let #Derived_gen.15 : Int1 = lowlevel RefCountIsUnique #Attr.12; + if #Derived_gen.15 then free #Attr.12; - jump #Derived_gen.12; + jump #Derived_gen.14; else inc Test.7; decref #Attr.12; - jump #Derived_gen.12; + jump #Derived_gen.14; procedure Test.0 (): let Test.41 : Int1 = false; diff --git a/crates/compiler/test_mono/generated/encode_derived_nested_record_string.txt b/crates/compiler/test_mono/generated/encode_derived_nested_record_string.txt index da00523cb6..b838ca257f 100644 --- a/crates/compiler/test_mono/generated/encode_derived_nested_record_string.txt +++ b/crates/compiler/test_mono/generated/encode_derived_nested_record_string.txt @@ -235,7 +235,23 @@ procedure List.8 (#Attr.2, #Attr.3): let List.668 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; ret List.668; -procedure List.80 (#Derived_gen.30, #Derived_gen.31, #Derived_gen.32, #Derived_gen.33, #Derived_gen.34): +procedure List.80 (#Derived_gen.20, #Derived_gen.21, #Derived_gen.22, #Derived_gen.23, #Derived_gen.24): + joinpoint List.556 List.439 List.440 List.441 List.442 List.443: + let List.558 : Int1 = CallByName Num.22 List.442 List.443; + if List.558 then + let List.565 : {Str, Str} = CallByName List.66 List.439 List.442; + inc List.565; + let List.559 : {List U8, U64} = CallByName List.145 List.440 List.565 List.441; + let List.562 : U64 = 1i64; + let List.561 : U64 = CallByName Num.19 List.442 List.562; + jump List.556 List.439 List.559 List.441 List.561 List.443; + else + dec List.439; + ret List.440; + in + jump List.556 #Derived_gen.20 #Derived_gen.21 #Derived_gen.22 #Derived_gen.23 #Derived_gen.24; + +procedure List.80 (#Derived_gen.28, #Derived_gen.29, #Derived_gen.30, #Derived_gen.31, #Derived_gen.32): joinpoint List.715 List.439 List.440 List.441 List.442 List.443: let List.717 : Int1 = CallByName Num.22 List.442 List.443; if List.717 then @@ -259,9 +275,9 @@ procedure List.80 (#Derived_gen.30, #Derived_gen.31, #Derived_gen.32, #Derived_g let List.716 : [C {U64, Int1}, C {U64, Int1}] = TagId(1) List.440; ret List.716; in - jump List.715 #Derived_gen.30 #Derived_gen.31 #Derived_gen.32 #Derived_gen.33 #Derived_gen.34; + jump List.715 #Derived_gen.28 #Derived_gen.29 #Derived_gen.30 #Derived_gen.31 #Derived_gen.32; -procedure List.80 (#Derived_gen.36, #Derived_gen.37, #Derived_gen.38, #Derived_gen.39, #Derived_gen.40): +procedure List.80 (#Derived_gen.43, #Derived_gen.44, #Derived_gen.45, #Derived_gen.46, #Derived_gen.47): joinpoint List.644 List.439 List.440 List.441 List.442 List.443: let List.646 : Int1 = CallByName Num.22 List.442 List.443; if List.646 then @@ -274,9 +290,9 @@ procedure List.80 (#Derived_gen.36, #Derived_gen.37, #Derived_gen.38, #Derived_g dec List.439; ret List.440; in - jump List.644 #Derived_gen.36 #Derived_gen.37 #Derived_gen.38 #Derived_gen.39 #Derived_gen.40; + jump List.644 #Derived_gen.43 #Derived_gen.44 #Derived_gen.45 #Derived_gen.46 #Derived_gen.47; -procedure List.80 (#Derived_gen.41, #Derived_gen.42, #Derived_gen.43, #Derived_gen.44, #Derived_gen.45): +procedure List.80 (#Derived_gen.48, #Derived_gen.49, #Derived_gen.50, #Derived_gen.51, #Derived_gen.52): joinpoint List.624 List.439 List.440 List.441 List.442 List.443: let List.626 : Int1 = CallByName Num.22 List.442 List.443; if List.626 then @@ -290,23 +306,7 @@ procedure List.80 (#Derived_gen.41, #Derived_gen.42, #Derived_gen.43, #Derived_g dec List.439; ret List.440; in - jump List.624 #Derived_gen.41 #Derived_gen.42 #Derived_gen.43 #Derived_gen.44 #Derived_gen.45; - -procedure List.80 (#Derived_gen.52, #Derived_gen.53, #Derived_gen.54, #Derived_gen.55, #Derived_gen.56): - joinpoint List.556 List.439 List.440 List.441 List.442 List.443: - let List.558 : Int1 = CallByName Num.22 List.442 List.443; - if List.558 then - let List.565 : {Str, Str} = CallByName List.66 List.439 List.442; - inc List.565; - let List.559 : {List U8, U64} = CallByName List.145 List.440 List.565 List.441; - let List.562 : U64 = 1i64; - let List.561 : U64 = CallByName Num.19 List.442 List.562; - jump List.556 List.439 List.559 List.441 List.561 List.443; - else - dec List.439; - ret List.440; - in - jump List.556 #Derived_gen.52 #Derived_gen.53 #Derived_gen.54 #Derived_gen.55 #Derived_gen.56; + jump List.624 #Derived_gen.48 #Derived_gen.49 #Derived_gen.50 #Derived_gen.51 #Derived_gen.52; procedure List.93 (List.436, List.437, List.438): let List.554 : U64 = 0i64; @@ -388,8 +388,8 @@ procedure Str.9 (Str.79): else let Str.291 : U8 = StructAtIndex 3 Str.80; let Str.292 : U64 = StructAtIndex 0 Str.80; - let #Derived_gen.57 : Str = StructAtIndex 1 Str.80; - dec #Derived_gen.57; + let #Derived_gen.58 : Str = StructAtIndex 1 Str.80; + dec #Derived_gen.58; let Str.290 : {U64, U8} = Struct {Str.292, Str.291}; let Str.289 : [C {U64, U8}, C Str] = TagId(0) Str.290; ret Str.289; @@ -1019,8 +1019,8 @@ procedure TotallyNotJson.102 (TotallyNotJson.852): else let TotallyNotJson.1691 : Str = "Z"; let TotallyNotJson.1692 : Int1 = lowlevel Eq TotallyNotJson.1691 TotallyNotJson.852; - dec TotallyNotJson.852; dec TotallyNotJson.1691; + dec TotallyNotJson.852; if TotallyNotJson.1692 then let TotallyNotJson.1689 : Int1 = CallByName Bool.2; ret TotallyNotJson.1689; @@ -1331,14 +1331,14 @@ procedure TotallyNotJson.82 (TotallyNotJson.802, TotallyNotJson.803): procedure TotallyNotJson.832 (TotallyNotJson.1493): let TotallyNotJson.1845 : List Str = StructAtIndex 1 TotallyNotJson.1493; - let #Derived_gen.58 : List Str = StructAtIndex 0 TotallyNotJson.1493; - dec #Derived_gen.58; + let #Derived_gen.59 : List Str = StructAtIndex 0 TotallyNotJson.1493; + dec #Derived_gen.59; ret TotallyNotJson.1845; procedure TotallyNotJson.840 (TotallyNotJson.1214): let TotallyNotJson.1566 : List Str = StructAtIndex 1 TotallyNotJson.1214; - let #Derived_gen.59 : List Str = StructAtIndex 0 TotallyNotJson.1214; - dec #Derived_gen.59; + let #Derived_gen.57 : List Str = StructAtIndex 0 TotallyNotJson.1214; + dec #Derived_gen.57; ret TotallyNotJson.1566; procedure TotallyNotJson.87 (TotallyNotJson.809): @@ -1389,11 +1389,11 @@ procedure TotallyNotJson.95 (TotallyNotJson.829): let TotallyNotJson.1840 : List Str = CallByName TotallyNotJson.832 TotallyNotJson.1842; let TotallyNotJson.1841 : Str = ""; let TotallyNotJson.1839 : Str = CallByName Str.4 TotallyNotJson.1840 TotallyNotJson.1841; - dec TotallyNotJson.1840; dec TotallyNotJson.1841; + dec TotallyNotJson.1840; ret TotallyNotJson.1839; -procedure TotallyNotJson.96 (#Derived_gen.29): +procedure TotallyNotJson.96 (#Derived_gen.56): joinpoint TotallyNotJson.1847 TotallyNotJson.1168: let TotallyNotJson.834 : List Str = StructAtIndex 0 TotallyNotJson.1168; let TotallyNotJson.833 : List Str = StructAtIndex 1 TotallyNotJson.1168; @@ -1429,7 +1429,7 @@ procedure TotallyNotJson.96 (#Derived_gen.29): let TotallyNotJson.1848 : {List Str, List Str} = Struct {TotallyNotJson.834, TotallyNotJson.833}; ret TotallyNotJson.1848; in - jump TotallyNotJson.1847 #Derived_gen.29; + jump TotallyNotJson.1847 #Derived_gen.56; procedure TotallyNotJson.97 (TotallyNotJson.837): let TotallyNotJson.838 : List Str = CallByName Str.55 TotallyNotJson.837; @@ -1446,7 +1446,7 @@ procedure TotallyNotJson.97 (TotallyNotJson.837): dec TotallyNotJson.1562; ret TotallyNotJson.1560; -procedure TotallyNotJson.98 (#Derived_gen.35): +procedure TotallyNotJson.98 (#Derived_gen.36): joinpoint TotallyNotJson.1568 TotallyNotJson.1169: let TotallyNotJson.842 : List Str = StructAtIndex 0 TotallyNotJson.1169; let TotallyNotJson.841 : List Str = StructAtIndex 1 TotallyNotJson.1169; @@ -1482,7 +1482,7 @@ procedure TotallyNotJson.98 (#Derived_gen.35): let TotallyNotJson.1569 : {List Str, List Str} = Struct {TotallyNotJson.842, TotallyNotJson.841}; ret TotallyNotJson.1569; in - jump TotallyNotJson.1568 #Derived_gen.35; + jump TotallyNotJson.1568 #Derived_gen.36; procedure Test.0 (): let Test.12 : Str = "bar"; diff --git a/crates/compiler/test_mono/generated/encode_derived_record_one_field_string.txt b/crates/compiler/test_mono/generated/encode_derived_record_one_field_string.txt index 81f7d70c33..b321fb63dc 100644 --- a/crates/compiler/test_mono/generated/encode_derived_record_one_field_string.txt +++ b/crates/compiler/test_mono/generated/encode_derived_record_one_field_string.txt @@ -192,7 +192,7 @@ procedure List.8 (#Attr.2, #Attr.3): let List.600 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; ret List.600; -procedure List.80 (#Derived_gen.10, #Derived_gen.11, #Derived_gen.12, #Derived_gen.13, #Derived_gen.14): +procedure List.80 (#Derived_gen.11, #Derived_gen.12, #Derived_gen.13, #Derived_gen.14, #Derived_gen.15): joinpoint List.647 List.439 List.440 List.441 List.442 List.443: let List.649 : Int1 = CallByName Num.22 List.442 List.443; if List.649 then @@ -216,9 +216,9 @@ procedure List.80 (#Derived_gen.10, #Derived_gen.11, #Derived_gen.12, #Derived_g let List.648 : [C {U64, Int1}, C {U64, Int1}] = TagId(1) List.440; ret List.648; in - jump List.647 #Derived_gen.10 #Derived_gen.11 #Derived_gen.12 #Derived_gen.13 #Derived_gen.14; + jump List.647 #Derived_gen.11 #Derived_gen.12 #Derived_gen.13 #Derived_gen.14 #Derived_gen.15; -procedure List.80 (#Derived_gen.18, #Derived_gen.19, #Derived_gen.20, #Derived_gen.21, #Derived_gen.22): +procedure List.80 (#Derived_gen.16, #Derived_gen.17, #Derived_gen.18, #Derived_gen.19, #Derived_gen.20): joinpoint List.576 List.439 List.440 List.441 List.442 List.443: let List.578 : Int1 = CallByName Num.22 List.442 List.443; if List.578 then @@ -231,7 +231,7 @@ procedure List.80 (#Derived_gen.18, #Derived_gen.19, #Derived_gen.20, #Derived_g dec List.439; ret List.440; in - jump List.576 #Derived_gen.18 #Derived_gen.19 #Derived_gen.20 #Derived_gen.21 #Derived_gen.22; + jump List.576 #Derived_gen.16 #Derived_gen.17 #Derived_gen.18 #Derived_gen.19 #Derived_gen.20; procedure List.80 (#Derived_gen.31, #Derived_gen.32, #Derived_gen.33, #Derived_gen.34, #Derived_gen.35): joinpoint List.556 List.439 List.440 List.441 List.442 List.443: @@ -1215,14 +1215,14 @@ procedure TotallyNotJson.82 (TotallyNotJson.802, TotallyNotJson.803): procedure TotallyNotJson.832 (TotallyNotJson.1493): let TotallyNotJson.1494 : List Str = StructAtIndex 1 TotallyNotJson.1493; - let #Derived_gen.38 : List Str = StructAtIndex 0 TotallyNotJson.1493; - dec #Derived_gen.38; + let #Derived_gen.37 : List Str = StructAtIndex 0 TotallyNotJson.1493; + dec #Derived_gen.37; ret TotallyNotJson.1494; procedure TotallyNotJson.840 (TotallyNotJson.1214): let TotallyNotJson.1215 : List Str = StructAtIndex 1 TotallyNotJson.1214; - let #Derived_gen.37 : List Str = StructAtIndex 0 TotallyNotJson.1214; - dec #Derived_gen.37; + let #Derived_gen.38 : List Str = StructAtIndex 0 TotallyNotJson.1214; + dec #Derived_gen.38; ret TotallyNotJson.1215; procedure TotallyNotJson.87 (TotallyNotJson.809): @@ -1255,8 +1255,8 @@ procedure TotallyNotJson.94 (TotallyNotJson.824): let TotallyNotJson.1400 : List Str = CallByName List.13 TotallyNotJson.828 TotallyNotJson.827; let TotallyNotJson.1401 : Str = ""; let TotallyNotJson.1399 : Str = CallByName Str.4 TotallyNotJson.1400 TotallyNotJson.1401; - dec TotallyNotJson.1400; dec TotallyNotJson.1401; + dec TotallyNotJson.1400; ret TotallyNotJson.1399; else dec TotallyNotJson.825; @@ -1277,7 +1277,7 @@ procedure TotallyNotJson.95 (TotallyNotJson.829): dec TotallyNotJson.1489; ret TotallyNotJson.1488; -procedure TotallyNotJson.96 (#Derived_gen.26): +procedure TotallyNotJson.96 (#Derived_gen.30): joinpoint TotallyNotJson.1496 TotallyNotJson.1168: let TotallyNotJson.834 : List Str = StructAtIndex 0 TotallyNotJson.1168; let TotallyNotJson.833 : List Str = StructAtIndex 1 TotallyNotJson.1168; @@ -1313,7 +1313,7 @@ procedure TotallyNotJson.96 (#Derived_gen.26): let TotallyNotJson.1497 : {List Str, List Str} = Struct {TotallyNotJson.834, TotallyNotJson.833}; ret TotallyNotJson.1497; in - jump TotallyNotJson.1496 #Derived_gen.26; + jump TotallyNotJson.1496 #Derived_gen.30; procedure TotallyNotJson.97 (TotallyNotJson.837): let TotallyNotJson.838 : List Str = CallByName Str.55 TotallyNotJson.837; @@ -1330,7 +1330,7 @@ procedure TotallyNotJson.97 (TotallyNotJson.837): dec TotallyNotJson.1210; ret TotallyNotJson.1209; -procedure TotallyNotJson.98 (#Derived_gen.30): +procedure TotallyNotJson.98 (#Derived_gen.10): joinpoint TotallyNotJson.1217 TotallyNotJson.1169: let TotallyNotJson.842 : List Str = StructAtIndex 0 TotallyNotJson.1169; let TotallyNotJson.841 : List Str = StructAtIndex 1 TotallyNotJson.1169; @@ -1366,7 +1366,7 @@ procedure TotallyNotJson.98 (#Derived_gen.30): let TotallyNotJson.1218 : {List Str, List Str} = Struct {TotallyNotJson.842, TotallyNotJson.841}; ret TotallyNotJson.1218; in - jump TotallyNotJson.1217 #Derived_gen.30; + jump TotallyNotJson.1217 #Derived_gen.10; procedure Test.0 (): let Test.11 : Str = "foo"; diff --git a/crates/compiler/test_mono/generated/encode_derived_record_two_field_strings.txt b/crates/compiler/test_mono/generated/encode_derived_record_two_field_strings.txt index 810705ef6f..25f3b04045 100644 --- a/crates/compiler/test_mono/generated/encode_derived_record_two_field_strings.txt +++ b/crates/compiler/test_mono/generated/encode_derived_record_two_field_strings.txt @@ -199,7 +199,7 @@ procedure List.8 (#Attr.2, #Attr.3): let List.600 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; ret List.600; -procedure List.80 (#Derived_gen.14, #Derived_gen.15, #Derived_gen.16, #Derived_gen.17, #Derived_gen.18): +procedure List.80 (#Derived_gen.15, #Derived_gen.16, #Derived_gen.17, #Derived_gen.18, #Derived_gen.19): joinpoint List.647 List.439 List.440 List.441 List.442 List.443: let List.649 : Int1 = CallByName Num.22 List.442 List.443; if List.649 then @@ -223,9 +223,9 @@ procedure List.80 (#Derived_gen.14, #Derived_gen.15, #Derived_gen.16, #Derived_g let List.648 : [C {U64, Int1}, C {U64, Int1}] = TagId(1) List.440; ret List.648; in - jump List.647 #Derived_gen.14 #Derived_gen.15 #Derived_gen.16 #Derived_gen.17 #Derived_gen.18; + jump List.647 #Derived_gen.15 #Derived_gen.16 #Derived_gen.17 #Derived_gen.18 #Derived_gen.19; -procedure List.80 (#Derived_gen.22, #Derived_gen.23, #Derived_gen.24, #Derived_gen.25, #Derived_gen.26): +procedure List.80 (#Derived_gen.20, #Derived_gen.21, #Derived_gen.22, #Derived_gen.23, #Derived_gen.24): joinpoint List.576 List.439 List.440 List.441 List.442 List.443: let List.578 : Int1 = CallByName Num.22 List.442 List.443; if List.578 then @@ -238,7 +238,7 @@ procedure List.80 (#Derived_gen.22, #Derived_gen.23, #Derived_gen.24, #Derived_g dec List.439; ret List.440; in - jump List.576 #Derived_gen.22 #Derived_gen.23 #Derived_gen.24 #Derived_gen.25 #Derived_gen.26; + jump List.576 #Derived_gen.20 #Derived_gen.21 #Derived_gen.22 #Derived_gen.23 #Derived_gen.24; procedure List.80 (#Derived_gen.35, #Derived_gen.36, #Derived_gen.37, #Derived_gen.38, #Derived_gen.39): joinpoint List.556 List.439 List.440 List.441 List.442 List.443: @@ -1222,14 +1222,14 @@ procedure TotallyNotJson.82 (TotallyNotJson.802, TotallyNotJson.803): procedure TotallyNotJson.832 (TotallyNotJson.1493): let TotallyNotJson.1494 : List Str = StructAtIndex 1 TotallyNotJson.1493; - let #Derived_gen.42 : List Str = StructAtIndex 0 TotallyNotJson.1493; - dec #Derived_gen.42; + let #Derived_gen.41 : List Str = StructAtIndex 0 TotallyNotJson.1493; + dec #Derived_gen.41; ret TotallyNotJson.1494; procedure TotallyNotJson.840 (TotallyNotJson.1214): let TotallyNotJson.1215 : List Str = StructAtIndex 1 TotallyNotJson.1214; - let #Derived_gen.41 : List Str = StructAtIndex 0 TotallyNotJson.1214; - dec #Derived_gen.41; + let #Derived_gen.42 : List Str = StructAtIndex 0 TotallyNotJson.1214; + dec #Derived_gen.42; ret TotallyNotJson.1215; procedure TotallyNotJson.87 (TotallyNotJson.809): @@ -1262,8 +1262,8 @@ procedure TotallyNotJson.94 (TotallyNotJson.824): let TotallyNotJson.1400 : List Str = CallByName List.13 TotallyNotJson.828 TotallyNotJson.827; let TotallyNotJson.1401 : Str = ""; let TotallyNotJson.1399 : Str = CallByName Str.4 TotallyNotJson.1400 TotallyNotJson.1401; - dec TotallyNotJson.1400; dec TotallyNotJson.1401; + dec TotallyNotJson.1400; ret TotallyNotJson.1399; else dec TotallyNotJson.825; @@ -1284,7 +1284,7 @@ procedure TotallyNotJson.95 (TotallyNotJson.829): dec TotallyNotJson.1489; ret TotallyNotJson.1488; -procedure TotallyNotJson.96 (#Derived_gen.30): +procedure TotallyNotJson.96 (#Derived_gen.34): joinpoint TotallyNotJson.1496 TotallyNotJson.1168: let TotallyNotJson.834 : List Str = StructAtIndex 0 TotallyNotJson.1168; let TotallyNotJson.833 : List Str = StructAtIndex 1 TotallyNotJson.1168; @@ -1320,7 +1320,7 @@ procedure TotallyNotJson.96 (#Derived_gen.30): let TotallyNotJson.1497 : {List Str, List Str} = Struct {TotallyNotJson.834, TotallyNotJson.833}; ret TotallyNotJson.1497; in - jump TotallyNotJson.1496 #Derived_gen.30; + jump TotallyNotJson.1496 #Derived_gen.34; procedure TotallyNotJson.97 (TotallyNotJson.837): let TotallyNotJson.838 : List Str = CallByName Str.55 TotallyNotJson.837; @@ -1337,7 +1337,7 @@ procedure TotallyNotJson.97 (TotallyNotJson.837): dec TotallyNotJson.1210; ret TotallyNotJson.1209; -procedure TotallyNotJson.98 (#Derived_gen.34): +procedure TotallyNotJson.98 (#Derived_gen.14): joinpoint TotallyNotJson.1217 TotallyNotJson.1169: let TotallyNotJson.842 : List Str = StructAtIndex 0 TotallyNotJson.1169; let TotallyNotJson.841 : List Str = StructAtIndex 1 TotallyNotJson.1169; @@ -1373,7 +1373,7 @@ procedure TotallyNotJson.98 (#Derived_gen.34): let TotallyNotJson.1218 : {List Str, List Str} = Struct {TotallyNotJson.842, TotallyNotJson.841}; ret TotallyNotJson.1218; in - jump TotallyNotJson.1217 #Derived_gen.34; + jump TotallyNotJson.1217 #Derived_gen.14; procedure Test.0 (): let Test.11 : Str = "foo"; diff --git a/crates/compiler/test_mono/generated/encode_derived_string.txt b/crates/compiler/test_mono/generated/encode_derived_string.txt index 3d42e396c8..be6f580b91 100644 --- a/crates/compiler/test_mono/generated/encode_derived_string.txt +++ b/crates/compiler/test_mono/generated/encode_derived_string.txt @@ -88,7 +88,7 @@ procedure List.8 (#Attr.2, #Attr.3): let List.529 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; ret List.529; -procedure List.80 (#Derived_gen.0, #Derived_gen.1, #Derived_gen.2, #Derived_gen.3, #Derived_gen.4): +procedure List.80 (#Derived_gen.3, #Derived_gen.4, #Derived_gen.5, #Derived_gen.6, #Derived_gen.7): joinpoint List.540 List.439 List.440 List.441 List.442 List.443: let List.542 : Int1 = CallByName Num.22 List.442 List.443; if List.542 then @@ -101,7 +101,7 @@ procedure List.80 (#Derived_gen.0, #Derived_gen.1, #Derived_gen.2, #Derived_gen. dec List.439; ret List.440; in - jump List.540 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4; + jump List.540 #Derived_gen.3 #Derived_gen.4 #Derived_gen.5 #Derived_gen.6 #Derived_gen.7; procedure List.80 (#Derived_gen.8, #Derived_gen.9, #Derived_gen.10, #Derived_gen.11, #Derived_gen.12): joinpoint List.578 List.439 List.440 List.441 List.442 List.443: diff --git a/crates/compiler/test_mono/generated/encode_derived_tag_one_field_string.txt b/crates/compiler/test_mono/generated/encode_derived_tag_one_field_string.txt index d89fbb2e38..6a54186716 100644 --- a/crates/compiler/test_mono/generated/encode_derived_tag_one_field_string.txt +++ b/crates/compiler/test_mono/generated/encode_derived_tag_one_field_string.txt @@ -173,7 +173,7 @@ procedure List.80 (#Derived_gen.16, #Derived_gen.17, #Derived_gen.18, #Derived_g in jump List.627 #Derived_gen.16 #Derived_gen.17 #Derived_gen.18 #Derived_gen.19 #Derived_gen.20; -procedure List.80 (#Derived_gen.24, #Derived_gen.25, #Derived_gen.26, #Derived_gen.27, #Derived_gen.28): +procedure List.80 (#Derived_gen.21, #Derived_gen.22, #Derived_gen.23, #Derived_gen.24, #Derived_gen.25): joinpoint List.574 List.439 List.440 List.441 List.442 List.443: let List.576 : Int1 = CallByName Num.22 List.442 List.443; if List.576 then @@ -186,7 +186,7 @@ procedure List.80 (#Derived_gen.24, #Derived_gen.25, #Derived_gen.26, #Derived_g dec List.439; ret List.440; in - jump List.574 #Derived_gen.24 #Derived_gen.25 #Derived_gen.26 #Derived_gen.27 #Derived_gen.28; + jump List.574 #Derived_gen.21 #Derived_gen.22 #Derived_gen.23 #Derived_gen.24 #Derived_gen.25; procedure List.80 (#Derived_gen.29, #Derived_gen.30, #Derived_gen.31, #Derived_gen.32, #Derived_gen.33): joinpoint List.554 List.439 List.440 List.441 List.442 List.443: diff --git a/crates/compiler/test_mono/generated/encode_derived_tag_two_payloads_string.txt b/crates/compiler/test_mono/generated/encode_derived_tag_two_payloads_string.txt index 93524dfb6b..cddc9bc474 100644 --- a/crates/compiler/test_mono/generated/encode_derived_tag_two_payloads_string.txt +++ b/crates/compiler/test_mono/generated/encode_derived_tag_two_payloads_string.txt @@ -150,7 +150,7 @@ procedure List.8 (#Attr.2, #Attr.3): let List.599 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; ret List.599; -procedure List.80 (#Derived_gen.11, #Derived_gen.12, #Derived_gen.13, #Derived_gen.14, #Derived_gen.15): +procedure List.80 (#Derived_gen.14, #Derived_gen.15, #Derived_gen.16, #Derived_gen.17, #Derived_gen.18): joinpoint List.627 List.439 List.440 List.441 List.442 List.443: let List.629 : Int1 = CallByName Num.22 List.442 List.443; if List.629 then @@ -174,7 +174,7 @@ procedure List.80 (#Derived_gen.11, #Derived_gen.12, #Derived_gen.13, #Derived_g let List.628 : [C {U64, Int1}, C {U64, Int1}] = TagId(1) List.440; ret List.628; in - jump List.627 #Derived_gen.11 #Derived_gen.12 #Derived_gen.13 #Derived_gen.14 #Derived_gen.15; + jump List.627 #Derived_gen.14 #Derived_gen.15 #Derived_gen.16 #Derived_gen.17 #Derived_gen.18; procedure List.80 (#Derived_gen.19, #Derived_gen.20, #Derived_gen.21, #Derived_gen.22, #Derived_gen.23): joinpoint List.554 List.439 List.440 List.441 List.442 List.443: diff --git a/crates/compiler/test_mono/generated/inline_return_joinpoints_in_union_lambda_set.txt b/crates/compiler/test_mono/generated/inline_return_joinpoints_in_union_lambda_set.txt index 6ab49274c5..750e2fa29d 100644 --- a/crates/compiler/test_mono/generated/inline_return_joinpoints_in_union_lambda_set.txt +++ b/crates/compiler/test_mono/generated/inline_return_joinpoints_in_union_lambda_set.txt @@ -17,7 +17,7 @@ procedure Test.4 (Test.5, #Attr.12): let Test.16 : I64 = CallByName Num.19 Test.5 Test.1; ret Test.16; -procedure Test.0 (#Derived_gen.0): +procedure Test.0 (#Derived_gen.2): joinpoint Test.7 Test.1: let Test.20 : I64 = 1i64; let Test.9 : I64 = CallByName Num.19 Test.1 Test.20; @@ -33,4 +33,4 @@ procedure Test.0 (#Derived_gen.0): ret Test.8; in - jump Test.7 #Derived_gen.0; + jump Test.7 #Derived_gen.2; diff --git a/crates/compiler/test_mono/generated/issue_4749.txt b/crates/compiler/test_mono/generated/issue_4749.txt index 61797ec653..962d50a255 100644 --- a/crates/compiler/test_mono/generated/issue_4749.txt +++ b/crates/compiler/test_mono/generated/issue_4749.txt @@ -163,7 +163,7 @@ procedure List.8 (#Attr.2, #Attr.3): let List.547 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; ret List.547; -procedure List.80 (#Derived_gen.0, #Derived_gen.1, #Derived_gen.2, #Derived_gen.3, #Derived_gen.4): +procedure List.80 (#Derived_gen.1, #Derived_gen.2, #Derived_gen.3, #Derived_gen.4, #Derived_gen.5): joinpoint List.599 List.439 List.440 List.441 List.442 List.443: let List.601 : Int1 = CallByName Num.22 List.442 List.443; if List.601 then @@ -187,7 +187,7 @@ procedure List.80 (#Derived_gen.0, #Derived_gen.1, #Derived_gen.2, #Derived_gen. let List.600 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = TagId(1) List.440; ret List.600; in - jump List.599 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4; + jump List.599 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4 #Derived_gen.5; procedure List.93 (List.436, List.437, List.438): let List.597 : U64 = 0i64; @@ -247,8 +247,8 @@ procedure Str.9 (Str.79): else let Str.291 : U8 = StructAtIndex 3 Str.80; let Str.292 : U64 = StructAtIndex 0 Str.80; - let #Derived_gen.6 : Str = StructAtIndex 1 Str.80; - dec #Derived_gen.6; + let #Derived_gen.7 : Str = StructAtIndex 1 Str.80; + dec #Derived_gen.7; let Str.290 : {U64, U8} = Struct {Str.292, Str.291}; let Str.289 : [C {U64, U8}, C Str] = TagId(0) Str.290; ret Str.289; @@ -263,8 +263,8 @@ procedure Test.3 (): let Test.5 : Int1 = CallByName Bool.11 Test.1 Test.6; dec Test.7; expect Test.5; - dec Test.0; dec Test.1; + dec Test.0; let Test.4 : {} = Struct {}; ret Test.4; @@ -281,8 +281,8 @@ procedure TotallyNotJson.525 (TotallyNotJson.526, TotallyNotJson.1175): inc TotallyNotJson.529; let TotallyNotJson.1323 : Int1 = CallByName List.1 TotallyNotJson.529; if TotallyNotJson.1323 then - dec TotallyNotJson.529; dec TotallyNotJson.530; + dec TotallyNotJson.529; let TotallyNotJson.1326 : {} = Struct {}; let TotallyNotJson.1325 : [C {}, C Str] = TagId(0) TotallyNotJson.1326; let TotallyNotJson.1324 : {List U8, [C {}, C Str]} = Struct {TotallyNotJson.526, TotallyNotJson.1325}; @@ -309,8 +309,8 @@ procedure TotallyNotJson.525 (TotallyNotJson.526, TotallyNotJson.1175): let TotallyNotJson.1181 : {List U8, [C {}, C Str]} = Struct {TotallyNotJson.530, TotallyNotJson.1182}; ret TotallyNotJson.1181; else - dec TotallyNotJson.533; dec TotallyNotJson.530; + dec TotallyNotJson.533; let TotallyNotJson.1185 : {} = Struct {}; let TotallyNotJson.1184 : [C {}, C Str] = TagId(0) TotallyNotJson.1185; let TotallyNotJson.1183 : {List U8, [C {}, C Str]} = Struct {TotallyNotJson.526, TotallyNotJson.1184}; @@ -365,8 +365,8 @@ procedure TotallyNotJson.534 (TotallyNotJson.535): procedure TotallyNotJson.536 (TotallyNotJson.1192): let TotallyNotJson.1193 : List U8 = StructAtIndex 1 TotallyNotJson.1192; - let #Derived_gen.7 : List U8 = StructAtIndex 0 TotallyNotJson.1192; - dec #Derived_gen.7; + let #Derived_gen.6 : List U8 = StructAtIndex 0 TotallyNotJson.1192; + dec #Derived_gen.6; ret TotallyNotJson.1193; procedure TotallyNotJson.60 (): @@ -733,7 +733,7 @@ procedure TotallyNotJson.69 (): let TotallyNotJson.1247 : List U8 = CallByName TotallyNotJson.68 TotallyNotJson.1248 TotallyNotJson.1249 TotallyNotJson.1250 TotallyNotJson.1251; ret TotallyNotJson.1247; -procedure TotallyNotJson.70 (#Derived_gen.5): +procedure TotallyNotJson.70 (#Derived_gen.0): joinpoint TotallyNotJson.1198 TotallyNotJson.1166: let TotallyNotJson.600 : List U8 = StructAtIndex 0 TotallyNotJson.1166; inc 4 TotallyNotJson.600; @@ -834,4 +834,4 @@ procedure TotallyNotJson.70 (#Derived_gen.5): let TotallyNotJson.1276 : {List U8, List U8} = Struct {TotallyNotJson.600, TotallyNotJson.601}; ret TotallyNotJson.1276; in - jump TotallyNotJson.1198 #Derived_gen.5; + jump TotallyNotJson.1198 #Derived_gen.0; diff --git a/crates/compiler/test_mono/generated/issue_4772_weakened_monomorphic_destructure.txt b/crates/compiler/test_mono/generated/issue_4772_weakened_monomorphic_destructure.txt index 368ce7bef1..0329be3c40 100644 --- a/crates/compiler/test_mono/generated/issue_4772_weakened_monomorphic_destructure.txt +++ b/crates/compiler/test_mono/generated/issue_4772_weakened_monomorphic_destructure.txt @@ -248,8 +248,8 @@ procedure Str.9 (Str.79): else let Str.301 : U8 = StructAtIndex 3 Str.80; let Str.302 : U64 = StructAtIndex 0 Str.80; - let #Derived_gen.7 : Str = StructAtIndex 1 Str.80; - dec #Derived_gen.7; + let #Derived_gen.6 : Str = StructAtIndex 1 Str.80; + dec #Derived_gen.6; let Str.300 : {U64, U8} = Struct {Str.302, Str.301}; let Str.299 : [C {U64, U8}, C Str] = TagId(0) Str.300; ret Str.299; @@ -281,8 +281,8 @@ procedure Test.0 (): let Test.22 : [C Str, C {List U8, I64}] = TagId(0) Test.24; ret Test.22; else - dec Test.1; dec Test.2; + dec Test.1; let Test.30 : Str = "not a number"; let Test.28 : [C Str, C {List U8, I64}] = TagId(0) Test.30; ret Test.28; @@ -313,8 +313,8 @@ procedure TotallyNotJson.525 (TotallyNotJson.526, TotallyNotJson.1175): inc TotallyNotJson.529; let TotallyNotJson.1323 : Int1 = CallByName List.1 TotallyNotJson.529; if TotallyNotJson.1323 then - dec TotallyNotJson.529; dec TotallyNotJson.530; + dec TotallyNotJson.529; let TotallyNotJson.1326 : {} = Struct {}; let TotallyNotJson.1325 : [C {}, C Str] = TagId(0) TotallyNotJson.1326; let TotallyNotJson.1324 : {List U8, [C {}, C Str]} = Struct {TotallyNotJson.526, TotallyNotJson.1325}; @@ -341,8 +341,8 @@ procedure TotallyNotJson.525 (TotallyNotJson.526, TotallyNotJson.1175): let TotallyNotJson.1181 : {List U8, [C {}, C Str]} = Struct {TotallyNotJson.530, TotallyNotJson.1182}; ret TotallyNotJson.1181; else - dec TotallyNotJson.533; dec TotallyNotJson.530; + dec TotallyNotJson.533; let TotallyNotJson.1185 : {} = Struct {}; let TotallyNotJson.1184 : [C {}, C Str] = TagId(0) TotallyNotJson.1185; let TotallyNotJson.1183 : {List U8, [C {}, C Str]} = Struct {TotallyNotJson.526, TotallyNotJson.1184}; @@ -397,8 +397,8 @@ procedure TotallyNotJson.534 (TotallyNotJson.535): procedure TotallyNotJson.536 (TotallyNotJson.1192): let TotallyNotJson.1193 : List U8 = StructAtIndex 1 TotallyNotJson.1192; - let #Derived_gen.6 : List U8 = StructAtIndex 0 TotallyNotJson.1192; - dec #Derived_gen.6; + let #Derived_gen.7 : List U8 = StructAtIndex 0 TotallyNotJson.1192; + dec #Derived_gen.7; ret TotallyNotJson.1193; procedure TotallyNotJson.60 (): diff --git a/crates/compiler/test_mono/generated/list_map_take_capturing_or_noncapturing.txt b/crates/compiler/test_mono/generated/list_map_take_capturing_or_noncapturing.txt index 6054fd9062..f99e41aaf1 100644 --- a/crates/compiler/test_mono/generated/list_map_take_capturing_or_noncapturing.txt +++ b/crates/compiler/test_mono/generated/list_map_take_capturing_or_noncapturing.txt @@ -57,8 +57,8 @@ procedure Test.0 (): else let Test.20 : Str = "B"; let Test.21 : Int1 = lowlevel Eq Test.20 Test.12; - dec Test.20; dec Test.12; + dec Test.20; if Test.21 then let Test.16 : [C U8, C U8, C ] = TagId(1) Test.2; jump Test.13 Test.16; diff --git a/crates/compiler/test_mono/generated/pattern_as_toplevel.txt b/crates/compiler/test_mono/generated/pattern_as_toplevel.txt index 4a70501f51..a124668cf0 100644 --- a/crates/compiler/test_mono/generated/pattern_as_toplevel.txt +++ b/crates/compiler/test_mono/generated/pattern_as_toplevel.txt @@ -20,9 +20,9 @@ procedure Test.0 (): if Test.13 then let Test.6 : {I64, Str} = CallByName Test.1; let Test.5 : Int1 = CallByName Bool.11 Test.6 Test.4; - dec Test.6; let #Derived_gen.0 : Str = StructAtIndex 1 Test.4; dec #Derived_gen.0; + dec Test.6; ret Test.5; else let #Derived_gen.1 : Str = StructAtIndex 1 Test.4; diff --git a/crates/compiler/test_mono/generated/recursive_function_and_union_with_inference_hole.txt b/crates/compiler/test_mono/generated/recursive_function_and_union_with_inference_hole.txt index 2e772fba51..32b2274361 100644 --- a/crates/compiler/test_mono/generated/recursive_function_and_union_with_inference_hole.txt +++ b/crates/compiler/test_mono/generated/recursive_function_and_union_with_inference_hole.txt @@ -6,10 +6,10 @@ procedure List.5 (#Attr.2, #Attr.3): procedure Test.2 (Test.5): let Test.6 : List [C List *self] = UnionAtIndex (Id 0) (Index 0) Test.5; inc Test.6; - let #Derived_gen.2 : [C List *self] = Reset { symbol: Test.5, id: UpdateModeId { id: 1 } }; + let #Derived_gen.1 : [C List *self] = Reset { symbol: Test.5, id: UpdateModeId { id: 0 } }; let Test.15 : {} = Struct {}; let Test.7 : List [C List *self] = CallByName List.5 Test.6 Test.15; - let Test.14 : [C List *self] = Reuse #Derived_gen.2 UpdateModeId { id: 1 } TagId(0) Test.7; + let Test.14 : [C List *self] = Reuse #Derived_gen.1 UpdateModeId { id: 0 } TagId(0) Test.7; ret Test.14; procedure Test.0 (): diff --git a/crates/compiler/test_mono/generated/recursive_lambda_set_resolved_only_upon_specialization.txt b/crates/compiler/test_mono/generated/recursive_lambda_set_resolved_only_upon_specialization.txt index a6ad8acc15..4dd159615f 100644 --- a/crates/compiler/test_mono/generated/recursive_lambda_set_resolved_only_upon_specialization.txt +++ b/crates/compiler/test_mono/generated/recursive_lambda_set_resolved_only_upon_specialization.txt @@ -10,7 +10,7 @@ procedure Num.21 (#Attr.2, #Attr.3): let Num.292 : U8 = lowlevel NumMul #Attr.2 #Attr.3; ret Num.292; -procedure Test.1 (#Derived_gen.0, #Derived_gen.1): +procedure Test.1 (#Derived_gen.2, #Derived_gen.3): joinpoint Test.11 Test.2 Test.3: let Test.24 : U8 = 0i64; let Test.20 : Int1 = CallByName Bool.11 Test.2 Test.24; @@ -33,9 +33,9 @@ procedure Test.1 (#Derived_gen.0, #Derived_gen.1): let Test.14 : [, C *self U8] = TagId(0) Test.3 Test.2; jump Test.11 Test.13 Test.14; in - jump Test.11 #Derived_gen.0 #Derived_gen.1; + jump Test.11 #Derived_gen.2 #Derived_gen.3; -procedure Test.4 (#Derived_gen.2, #Derived_gen.3): +procedure Test.4 (#Derived_gen.0, #Derived_gen.1): joinpoint Test.15 Test.5 #Attr.12: let Test.2 : U8 = UnionAtIndex (Id 0) (Index 1) #Attr.12; let Test.3 : [, C *self U8] = UnionAtIndex (Id 0) (Index 0) #Attr.12; @@ -61,7 +61,7 @@ procedure Test.4 (#Derived_gen.2, #Derived_gen.3): decref #Attr.12; jump #Derived_gen.4; in - jump Test.15 #Derived_gen.2 #Derived_gen.3; + jump Test.15 #Derived_gen.0 #Derived_gen.1; procedure Test.6 (Test.7): ret Test.7; diff --git a/crates/compiler/test_mono/generated/recursively_build_effect.txt b/crates/compiler/test_mono/generated/recursively_build_effect.txt index cac652954a..7d1b9ea289 100644 --- a/crates/compiler/test_mono/generated/recursively_build_effect.txt +++ b/crates/compiler/test_mono/generated/recursively_build_effect.txt @@ -8,8 +8,8 @@ procedure Str.3 (#Attr.2, #Attr.3): procedure Test.11 (Test.29, #Attr.12): let Test.10 : {} = UnionAtIndex (Id 0) (Index 0) #Attr.12; - let #Derived_gen.9 : Int1 = lowlevel RefCountIsUnique #Attr.12; - if #Derived_gen.9 then + let #Derived_gen.11 : Int1 = lowlevel RefCountIsUnique #Attr.12; + if #Derived_gen.11 then free #Attr.12; ret Test.10; else @@ -19,11 +19,11 @@ procedure Test.11 (Test.29, #Attr.12): procedure Test.11 (Test.29, Test.10): ret Test.10; -procedure Test.14 (#Derived_gen.7, #Derived_gen.8): +procedure Test.14 (#Derived_gen.0, #Derived_gen.1): joinpoint Test.37 Test.36 #Attr.12: let Test.12 : {} = UnionAtIndex (Id 1) (Index 1) #Attr.12; let Test.13 : I64 = UnionAtIndex (Id 1) (Index 0) #Attr.12; - joinpoint #Derived_gen.10: + joinpoint #Derived_gen.9: let Test.43 : {} = Struct {}; let Test.42 : {} = CallByName Test.11 Test.43 Test.12; let Test.38 : [C {}, C I64 {}] = CallByName Test.9 Test.42 Test.13; @@ -38,15 +38,15 @@ procedure Test.14 (#Derived_gen.7, #Derived_gen.8): jump Test.37 Test.40 Test.38; in - let #Derived_gen.11 : Int1 = lowlevel RefCountIsUnique #Attr.12; - if #Derived_gen.11 then + let #Derived_gen.10 : Int1 = lowlevel RefCountIsUnique #Attr.12; + if #Derived_gen.10 then free #Attr.12; - jump #Derived_gen.10; + jump #Derived_gen.9; else decref #Attr.12; - jump #Derived_gen.10; + jump #Derived_gen.9; in - jump Test.37 #Derived_gen.7 #Derived_gen.8; + jump Test.37 #Derived_gen.0 #Derived_gen.1; procedure Test.2 (): let Test.6 : Str = "Hello"; diff --git a/crates/compiler/test_mono/generated/specialize_after_match.txt b/crates/compiler/test_mono/generated/specialize_after_match.txt index dfb63f7e7d..58d5048463 100644 --- a/crates/compiler/test_mono/generated/specialize_after_match.txt +++ b/crates/compiler/test_mono/generated/specialize_after_match.txt @@ -23,7 +23,7 @@ procedure Test.2 (Test.9, Test.10): let Test.29 : U64 = CallByName Test.3 Test.9; ret Test.29; else - joinpoint #Derived_gen.4: + joinpoint #Derived_gen.1: let Test.13 : Str = UnionAtIndex (Id 0) (Index 0) Test.10; let Test.14 : [, C Str *self] = UnionAtIndex (Id 0) (Index 1) Test.10; let Test.33 : U64 = CallByName Test.3 Test.12; @@ -36,15 +36,15 @@ procedure Test.2 (Test.9, Test.10): else ret Test.16; in - let #Derived_gen.5 : Int1 = lowlevel RefCountIsUnique Test.9; - if #Derived_gen.5 then + let #Derived_gen.2 : Int1 = lowlevel RefCountIsUnique Test.9; + if #Derived_gen.2 then dec Test.11; free Test.9; - jump #Derived_gen.4; + jump #Derived_gen.1; else inc Test.12; decref Test.9; - jump #Derived_gen.4; + jump #Derived_gen.1; procedure Test.3 (Test.17): let Test.26 : U8 = 1i64; @@ -55,22 +55,22 @@ procedure Test.3 (Test.17): ret Test.22; else let Test.18 : [, C Str *self] = UnionAtIndex (Id 0) (Index 1) Test.17; - joinpoint #Derived_gen.1: + joinpoint #Derived_gen.3: let Test.24 : U64 = 1i64; let Test.25 : U64 = CallByName Test.3 Test.18; let Test.23 : U64 = CallByName Num.19 Test.24 Test.25; ret Test.23; in - let #Derived_gen.3 : Int1 = lowlevel RefCountIsUnique Test.17; - if #Derived_gen.3 then - let #Derived_gen.2 : Str = UnionAtIndex (Id 0) (Index 0) Test.17; - dec #Derived_gen.2; + let #Derived_gen.5 : Int1 = lowlevel RefCountIsUnique Test.17; + if #Derived_gen.5 then + let #Derived_gen.4 : Str = UnionAtIndex (Id 0) (Index 0) Test.17; + dec #Derived_gen.4; free Test.17; - jump #Derived_gen.1; + jump #Derived_gen.3; else inc Test.18; decref Test.17; - jump #Derived_gen.1; + jump #Derived_gen.3; procedure Test.0 (): let Test.5 : [, C Str *self] = TagId(1) ; diff --git a/crates/compiler/test_mono/generated/unspecialized_lambda_set_unification_does_not_duplicate_identical_concrete_types.txt b/crates/compiler/test_mono/generated/unspecialized_lambda_set_unification_does_not_duplicate_identical_concrete_types.txt index ebeec28457..2777a240c6 100644 --- a/crates/compiler/test_mono/generated/unspecialized_lambda_set_unification_does_not_duplicate_identical_concrete_types.txt +++ b/crates/compiler/test_mono/generated/unspecialized_lambda_set_unification_does_not_duplicate_identical_concrete_types.txt @@ -136,7 +136,7 @@ procedure List.8 (#Attr.2, #Attr.3): let List.598 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; ret List.598; -procedure List.80 (#Derived_gen.19, #Derived_gen.20, #Derived_gen.21, #Derived_gen.22, #Derived_gen.23): +procedure List.80 (#Derived_gen.16, #Derived_gen.17, #Derived_gen.18, #Derived_gen.19, #Derived_gen.20): joinpoint List.553 List.439 List.440 List.441 List.442 List.443: let List.555 : Int1 = CallByName Num.22 List.442 List.443; if List.555 then @@ -150,7 +150,7 @@ procedure List.80 (#Derived_gen.19, #Derived_gen.20, #Derived_gen.21, #Derived_g dec List.439; ret List.440; in - jump List.553 #Derived_gen.19 #Derived_gen.20 #Derived_gen.21 #Derived_gen.22 #Derived_gen.23; + jump List.553 #Derived_gen.16 #Derived_gen.17 #Derived_gen.18 #Derived_gen.19 #Derived_gen.20; procedure List.80 (#Derived_gen.3, #Derived_gen.4, #Derived_gen.5, #Derived_gen.6, #Derived_gen.7): joinpoint List.573 List.439 List.440 List.441 List.442 List.443: From 9b8d8e85e7df39e4e5381a717fab6e78a9e69920 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Fri, 11 Aug 2023 01:48:44 -0400 Subject: [PATCH 087/176] Fix some formatting on Community.roc --- examples/Community.roc | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/examples/Community.roc b/examples/Community.roc index 66918e22a9..861a5ad545 100644 --- a/examples/Community.roc +++ b/examples/Community.roc @@ -13,24 +13,24 @@ Community := { people : List Person, friends : List (Set Nat), } - has [ - Inspect { - toInspector: inspectCommunity, - }, - ] + has [ + Inspect { + toInspector: inspectCommunity, + }, + ] Person := { firstName : Str, lastName : Str, age : U8, hasBeard : Bool, - favoriteColor: Color, + favoriteColor : Color, } - has [ - Inspect { - toInspector: inspectPerson, - }, - ] + has [ + Inspect { + toInspector: inspectPerson, + }, + ] Color : [ Red, From 60bbd33f8bcb8b9ad0d6abe9a19cd178aac08454 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Fri, 11 Aug 2023 01:48:54 -0400 Subject: [PATCH 088/176] Work around `roc format` bug --- examples/Community.roc | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/examples/Community.roc b/examples/Community.roc index 861a5ad545..23257ccd71 100644 --- a/examples/Community.roc +++ b/examples/Community.roc @@ -121,25 +121,27 @@ inspectPerson = \@Person { firstName, lastName, age, hasBeard, favoriteColor } - # This is what the auto-derive would generate. f0 <- Inspect.custom + + favoriteColorTag = + when favoriteColor is + Red -> + Inspect.tag "Red" [] + + Green -> + Inspect.tag "Green" [] + + Blue -> + Inspect.tag "Blue" [] + + RGB (r, g, b) -> + Inspect.tag "RGB" [Inspect.tuple [Inspect.u8 r, Inspect.u8 g, Inspect.u8 b]] + [ { key: "firstName", value: Inspect.str firstName }, { key: "lastName", value: Inspect.str lastName }, { key: "age", value: Inspect.u8 age }, { key: "hasBeard", value: Inspect.bool hasBeard }, - { - key: "favoriteColor", - value: - when favoriteColor is - Red -> - Inspect.tag "Red" [] - Green -> - Inspect.tag "Green" [] - Blue -> - Inspect.tag "Blue" [] - RGB (r, g, b) -> - Inspect.tag "RGB" [Inspect.tuple [Inspect.u8 r, Inspect.u8 g, Inspect.u8 b]] - , - }, + { key: "favoriteColor", value: favoriteColorTag }, ] |> Inspect.record |> Inspect.apply f0 From 04739fb132e60354739ac9f170fd3f8b7f1be12c Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Fri, 11 Aug 2023 01:49:11 -0400 Subject: [PATCH 089/176] roc format --- examples/GuiFormatter.roc | 54 +++++++++++++++++++-------------------- examples/LogFormatter.roc | 54 +++++++++++++++++++-------------------- 2 files changed, 54 insertions(+), 54 deletions(-) diff --git a/examples/GuiFormatter.roc b/examples/GuiFormatter.roc index 22266a1ea4..8cb25d0cf4 100644 --- a/examples/GuiFormatter.roc +++ b/examples/GuiFormatter.roc @@ -12,34 +12,34 @@ ButtonStyles : { bgColor : Rgba, borderColor : Rgba, borderWidth : F32, textColo Elem : [Button Elem ButtonStyles, Col (List Elem), Row (List Elem), Text Str] GuiFormatter := { nodes : List Elem } - has [ - Formatter { - init: init, - list: list, - set: set, - dict: dict, - tag: tag, - tuple: tuple, - record: record, - bool: bool, - str: str, - opaque: opaque, - u8: u8, - i8: i8, - u16: u16, - i16: i16, - u32: u32, - i32: i32, - u64: u64, - i64: i64, - u128: u128, - i128: i128, - f32: f32, - f64: f64, - dec: dec, + has [ + Formatter { + init: init, + list: list, + set: set, + dict: dict, + tag: tag, + tuple: tuple, + record: record, + bool: bool, + str: str, + opaque: opaque, + u8: u8, + i8: i8, + u16: u16, + i16: i16, + u32: u32, + i32: i32, + u64: u64, + i64: i64, + u128: u128, + i128: i128, + f32: f32, + f64: f64, + dec: dec, - }, - ] + }, + ] init : {} -> GuiFormatter init = \{} -> @GuiFormatter { nodes: [] } diff --git a/examples/LogFormatter.roc b/examples/LogFormatter.roc index 2e2a0308a2..c24f8a15ae 100644 --- a/examples/LogFormatter.roc +++ b/examples/LogFormatter.roc @@ -6,34 +6,34 @@ interface LogFormatter imports [] LogFormatter := { data : Str } - has [ - InspectFormatter { - init: init, - list: list, - set: set, - dict: dict, - tag: tag, - tuple: tuple, - record: record, - bool: bool, - str: str, - opaque: opaque, - u8: u8, - i8: i8, - u16: u16, - i16: i16, - u32: u32, - i32: i32, - u64: u64, - i64: i64, - u128: u128, - i128: i128, - f32: f32, - f64: f64, - dec: dec, + has [ + InspectFormatter { + init: init, + list: list, + set: set, + dict: dict, + tag: tag, + tuple: tuple, + record: record, + bool: bool, + str: str, + opaque: opaque, + u8: u8, + i8: i8, + u16: u16, + i16: i16, + u32: u32, + i32: i32, + u64: u64, + i64: i64, + u128: u128, + i128: i128, + f32: f32, + f64: f64, + dec: dec, - }, - ] + }, + ] init : {} -> LogFormatter init = \{} -> @LogFormatter { data: "" } From f68272944c1c5c8c675fb2ab94358dc156ccd17d Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Fri, 11 Aug 2023 06:34:17 -0400 Subject: [PATCH 090/176] Update uitest --- .../generalization_among_large_recursive_group.txt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/crates/compiler/uitest/tests/recursion/generalization_among_large_recursive_group.txt b/crates/compiler/uitest/tests/recursion/generalization_among_large_recursive_group.txt index 2a62926c8f..6238bd9ad1 100644 --- a/crates/compiler/uitest/tests/recursion/generalization_among_large_recursive_group.txt +++ b/crates/compiler/uitest/tests/recursion/generalization_among_large_recursive_group.txt @@ -3,22 +3,22 @@ app "test" provides [main] to "./platform" f = \{} -> -#^{-1} <1600><117>{} -<120>[[f(1)]]-> <116>[Ok <1608>{}]<80>* +#^{-1} <1874><117>{} -<120>[[f(1)]]-> <116>[Ok <1882>{}]<80>* when g {} is -# ^ <1590><1608>{} -<1598>[[g(2)]]-> <72>[Ok <1608>{}]<102>* +# ^ <1864><1882>{} -<1872>[[g(2)]]-> <72>[Ok <1882>{}]<102>* _ -> Ok {} g = \{} -> -#^{-1} <1590><1608>{} -<1598>[[g(2)]]-> <72>[Ok <1608>{}]<102>* +#^{-1} <1864><1882>{} -<1872>[[g(2)]]-> <72>[Ok <1882>{}]<102>* when h {} is -# ^ <1595><1608>{} -<1603>[[h(3)]]-> <94>[Ok <1608>{}]<124>* +# ^ <1869><1882>{} -<1877>[[h(3)]]-> <94>[Ok <1882>{}]<124>* _ -> Ok {} h = \{} -> -#^{-1} <1595><1608>{} -<1603>[[h(3)]]-> <94>[Ok <1608>{}]<124>* +#^{-1} <1869><1882>{} -<1877>[[h(3)]]-> <94>[Ok <1882>{}]<124>* when f {} is -# ^ <1600><117>{} -<120>[[f(1)]]-> <116>[Ok <1608>{}]<80>* +# ^ <1874><117>{} -<120>[[f(1)]]-> <116>[Ok <1882>{}]<80>* _ -> Ok {} main = f {} -# ^ <1610><133>{} -<136>[[f(1)]]-> <138>[Ok <1608>{}]<1609>w_a +# ^ <1884><133>{} -<136>[[f(1)]]-> <138>[Ok <1882>{}]<1883>w_a From 954f68766621df016c0cf5d220be579c350fe19c Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Fri, 11 Aug 2023 16:14:33 +0200 Subject: [PATCH 091/176] minor fixes --- crates/compiler/parse/src/expr.rs | 2 +- crates/compiler/parse/src/parser.rs | 2 +- crates/compiler/parse/src/type_annotation.rs | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/crates/compiler/parse/src/expr.rs b/crates/compiler/parse/src/expr.rs index 31bbc89290..ed216452e3 100644 --- a/crates/compiler/parse/src/expr.rs +++ b/crates/compiler/parse/src/expr.rs @@ -1286,7 +1286,7 @@ mod ability { Exact(u32), } - /// Parses an ability demand like `hash : a -> U64 | a implements Hash`, in the context of a larger + /// Parses an ability demand like `hash : a -> U64 where a implements Hash`, in the context of a larger /// ability definition. /// This is basically the same as parsing a free-floating annotation, but with stricter rules. pub fn parse_demand<'a>( diff --git a/crates/compiler/parse/src/parser.rs b/crates/compiler/parse/src/parser.rs index 2604888417..1caef42867 100644 --- a/crates/compiler/parse/src/parser.rs +++ b/crates/compiler/parse/src/parser.rs @@ -599,7 +599,7 @@ pub enum EType<'a> { TEnd(Position), TFunctionArgument(Position), TWhereBar(Position), - THasClause(Position), + TImplementsClause(Position), TAbilityImpl(ETypeAbilityImpl<'a>, Position), /// TIndentStart(Position), diff --git a/crates/compiler/parse/src/type_annotation.rs b/crates/compiler/parse/src/type_annotation.rs index 6f33073a66..7f5d85205b 100644 --- a/crates/compiler/parse/src/type_annotation.rs +++ b/crates/compiler/parse/src/type_annotation.rs @@ -426,7 +426,7 @@ fn ability_chain<'a>() -> impl Parser<'a, Vec<'a, Loc>>, ETyp EType::TIndentEnd, ), zero_or_more!(skip_first!( - word1(b'&', EType::THasClause), + word1(b'&', EType::TImplementsClause), space0_before_optional_after( specialize(EType::TApply, loc!(concrete_type())), EType::TIndentStart, @@ -459,7 +459,7 @@ fn implements_clause<'a>() -> impl Parser<'a, Loc>, EType<' ), skip_first!( // Parse "implements"; we don't care about this keyword - word(crate::keyword::IMPLEMENTS, EType::THasClause), + word(crate::keyword::IMPLEMENTS, EType::TImplementsClause), // Parse "Hash & ..."; this may be qualified from another module like "Hash.Hash" absolute_column_min_indent(ability_chain()) ) @@ -494,7 +494,7 @@ fn implements_clause_chain<'a>( let (_, first_clause, state) = implements_clause().parse(arena, state, min_indent)?; let (_, mut clauses, state) = zero_or_more!(skip_first!( - word1(b',', EType::THasClause), + word1(b',', EType::TImplementsClause), implements_clause() )) .parse(arena, state, min_indent)?; @@ -514,7 +514,7 @@ fn implements_clause_chain<'a>( pub fn implements_abilities<'a>() -> impl Parser<'a, Loc>, EType<'a>> { increment_min_indent(skip_first!( // Parse "implements"; we don't care about this keyword - word(crate::keyword::IMPLEMENTS, EType::THasClause), + word(crate::keyword::IMPLEMENTS, EType::TImplementsClause), // Parse "Hash"; this may be qualified from another module like "Hash.Hash" space0_before_e( loc!(map!( From 9fe08cafd01f0f6b9349cc90017c127682f2e6c9 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Fri, 11 Aug 2023 20:59:40 -0400 Subject: [PATCH 092/176] Render docs for abilities, tuples, and `as` --- crates/compiler/load_internal/src/docs.rs | 71 ++++++++- crates/compiler/parse/src/ast.rs | 7 + crates/docs/src/lib.rs | 174 +++++++++++++++------- 3 files changed, 199 insertions(+), 53 deletions(-) diff --git a/crates/compiler/load_internal/src/docs.rs b/crates/compiler/load_internal/src/docs.rs index 55db7563b3..b84f701bf2 100644 --- a/crates/compiler/load_internal/src/docs.rs +++ b/crates/compiler/load_internal/src/docs.rs @@ -54,11 +54,30 @@ pub enum TypeAnnotation { fields: Vec, extension: Box, }, + Tuple { + elems: Vec, + extension: Box, + }, Ability { members: Vec, }, Wildcard, NoTypeAnn, + Where { + ann: Box, + implements: Vec, + }, + As { + ann: Box, + name: String, + vars: Vec, + }, +} + +#[derive(Debug, Clone)] +pub struct ImplementsClause { + pub name: String, + pub abilities: Vec, } #[derive(Debug, Clone)] @@ -540,7 +559,57 @@ fn type_to_docs(in_func_type_ann: bool, type_annotation: ast::TypeAnnotation) -> } } ast::TypeAnnotation::Wildcard => TypeAnnotation::Wildcard, - _ => NoTypeAnn, + ast::TypeAnnotation::As(loc_ann, _comments, type_header) => TypeAnnotation::As { + ann: Box::new(type_to_docs(in_func_type_ann, loc_ann.value)), + name: type_header.name.value.to_string(), + vars: type_header + .vars + .iter() + .filter_map(|loc_pattern| match loc_pattern.value { + ast::Pattern::Identifier(ident) => Some(ident.to_string()), + _ => None, + }) + .collect(), + }, + ast::TypeAnnotation::Tuple { elems, ext } => { + let mut doc_elems = Vec::new(); + + for loc_ann in elems.items { + doc_elems.push(type_to_docs(in_func_type_ann, loc_ann.value)); + } + + let extension = match ext { + None => NoTypeAnn, + Some(ext_type_ann) => type_to_docs(in_func_type_ann, ext_type_ann.value), + }; + + TypeAnnotation::Tuple { + elems: doc_elems, + extension: Box::new(extension), + } + } + ast::TypeAnnotation::Where(loc_ann, implements) => TypeAnnotation::Where { + ann: Box::new(type_to_docs(in_func_type_ann, loc_ann.value)), + implements: implements + .iter() + .map(|clause| { + let abilities = clause + .value + .abilities + .iter() + .map(|ability| type_to_docs(in_func_type_ann, ability.value)) + .collect(); + + ImplementsClause { + name: clause.value.var.value.item().to_string(), + abilities, + } + }) + .collect(), + }, + ast::TypeAnnotation::Malformed(_) | ast::TypeAnnotation::Inferred => { + TypeAnnotation::NoTypeAnn + } } } diff --git a/crates/compiler/parse/src/ast.rs b/crates/compiler/parse/src/ast.rs index d97d2ce8dd..2cafc3522a 100644 --- a/crates/compiler/parse/src/ast.rs +++ b/crates/compiler/parse/src/ast.rs @@ -38,6 +38,13 @@ impl<'a, T> Spaced<'a, T> { } } } + + pub fn item(&self) -> &T { + match self { + Spaced::Item(answer) => answer, + Spaced::SpaceBefore(next, _spaces) | Spaced::SpaceAfter(next, _spaces) => next.item(), + } + } } impl<'a, T: Debug> Debug for Spaced<'a, T> { diff --git a/crates/docs/src/lib.rs b/crates/docs/src/lib.rs index cbf6fb0251..a3ff1bf596 100644 --- a/crates/docs/src/lib.rs +++ b/crates/docs/src/lib.rs @@ -11,6 +11,7 @@ use roc_load::{ExecutionMode, LoadConfig, LoadedModule, LoadingProblem, Threadin use roc_module::symbol::{Interns, Symbol}; use roc_packaging::cache::{self, RocCacheDir}; use roc_parse::ident::{parse_ident, Accessor, Ident}; +use roc_parse::keyword; use roc_parse::state::State; use roc_region::all::Region; use std::fs; @@ -626,6 +627,7 @@ fn type_annotation_to_html( TypeAnnotation::Function { args, output } => { let mut paren_is_open = false; let mut peekable_args = args.iter().peekable(); + while let Some(arg) = peekable_args.next() { if is_multiline { if !should_be_multiline(arg) { @@ -638,8 +640,7 @@ fn type_annotation_to_html( paren_is_open = true; } - let child_needs_parens = - matches!(arg, TypeAnnotation::Function { args: _, output: _ }); + let child_needs_parens = matches!(arg, TypeAnnotation::Function { .. }); type_annotation_to_html(indent_level, buf, arg, child_needs_parens); if peekable_args.peek().is_some() { @@ -676,77 +677,146 @@ fn type_annotation_to_html( } TypeAnnotation::NoTypeAnn => {} TypeAnnotation::Wildcard => buf.push('*'), + TypeAnnotation::Tuple { elems, extension } => { + let elems_len = elems.len(); + let tuple_indent = indent_level + 1; + + if is_multiline { + new_line(buf); + indent(buf, tuple_indent); + } + + buf.push('('); + + if is_multiline { + new_line(buf); + } + + let next_indent_level = tuple_indent + 1; + + for (index, elem) in elems.iter().enumerate() { + if is_multiline { + indent(buf, next_indent_level); + } + + type_annotation_to_html(next_indent_level, buf, elem, false); + + if is_multiline { + if index < (elems_len - 1) { + buf.push(','); + } + + new_line(buf); + } + } + + if is_multiline { + indent(buf, tuple_indent); + } + + buf.push(')'); + + type_annotation_to_html(indent_level, buf, extension, true); + } + TypeAnnotation::Where { ann, implements } => { + type_annotation_to_html(indent_level, buf, ann, false); + + new_line(buf); + indent(buf, indent_level + 1); + + buf.push_str(keyword::WHERE); + + let multiline_implements = implements + .iter() + .any(|imp| imp.abilities.iter().any(should_be_multiline)); + + for (index, imp) in implements.iter().enumerate() { + if index != 0 { + buf.push(','); + } + + if multiline_implements { + new_line(buf); + indent(buf, indent_level + 2); + } else { + buf.push(' ') + } + + buf.push_str(&imp.name); + buf.push(' '); + buf.push_str(keyword::IMPLEMENTS); + buf.push(' '); + + for (index, ability) in imp.abilities.iter().enumerate() { + if index != 0 { + buf.push_str(" & "); + } + + type_annotation_to_html(indent_level, buf, ability, false); + } + } + } + TypeAnnotation::As { ann, name, vars } => { + type_annotation_to_html(indent_level, buf, ann, true); + buf.push(' '); + buf.push_str(name); + + for var in vars { + buf.push(' '); + buf.push_str(var); + } + } } } fn should_be_multiline(type_ann: &TypeAnnotation) -> bool { match type_ann { TypeAnnotation::TagUnion { tags, extension } => { - let mut is_multiline = should_be_multiline(extension) || tags.len() > 1; - - for tag in tags { - for value in &tag.values { - if is_multiline { - break; - } - is_multiline = should_be_multiline(value); - } - } - - is_multiline + tags.len() > 1 + || should_be_multiline(extension) + || tags + .iter() + .any(|tag| tag.values.iter().any(should_be_multiline)) } TypeAnnotation::Function { args, output } => { - let mut is_multiline = should_be_multiline(output) || args.len() > 2; - - for arg in args { - if is_multiline { - break; - } - - is_multiline = should_be_multiline(arg); - } - - is_multiline + args.len() > 2 || should_be_multiline(output) || args.iter().any(should_be_multiline) } TypeAnnotation::ObscuredTagUnion => false, TypeAnnotation::ObscuredRecord => false, TypeAnnotation::BoundVariable(_) => false, - TypeAnnotation::Apply { parts, .. } => { - let mut is_multiline = false; - - for part in parts { - is_multiline = should_be_multiline(part); - - if is_multiline { - break; - } - } - - is_multiline - } + TypeAnnotation::Apply { parts, .. } => parts.iter().any(should_be_multiline), TypeAnnotation::Record { fields, extension } => { - let mut is_multiline = should_be_multiline(extension) || fields.len() > 1; - - for field in fields { - if is_multiline { - break; - } - match field { + fields.len() > 1 + || should_be_multiline(extension) + || fields.iter().any(|field| match field { RecordField::RecordField { type_annotation, .. - } => is_multiline = should_be_multiline(type_annotation), + } => should_be_multiline(type_annotation), RecordField::OptionalField { type_annotation, .. - } => is_multiline = should_be_multiline(type_annotation), - RecordField::LabelOnly { .. } => {} - } - } - - is_multiline + } => should_be_multiline(type_annotation), + RecordField::LabelOnly { .. } => false, + }) } TypeAnnotation::Ability { .. } => true, TypeAnnotation::Wildcard => false, TypeAnnotation::NoTypeAnn => false, + TypeAnnotation::Tuple { elems, extension } => { + elems.len() > 1 + || should_be_multiline(extension) + || elems.iter().any(should_be_multiline) + } + TypeAnnotation::Where { ann, implements } => { + should_be_multiline(ann) + || implements + .iter() + .any(|imp| imp.abilities.iter().any(should_be_multiline)) + } + TypeAnnotation::As { + ann, + name: _, + vars: _, + } => should_be_multiline(ann), } } From b7ebb01f884bbc3303e891161c5d2d83546f38ce Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Fri, 11 Aug 2023 21:01:24 -0400 Subject: [PATCH 093/176] Fix spaces in docs rendering for `->` in functions --- crates/docs/src/lib.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/docs/src/lib.rs b/crates/docs/src/lib.rs index a3ff1bf596..88bb1cd44a 100644 --- a/crates/docs/src/lib.rs +++ b/crates/docs/src/lib.rs @@ -651,9 +651,11 @@ fn type_annotation_to_html( if is_multiline { new_line(buf); indent(buf, indent_level + 1); + } else { + buf.push(' '); } - buf.push_str(" -> "); + buf.push_str("-> "); let mut next_indent_level = indent_level; From fc7e0697126ffe38cb114802ce205dfa5564b4e5 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Fri, 11 Aug 2023 21:13:50 -0400 Subject: [PATCH 094/176] Generate docs for ability definitions --- crates/docs/src/lib.rs | 58 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 55 insertions(+), 3 deletions(-) diff --git a/crates/docs/src/lib.rs b/crates/docs/src/lib.rs index 88bb1cd44a..031a05c830 100644 --- a/crates/docs/src/lib.rs +++ b/crates/docs/src/lib.rs @@ -261,7 +261,13 @@ fn render_module_documentation( let type_ann = &doc_def.type_annotation; if !matches!(type_ann, TypeAnnotation::NoTypeAnn) { - content.push_str(" : "); + // Ability declarations don't have ":" after the name, just `implements` + if !matches!(type_ann, TypeAnnotation::Ability { .. }) { + content.push_str(" :"); + } + + content.push(' '); + type_annotation_to_html(0, &mut content, type_ann, false); } @@ -668,8 +674,54 @@ fn type_annotation_to_html( buf.push(')'); } } - TypeAnnotation::Ability { members: _ } => { - // TODO(abilities): fill me in + TypeAnnotation::Ability { members } => { + buf.push_str(keyword::IMPLEMENTS); + + for member in members { + new_line(buf); + indent(buf, indent_level + 1); + + // TODO use member.docs somehow. This doesn't look good though: + // if let Some(docs) = &member.docs { + // buf.push_str("## "); + // buf.push_str(docs); + + // new_line(buf); + // indent(buf, indent_level + 1); + // } + + buf.push_str(&member.name); + buf.push_str(" : "); + + type_annotation_to_html(indent_level + 1, buf, &member.type_annotation, false); + + if !member.able_variables.is_empty() { + new_line(buf); + indent(buf, indent_level + 2); + buf.push_str(keyword::WHERE); + + for (index, (name, type_anns)) in member.able_variables.iter().enumerate() { + if index != 0 { + buf.push(','); + } + + buf.push(' '); + buf.push_str(name); + buf.push(' '); + buf.push_str(keyword::IMPLEMENTS); + + for (index, ann) in type_anns.iter().enumerate() { + if index != 0 { + buf.push_str(" &"); + } + + buf.push(' '); + + type_annotation_to_html(indent_level + 2, buf, ann, false); + } + } + } + } } TypeAnnotation::ObscuredTagUnion => { buf.push_str("[@..]"); From c416e029a32ae0d0dac27e38347fead05c5d7dfb Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Fri, 11 Aug 2023 21:00:10 -0400 Subject: [PATCH 095/176] Remove some Dict and Set ability constraints --- crates/compiler/builtins/roc/Dict.roc | 4 ++-- crates/compiler/builtins/roc/Set.roc | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/compiler/builtins/roc/Dict.roc b/crates/compiler/builtins/roc/Dict.roc index 593e37d139..bdfdd53cc7 100644 --- a/crates/compiler/builtins/roc/Dict.roc +++ b/crates/compiler/builtins/roc/Dict.roc @@ -130,7 +130,7 @@ hashDict = \hasher, dict -> Hash.hashUnordered hasher (toList dict) List.walk ## ``` ## emptyDict = Dict.empty {} ## ``` -empty : {} -> Dict k v where k implements Hash & Eq +empty : {} -> Dict * * empty = \{} -> @Dict { metadata: List.repeat emptySlot 8, @@ -156,7 +156,7 @@ capacity = \@Dict { dataIndices } -> ## Return a dictionary with space allocated for a number of entries. This ## may provide a performance optimization if you know how many entries will be ## inserted. -withCapacity : Nat -> Dict k v where k implements Hash & Eq +withCapacity : Nat -> Dict * * withCapacity = \_ -> # TODO: power of 2 * 8 and actual implementation empty {} diff --git a/crates/compiler/builtins/roc/Set.roc b/crates/compiler/builtins/roc/Set.roc index 80f08a4b67..19e6a82ebf 100644 --- a/crates/compiler/builtins/roc/Set.roc +++ b/crates/compiler/builtins/roc/Set.roc @@ -60,13 +60,13 @@ hashSet = \hasher, @Set inner -> Hash.hash hasher inner ## ## expect countValues == 0 ## ``` -empty : {} -> Set k where k implements Hash & Eq +empty : {} -> Set * empty = \{} -> @Set (Dict.empty {}) ## Return a dictionary with space allocated for a number of entries. This ## may provide a performance optimization if you know how many entries will be ## inserted. -withCapacity : Nat -> Set k where k implements Hash & Eq +withCapacity : Nat -> Set * withCapacity = \cap -> @Set (Dict.withCapacity cap) From d41d976dac0f040d7e72817e411235078496fd70 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Fri, 11 Aug 2023 21:14:01 -0400 Subject: [PATCH 096/176] Improve Hash.Hash docs a bit --- crates/compiler/builtins/roc/Hash.roc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/compiler/builtins/roc/Hash.roc b/crates/compiler/builtins/roc/Hash.roc index d96f1c5eb0..6a52054091 100644 --- a/crates/compiler/builtins/roc/Hash.roc +++ b/crates/compiler/builtins/roc/Hash.roc @@ -28,7 +28,7 @@ interface Hash Num.{ U8, U16, U32, U64, U128, I8, I16, I32, I64, I128, Nat, Dec }, ] -## A value that can hashed. +## A value that can be hashed. Hash implements ## Hashes a value into a [Hasher]. ## Note that [hash] does not produce a hash value itself; the hasher must be From d869ea11445aec033f38c19be9310b8a8ae66583 Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Sat, 12 Aug 2023 17:34:44 +0200 Subject: [PATCH 097/176] use basic-cli main branch again the new-abilities-syntax branch has been merged into basic-cli main Signed-off-by: Anton-4 <17049058+Anton-4@users.noreply.github.com> --- www/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/build.sh b/www/build.sh index 79ed5d67e6..ff1b92f33d 100755 --- a/www/build.sh +++ b/www/build.sh @@ -107,7 +107,7 @@ export ROC_DOCS_URL_ROOT=/packages/basic-cli rm -rf ./downloaded-basic-cli -git clone --branch new-abilities-syntax --depth 1 https://github.com/roc-lang/basic-cli.git downloaded-basic-cli +git clone --depth 1 https://github.com/roc-lang/basic-cli.git downloaded-basic-cli cargo run --bin roc-docs downloaded-basic-cli/src/main.roc From ac9421c1b42561a70b7653f673538fe677635fe9 Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Sat, 12 Aug 2023 19:34:33 +0200 Subject: [PATCH 098/176] basic-cli 0.4.0 -> 0.5.0 --- .../pass/newline_in_packages.full.formatted.roc | 2 +- .../pass/newline_in_packages.full.result-ast | 2 +- .../snapshots/pass/newline_in_packages.full.roc | 2 +- crates/reporting/tests/test_reporting.rs | 2 +- examples/helloWorld.roc | 2 +- examples/parser/examples/letter-counts.roc | 2 +- www/generate_tutorial/src/input/tutorial.md | 12 ++++++------ www/wip_new_website/build.roc | 2 +- www/wip_new_website/content/index.md | 2 +- www/wip_new_website/content/install.md | 5 +++-- 10 files changed, 17 insertions(+), 16 deletions(-) diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/newline_in_packages.full.formatted.roc b/crates/compiler/test_syntax/tests/snapshots/pass/newline_in_packages.full.formatted.roc index 65594cfd38..cba8a15175 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/newline_in_packages.full.formatted.roc +++ b/crates/compiler/test_syntax/tests/snapshots/pass/newline_in_packages.full.formatted.roc @@ -1,7 +1,7 @@ app "hello" packages { pf: - "https://github.com/roc-lang/basic-cli/releases/download/0.4.0/DI4lqn7LIZs8ZrCDUgLK-tHHpQmxGF1ZrlevRKq5LXk.tar.br", + "https://github.com/roc-lang/basic-cli/releases/download/0.5.0/Cufzl36_SnJ4QbOoEmiJ5dIpUxBvdB3NEySvuH82Wio.tar.br", } imports [pf.Stdout] provides [main] to pf diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/newline_in_packages.full.result-ast b/crates/compiler/test_syntax/tests/snapshots/pass/newline_in_packages.full.result-ast index 54d44bb72a..975efca1c3 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/newline_in_packages.full.result-ast +++ b/crates/compiler/test_syntax/tests/snapshots/pass/newline_in_packages.full.result-ast @@ -24,7 +24,7 @@ Full { Newline, ], package_name: @31-145 PackageName( - "https://github.com/roc-lang/basic-cli/releases/download/0.4.0/DI4lqn7LIZs8ZrCDUgLK-tHHpQmxGF1ZrlevRKq5LXk.tar.br", + "https://github.com/roc-lang/basic-cli/releases/download/0.5.0/Cufzl36_SnJ4QbOoEmiJ5dIpUxBvdB3NEySvuH82Wio.tar.br", ), }, [ diff --git a/crates/compiler/test_syntax/tests/snapshots/pass/newline_in_packages.full.roc b/crates/compiler/test_syntax/tests/snapshots/pass/newline_in_packages.full.roc index aebf7bf46a..58dcb520fc 100644 --- a/crates/compiler/test_syntax/tests/snapshots/pass/newline_in_packages.full.roc +++ b/crates/compiler/test_syntax/tests/snapshots/pass/newline_in_packages.full.roc @@ -1,6 +1,6 @@ app "hello" packages { pf: -"https://github.com/roc-lang/basic-cli/releases/download/0.4.0/DI4lqn7LIZs8ZrCDUgLK-tHHpQmxGF1ZrlevRKq5LXk.tar.br" +"https://github.com/roc-lang/basic-cli/releases/download/0.5.0/Cufzl36_SnJ4QbOoEmiJ5dIpUxBvdB3NEySvuH82Wio.tar.br" } imports [pf.Stdout] provides [main] to pf diff --git a/crates/reporting/tests/test_reporting.rs b/crates/reporting/tests/test_reporting.rs index 13a920d45b..038fb32fb7 100644 --- a/crates/reporting/tests/test_reporting.rs +++ b/crates/reporting/tests/test_reporting.rs @@ -5929,7 +5929,7 @@ In roc, functions are always written as a lambda, like{} r#" app "broken" packages { - pf: "https://github.com/roc-lang/basic-cli/releases/download/0.3.2/tE4xS_zLdmmxmHwHih9kHWQ7fsXtJr7W7h3425-eZFk.tar.br", + pf: "https://github.com/roc-lang/basic-cli/releases/download/0.5.0/Cufzl36_SnJ4QbOoEmiJ5dIpUxBvdB3NEySvuH82Wio.tar.br", } imports [ pf.Stdout, diff --git a/examples/helloWorld.roc b/examples/helloWorld.roc index 6501e3f0d4..fe6bddd76e 100644 --- a/examples/helloWorld.roc +++ b/examples/helloWorld.roc @@ -1,5 +1,5 @@ app "helloWorld" - packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.4.0/DI4lqn7LIZs8ZrCDUgLK-tHHpQmxGF1ZrlevRKq5LXk.tar.br" } + packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.5.0/Cufzl36_SnJ4QbOoEmiJ5dIpUxBvdB3NEySvuH82Wio.tar.br" } imports [pf.Stdout] provides [main] to pf diff --git a/examples/parser/examples/letter-counts.roc b/examples/parser/examples/letter-counts.roc index 0978188a11..05ee2f37ad 100644 --- a/examples/parser/examples/letter-counts.roc +++ b/examples/parser/examples/letter-counts.roc @@ -1,6 +1,6 @@ app "example" packages { - cli: "https://github.com/roc-lang/basic-cli/releases/download/0.4.0/DI4lqn7LIZs8ZrCDUgLK-tHHpQmxGF1ZrlevRKq5LXk.tar.br", + cli: "https://github.com/roc-lang/basic-cli/releases/download/0.5.0/Cufzl36_SnJ4QbOoEmiJ5dIpUxBvdB3NEySvuH82Wio.tar.br", parser: "../package/main.roc", } imports [ diff --git a/www/generate_tutorial/src/input/tutorial.md b/www/generate_tutorial/src/input/tutorial.md index 6ed341202c..da7cbeac2f 100644 --- a/www/generate_tutorial/src/input/tutorial.md +++ b/www/generate_tutorial/src/input/tutorial.md @@ -131,7 +131,7 @@ Make a file named `main.roc` and put this in it: ```roc app "hello" - packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.4.0/DI4lqn7LIZs8ZrCDUgLK-tHHpQmxGF1ZrlevRKq5LXk.tar.br" } + packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.5.0/Cufzl36_SnJ4QbOoEmiJ5dIpUxBvdB3NEySvuH82Wio.tar.br" } imports [pf.Stdout] provides [main] to pf @@ -1376,7 +1376,7 @@ Let's take a closer look at the part of `main.roc` above the `main` def: ```roc app "hello" - packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.4.0/DI4lqn7LIZs8ZrCDUgLK-tHHpQmxGF1ZrlevRKq5LXk.tar.br" } + packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.5.0/Cufzl36_SnJ4QbOoEmiJ5dIpUxBvdB3NEySvuH82Wio.tar.br" } imports [pf.Stdout] provides [main] to pf ``` @@ -1388,7 +1388,7 @@ The line `app "hello"` states that this module defines a Roc application, and th The remaining lines all involve the [platform](https://github.com/roc-lang/roc/wiki/Roc-concepts-explained#platform) this application is built on: ```roc -packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.4.0/DI4lqn7LIZs8ZrCDUgLK-tHHpQmxGF1ZrlevRKq5LXk.tar.br" } +packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.5.0/Cufzl36_SnJ4QbOoEmiJ5dIpUxBvdB3NEySvuH82Wio.tar.br" } imports [pf.Stdout] provides [main] to pf ``` @@ -1474,7 +1474,7 @@ Let's start with a basic "Hello World" program. ```roc app "cli-tutorial" - packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.4.0/DI4lqn7LIZs8ZrCDUgLK-tHHpQmxGF1ZrlevRKq5LXk.tar.br" } + packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.5.0/Cufzl36_SnJ4QbOoEmiJ5dIpUxBvdB3NEySvuH82Wio.tar.br" } imports [pf.Stdout] provides [main] to pf @@ -1504,7 +1504,7 @@ Let's change `main` to read a line from `stdin`, and then print it back out agai ```roc app "cli-tutorial" - packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.4.0/DI4lqn7LIZs8ZrCDUgLK-tHHpQmxGF1ZrlevRKq5LXk.tar.br" } + packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.5.0/Cufzl36_SnJ4QbOoEmiJ5dIpUxBvdB3NEySvuH82Wio.tar.br" } imports [pf.Stdout, pf.Stdin, pf.Task] provides [main] to pf @@ -1545,7 +1545,7 @@ This works, but we can make it a little nicer to read. Let's change it to the fo ```roc app "cli-tutorial" - packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.4.0/DI4lqn7LIZs8ZrCDUgLK-tHHpQmxGF1ZrlevRKq5LXk.tar.br" } + packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.5.0/Cufzl36_SnJ4QbOoEmiJ5dIpUxBvdB3NEySvuH82Wio.tar.br" } imports [pf.Stdout, pf.Stdin, pf.Task.{ await }] provides [main] to pf diff --git a/www/wip_new_website/build.roc b/www/wip_new_website/build.roc index ab4bd61551..b5b5566154 100755 --- a/www/wip_new_website/build.roc +++ b/www/wip_new_website/build.roc @@ -1,6 +1,6 @@ #!/usr/bin/env roc app "website-builder" - packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.4.0/DI4lqn7LIZs8ZrCDUgLK-tHHpQmxGF1ZrlevRKq5LXk.tar.br" } + packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.5.0/Cufzl36_SnJ4QbOoEmiJ5dIpUxBvdB3NEySvuH82Wio.tar.br" } imports [ pf.Task.{ Task }, pf.Command, diff --git a/www/wip_new_website/content/index.md b/www/wip_new_website/content/index.md index 7df0ac858a..92f7397d2c 100644 --- a/www/wip_new_website/content/index.md +++ b/www/wip_new_website/content/index.md @@ -34,7 +34,7 @@ The code below shows a Roc application which prints `Hello World!` to the termin ```roc app "hello-world" - packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.3.2/tE4xS_zLdmmxmHwHih9kHWQ7fsXtJr7W7h3425-eZFk.tar.br" } + packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.5.0/Cufzl36_SnJ4QbOoEmiJ5dIpUxBvdB3NEySvuH82Wio.tar.br" } imports [pf.Stdout] provides [main] to pf diff --git a/www/wip_new_website/content/install.md b/www/wip_new_website/content/install.md index ae76396cae..7ce61eec31 100644 --- a/www/wip_new_website/content/install.md +++ b/www/wip_new_website/content/install.md @@ -31,9 +31,10 @@ You can include packages using an URL: app "hello" packages { # basic-cli platform - pf: "https://github.com/roc-lang/basic-cli/releases/download/0.4.0/DI4lqn7LIZs8ZrCDUgLK-tHHpQmxGF1ZrlevRKq5LXk.tar.br", + pf: "https://github.com/roc-lang/basic-cli/releases/download/0.5.0/Cufzl36_SnJ4QbOoEmiJ5dIpUxBvdB3NEySvuH82Wio.tar.br", # json package - json: "https://github.com/lukewilliamboswell/roc-json/releases/download/0.1.0/xbO9bXdHi7E9ja6upN5EJXpDoYm7lwmJ8VzL7a5zhYE.tar.br", + # TODO update to json 0.3.0 + json: "https://github.com/lukewilliamboswell/roc-json/releases/download/0.2.0/gh4zvR8xyEsef0R961Fcv5vxFEZJ-GJF-7bQwgL2Xz8.tar.br", } imports [ pf.Stdout, From d9535f27499b5f60b9f9708cb711338e7658c1d9 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Sat, 12 Aug 2023 15:32:45 -0400 Subject: [PATCH 099/176] Remove unused `br` import from WIP new website --- www/wip_new_website/main.roc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/www/wip_new_website/main.roc b/www/wip_new_website/main.roc index 7ffaf0dded..494b5fd494 100644 --- a/www/wip_new_website/main.roc +++ b/www/wip_new_website/main.roc @@ -1,13 +1,13 @@ app "roc-website" - packages { pf: "../../examples/static-site-gen/platform/main.roc" } + packages { pf: "../../examples/static-site-gen/platform/main.roc" } imports [ - pf.Html.{ html, head, body, footer, br, div, main, text, nav, a, link, meta }, + pf.Html.{ html, head, body, footer, div, main, text, nav, a, link, meta }, pf.Html.Attributes.{ content, name, id, href, rel, lang, class, title, charset }, ] provides [transformFileContent] to pf -pageData = - Dict.empty {} +pageData = + Dict.empty {} |> Dict.insert "community.html" { title: "Community", description: "The Roc community" } |> Dict.insert "design_goals.html" { title: "Design Goals", description: "Roc's design goals" } |> Dict.insert "docs.html" { title: "Documentation", description: "Learn the Roc programming language" } @@ -22,11 +22,11 @@ getPage = \current -> |> Result.withDefault { title: "", description: ""} getTitle : Str -> Str -getTitle = \current -> +getTitle = \current -> getPage current |> .title getDescription : Str -> Str -getDescription = \current -> +getDescription = \current -> getPage current |> .description transformFileContent : Str, Str -> Str @@ -78,7 +78,7 @@ viewNavbar = ], ] -rocLogo = +rocLogo = (Html.element "svg") [ (Html.attribute "viewBox") "0 -6 51 58", (Html.attribute "xmlns") "http://www.w3.org/2000/svg", From 47c3b1a1cbbd37c92a8a9cff0a8f6f3f2f452e78 Mon Sep 17 00:00:00 2001 From: Luke Boswell Date: Sun, 13 Aug 2023 16:50:01 +1000 Subject: [PATCH 100/176] fix broken references, roc format --- .../virtual-dom-wip/platform/Html/Attributes.roc | 2 +- examples/virtual-dom-wip/platform/Html/Event.roc | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/examples/virtual-dom-wip/platform/Html/Attributes.roc b/examples/virtual-dom-wip/platform/Html/Attributes.roc index f068391da9..6d6f63d121 100644 --- a/examples/virtual-dom-wip/platform/Html/Attributes.roc +++ b/examples/virtual-dom-wip/platform/Html/Attributes.roc @@ -134,7 +134,7 @@ interface Html.Attributes width, wrap, ] - imports [Html.Internal.{ Attribute }] + imports [Html.Internal.Shared.{ Attribute }] attribute : Str -> (Str -> Attribute state) attribute = \attrType -> diff --git a/examples/virtual-dom-wip/platform/Html/Event.roc b/examples/virtual-dom-wip/platform/Html/Event.roc index 9643a9c747..95a7a8056c 100644 --- a/examples/virtual-dom-wip/platform/Html/Event.roc +++ b/examples/virtual-dom-wip/platform/Html/Event.roc @@ -20,25 +20,25 @@ interface Html.Event ] imports [ Action.{ Action }, - Html.Internal.{ Attribute }, + Html.Internal.Shared.{ Attribute }, ] -Handler state : Html.Internal.Handler state -CyclicStructureAccessor : Html.Internal.CyclicStructureAccessor +Handler state : Html.Internal.Shared.Handler state +CyclicStructureAccessor : Html.Internal.Shared.CyclicStructureAccessor custom : Str, List CyclicStructureAccessor, (state, List (List U8) -> { action : Action state, stopPropagation : Bool, preventDefault : Bool }) -> Attribute state custom = \eventName, accessors, callback -> - EventListener eventName accessors (Ok (Custom callback)) + EventListener eventName accessors (Custom callback) on : Str, List CyclicStructureAccessor, (state, List (List U8) -> Action state) -> Attribute state on = \eventName, accessors, callback -> - EventListener eventName accessors (Ok (Normal callback)) + EventListener eventName accessors (Normal callback) # Internal helper curriedOn : Str -> (List CyclicStructureAccessor, (state, List (List U8) -> Action state) -> Attribute state) curriedOn = \eventName -> \accessors, callback -> - EventListener eventName accessors (Ok (Normal callback)) + EventListener eventName accessors (Normal callback) onClick = curriedOn "click" onDoubleClick = curriedOn "dblclick" @@ -61,7 +61,7 @@ onInput = \accessors, callback -> preventDefault: Bool.false, } - EventListener "input" accessors (Ok (Custom customCallback)) + EventListener "input" accessors (Custom customCallback) onSubmit : List CyclicStructureAccessor, (state, List (List U8) -> Action state) -> Attribute state onSubmit = \accessors, callback -> @@ -71,7 +71,7 @@ onSubmit = \accessors, callback -> preventDefault: Bool.true, } - EventListener "submit" accessors (Ok (Custom customCallback)) + EventListener "submit" accessors (Custom customCallback) # Notes from Elm: # - stopPropagation causes immediate view update, without waiting for animationFrame, From 4b1a156290b3471fa22fcd1f751290c873a78ce4 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Sun, 13 Aug 2023 12:51:51 -0400 Subject: [PATCH 101/176] Update FAQ.md The editor entry doesn't make sense in light of now wanting to have both `roc edit` as well as extensions for other editors. Signed-off-by: Richard Feldman --- FAQ.md | 6 ------ 1 file changed, 6 deletions(-) diff --git a/FAQ.md b/FAQ.md index ff00856f08..6ac345a4f0 100644 --- a/FAQ.md +++ b/FAQ.md @@ -31,12 +31,6 @@ fantastical, and it has incredible potential for puns. Here are some different w Fun fact: "roc" translates to 鹏 in Chinese, [which means](https://www.mdbg.net/chinese/dictionary?page=worddict&wdrst=0&wdqb=%E9%B9%8F) "a large fabulous bird." -## Why make a new editor instead of making an LSP plugin for VSCode, Vim or Emacs? - -The Roc editor is one of the key areas where we want to innovate. Constraining ourselves to a plugin for existing editors would severely limit our possibilities for innovation. - -A key part of our editor will be the use of plugins that are shipped with libraries. Think of a regex visualizer, parser debugger, or color picker. For library authors, it would be most convenient to write these plugins in Roc. Trying to dynamically load library plugins (written in Roc) in for example VSCode seems very difficult. - ## Is there syntax highlighting for Vim/Emacs/VS Code or a LSP? Not currently. Although they will presumably exist someday, while Roc is in the early days there's actually a conscious From 7781080289193b26765292a3f85d47e91c073fab Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Sun, 13 Aug 2023 12:53:13 -0400 Subject: [PATCH 102/176] Reorganize FAQ a bit Also drop some more obsolete notes about how there's no syntax highlighting for any third-party editors etc. Signed-off-by: Richard Feldman --- FAQ.md | 78 ++++++++++++++++++++++------------------------------------ 1 file changed, 29 insertions(+), 49 deletions(-) diff --git a/FAQ.md b/FAQ.md index 6ac345a4f0..1a00403016 100644 --- a/FAQ.md +++ b/FAQ.md @@ -31,55 +31,6 @@ fantastical, and it has incredible potential for puns. Here are some different w Fun fact: "roc" translates to 鹏 in Chinese, [which means](https://www.mdbg.net/chinese/dictionary?page=worddict&wdrst=0&wdqb=%E9%B9%8F) "a large fabulous bird." -## Is there syntax highlighting for Vim/Emacs/VS Code or a LSP? - -Not currently. Although they will presumably exist someday, while Roc is in the early days there's actually a conscious -effort to focus on the Roc Editor _instead of_ adding Roc support to other editors - specifically in order to give the Roc -Editor the best possible chance at kickstarting a virtuous cycle of plugin authorship. - -This is an unusual approach, but there are more details in [this 2021 interview](https://youtu.be/ITrDd6-PbvY?t=212). - -In the meantime, using CoffeeScript syntax highlighting for .roc files turns out to work surprisingly well! - -## Why won't the editor be able to edit non-roc files like .md, .gitignore, .yml, ... ? - -The downside of having the Roc editor support files other than .roc is that it seems extremely difficult to avoid scope creep if we allow it. For example, it starts with just editing json as plaintext but then it's annoying that there's no syntax highlighting, so maybe we add the capability to do syntax highlighting for json but of course then some people want it for toml, .md, etc, so we need to add a way to specify custom syntax highlighting rules for all of those. - -Then of course people don't want to be copy/pasting syntax highlighting rules from online, so maybe someone develops a third party "plugin manager" for the editor to distribute these syntax highlighting definitions. -So maybe we add sharing syntax highlighting as a first-class thing, so people don't have to download a separate tool to use their editor normally but then some people who are using it for .json and .yaml start using it for .css too. Syntax highlighting is okay but it's annoying that they don't get error reporting when they mess up syntax or type an invalid selector or import and pretty soon there's demand for the Roc editor to do all the hardest parts of VS code. - -We have to draw the line somewhere in there...but where to draw it? -It seems like drawing a bright line at .roc files is the most straightforward. It means the roc editor is the absolute best at editing .roc files and it isn't a weak editor for anything else because it doesn't try to be an editor for anything else and it means the scope is very clear. - -## Why is there no way to specify "import everything this module exposes" in `imports`? - -In [Elm](https://elm-lang.org), it's possible to import a module in a way that brings everything that module -exposes into scope. It can be convenient, but like all programming language features, it has downsides. - -A minor reason Roc doesn't have this feature is that exposing everything can make it more difficult -outside the editor (e.g. on a website) to tell where something comes from, especially if multiple imports are -using this. ("I don't see `blah` defined in this module, so it must be coming from an import...but which of -these several import-exposing-everything modules could it be? I'll have to check all of them, or -download this code base and open it up in the editor so I can jump to definition!") - -The main reason for this design, though, is compiler performance. - -Currently, the name resolution step in compilation can be parallelized across modules, because it's possible to -tell if there's a naming error within a module using only the contents of that module. If "expose everything" is -allowed, then it's no longer clear whether anything is a naming error or not, until all the "expose everything" -modules have been processed, so we know exactly which names they expose. Because that feature doesn't exist in Roc, -all modules can do name resolution in parallel. - -Of note, allowing this feature would only slow down modules that used it; modules that didn't use it would still be -parallelizable. However, when people find out ways to speed up their builds (in any language), advice starts to -circulate about how to unlock those speed boosts. If Roc had this feature, it's predictable that a commonly-accepted -piece of advice would eventually circulate: "don't use this feature because it slows down your builds." - -If a feature exists in a language, but the common recommendation is never to use it, that's cause for reconsidering -whether the feature should be in the language at all. In the case of this feature, I think it's simpler if the -language doesn't have it; that way nobody has to learn (or spend time spreading the word) about the -performance-boosting advice not to use it. - ## Why can't functions be compared for equality using the `==` operator? Function equality has been proven to be undecidable in the general case because of the [halting problem](https://en.wikipedia.org/wiki/Halting_problem). @@ -120,6 +71,35 @@ The first of these problems could be addressed by having function equality alway Each of these designs makes Roc a language that's some combination of more error-prone, more confusing, and more brittle to change. Disallowing function equality at compile time eliminates all of these drawbacks. +## Why is there no way to specify "import everything this module exposes" in `imports`? + +In [Elm](https://elm-lang.org), it's possible to import a module in a way that brings everything that module +exposes into scope. It can be convenient, but like all programming language features, it has downsides. + +A minor reason Roc doesn't have this feature is that exposing everything can make it more difficult +outside the editor (e.g. on a website) to tell where something comes from, especially if multiple imports are +using this. ("I don't see `blah` defined in this module, so it must be coming from an import...but which of +these several import-exposing-everything modules could it be? I'll have to check all of them, or +download this code base and open it up in the editor so I can jump to definition!") + +The main reason for this design, though, is compiler performance. + +Currently, the name resolution step in compilation can be parallelized across modules, because it's possible to +tell if there's a naming error within a module using only the contents of that module. If "expose everything" is +allowed, then it's no longer clear whether anything is a naming error or not, until all the "expose everything" +modules have been processed, so we know exactly which names they expose. Because that feature doesn't exist in Roc, +all modules can do name resolution in parallel. + +Of note, allowing this feature would only slow down modules that used it; modules that didn't use it would still be +parallelizable. However, when people find out ways to speed up their builds (in any language), advice starts to +circulate about how to unlock those speed boosts. If Roc had this feature, it's predictable that a commonly-accepted +piece of advice would eventually circulate: "don't use this feature because it slows down your builds." + +If a feature exists in a language, but the common recommendation is never to use it, that's cause for reconsidering +whether the feature should be in the language at all. In the case of this feature, I think it's simpler if the +language doesn't have it; that way nobody has to learn (or spend time spreading the word) about the +performance-boosting advice not to use it. + ## Why doesn't Roc have a `Maybe` or `Option` or `Optional` type, or `null` or `nil` or `undefined`? It's common for programming languages to have a [null reference](https://en.wikipedia.org/wiki/Null_pointer) From 0a9e664022dab5a050d2651f5692797d204531b6 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Sun, 13 Aug 2023 14:20:05 -0400 Subject: [PATCH 103/176] Revise some FAQ entries --- FAQ.md | 47 +++++++++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/FAQ.md b/FAQ.md index 1a00403016..491de1ee61 100644 --- a/FAQ.md +++ b/FAQ.md @@ -162,34 +162,33 @@ would be unable to infer a type—and you'd have to write a type annotation. Thi situations where the editor would not be able to reliably tell you the type of part of your program, unlike today where it can accurately tell you the type of anything, even if you have no type annotations in your entire code base. -assuming that's right, here is a proposed new FAQ entry: +This is one factor that higher-rank and higher-kinded types have in common. There are other factors which are specific +to each. ### Higher-rank types -Roc uses a Rank-1 type system. Other languages, like Haskell, support Rank-2 or even arbitrary-rank (aka "Rank-N") types. Supporting higher-rank types in Roc has been discussed before, but it has several important downsides: - -- It would remove principal decidable type inference. (Only Rank-1 types are compatible with principal decidable type inference; Rank-2 types are decidable but the inferred types are not principal, and Rank 3+ types are not even fully decidable.) +Supporting higher-rank types in Roc has been discussed before, but it has several important downsides: + - It would increase the complexity of the language. - It would make some compiler error messages more confusing (e.g. they might mention `forall` because that was the most general type that could be inferred, even if that wasn't helpful or related to the actual problem). - It would substantially increase the complexity of the type checker, which would necessarily slow it down. -- Most significantly, it would make the runtime slower, because Roc compiles programs by fully specializing all function calls to their type instances (this is sometimes called monomorphization). It's unclear how we could fully specialize programs containing Rank-2 types, which means compiling programs that included Rank-2 types (or higher) would require losing specialization in general—which would substantially degrade runtime performance. +- It would make some Roc programs run significantly more slowly. Roc compiles programs by [monomorphizing](https://en.wikipedia.org/wiki/Monomorphization), and it's unclear how we could fully monomorphize programs containing Rank-2 types. This means compiling programs which include Rank-2 types (or higher) would require sacrificing monomorphization, which would substantially degrade runtime performance. As such, the plan is for Roc to stick with Rank-1 types indefinitely. ### Higher-kinded polymorphism -I want to be really clear about this one: the explicit plan is that Roc will never support higher-kinded polymorphism. +The explicit plan is that Roc will never support higher-kinded polymorphism. -On the technical side, the reasons for this are ordinary: I understand the practical benefits and -drawbacks of HKP, and I think the drawbacks outweigh the benefits when it comes to Roc. (Those who come to a -different conclusion may think HKP's drawbacks would be less of a big a deal in Roc than I do. That's reasonable; -we programmers often weigh the same trade-offs differently.) To be clear, I think this in the specific context of -Roc; there are plenty of other languages where HKP seems like a great fit. For example, it's hard to imagine Haskell -without it. Similarly, I think lifetime annotations are a great fit for Rust, but don't think they'd be right -for Roc either. +On the technical side, the reasons for this are ordinary: like any language feature, HKP has both benefits and drawbacks, +and in the context of Roc, the drawbacks seem to outweigh the benefits. (Those who come to a different conclusion may +think HKP's drawbacks would be less of a big a deal in Roc. That's reasonable; we programmers often weigh the same +trade-offs differently.) To be clear, this analysis of HKP is in the specific context of Roc; there are plenty of +other languages where HKP seems like a great fit. For example, it's hard to imagine Haskell without it. Similarly, +lifetime annotations might be a natural fit for Rust, but they wouldn't be a good fit for Roc either. -I also think it's important to consider the cultural implications of deciding whether or not to support HKP. -To illustrate what I mean, imagine this conversation: +It's also important to consider the cultural implications of deciding whether or not to support HKP. +To illustrate these implications, imagine this conversation: **Programmer 1:** "How do you feel about higher-kinded polymorphism?" @@ -199,9 +198,9 @@ To illustrate what I mean, imagine this conversation: **Programmer 2:** "OH NO." -I've had several variations of this conversation: I'm talking about higher-kinded types, -another programmer asks what that means, I give monads as an example, and their reaction is strongly negative. -I've also had plenty of conversations with programmers who love HKP and vigorously advocate for its addition +For some, this conversation does not require imagining, because it's so familiar: higher-kinded types come up in +conversation, another programmer asks what that means, monads are given as an example, and their reaction is +strongly negative. On the flip side, plenty of programmers love HKP and vigorously advocate for its addition to languages they use which don't have it. Feelings about HKP seem strongly divided, maybe more so than any other type system feature besides static and dynamic types. @@ -217,12 +216,12 @@ Given this, language designers have three options: - Have HKP and don't have Monad in the standard library. An alternate standard library built around monads will inevitably emerge, and both the community and ecosystem will divide themselves along pro-monad and anti-monad lines. - Don't have HKP; build a culture and ecosystem around other things. -Considering that these are the only three options, I think the best choice for Roc—not only on a technical -level, but on a cultural level as well—is to make it clear that the plan is for Roc never to support HKP. -I hope this clarity can save a lot of community members' time that would otherwise be spent on advocacy or -arguing between the two sides of the divide. Again, I think it's completely reasonable for anyone to have a -different preference, but given that language designers can only choose one of these options, I'm confident -I've made the right choice for Roc by designing it never to have higher-kinded polymorphism. +Considering that these are the only three options, an early decision in Roc's design—not only on a technical +level, but on a cultural level as well—was to make it clear that the plan is for Roc never to support HKP. +The hope is that this clarity can save a lot of community members' time that would otherwise be spent on advocacy or +arguing between the two sides of the divide. Again, it's completely reasonable for anyone to have a different preference, +but given that language designers can only choose one of these options, it seems clear that the right choice for Roc +is for it to never have higher-kinded polymorphism. ## Why do Roc's syntax and standard library differ from Elm's? From c3802d228b9afce0590184352aa8f5abaedb8311 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Sun, 13 Aug 2023 14:22:31 -0400 Subject: [PATCH 104/176] Remove FAQ entry on differences from Elm This info is covered better by roc-for-elm-programmers.md --- FAQ.md | 35 ----------------------------------- 1 file changed, 35 deletions(-) diff --git a/FAQ.md b/FAQ.md index 491de1ee61..8320feb779 100644 --- a/FAQ.md +++ b/FAQ.md @@ -223,41 +223,6 @@ arguing between the two sides of the divide. Again, it's completely reasonable f but given that language designers can only choose one of these options, it seems clear that the right choice for Roc is for it to never have higher-kinded polymorphism. -## Why do Roc's syntax and standard library differ from Elm's? - -Roc is a direct descendant of [Elm](https://elm-lang.org/). However, there are some differences between the two languages. - -Syntactic differences are among these. This is a feature, not a bug; if Roc had identical syntax to Elm, then it's -predictable that people would write code that was designed to work in both languages - and would then rely on -that being true, for example by making a package which advertised "Works in both Elm and Roc!" This in turn -would mean that later if either language were to change its syntax in a way that didn't make sense for the other, -the result would be broken code and sadness. - -So why does Roc have the specific syntax changes it does? Here are some brief explanations: - -- `#` instead of `--` for comments - this allows [hashbang](https://senthilnayagan.medium.com/shebang-hashbang-10966b8f28a8)s to work without needing special syntax. That isn't a use case Elm supports, but it is one Roc is designed to support. -- `{}` instead of `()` for the unit type - Elm has both, and they can both be used as a unit type. Since `{}` has other uses in the type system, but `()` doesn't, I consider it redundant and took it out. -- `when`...`is` instead of `case`...`of` - I predict it will be easier for beginners to pick up, because usually the way I explain `case`...`of` to beginners is by saying the words "when" and "is" out loud - e.g. "when `color` is `Red`, it runs this first branch; when `color` is `Blue`, it runs this other branch..." -- `:` instead of `=` for record field definitions (e.g. `{ foo: bar }` where Elm syntax would be `{ foo = bar }`): I like `=` being reserved for definitions, and `:` is the most popular alternative. -- Backpassing syntax - since Roc is designed to be used for use cases like command-line apps, shell scripts, and servers, I expect chained effects to come up a lot more often than they do in Elm. I think backpassing is nice for those use cases, similarly to how `do` notation is nice for them in Haskell. -- Tag unions instead of Elm's custom types (aka algebraic data types). This isn't just a syntactic change; tag unions are mainly in Roc because they can facilitate errors being accumulated across chained effects, which (as noted a moment ago) I expect to be a lot more common in Roc than in Elm. If you have tag unions, you don't really need a separate language feature for algebraic data types, since closed tag unions essentially work the same way - aside from not giving you a way to selectively expose variants or define phantom types. Roc's opaque types language feature covers those use cases instead. -- No `::` operator, or `::` pattern matching for lists. Both of these are for the same reason: an Elm `List` is a linked list, so both prepending to it and removing an element from the front are very cheap operations. In contrast, a Roc `List` is a flat array, so both prepending to it and removing an element from the front are among the most expensive operations you can possibly do with it! To get good performance, this usage pattern should be encouraged in Elm and discouraged in Roc. Since having special syntax would encourage it, it would not be good for Roc to have that syntax! -- No `<|` operator. In Elm, I almost exclusively found myself wanting to use this in conjunction with anonymous functions (e.g. `foo <| \bar -> ...`) or conditionals (e.g. `foo <| if bar then ...`). In Roc you can do both of these without the `<|`. That means the main remaining use for `<|` is to reduce parentheses, but I tend to think `|>` is better at that (or else the parens are fine), so after the other syntactic changes, I considered `<|` an unnecessary stylistic alternative to `|>` or parens. -- The `|>` operator passes the expression before the `|>` as the _first_ argument to the function after the `|>` instead of as the last argument. See the section on currying for details on why this works this way. -- `:` instead of `type alias` - I like to avoid reserved keywords for terms that are desirable in userspace, so that people don't have to name things `typ` because `type` is a reserved keyword, or `clazz` because `class` is reserved. (I couldn't think of satisfactory alternatives for `as`, `when`, `is`, or `if` other than different reserved keywords. I could see an argument for `then`—and maybe even `is`—being replaced with a `->` or `=>` or something, but I don't anticipate missing either of those words much in userspace. `then` is used in JavaScript promises, but I think there are several better names for that function.) -- No underscores in variable names - I've seen Elm beginners reflexively use `snake_case` over `camelCase` and then need to un-learn the habit after the compiler accepted it. I'd rather have the compiler give feedback that this isn't the way to do it in Roc, and suggest a camelCase alternative. I've also seen underscores used for lazy naming, e.g. `foo` and then `foo_`. If lazy naming is the goal, `foo2` is just as concise as `foo_`, but `foo3` is more concise than `foo__`. So in a way, removing `_` is a forcing function for improved laziness. (Of course, more descriptive naming would be even better.) Acronyms also use camelCase despite being capitalized in English, eg. `xmlHttpRequest` for a variable and `XmlHttpRequest` for a type. Each word starts with a capital letter, so if acronyms are only capitals it's harder to see where the words start. eg. `XMLHTTPRequest` is less clear than `XmlHttpRequest`, unless you already know the acronyms. -- Trailing commas - I've seen people walk away (in some cases physically!) from Elm as soon as they saw the leading commas in collection literals. While I think they've made a mistake by not pushing past this aesthetic preference to give the language a chance, I also would prefer not put them in a position to make such a mistake in the first place. Secondarily, while I'm personally fine with either style, between the two I prefer the look of trailing commas. -- The `!` unary prefix operator. I didn't want to have a `Basics` module (more on that in a moment), and without `Basics`, this would either need to be called fully-qualified (`Bool.not`) or else a module import of `Bool.{ not }` would be necessary. Both seemed less nice than supporting the `!` prefix that's common to so many widely-used languages, especially when we already have a unary prefix operator of `-` for negation (e.g. `-x`). -- `!=` for the inequality operator (instead of Elm's `/=`) - this one pairs more naturally with the `!` prefix operator and is also very common in other languages. - -Roc also has a different standard library from Elm. Some of the differences come down to platforms and applications (e.g. having `Task` in Roc's standard library wouldn't make sense), but others do not. Here are some brief explanations: - -- No `Basics` module. I wanted to have a simple rule of "all modules in the standard library are imported by default, and so are their exposed types," and that's it. Given that I wanted the comparison operators (e.g. `<`) to work only on numbers, it ended up that having `Num` and `Bool` modules meant that almost nothing would be left for a `Basics` equivalent in Roc except `identity` and `Never`. The Roc type `[]` (empty tag union) is equivalent to `Never`, so that wasn't necessary, and I generally think that `identity` is a good concept but a sign of an incomplete API whenever its use comes up in practice. For example, instead of calling `|> List.filterMap identity` I'd rather have access to a more self-descriptive function like `|> List.dropNothings`. With `Num` and `Bool`, and without `identity` and `Never`, there was nothing left in `Basics`. -- `Str` instead of `String` - after using the `str` type in Rust, I realized I had no issue whatsoever with the more concise name, especially since it was used in so many places (similar to `Msg` and `Cmd` in Elm) - so I decided to save a couple of letters. -- No function composition operators - I stopped using these in Elm so long ago, at one point I forgot they were in the language! See the FAQ entry on currying for details about why. -- No `Char`. What most people think of as a "character" is a rendered glyph. However, rendered glyphs are comprised of [grapheme clusters](https://stackoverflow.com/a/27331885), which are a variable number of Unicode code points - and there's no upper bound on how many code points there can be in a single cluster. In a world of emoji, I think this makes `Char` error-prone and it's better to have `Str` be the only first-class unit. For convenience when working with unicode code points (e.g. for performance-critical tasks like parsing), the single-quote syntax is sugar for the corresponding `U32` code point - for example, writing `'鹏'` is exactly the same as writing `40527`. Like Rust, you get a compiler error if you put something in single quotes that's not a valid [Unicode scalar value](http://www.unicode.org/glossary/#unicode_scalar_value). -- No `Maybe`. See the "Why doesn't Roc have a `Maybe`/`Option`/`Optional` type" FAQ question - ## Why aren't Roc functions curried by default? Although technically any language with first-class functions makes it possible to curry From 31da0520c4810c1de203a31787f358bcd099487d Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Sun, 13 Aug 2023 15:07:13 -0400 Subject: [PATCH 105/176] Revise the FAQ to no longer use first person --- FAQ.md | 112 +++++++++++++++++++++++++++------------------------------ 1 file changed, 53 insertions(+), 59 deletions(-) diff --git a/FAQ.md b/FAQ.md index 8320feb779..3d8187c6ee 100644 --- a/FAQ.md +++ b/FAQ.md @@ -96,7 +96,7 @@ circulate about how to unlock those speed boosts. If Roc had this feature, it's piece of advice would eventually circulate: "don't use this feature because it slows down your builds." If a feature exists in a language, but the common recommendation is never to use it, that's cause for reconsidering -whether the feature should be in the language at all. In the case of this feature, I think it's simpler if the +whether the feature should be in the language at all. In the case of this feature, it's simpler if the language doesn't have it; that way nobody has to learn (or spend time spreading the word) about the performance-boosting advice not to use it. @@ -148,7 +148,7 @@ On a historical note, `Maybe` may have been thought of as a substitute for null ## Why doesn't Roc have higher-kinded polymorphism or arbitrary-rank types? -_Since this is a FAQ answer, I'm going to assume familiarity with higher-kinded types and higher-rank types instead of including a primer on them._ +_Since this is a FAQ answer, it assumes familiarity with higher-kinded types and higher-rank types instead of including a primer on them._ A valuable aspect of Roc's type system is that it has decidable [principal](https://en.wikipedia.org/wiki/Principal_type) type inference. This means that: @@ -210,7 +210,7 @@ language will inevitably follow. If the language does support HKP, one or more a around monads will inevitably follow, along with corresponding cultural changes. (See Scala for example.) Culturally, to support HKP is to take a side, and to decline to support it is also to take a side. -Given this, language designers have three options: +Given this, languages have three options: - Have HKP and have Monad in the standard library. Embrace them and build a culture and ecosystem around them. - Have HKP and don't have Monad in the standard library. An alternate standard library built around monads will inevitably emerge, and both the community and ecosystem will divide themselves along pro-monad and anti-monad lines. @@ -220,22 +220,18 @@ Considering that these are the only three options, an early decision in Roc's de level, but on a cultural level as well—was to make it clear that the plan is for Roc never to support HKP. The hope is that this clarity can save a lot of community members' time that would otherwise be spent on advocacy or arguing between the two sides of the divide. Again, it's completely reasonable for anyone to have a different preference, -but given that language designers can only choose one of these options, it seems clear that the right choice for Roc +but given that languages can only choose one of these options, it seems clear that the right choice for Roc is for it to never have higher-kinded polymorphism. ## Why aren't Roc functions curried by default? Although technically any language with first-class functions makes it possible to curry -any function (e.g. I can manually curry a Roc function `\x, y, z ->` by writing `\x -> \y -> \z ->` instead), +any function (e.g. anyone can manually curry a Roc function `\x, y, z ->` by writing `\x -> \y -> \z ->` instead), typically what people mean when they say Roc isn't a curried language is that Roc functions aren't curried -by default. For the rest of this section, I'll use "currying" as a shorthand for "functions that are curried +by default. The rest of this section will use "currying" as a shorthand for "functions that are curried by default" for the sake of brevity. -As I see it, currying has one major upside and several major downsides. The upside: - -- It makes function calls more concise in some cases. - -The downsides: +Currying makes function calls more concise in some cases, but it has several significant downsides: - It lowers error message quality, because there can no longer be an error for "function called with too few arguments." (Calling a function with fewer arguments is always valid in curried functions; the error you get instead will unavoidably be some other sort of type mismatch, and it will be up to you to figure out that the real problem was that you forgot an argument.) - It makes the `|>` operator more error-prone in some cases. @@ -244,10 +240,10 @@ The downsides: - It facilitates pointfree function composition. (More on why this is listed as a downside later.) There's also a downside that it would make runtime performance of compiled programs worse by default, -but I assume it would be possible to optimize that away at the cost of slightly longer compile times. +but it would most likely be possible to optimize that away at the cost of slightly longer compile times. -I consider the one upside (conciseness in some places) extremely minor, and have almost never missed it in Roc. -Here are some more details about the downsides as I see them. +These downsides seem to outweigh the one upside (conciseness in some places). Here are some more details about each of +the downsides. ### Currying and the `|>` operator @@ -262,11 +258,19 @@ Str.concat "Hello, " "World!" |> Str.concat "World!" ``` -In curried languages with a `|>` operator, the first expression still returns `"Hello, World!"` but the second one returns `"World!Hello, "`. This is because Roc's `|>` operator uses the expression before the `|>` as the _first_ argument, whereas in curried languages, `|>` uses it as the _last_ argument. +It's unsurprising to most beginners that these work the same way; it's common for a beginner who has recently learned +how `|>` works to expect that `|> Str.concat "!"` would concatenate `!` onto the end of a string. -(For example, this is how `|>` works in both [F#](https://docs.microsoft.com/en-us/dotnet/fsharp/language-reference/symbol-and-operator-reference/#function-symbols-and-operators) and in [Elm](https://package.elm-lang.org/packages/elm/core/1.0.5/Basics#|%3E), both of which are curried languages. In contrast, Roc's `|>` design uses the same argument ordering as [Elixir](https://hexdocs.pm/elixir/1.14.0/Kernel.html#%7C%3E/2) and [Gleam](https://gleam.run/book/tour/functions.html#pipe-operator), neither of which is a curried language.) +This is not how it works in curried languages, however. In curried languages with a `|>` operator, the first expression +still returns `"Hello, World!"` but the second one returns `"World!Hello, "` instead. This can be an unpleasant surprise +for beginners, but even experienced users commonly find that this behavior is less useful than having both of +these expressions evaluate to the same thing. -This comes up in other situations as well. For example, consider subtraction and division: +In Roc, both expressions evaluate to the same thing in Roc because Roc's `|>` operator uses the expression before the `|>` as the _first_ argument, whereas in curried languages, `|>` uses it as the _last_ argument. + +(For example, this is how `|>` works in both [F#](https://docs.microsoft.com/en-us/dotnet/fsharp/language-reference/symbol-and-operator-reference/#function-symbols-and-operators) and in [Elm](https://package.elm-lang.org/packages/elm/core/1.0.5/Basics#|%3E), both of which are curried languages. In contrast, Roc's `|>` design uses the same argument ordering as [Elixir](https://hexdocs.pm/elixir/1.14.0/Kernel.html#%7C%3E/2) and [Gleam](https://gleam.run/book/tour/functions.html#pipe-operator), none of which are curried languages.) + +This comes up in other situations besides string concatenation. For example, consider subtraction and division: ```elixir someNumber @@ -278,9 +282,12 @@ someNumber |> Num.sub 1 ``` -What do you expect these expressions to do? - -In Roc, the first divides `someNumber` by 2 and the second one subtracts 1 from `someNumber`. In languages where `|>` uses the other argument ordering, the first example instead takes 2 and divides it by `someNumber`, while the second takes 1 and subtracts `someNumber` from it. This was a pain point I ran into with curried languages, and I was pleasantly surprised that changing the argument ordering in `|>` addressed the pain point. +Again, it's reasonable to expect that `|> Num.div 2` will divide a number by 2, and that +`|> Num.sub 1` will subtract 1 from a number. In Roc, this is how they work, but in +curried languages they work the opposite way: `|> Num.div 2` takes the number 2 and +divides it by a number, and `|> Num.sub 1` takes the number 1 and subtracts a number +from it. This is once again both more surprising to beginners and less useful to +experienced users. This style has a second benefit when it comes to higher-order functions. Consider these two examples: @@ -325,29 +332,26 @@ answer = numbers ``` -This was also a pain point I'd encountered in curried languages. I prefer the way the former example reads, but that style doesn't work with the argument order that currying encourages for higher-order functions like `List.map`. (Prior to using curried languages, I'd used [CoffeeScript](https://coffeescript.org/) in a functional style with [`_.map`](https://underscorejs.org/#map), and was disappointed to realize that I could no longer use the enjoyable style of `answer = _.map numbers (num) -> …` as I had before. In Roc, this style works.) - As a historical note, these stylistic benefits (of `|> Num.sub 1` working as expected, and being able to write `List.map numbers \num ->`) were not among the original reasons Roc did not have currying. These benefits were discovered after the decision had already been made that Roc would not be a curried language, and they served to reinforce after the fact that the decision was the right one for Roc given the language's goals. ### Currying and learning curve -Prior to designing Roc, I taught a lot of beginner [Elm](https://elm-lang.org/) workshops. Sometimes at -conferences, sometimes for [Frontend Masters](https://frontendmasters.com/courses/intro-elm/), -sometimes for free at local coding bootcamps or meetup groups. -In total I've spent well over 100 hours standing in front of a class, introducing the students to their -first pure functional programming language. +Currying leads to function signatures that look surprising to beginners. For example, in Roc, the +[`Bool.and`](https://www.roc-lang.org/builtins/Bool#and) function has the type `Bool, Bool -> Bool`. If Roc were a +curried language, this function would instead have the type `Bool -> Bool -> Bool`. Since no mainstream programming +languages today are curried, anyone who knows a mainstream language and is learning their first curried language will +require additional explaination about why function types look this way. -Here was my experience teaching currying: +This explanation is nontrivial. It requires explaining partial application, how curried functions facilitate partial +application, how function signatures accurately reflect that they're curried, and going through examples for all of these. +All of it builds up to the punchline that "technically, all functions in this language have a single argument," which +some percentage of learners find interesting, and some percentage still find confusing even after all that explanation. -- The only way to avoid teaching it is to refuse to explain why multi-argument functions have multiple `->`s in them. (If you don't explain it, at least one student will ask about it - and many if not all of the others will wonder.) -- Teaching currying properly takes a solid chunk of time, because it requires explaining partial application, explaining how curried functions facilitate partial application, how function signatures accurately reflect that they're curried, and going through examples for all of these. -- Even after doing all this, and iterating on my approach each time to try to explain it more effectively than I had the time before, I'd estimate that under 50% of the class ended up actually understanding currying. I consistently heard that in practice it only "clicked" for most people after spending significantly more time writing code with it. - -This is not the end of the world, especially because it's easy enough to think "okay, I still don't totally get this -even after that explanation, but I can remember that function arguments are separated by `->` in this language -and maybe I'll understand the rest later." (Which they almost always do, if they stick with the language.) -Clearly currying doesn't preclude a language from being easy to learn, because Elm has currying, and Elm's learning -curve is famously gentle. +It's common for beginners to report that currying only "clikced" for them after spending significant time writing code +in a curried language. This is not the end of the world, especially because it's easy enough to think "I still don't +totally get this even after that explanation, but I can remember that function arguments are separated by `->` in this +language and maybe I'll understand the rest later." Clearly currying doesn't preclude a language from being easy to learn, +because Elm has currying, and Elm's learning curve is famously gentle. That said, beginners who feel confused while learning the language are less likely to continue with it. And however easy Roc would be to learn if it had currying, the language is certainly easier to learn without it. @@ -366,37 +370,27 @@ compose : (a -> b), (c -> a) -> (c -> b) compose = \f, g, x -> f (g x) ``` -Here's how I would instead write this: +Here's a way to write it without pointfree function composition: ```elm reverseSort : List elem -> List elem reverseSort = \list -> List.reverse (List.sort list) ``` -I've consistently found that I can more quickly and accurately understand function definitions that use -named arguments, even though the code is longer. I suspect this is because I'm faster at reading than I am at -eta-expanding ( e.g. converting `List.sort` into `\l -> List.sort l` ). Whenever I read -the top version I end up needing to mentally eta-expand it into the bottom version. -In more complex examples (this is among the tamest pointfree function composition examples I've seen), I make -a mistake in my mental eta-expansion, and misunderstand what the function is doing - which can cause bugs. +It's very common for programmers to build a mental model of what `compose List.reverse List.sort` does by +mentally translating it into `\list -> List.reverse (List.sort list)`. This makes it take longer to read +and to understand despite being technically more concise. Worse, in more complex examples (this is among +the tamest of pointfree function composition examples), the chances increase of making a mistake in the mental +translation step, leading to a misundesrtanding of what the function is doing—which can cause bugs. -I assumed I would get faster and more accurate at this over time. However, by now it's been about a decade -since I first learned about the technique, and I'm still slower and less accurate at reading code that uses -pointfree function composition (including if I wrote it - but even moreso if I didn't) than code written with -with named arguments. I've asked a lot of other programmers about their experiences with pointfree function -composition over the years, and the overwhelming majority of responses have been consistent with my experience. - -As such, my opinion about pointfree function composition has gotten less and less nuanced over time. I've now moved -past "it's the right tool for the job, sometimes" to concluding it's best thought of as an antipattern. This is -because I realized how much time I was spending evaluating on a case-by-case basis whether it might be the -right fit for a given situation. The time spent on this analysis alone vastly outweighed the sum of all the -benefits I got in the rare cases where I concluded it was a fit. So I've found the way to get the most out of -pointfree function composition is to never even think about using it; every other strategy leads to a worse outcome. - -Currying facilitates the antipattern of pointfree function composition, which I view as a downside of currying. +In these ways, pointfree function composition makes code take longer to read and to understand, while increasing the +odds of misunderstanding what the code is doing. Some languages place such a high value on conciseness that they would +consider the conciceness upside to outweigh these downsides, but Roc is not one of those languages. It's considered +stylistically better in Roc to write the second version above. Given this, since currying facilitates pointfree function +composition, making Roc a curried language would have the downside of facilitating an antipattern in the language. Stacking up all these downsides of currying against the one upside of making certain function calls more concise, -I concluded that it would be a mistake to have it in Roc. +it seems clear that Roc should not be a curried language. ## Will Roc ever have linear types, dependent types, refinement types, or uniqueness types? From 7404842f49ecb849d7466f000e4bc984f2c5d30c Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Sun, 13 Aug 2023 21:48:23 -0400 Subject: [PATCH 106/176] Don't put spaces inside tuples in error messages --- crates/reporting/src/error/type.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/reporting/src/error/type.rs b/crates/reporting/src/error/type.rs index 794e981547..e9ad9e9552 100644 --- a/crates/reporting/src/error/type.rs +++ b/crates/reporting/src/error/type.rs @@ -4115,21 +4115,21 @@ mod report_text { alloc.text("()") } else { alloc - .text("( ") - .append(alloc.ellipsis().append(alloc.text(" }"))) + .text("(") + .append(alloc.ellipsis().append(alloc.text(")"))) } .append(ext_doc) } else if entries.len() == 1 { // Single-field records get printed on one line; multi-field records get multiple lines alloc - .text("( ") + .text("(") .append(entries.into_iter().next().unwrap()) .append(if fields_omitted == 0 { alloc.text("") } else { alloc.text(", ").append(alloc.ellipsis()) }) - .append(alloc.text(" )")) + .append(alloc.text(")")) .append(ext_doc) } else { let ending = if fields_omitted == 0 { @@ -4142,7 +4142,7 @@ mod report_text { } .append(ext_doc); - // Multi-elem tuple get printed on multiple lines + // Multi-elem tuples get printed on multiple lines alloc.vcat( std::iter::once(alloc.reflow("(")).chain( entries From 04b058bb36d9117e46e467d9065f63c1d5995d9a Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Mon, 14 Aug 2023 16:42:00 +0200 Subject: [PATCH 107/176] added arm64 basic-cli test --- .github/workflows/basic_cli_test_arm64.yml | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 .github/workflows/basic_cli_test_arm64.yml diff --git a/.github/workflows/basic_cli_test_arm64.yml b/.github/workflows/basic_cli_test_arm64.yml new file mode 100644 index 0000000000..09a97d9012 --- /dev/null +++ b/.github/workflows/basic_cli_test_arm64.yml @@ -0,0 +1,25 @@ +on: + pull_request: + workflow_dispatch: + +# this cancels workflows currently in progress if you start a new one +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + test-basic-cli-release-arm64: + runs-on: [self-hosted, Linux, ARM64] + steps: + - name: clone basic-cli repo + uses: actions/checkout@v3 + with: + repository: roc-lang/basic-cli + ref: main + + - run: Run all tests with latest roc release + latest basic-cli release + run: ./ci/test_latest_release.sh + + + + From 5498d75baee47418da4fea925e51d84bae17c2bf Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Mon, 14 Aug 2023 16:43:01 +0200 Subject: [PATCH 108/176] minor cleanup --- .github/workflows/basic_cli_test_arm64.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/basic_cli_test_arm64.yml b/.github/workflows/basic_cli_test_arm64.yml index 09a97d9012..a892626949 100644 --- a/.github/workflows/basic_cli_test_arm64.yml +++ b/.github/workflows/basic_cli_test_arm64.yml @@ -17,9 +17,5 @@ jobs: repository: roc-lang/basic-cli ref: main - - run: Run all tests with latest roc release + latest basic-cli release + - name: Run all tests with latest roc release + latest basic-cli release run: ./ci/test_latest_release.sh - - - - From d20a83ad62cb98d96ad4affdd8d02fcfdbb77708 Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Mon, 14 Aug 2023 16:48:35 +0200 Subject: [PATCH 109/176] use arm64 release Signed-off-by: Anton-4 <17049058+Anton-4@users.noreply.github.com> --- .github/workflows/basic_cli_test_arm64.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/basic_cli_test_arm64.yml b/.github/workflows/basic_cli_test_arm64.yml index a892626949..c6cd0eafcf 100644 --- a/.github/workflows/basic_cli_test_arm64.yml +++ b/.github/workflows/basic_cli_test_arm64.yml @@ -17,5 +17,7 @@ jobs: repository: roc-lang/basic-cli ref: main - - name: Run all tests with latest roc release + latest basic-cli release - run: ./ci/test_latest_release.sh + - name: Run all tests with latest roc nightly + latest basic-cli release + run: | + sed -i 's/x86_64/arm64/g' ./ci/test_latest_release.sh + ./ci/test_latest_release.sh From a5b601ade8e5803e17668e83e3f1b2f6de84ced5 Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Mon, 14 Aug 2023 18:33:12 +0200 Subject: [PATCH 110/176] remove PR trigger Signed-off-by: Anton-4 <17049058+Anton-4@users.noreply.github.com> --- .github/workflows/basic_cli_test_arm64.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/basic_cli_test_arm64.yml b/.github/workflows/basic_cli_test_arm64.yml index c6cd0eafcf..c9fd4f14f4 100644 --- a/.github/workflows/basic_cli_test_arm64.yml +++ b/.github/workflows/basic_cli_test_arm64.yml @@ -1,5 +1,4 @@ on: - pull_request: workflow_dispatch: # this cancels workflows currently in progress if you start a new one From 5d6c787deb6191c8b3a4c268ae415d4c2c903ae1 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Mon, 14 Aug 2023 14:50:53 -0400 Subject: [PATCH 111/176] Special-case layout conversions for builtin alias --- crates/compiler/builtins/roc/Inspect.roc | 2 ++ crates/compiler/mono/src/ir.rs | 2 +- crates/compiler/mono/src/layout.rs | 8 +++++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/crates/compiler/builtins/roc/Inspect.roc b/crates/compiler/builtins/roc/Inspect.roc index 9c2521712c..11f8c3a5a4 100644 --- a/crates/compiler/builtins/roc/Inspect.roc +++ b/crates/compiler/builtins/roc/Inspect.roc @@ -36,6 +36,8 @@ interface Inspect imports [ Bool.{ Bool }, Num.{ U8, U16, U32, U64, U128, I8, I16, I32, I64, I128, F32, F64, Dec }, + List, + Str, ] KeyValWalker state collection key val : collection, state, (state, key, val -> state) -> state diff --git a/crates/compiler/mono/src/ir.rs b/crates/compiler/mono/src/ir.rs index 2a4df79103..4d4bfdb2a3 100644 --- a/crates/compiler/mono/src/ir.rs +++ b/crates/compiler/mono/src/ir.rs @@ -3965,7 +3965,7 @@ fn build_specialized_proc<'a>( } } Ordering::Less => panic!( - "more argument symbols than arguments (according to the layout) for {proc_name:?}" + "more argument symbols than arguments (according to the layout) for {proc_name:?}. Pattern symbols: {:?}\n\nPattern layouts: {:?}", pattern_symbols, pattern_layouts_len, ), } } diff --git a/crates/compiler/mono/src/layout.rs b/crates/compiler/mono/src/layout.rs index a1a31a0e94..2508617e7e 100644 --- a/crates/compiler/mono/src/layout.rs +++ b/crates/compiler/mono/src/layout.rs @@ -580,10 +580,16 @@ impl<'a> RawFunctionLayout<'a> { cacheable(Ok(Self::ZeroArgumentThunk(Layout::usize(env.target_info)))) } - Alias(symbol, _, _, _) if symbol.is_builtin() => { + Alias(Symbol::NUM_NUM | Symbol::NUM_INT | Symbol::NUM_FRAC | Symbol::NUM_DEC | Symbol::BOOL_BOOL | Symbol::RESULT_RESULT, _, _, _) => { Layout::new_help(env, var, content).then(Self::ZeroArgumentThunk) } + Alias(Symbol::INSPECT_ELEM_WALKER | Symbol::INSPECT_KEY_VAL_WALKER, _, var, _) => Self::from_var(env, var), + + Alias(symbol, _, _, _) if symbol.is_builtin() => { + unreachable!("Need to special-case this builtin, like the ones above: {:?}", symbol); + } + Alias(_, _, var, _) => Self::from_var(env, var), Error => cacheable(Err(LayoutProblem::Erroneous)), } From 609d76529a8741943b46adc179c99230ba407ad2 Mon Sep 17 00:00:00 2001 From: Folkert Date: Mon, 14 Aug 2023 22:24:47 +0200 Subject: [PATCH 112/176] skeleton for unsized glue --- crates/glue/src/RustGlue.roc | 69 ++++++++++++++++++-------- examples/glue/rust-platform/Cargo.toml | 3 +- examples/glue/rust-platform/src/lib.rs | 12 ++--- 3 files changed, 56 insertions(+), 28 deletions(-) diff --git a/crates/glue/src/RustGlue.roc b/crates/glue/src/RustGlue.roc index 8c5d6a4718..d94c205fc2 100644 --- a/crates/glue/src/RustGlue.roc +++ b/crates/glue/src/RustGlue.roc @@ -1,7 +1,10 @@ app "rust-glue" packages { pf: "../platform/main.roc" } imports [ - pf.Types.{ Types }, pf.Shape.{ Shape, RocFn }, pf.File.{ File }, pf.TypeId.{ TypeId }, + pf.Types.{ Types }, + pf.Shape.{ Shape, RocFn }, + pf.File.{ File }, + pf.TypeId.{ TypeId }, "../static/Cargo.toml" as rocAppCargoToml : Str, "../../roc_std/Cargo.toml" as rocStdCargoToml : Str, "../../roc_std/src/lib.rs" as rocStdLib : Str, @@ -39,18 +42,17 @@ makeGlue = \typesByArch -> ## These are always included, and don't depend on the specifics of the app. staticFiles : List File -staticFiles = - [ - { name: "roc_app/Cargo.toml", content: rocAppCargoToml }, - { name: "roc_std/Cargo.toml", content: rocStdCargoToml }, - { name: "roc_std/src/lib.rs", content: rocStdLib }, - { name: "roc_std/src/roc_box.rs", content: rocStdBox }, - { name: "roc_std/src/roc_list.rs", content: rocStdList }, - { name: "roc_std/src/roc_dict.rs", content: rocStdDict }, - { name: "roc_std/src/roc_set.rs", content: rocStdSet }, - { name: "roc_std/src/roc_str.rs", content: rocStdStr }, - { name: "roc_std/src/storage.rs", content: rocStdStorage }, - ] +staticFiles = [ + { name: "roc_app/Cargo.toml", content: rocAppCargoToml }, + { name: "roc_std/Cargo.toml", content: rocStdCargoToml }, + { name: "roc_std/src/lib.rs", content: rocStdLib }, + { name: "roc_std/src/roc_box.rs", content: rocStdBox }, + { name: "roc_std/src/roc_list.rs", content: rocStdList }, + { name: "roc_std/src/roc_dict.rs", content: rocStdDict }, + { name: "roc_std/src/roc_set.rs", content: rocStdSet }, + { name: "roc_std/src/roc_str.rs", content: rocStdStr }, + { name: "roc_std/src/storage.rs", content: rocStdStorage }, +] convertTypesToFile : Types -> File convertTypesToFile = \types -> @@ -845,6 +847,32 @@ generateRecursiveTagUnion = \buf, types, id, tagUnionName, tags, discriminantSiz None -> [] + fieldGetters = + List.walk payloadFields { i: 0, accum: "" } \{ i, accum }, fieldTypeId -> + fieldTypeName = typeName types fieldTypeId + fieldIndex = Num.toStr i + + { + i: i + 1, + accum: + """ + \(accum) + pub fn get_\(tagName)_f\(fieldIndex)(&self) -> &\(fieldTypeName) { + debug_assert!(self.is_\(tagName)()); + + // extern "C" { + // fn foobar(tag_id: u16, field_index: usize) -> usize; + // } + + // let offset = unsafe { foobar(\(fieldIndex)) }; + let offset = 0; + unsafe { &*self.unmasked_pointer().add(offset).cast() } + } + + """, + } + |> .accum + payloadFieldNames = commaSeparated "" payloadFields \_, i -> n = Num.toStr i @@ -896,6 +924,7 @@ generateRecursiveTagUnion = \buf, types, id, tagUnionName, tags, discriminantSiz Self((ptr as usize | tag_id as usize) as *mut _) } + \(fieldGetters) pub fn get_\(tagName)(mut self) -> \(escapedName)_\(tagName) { debug_assert!(self.is_\(tagName)()); @@ -1040,8 +1069,6 @@ generateRecursiveTagUnion = \buf, types, id, tagUnionName, tags, discriminantSiz |> List.mapWithIndex hashCase |> Str.joinWith "\n" - - hashImpl = if canSupportPartialEqOrd types (Types.shape types id) then """ @@ -1144,7 +1171,7 @@ generateRecursiveTagUnion = \buf, types, id, tagUnionName, tags, discriminantSiz } } - unsafe fn ptr_read_union(&self) -> core::mem::ManuallyDrop { + fn unmasked_pointer(&self) -> *mut union_Op { debug_assert!(!self.0.is_null()); let mask = match std::mem::size_of::() { @@ -1153,7 +1180,11 @@ generateRecursiveTagUnion = \buf, types, id, tagUnionName, tags, discriminantSiz _ => unreachable!(), }; - let ptr = ((self.0 as usize) & mask) as *mut union_\(escapedName); + ((self.0 as usize) & mask) as *mut union_Op + } + + unsafe fn ptr_read_union(&self) -> core::mem::ManuallyDrop { + let ptr = self.unmasked_pointer(); core::mem::ManuallyDrop::new(unsafe { std::ptr::read(ptr) }) } @@ -1803,12 +1834,11 @@ canDeriveCopy = \types, type -> cannotSupportDefault = \types, type -> when type is Unit | Unsized | EmptyTagUnion | TagUnion _ | RocResult _ _ | RecursivePointer _ | Function _ -> Bool.true - RocStr | Bool | Num _ -> Bool.false + RocStr | Bool | Num _ -> Bool.false RocList id | RocSet id | RocBox id -> cannotSupportDefault types (Types.shape types id) TagUnionPayload { fields: HasClosure _ } -> Bool.true - RocDict keyId valId -> cannotSupportCopy types (Types.shape types keyId) || cannotSupportCopy types (Types.shape types valId) @@ -2090,7 +2120,6 @@ nextMultipleOf = \lhs, rhs -> 0 -> lhs r -> lhs + (rhs - r) - isUnit : Shape -> Bool isUnit = \shape -> when shape is diff --git a/examples/glue/rust-platform/Cargo.toml b/examples/glue/rust-platform/Cargo.toml index 8d10ce6eea..3cfadfba58 100644 --- a/examples/glue/rust-platform/Cargo.toml +++ b/examples/glue/rust-platform/Cargo.toml @@ -16,7 +16,8 @@ name = "host" path = "src/main.rs" [dependencies] -roc_std = { path = "../../../crates/roc_std" } +roc_app = { path = "roc_app" } +roc_std = { path = "roc_std" } libc = "0.2" [workspace] diff --git a/examples/glue/rust-platform/src/lib.rs b/examples/glue/rust-platform/src/lib.rs index fe5398b647..e821634b41 100644 --- a/examples/glue/rust-platform/src/lib.rs +++ b/examples/glue/rust-platform/src/lib.rs @@ -1,15 +1,13 @@ #![allow(non_snake_case)] -mod test_glue; - use core::ffi::c_void; +use roc_app::Op; use roc_std::RocStr; use std::ffi::CStr; use std::io::Write; use std::os::raw::c_char; -use test_glue::Op; -use test_glue::mainForHost as roc_main; +use roc_app::mainForHost as roc_main; #[no_mangle] pub unsafe extern "C" fn roc_alloc(size: usize, _alignment: u32) -> *mut c_void { @@ -80,7 +78,7 @@ pub unsafe extern "C" fn roc_shm_open( #[no_mangle] pub extern "C" fn rust_main() -> i32 { - use test_glue::discriminant_Op::*; + use roc_app::discriminant_Op::*; println!("Let's do things!"); @@ -91,7 +89,7 @@ pub extern "C" fn rust_main() -> i32 { StdoutWrite => { let stdout_write = op.get_StdoutWrite(); let output: RocStr = stdout_write.f0; - op = unsafe { stdout_write.f1.force_thunk(()) }; + op = unsafe { stdout_write.f1.force_thunk() }; if let Err(e) = std::io::stdout().write_all(output.as_bytes()) { panic!("Writing to stdout failed! {:?}", e); @@ -100,7 +98,7 @@ pub extern "C" fn rust_main() -> i32 { StderrWrite => { let stderr_write = op.get_StderrWrite(); let output: RocStr = stderr_write.f0; - op = unsafe { stderr_write.f1.force_thunk(()) }; + op = unsafe { stderr_write.f1.force_thunk() }; if let Err(e) = std::io::stderr().write_all(output.as_bytes()) { panic!("Writing to stdout failed! {:?}", e); From 83ead6b2b2fe9928151892077d182723c1ec1267 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Mon, 14 Aug 2023 18:47:50 -0400 Subject: [PATCH 113/176] Special-case TotallyNotJson types for now --- crates/compiler/module/src/symbol.rs | 6 ++++++ crates/compiler/mono/src/layout.rs | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/crates/compiler/module/src/symbol.rs b/crates/compiler/module/src/symbol.rs index 3d52c928a5..9fe4b5a58c 100644 --- a/crates/compiler/module/src/symbol.rs +++ b/crates/compiler/module/src/symbol.rs @@ -1624,6 +1624,12 @@ define_builtins! { } 15 JSON: "TotallyNotJson" => { 0 JSON_JSON: "TotallyNotJson" + 1 JSON_FIELD_NAME_MAPPING: "FieldNameMapping" + 2 JSON_NUMBER_STATE: "NumberState" + 3 JSON_STRING_STATE: "StringState" + 4 JSON_ARRAY_OPENING_STATE: "ArrayOpeningState" + 5 JSON_ARRAY_CLOSING_STATE: "ArrayClosingState" + 6 JSON_OBJECT_STATE: "ObjectState" } num_modules: 16 // Keep this count up to date by hand! (TODO: see the mut_map! macro for how we could determine this count correctly in the macro) diff --git a/crates/compiler/mono/src/layout.rs b/crates/compiler/mono/src/layout.rs index 2508617e7e..ede5aee641 100644 --- a/crates/compiler/mono/src/layout.rs +++ b/crates/compiler/mono/src/layout.rs @@ -580,14 +580,14 @@ impl<'a> RawFunctionLayout<'a> { cacheable(Ok(Self::ZeroArgumentThunk(Layout::usize(env.target_info)))) } - Alias(Symbol::NUM_NUM | Symbol::NUM_INT | Symbol::NUM_FRAC | Symbol::NUM_DEC | Symbol::BOOL_BOOL | Symbol::RESULT_RESULT, _, _, _) => { + Alias(Symbol::NUM_NUM | Symbol::NUM_INT | Symbol::NUM_FRAC | Symbol::NUM_DEC | Symbol::BOOL_BOOL | Symbol::RESULT_RESULT | Symbol::JSON_FIELD_NAME_MAPPING | Symbol::JSON_JSON | Symbol::JSON_NUMBER_STATE | Symbol::JSON_STRING_STATE | Symbol::JSON_ARRAY_OPENING_STATE | Symbol::JSON_ARRAY_CLOSING_STATE | Symbol::JSON_OBJECT_STATE, _, _, _) => { Layout::new_help(env, var, content).then(Self::ZeroArgumentThunk) } Alias(Symbol::INSPECT_ELEM_WALKER | Symbol::INSPECT_KEY_VAL_WALKER, _, var, _) => Self::from_var(env, var), Alias(symbol, _, _, _) if symbol.is_builtin() => { - unreachable!("Need to special-case this builtin, like the ones above: {:?}", symbol); + unreachable!("The named builtin type {:?} does not have an explicit entry for whether it's a zero-arg thunk or type alias.", symbol); } Alias(_, _, var, _) => Self::from_var(env, var), From 995c985fbe126464c6445623c71beea91033d97d Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Mon, 14 Aug 2023 18:59:36 -0400 Subject: [PATCH 114/176] Give up on exhaustively enumerating aliases Keep getting errors in the build ruby example on Json, and it doesn't tell me the name of the symbol, just the IdentId, which makes this really hard to track down. This approach works fine, it'll just be harder to debug the next time we run into a special case like ElemWalker. --- crates/compiler/mono/src/layout.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/crates/compiler/mono/src/layout.rs b/crates/compiler/mono/src/layout.rs index ede5aee641..ba76bff506 100644 --- a/crates/compiler/mono/src/layout.rs +++ b/crates/compiler/mono/src/layout.rs @@ -580,14 +580,10 @@ impl<'a> RawFunctionLayout<'a> { cacheable(Ok(Self::ZeroArgumentThunk(Layout::usize(env.target_info)))) } - Alias(Symbol::NUM_NUM | Symbol::NUM_INT | Symbol::NUM_FRAC | Symbol::NUM_DEC | Symbol::BOOL_BOOL | Symbol::RESULT_RESULT | Symbol::JSON_FIELD_NAME_MAPPING | Symbol::JSON_JSON | Symbol::JSON_NUMBER_STATE | Symbol::JSON_STRING_STATE | Symbol::JSON_ARRAY_OPENING_STATE | Symbol::JSON_ARRAY_CLOSING_STATE | Symbol::JSON_OBJECT_STATE, _, _, _) => { - Layout::new_help(env, var, content).then(Self::ZeroArgumentThunk) - } - Alias(Symbol::INSPECT_ELEM_WALKER | Symbol::INSPECT_KEY_VAL_WALKER, _, var, _) => Self::from_var(env, var), - Alias(symbol, _, _, _) if symbol.is_builtin() => { - unreachable!("The named builtin type {:?} does not have an explicit entry for whether it's a zero-arg thunk or type alias.", symbol); + Alias(symbol, _, var, _) if symbol.is_builtin() => { + Layout::new_help(env, var, content).then(Self::ZeroArgumentThunk) } Alias(_, _, var, _) => Self::from_var(env, var), From e31b41864e2ba776b0f5e641baa818b3720c3aee Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Mon, 14 Aug 2023 16:03:05 -0400 Subject: [PATCH 115/176] Use wrapping and saturating arithmetic in builtins --- crates/compiler/builtins/roc/Dict.roc | 14 ++++----- crates/compiler/builtins/roc/List.roc | 44 ++++++++++++++++----------- crates/compiler/builtins/roc/Num.roc | 8 ++--- crates/compiler/builtins/roc/Str.roc | 24 ++++++++------- 4 files changed, 50 insertions(+), 40 deletions(-) diff --git a/crates/compiler/builtins/roc/Dict.roc b/crates/compiler/builtins/roc/Dict.roc index 593e37d139..e188688eb5 100644 --- a/crates/compiler/builtins/roc/Dict.roc +++ b/crates/compiler/builtins/roc/Dict.roc @@ -151,7 +151,7 @@ capacity : Dict * * -> Nat capacity = \@Dict { dataIndices } -> cap = List.len dataIndices - cap - Num.shiftRightZfBy cap 3 + Num.subWrap cap (Num.shiftRightZfBy cap 3) ## Return a dictionary with space allocated for a number of entries. This ## may provide a performance optimization if you know how many entries will be @@ -401,7 +401,7 @@ insert = \@Dict { metadata, dataIndices, data, size }, key, value -> metadata, dataIndices, data, - size: size + 1, + size: Num.addWrap size 1, } ) @@ -430,7 +430,7 @@ remove = \@Dict { metadata, dataIndices, data, size }, key -> when findIndexHelper metadata dataIndices data h2Key key probe 0 is Ok index -> - last = List.len data - 1 + last = Num.subWrap (List.len data) 1 dataIndex = listGetUnsafe dataIndices index if dataIndex == last then @@ -438,7 +438,7 @@ remove = \@Dict { metadata, dataIndices, data, size }, key -> metadata: List.set metadata index deletedSlot, dataIndices, data: List.dropLast data, - size: size - 1, + size: Num.subWrap size 1, } else swapAndUpdateDataIndex (@Dict { metadata, dataIndices, data, size }) index last @@ -626,7 +626,7 @@ swapAndUpdateDataIndex = \@Dict { metadata, dataIndices, data, size }, removedIn # Update index of swaped element. dataIndices: List.set dataIndices index dataIndex, data: nextData, - size: size - 1, + size: Num.subWrap size 1, } Err NotFound -> @@ -701,7 +701,7 @@ maybeRehash = \@Dict { metadata, dataIndices, data, size } -> cap = List.len dataIndices maxLoadCap = # This is 7/8 * capacity, which is the max load factor. - cap - Num.shiftRightZfBy cap 3 + Num.subWrap cap (Num.shiftRightZfBy cap 3) if size > maxLoadCap then rehash (@Dict { metadata, dataIndices, data, size }) @@ -737,7 +737,7 @@ rehashHelper = \dict, oldMetadata, oldDataIndices, oldData, index -> # Empty or deleted data dict - rehashHelper nextDict oldMetadata oldDataIndices oldData (index + 1) + rehashHelper nextDict oldMetadata oldDataIndices oldData (Num.addWrap index 1) Err OutOfBounds -> # Walked entire list, complete now. diff --git a/crates/compiler/builtins/roc/List.roc b/crates/compiler/builtins/roc/List.roc index 9c91295c6c..b4e3031608 100644 --- a/crates/compiler/builtins/roc/List.roc +++ b/crates/compiler/builtins/roc/List.roc @@ -391,7 +391,7 @@ repeat = \value, count -> repeatHelp : a, Nat, List a -> List a repeatHelp = \value, count, accum -> if count > 0 then - repeatHelp value (count - 1) (List.appendUnsafe accum value) + repeatHelp value (dec count) (List.appendUnsafe accum value) else accum @@ -405,7 +405,7 @@ reverse = \list -> reverseHelp = \list, left, right -> if left < right then - reverseHelp (List.swap list left right) (left + 1) (right - 1) + reverseHelp (List.swap list left right) (inc left) (dec right) else list @@ -418,7 +418,7 @@ reverseHelp = \list, left, right -> join : List (List a) -> List a join = \lists -> totalLength = - List.walk lists 0 (\state, list -> state + List.len list) + List.walk lists 0 (\state, list -> Num.addWrap state (List.len list)) List.walk lists (List.withCapacity totalLength) (\state, list -> List.concat state list) @@ -478,7 +478,7 @@ walkBackwardsHelp = \list, state, f, indexPlusOne -> if indexPlusOne == 0 then state else - index = indexPlusOne - 1 + index = dec indexPlusOne nextState = f state (getUnsafe list index) walkBackwardsHelp list nextState f index @@ -590,9 +590,9 @@ keepIfHelp : List a, (a -> Bool), Nat, Nat, Nat -> List a keepIfHelp = \list, predicate, kept, index, length -> if index < length then if predicate (List.getUnsafe list index) then - keepIfHelp (List.swap list kept index) predicate (kept + 1) (index + 1) length + keepIfHelp (List.swap list kept index) predicate (inc kept) (inc index) length else - keepIfHelp list predicate kept (index + 1) length + keepIfHelp list predicate kept (inc index) length else List.takeFirst list kept @@ -619,7 +619,7 @@ countIf : List a, (a -> Bool) -> Nat countIf = \list, predicate -> walkState = \state, elem -> if predicate elem then - state + 1 + inc state else state @@ -712,7 +712,7 @@ mapWithIndexHelp = \src, dest, func, index, length -> mappedElem = func elem index newDest = List.appendUnsafe dest mappedElem - mapWithIndexHelp src newDest func (index + 1) length + mapWithIndexHelp src newDest func (inc index) length else dest @@ -817,7 +817,7 @@ rangeLengthHelp = \accum, i, remaining, calcNext -> else when i is Ok val -> - rangeLengthHelp (List.appendUnsafe accum val) (calcNext val) (remaining - 1) calcNext + rangeLengthHelp (List.appendUnsafe accum val) (calcNext val) (dec remaining) calcNext Err _ -> # We went past the end of the numeric range and there is no next. @@ -1036,7 +1036,7 @@ findFirstIndex = \list, matcher -> if matcher elem then Break index else - Continue (index + 1) + Continue (inc index) when foundIndex is Break index -> Ok index @@ -1048,10 +1048,12 @@ findFirstIndex = \list, matcher -> findLastIndex : List elem, (elem -> Bool) -> Result Nat [NotFound] findLastIndex = \list, matches -> foundIndex = List.iterateBackwards list (List.len list) \prevIndex, elem -> + answer = dec prevIndex + if matches elem then - Break (prevIndex - 1) + Break answer else - Continue (prevIndex - 1) + Continue answer when foundIndex is Break index -> Ok index @@ -1137,7 +1139,7 @@ split = \elements, userSplitIndex -> length = List.len elements splitIndex = if length > userSplitIndex then userSplitIndex else length before = List.sublist elements { start: 0, len: splitIndex } - others = List.sublist elements { start: splitIndex, len: length - splitIndex } + others = List.sublist elements { start: splitIndex, len: Num.subWrap length splitIndex } { before, others } @@ -1151,7 +1153,7 @@ splitFirst = \list, delimiter -> when List.findFirstIndex list (\elem -> elem == delimiter) is Ok index -> before = List.sublist list { start: 0, len: index } - after = List.sublist list { start: index + 1, len: List.len list - index - 1 } + after = List.sublist list { start: inc index, len: Num.subWrap (List.len list) index |> dec } Ok { before, after } @@ -1167,7 +1169,7 @@ splitLast = \list, delimiter -> when List.findLastIndex list (\elem -> elem == delimiter) is Ok index -> before = List.sublist list { start: 0, len: index } - after = List.sublist list { start: index + 1, len: List.len list - index - 1 } + after = List.sublist list { start: inc index, len: Num.subWrap (List.len list) index |> dec } Ok { before, after } @@ -1202,7 +1204,7 @@ walkTryHelp : List elem, state, (state, elem -> Result state err), Nat, Nat -> R walkTryHelp = \list, state, f, index, length -> if index < length then when f state (List.getUnsafe list index) is - Ok nextState -> walkTryHelp list nextState f (index + 1) length + Ok nextState -> walkTryHelp list nextState f (inc index) length Err b -> Err b else Ok state @@ -1217,7 +1219,7 @@ iterHelp : List elem, s, (s, elem -> [Continue s, Break b]), Nat, Nat -> [Contin iterHelp = \list, state, f, index, length -> if index < length then when f state (List.getUnsafe list index) is - Continue nextState -> iterHelp list nextState f (index + 1) length + Continue nextState -> iterHelp list nextState f (inc index) length Break b -> Break b else Continue state @@ -1232,10 +1234,16 @@ iterateBackwards = \list, init, func -> iterBackwardsHelp : List elem, s, (s, elem -> [Continue s, Break b]), Nat -> [Continue s, Break b] iterBackwardsHelp = \list, state, f, prevIndex -> if prevIndex > 0 then - index = prevIndex - 1 + index = dec prevIndex when f state (List.getUnsafe list index) is Continue nextState -> iterBackwardsHelp list nextState f index Break b -> Break b else Continue state + +inc : Int a -> Int a +inc = \num -> Num.addWrap num 1 + +dec : Int a -> Int a +dec = \num -> Num.subWrap num 1 diff --git a/crates/compiler/builtins/roc/Num.roc b/crates/compiler/builtins/roc/Num.roc index 24e265cd9e..2779518924 100644 --- a/crates/compiler/builtins/roc/Num.roc +++ b/crates/compiler/builtins/roc/Num.roc @@ -540,7 +540,7 @@ bytesToU16 = \bytes, index -> # we need at least 1 more byte offset = 1 - if index + offset < List.len bytes then + if Num.addSaturated index offset < List.len bytes then Ok (bytesToU16Lowlevel bytes index) else Err OutOfBounds @@ -550,7 +550,7 @@ bytesToU32 = \bytes, index -> # we need at least 3 more bytes offset = 3 - if index + offset < List.len bytes then + if Num.addSaturated index offset < List.len bytes then Ok (bytesToU32Lowlevel bytes index) else Err OutOfBounds @@ -560,7 +560,7 @@ bytesToU64 = \bytes, index -> # we need at least 7 more bytes offset = 7 - if index + offset < List.len bytes then + if Num.addSaturated index offset < List.len bytes then Ok (bytesToU64Lowlevel bytes index) else Err OutOfBounds @@ -570,7 +570,7 @@ bytesToU128 = \bytes, index -> # we need at least 15 more bytes offset = 15 - if index + offset < List.len bytes then + if Num.addSaturated index offset < List.len bytes then Ok (bytesToU128Lowlevel bytes index) else Err OutOfBounds diff --git a/crates/compiler/builtins/roc/Str.roc b/crates/compiler/builtins/roc/Str.roc index 3783b8edc7..dfe600a523 100644 --- a/crates/compiler/builtins/roc/Str.roc +++ b/crates/compiler/builtins/roc/Str.roc @@ -400,7 +400,7 @@ expect (Str.fromUtf8 [255]) |> Result.isErr ## ``` fromUtf8Range : List U8, { start : Nat, count : Nat } -> Result Str [BadUtf8 Utf8ByteProblem Nat, OutOfBounds] fromUtf8Range = \bytes, config -> - if config.start + config.count <= List.len bytes then + if Num.addSaturated config.start config.count <= List.len bytes then result = fromUtf8RangeLowlevel bytes config.start config.count if result.cIsOk then @@ -721,7 +721,7 @@ splitFirst = \haystack, needle -> remaining = Str.countUtf8Bytes haystack - Str.countUtf8Bytes needle - index before = Str.substringUnsafe haystack 0 index - after = Str.substringUnsafe haystack (index + Str.countUtf8Bytes needle) remaining + after = Str.substringUnsafe haystack (Num.addWrap index (Str.countUtf8Bytes needle)) remaining Ok { before, after } @@ -757,7 +757,7 @@ firstMatchHelp = \haystack, needle, index, lastPossible -> if matchesAt haystack index needle then Some index else - firstMatchHelp haystack needle (index + 1) lastPossible + firstMatchHelp haystack needle (inc index) lastPossible else None @@ -775,7 +775,7 @@ splitLast = \haystack, needle -> remaining = Str.countUtf8Bytes haystack - Str.countUtf8Bytes needle - index before = Str.substringUnsafe haystack 0 index - after = Str.substringUnsafe haystack (index + Str.countUtf8Bytes needle) remaining + after = Str.substringUnsafe haystack (Num.addWrap index (Str.countUtf8Bytes needle)) remaining Ok { before, after } @@ -820,7 +820,7 @@ matchesAt : Str, Nat, Str -> Bool matchesAt = \haystack, haystackIndex, needle -> haystackLength = Str.countUtf8Bytes haystack needleLength = Str.countUtf8Bytes needle - endIndex = min (haystackIndex + needleLength) haystackLength + endIndex = min (Num.addSaturated haystackIndex needleLength) haystackLength matchesAtHelp { haystack, @@ -847,8 +847,8 @@ matchesAtHelp = \state -> doesRestMatch = matchesAtHelp { state & - haystackIndex: haystackIndex + 1, - needleIndex: needleIndex + 1, + haystackIndex: inc haystackIndex, + needleIndex: inc needleIndex, } doesThisMatch && doesRestMatch @@ -871,7 +871,7 @@ walkUtf8WithIndexHelp = \string, state, step, index, length -> byte = Str.getUnsafe string index newState = step state byte index - walkUtf8WithIndexHelp string newState step (index + 1) length + walkUtf8WithIndexHelp string newState step (inc index) length else state @@ -892,7 +892,7 @@ walkUtf8Help = \str, state, step, index, length -> byte = Str.getUnsafe str index newState = step state byte - walkUtf8Help str newState step (index + 1) length + walkUtf8Help str newState step (inc index) length else state @@ -942,7 +942,7 @@ walkScalarsHelp = \string, state, step, index, length -> { scalar, bytesParsed } = getScalarUnsafe string index newState = step state scalar - walkScalarsHelp string newState step (index + bytesParsed) length + walkScalarsHelp string newState step (Num.addWrap index bytesParsed) length else state @@ -970,7 +970,7 @@ walkScalarsUntilHelp = \string, state, step, index, length -> when step state scalar is Continue newState -> - walkScalarsUntilHelp string newState step (index + bytesParsed) length + walkScalarsUntilHelp string newState step (Num.addWrap index bytesParsed) length Break newState -> newState @@ -995,3 +995,5 @@ strToNumHelp = \string -> ## ``` withPrefix : Str, Str -> Str withPrefix = \str, prefix -> Str.concat prefix str + +inc = \num -> Num.addWrap num 1 From e8e1d0457fd17303cb0dfea4fe81fd650fa23112 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Mon, 14 Aug 2023 20:06:04 -0400 Subject: [PATCH 116/176] Update mono tests --- .../generated/encode_derived_nested_record_string.txt | 10 +++++----- .../encode_derived_record_one_field_string.txt | 10 +++++----- .../encode_derived_record_two_field_strings.txt | 10 +++++----- .../test_mono/generated/encode_derived_string.txt | 10 +++++----- .../generated/encode_derived_tag_one_field_string.txt | 10 +++++----- .../encode_derived_tag_two_payloads_string.txt | 10 +++++----- crates/compiler/test_mono/generated/issue_4749.txt | 10 +++++----- .../issue_4772_weakened_monomorphic_destructure.txt | 10 +++++----- ...ion_does_not_duplicate_identical_concrete_types.txt | 10 +++++----- ...concrete_types_without_unification_of_unifiable.txt | 10 +++++----- 10 files changed, 50 insertions(+), 50 deletions(-) diff --git a/crates/compiler/test_mono/generated/encode_derived_nested_record_string.txt b/crates/compiler/test_mono/generated/encode_derived_nested_record_string.txt index b838ca257f..99ccc58176 100644 --- a/crates/compiler/test_mono/generated/encode_derived_nested_record_string.txt +++ b/crates/compiler/test_mono/generated/encode_derived_nested_record_string.txt @@ -1093,10 +1093,6 @@ procedure TotallyNotJson.189 (TotallyNotJson.1930, TotallyNotJson.192): ret TotallyNotJson.1955; -procedure TotallyNotJson.2 (): - let TotallyNotJson.1172 : [C , C [], C , C , C , C ] = TagId(2) ; - ret TotallyNotJson.1172; - procedure TotallyNotJson.215 (TotallyNotJson.216, TotallyNotJson.217): let TotallyNotJson.1901 : List U8 = CallByName TotallyNotJson.27 TotallyNotJson.217; let TotallyNotJson.1900 : List U8 = CallByName List.8 TotallyNotJson.216 TotallyNotJson.1901; @@ -1300,6 +1296,10 @@ procedure TotallyNotJson.29 (TotallyNotJson.233): let TotallyNotJson.1526 : List {Str, Str} = CallByName Encode.23 TotallyNotJson.233; ret TotallyNotJson.1526; +procedure TotallyNotJson.8 (): + let TotallyNotJson.1172 : [C , C [], C , C , C , C ] = TagId(2) ; + ret TotallyNotJson.1172; + procedure TotallyNotJson.82 (TotallyNotJson.802, TotallyNotJson.803): let TotallyNotJson.1873 : U8 = GetTagId TotallyNotJson.803; switch TotallyNotJson.1873: @@ -1486,7 +1486,7 @@ procedure TotallyNotJson.98 (#Derived_gen.36): procedure Test.0 (): let Test.12 : Str = "bar"; - let Test.10 : [C , C [], C , C , C , C ] = CallByName TotallyNotJson.2; + let Test.10 : [C , C [], C , C , C , C ] = CallByName TotallyNotJson.8; let Test.8 : List U8 = CallByName Encode.26 Test.12 Test.10; let Test.1 : [C {U64, U8}, C Str] = CallByName Str.9 Test.8; let Test.5 : U8 = 1i64; diff --git a/crates/compiler/test_mono/generated/encode_derived_record_one_field_string.txt b/crates/compiler/test_mono/generated/encode_derived_record_one_field_string.txt index b321fb63dc..08cc188123 100644 --- a/crates/compiler/test_mono/generated/encode_derived_record_one_field_string.txt +++ b/crates/compiler/test_mono/generated/encode_derived_record_one_field_string.txt @@ -1028,10 +1028,6 @@ procedure TotallyNotJson.189 (TotallyNotJson.1579, TotallyNotJson.192): ret TotallyNotJson.1604; -procedure TotallyNotJson.2 (): - let TotallyNotJson.1172 : [C , C [], C , C , C , C ] = TagId(2) ; - ret TotallyNotJson.1172; - procedure TotallyNotJson.215 (TotallyNotJson.216, TotallyNotJson.217): let TotallyNotJson.1550 : List U8 = CallByName TotallyNotJson.27 TotallyNotJson.217; let TotallyNotJson.1549 : List U8 = CallByName List.8 TotallyNotJson.216 TotallyNotJson.1550; @@ -1184,6 +1180,10 @@ procedure TotallyNotJson.29 (TotallyNotJson.233): let TotallyNotJson.1173 : List {Str, Str} = CallByName Encode.23 TotallyNotJson.233; ret TotallyNotJson.1173; +procedure TotallyNotJson.8 (): + let TotallyNotJson.1172 : [C , C [], C , C , C , C ] = TagId(2) ; + ret TotallyNotJson.1172; + procedure TotallyNotJson.82 (TotallyNotJson.802, TotallyNotJson.803): let TotallyNotJson.1522 : U8 = GetTagId TotallyNotJson.803; switch TotallyNotJson.1522: @@ -1370,7 +1370,7 @@ procedure TotallyNotJson.98 (#Derived_gen.10): procedure Test.0 (): let Test.11 : Str = "foo"; - let Test.10 : [C , C [], C , C , C , C ] = CallByName TotallyNotJson.2; + let Test.10 : [C , C [], C , C , C , C ] = CallByName TotallyNotJson.8; let Test.8 : List U8 = CallByName Encode.26 Test.11 Test.10; let Test.1 : [C {U64, U8}, C Str] = CallByName Str.9 Test.8; let Test.5 : U8 = 1i64; diff --git a/crates/compiler/test_mono/generated/encode_derived_record_two_field_strings.txt b/crates/compiler/test_mono/generated/encode_derived_record_two_field_strings.txt index 25f3b04045..3c4b345fb6 100644 --- a/crates/compiler/test_mono/generated/encode_derived_record_two_field_strings.txt +++ b/crates/compiler/test_mono/generated/encode_derived_record_two_field_strings.txt @@ -1035,10 +1035,6 @@ procedure TotallyNotJson.189 (TotallyNotJson.1579, TotallyNotJson.192): ret TotallyNotJson.1604; -procedure TotallyNotJson.2 (): - let TotallyNotJson.1172 : [C , C [], C , C , C , C ] = TagId(2) ; - ret TotallyNotJson.1172; - procedure TotallyNotJson.215 (TotallyNotJson.216, TotallyNotJson.217): let TotallyNotJson.1550 : List U8 = CallByName TotallyNotJson.27 TotallyNotJson.217; let TotallyNotJson.1549 : List U8 = CallByName List.8 TotallyNotJson.216 TotallyNotJson.1550; @@ -1191,6 +1187,10 @@ procedure TotallyNotJson.29 (TotallyNotJson.233): let TotallyNotJson.1173 : List {Str, Str} = CallByName Encode.23 TotallyNotJson.233; ret TotallyNotJson.1173; +procedure TotallyNotJson.8 (): + let TotallyNotJson.1172 : [C , C [], C , C , C , C ] = TagId(2) ; + ret TotallyNotJson.1172; + procedure TotallyNotJson.82 (TotallyNotJson.802, TotallyNotJson.803): let TotallyNotJson.1522 : U8 = GetTagId TotallyNotJson.803; switch TotallyNotJson.1522: @@ -1379,7 +1379,7 @@ procedure Test.0 (): let Test.11 : Str = "foo"; let Test.12 : Str = "bar"; let Test.9 : {Str, Str} = Struct {Test.11, Test.12}; - let Test.10 : [C , C [], C , C , C , C ] = CallByName TotallyNotJson.2; + let Test.10 : [C , C [], C , C , C , C ] = CallByName TotallyNotJson.8; let Test.8 : List U8 = CallByName Encode.26 Test.9 Test.10; let Test.1 : [C {U64, U8}, C Str] = CallByName Str.9 Test.8; let Test.5 : U8 = 1i64; diff --git a/crates/compiler/test_mono/generated/encode_derived_string.txt b/crates/compiler/test_mono/generated/encode_derived_string.txt index be6f580b91..f485dd5bf7 100644 --- a/crates/compiler/test_mono/generated/encode_derived_string.txt +++ b/crates/compiler/test_mono/generated/encode_derived_string.txt @@ -256,10 +256,6 @@ procedure TotallyNotJson.189 (TotallyNotJson.1226, TotallyNotJson.192): ret TotallyNotJson.1251; -procedure TotallyNotJson.2 (): - let TotallyNotJson.1172 : [C , C [], C , C , C , C ] = TagId(2) ; - ret TotallyNotJson.1172; - procedure TotallyNotJson.215 (TotallyNotJson.216, TotallyNotJson.217): let TotallyNotJson.1197 : List U8 = CallByName TotallyNotJson.27 TotallyNotJson.217; let TotallyNotJson.1196 : List U8 = CallByName List.8 TotallyNotJson.216 TotallyNotJson.1197; @@ -361,9 +357,13 @@ procedure TotallyNotJson.27 (TotallyNotJson.218): ret TotallyNotJson.1211; +procedure TotallyNotJson.8 (): + let TotallyNotJson.1172 : [C , C [], C , C , C , C ] = TagId(2) ; + ret TotallyNotJson.1172; + procedure Test.0 (): let Test.9 : Str = "abc"; - let Test.10 : [C , C [], C , C , C , C ] = CallByName TotallyNotJson.2; + let Test.10 : [C , C [], C , C , C , C ] = CallByName TotallyNotJson.8; let Test.8 : List U8 = CallByName Encode.26 Test.9 Test.10; let Test.1 : [C {U64, U8}, C Str] = CallByName Str.9 Test.8; let Test.5 : U8 = 1i64; diff --git a/crates/compiler/test_mono/generated/encode_derived_tag_one_field_string.txt b/crates/compiler/test_mono/generated/encode_derived_tag_one_field_string.txt index 6a54186716..69c90f145e 100644 --- a/crates/compiler/test_mono/generated/encode_derived_tag_one_field_string.txt +++ b/crates/compiler/test_mono/generated/encode_derived_tag_one_field_string.txt @@ -341,10 +341,6 @@ procedure TotallyNotJson.189 (TotallyNotJson.1267, TotallyNotJson.192): ret TotallyNotJson.1292; -procedure TotallyNotJson.2 (): - let TotallyNotJson.1172 : [C , C [], C , C , C , C ] = TagId(2) ; - ret TotallyNotJson.1172; - procedure TotallyNotJson.215 (TotallyNotJson.216, TotallyNotJson.217): let TotallyNotJson.1238 : List U8 = CallByName TotallyNotJson.27 TotallyNotJson.217; let TotallyNotJson.1237 : List U8 = CallByName List.8 TotallyNotJson.216 TotallyNotJson.1238; @@ -503,9 +499,13 @@ procedure TotallyNotJson.32 (TotallyNotJson.262, TotallyNotJson.263): let TotallyNotJson.1173 : {Str, List Str} = CallByName Encode.23 TotallyNotJson.1174; ret TotallyNotJson.1173; +procedure TotallyNotJson.8 (): + let TotallyNotJson.1172 : [C , C [], C , C , C , C ] = TagId(2) ; + ret TotallyNotJson.1172; + procedure Test.0 (): let Test.12 : Str = "foo"; - let Test.11 : [C , C [], C , C , C , C ] = CallByName TotallyNotJson.2; + let Test.11 : [C , C [], C , C , C , C ] = CallByName TotallyNotJson.8; let Test.10 : List U8 = CallByName Encode.26 Test.12 Test.11; let Test.2 : [C {U64, U8}, C Str] = CallByName Str.9 Test.10; let Test.7 : U8 = 1i64; diff --git a/crates/compiler/test_mono/generated/encode_derived_tag_two_payloads_string.txt b/crates/compiler/test_mono/generated/encode_derived_tag_two_payloads_string.txt index cddc9bc474..62c116be7c 100644 --- a/crates/compiler/test_mono/generated/encode_derived_tag_two_payloads_string.txt +++ b/crates/compiler/test_mono/generated/encode_derived_tag_two_payloads_string.txt @@ -344,10 +344,6 @@ procedure TotallyNotJson.189 (TotallyNotJson.1267, TotallyNotJson.192): ret TotallyNotJson.1292; -procedure TotallyNotJson.2 (): - let TotallyNotJson.1172 : [C , C [], C , C , C , C ] = TagId(2) ; - ret TotallyNotJson.1172; - procedure TotallyNotJson.215 (TotallyNotJson.216, TotallyNotJson.217): let TotallyNotJson.1238 : List U8 = CallByName TotallyNotJson.27 TotallyNotJson.217; let TotallyNotJson.1237 : List U8 = CallByName List.8 TotallyNotJson.216 TotallyNotJson.1238; @@ -506,11 +502,15 @@ procedure TotallyNotJson.32 (TotallyNotJson.262, TotallyNotJson.263): let TotallyNotJson.1173 : {Str, List Str} = CallByName Encode.23 TotallyNotJson.1174; ret TotallyNotJson.1173; +procedure TotallyNotJson.8 (): + let TotallyNotJson.1172 : [C , C [], C , C , C , C ] = TagId(2) ; + ret TotallyNotJson.1172; + procedure Test.0 (): let Test.13 : Str = "foo"; let Test.12 : Str = "foo"; let Test.1 : {Str, Str} = Struct {Test.12, Test.13}; - let Test.11 : [C , C [], C , C , C , C ] = CallByName TotallyNotJson.2; + let Test.11 : [C , C [], C , C , C , C ] = CallByName TotallyNotJson.8; let Test.10 : List U8 = CallByName Encode.26 Test.1 Test.11; let Test.2 : [C {U64, U8}, C Str] = CallByName Str.9 Test.10; let Test.7 : U8 = 1i64; diff --git a/crates/compiler/test_mono/generated/issue_4749.txt b/crates/compiler/test_mono/generated/issue_4749.txt index 962d50a255..a10282bc01 100644 --- a/crates/compiler/test_mono/generated/issue_4749.txt +++ b/crates/compiler/test_mono/generated/issue_4749.txt @@ -255,7 +255,7 @@ procedure Str.9 (Str.79): procedure Test.3 (): let Test.0 : List U8 = Array [82i64, 111i64, 99i64]; - let Test.8 : [C , C [], C , C , C , C ] = CallByName TotallyNotJson.2; + let Test.8 : [C , C [], C , C , C , C ] = CallByName TotallyNotJson.8; inc Test.0; let Test.1 : [C [C List U8, C ], C Str] = CallByName Decode.27 Test.0 Test.8; let Test.7 : Str = "Roc"; @@ -268,10 +268,6 @@ procedure Test.3 (): let Test.4 : {} = Struct {}; ret Test.4; -procedure TotallyNotJson.2 (): - let TotallyNotJson.1172 : [C , C [], C , C , C , C ] = TagId(2) ; - ret TotallyNotJson.1172; - procedure TotallyNotJson.525 (TotallyNotJson.526, TotallyNotJson.1175): joinpoint TotallyNotJson.1458: inc TotallyNotJson.526; @@ -835,3 +831,7 @@ procedure TotallyNotJson.70 (#Derived_gen.0): ret TotallyNotJson.1276; in jump TotallyNotJson.1198 #Derived_gen.0; + +procedure TotallyNotJson.8 (): + let TotallyNotJson.1172 : [C , C [], C , C , C , C ] = TagId(2) ; + ret TotallyNotJson.1172; diff --git a/crates/compiler/test_mono/generated/issue_4772_weakened_monomorphic_destructure.txt b/crates/compiler/test_mono/generated/issue_4772_weakened_monomorphic_destructure.txt index 0329be3c40..9794a2be06 100644 --- a/crates/compiler/test_mono/generated/issue_4772_weakened_monomorphic_destructure.txt +++ b/crates/compiler/test_mono/generated/issue_4772_weakened_monomorphic_destructure.txt @@ -257,7 +257,7 @@ procedure Str.9 (Str.79): procedure Test.0 (): let Test.37 : Str = "-1234"; let Test.35 : List U8 = CallByName Str.12 Test.37; - let Test.36 : [C , C [], C , C , C , C ] = CallByName TotallyNotJson.2; + let Test.36 : [C , C [], C , C , C , C ] = CallByName TotallyNotJson.8; let Test.34 : {List U8, [C {}, C Str]} = CallByName Decode.26 Test.35 Test.36; let Test.2 : List U8 = StructAtIndex 0 Test.34; let Test.1 : [C {}, C Str] = StructAtIndex 1 Test.34; @@ -300,10 +300,6 @@ procedure Test.12 (): let Test.13 : {} = Struct {}; ret Test.13; -procedure TotallyNotJson.2 (): - let TotallyNotJson.1172 : [C , C [], C , C , C , C ] = TagId(2) ; - ret TotallyNotJson.1172; - procedure TotallyNotJson.525 (TotallyNotJson.526, TotallyNotJson.1175): joinpoint TotallyNotJson.1458: inc TotallyNotJson.526; @@ -867,3 +863,7 @@ procedure TotallyNotJson.70 (#Derived_gen.5): ret TotallyNotJson.1276; in jump TotallyNotJson.1198 #Derived_gen.5; + +procedure TotallyNotJson.8 (): + let TotallyNotJson.1172 : [C , C [], C , C , C , C ] = TagId(2) ; + ret TotallyNotJson.1172; diff --git a/crates/compiler/test_mono/generated/unspecialized_lambda_set_unification_does_not_duplicate_identical_concrete_types.txt b/crates/compiler/test_mono/generated/unspecialized_lambda_set_unification_does_not_duplicate_identical_concrete_types.txt index 2777a240c6..64ad3a9b66 100644 --- a/crates/compiler/test_mono/generated/unspecialized_lambda_set_unification_does_not_duplicate_identical_concrete_types.txt +++ b/crates/compiler/test_mono/generated/unspecialized_lambda_set_unification_does_not_duplicate_identical_concrete_types.txt @@ -343,10 +343,6 @@ procedure TotallyNotJson.189 (TotallyNotJson.1270, TotallyNotJson.192): ret TotallyNotJson.1295; -procedure TotallyNotJson.2 (): - let TotallyNotJson.1172 : [C , C [], C , C , C , C ] = TagId(2) ; - ret TotallyNotJson.1172; - procedure TotallyNotJson.215 (TotallyNotJson.216, TotallyNotJson.217): let TotallyNotJson.1241 : List U8 = CallByName TotallyNotJson.27 TotallyNotJson.217; let TotallyNotJson.1240 : List U8 = CallByName List.8 TotallyNotJson.216 TotallyNotJson.1241; @@ -505,8 +501,12 @@ procedure TotallyNotJson.32 (TotallyNotJson.262, TotallyNotJson.263): let TotallyNotJson.1214 : {Str, List Str} = CallByName Encode.23 TotallyNotJson.1215; ret TotallyNotJson.1214; +procedure TotallyNotJson.8 (): + let TotallyNotJson.1172 : [C , C [], C , C , C , C ] = TagId(2) ; + ret TotallyNotJson.1172; + procedure Test.0 (): let Test.12 : {Str, Str} = CallByName Test.3; - let Test.13 : [C , C [], C , C , C , C ] = CallByName TotallyNotJson.2; + let Test.13 : [C , C [], C , C , C , C ] = CallByName TotallyNotJson.8; let Test.11 : List U8 = CallByName Encode.26 Test.12 Test.13; ret Test.11; diff --git a/crates/compiler/test_mono/generated/unspecialized_lambda_set_unification_keeps_all_concrete_types_without_unification_of_unifiable.txt b/crates/compiler/test_mono/generated/unspecialized_lambda_set_unification_keeps_all_concrete_types_without_unification_of_unifiable.txt index cf967c3b4d..798433a11e 100644 --- a/crates/compiler/test_mono/generated/unspecialized_lambda_set_unification_keeps_all_concrete_types_without_unification_of_unifiable.txt +++ b/crates/compiler/test_mono/generated/unspecialized_lambda_set_unification_keeps_all_concrete_types_without_unification_of_unifiable.txt @@ -228,10 +228,6 @@ procedure Test.5 (Test.6, Test.7, Test.4): let Test.22 : {Str, List [C {}, C {}]} = CallByName TotallyNotJson.32 Test.24 Test.25; jump Test.23 Test.22; -procedure TotallyNotJson.2 (): - let TotallyNotJson.1172 : [C , C [], C , C , C , C ] = TagId(2) ; - ret TotallyNotJson.1172; - procedure TotallyNotJson.264 (TotallyNotJson.265, TotallyNotJson.1175, #Attr.12): let TotallyNotJson.263 : List [C {}, C {}] = StructAtIndex 1 #Attr.12; let TotallyNotJson.262 : Str = StructAtIndex 0 #Attr.12; @@ -346,8 +342,12 @@ procedure TotallyNotJson.32 (TotallyNotJson.262, TotallyNotJson.263): let TotallyNotJson.1257 : {Str, List []} = CallByName Encode.23 TotallyNotJson.1258; ret TotallyNotJson.1257; +procedure TotallyNotJson.8 (): + let TotallyNotJson.1172 : [C , C [], C , C , C , C ] = TagId(2) ; + ret TotallyNotJson.1172; + procedure Test.0 (): let Test.13 : {{}, {}} = CallByName Test.3; - let Test.14 : [C , C [], C , C , C , C ] = CallByName TotallyNotJson.2; + let Test.14 : [C , C [], C , C , C , C ] = CallByName TotallyNotJson.8; let Test.12 : List U8 = CallByName Encode.26 Test.13 Test.14; ret Test.12; From fd866a5a6423b6fa2a76c5c4f44230cb147b99c6 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Mon, 14 Aug 2023 20:17:43 -0400 Subject: [PATCH 117/176] Update mono tests --- ...e_in_polymorphic_expression_issue_4717.txt | 154 ++--- .../generated/call_function_in_empty_list.txt | 4 +- .../call_function_in_empty_list_unbound.txt | 4 +- .../generated/capture_void_layout_task.txt | 62 +- ...ose_correct_recursion_var_under_record.txt | 66 +-- .../test_mono/generated/closure_in_list.txt | 4 +- ...lambda_set_productive_nullable_wrapped.txt | 66 ++- crates/compiler/test_mono/generated/dict.txt | 85 +-- .../generated/empty_list_of_function_type.txt | 32 +- .../compiler/test_mono/generated/encode.txt | 18 +- .../encode_derived_nested_record_string.txt | 555 +++++++++--------- ...encode_derived_record_one_field_string.txt | 430 +++++++------- ...ncode_derived_record_two_field_strings.txt | 430 +++++++------- .../generated/encode_derived_string.txt | 287 ++++----- .../encode_derived_tag_one_field_string.txt | 334 ++++++----- ...encode_derived_tag_two_payloads_string.txt | 330 ++++++----- .../test_mono/generated/ir_int_add.txt | 4 +- ...cialize_errors_behind_unified_branches.txt | 94 +-- .../test_mono/generated/issue_4749.txt | 270 ++++----- .../test_mono/generated/issue_4770.txt | 130 ++-- ..._4772_weakened_monomorphic_destructure.txt | 310 +++++----- ...ure_with_multiple_recursive_structures.txt | 64 +- .../test_mono/generated/list_append.txt | 18 +- .../generated/list_append_closure.txt | 18 +- .../generated/list_cannot_update_inplace.txt | 32 +- .../compiler/test_mono/generated/list_get.txt | 32 +- .../compiler/test_mono/generated/list_len.txt | 8 +- .../generated/list_map_closure_borrows.txt | 46 +- .../generated/list_map_closure_owns.txt | 42 +- ...ist_map_take_capturing_or_noncapturing.txt | 20 +- .../generated/list_pass_to_function.txt | 32 +- .../test_mono/generated/list_sort_asc.txt | 12 +- .../polymorphic_expression_unification.txt | 4 +- .../test_mono/generated/quicksort_swap.txt | 60 +- .../test_mono/generated/record_update.txt | 32 +- ...function_and_union_with_inference_hole.txt | 4 +- .../generated/recursively_build_effect.txt | 4 +- .../compiler/test_mono/generated/rigids.txt | 60 +- ...not_duplicate_identical_concrete_types.txt | 304 +++++----- ...types_without_unification_of_unifiable.txt | 157 ++--- .../weakening_avoids_overspecialization.txt | 154 ++--- 41 files changed, 2442 insertions(+), 2330 deletions(-) diff --git a/crates/compiler/test_mono/generated/anonymous_closure_in_polymorphic_expression_issue_4717.txt b/crates/compiler/test_mono/generated/anonymous_closure_in_polymorphic_expression_issue_4717.txt index f3eca0d0aa..660969c3dd 100644 --- a/crates/compiler/test_mono/generated/anonymous_closure_in_polymorphic_expression_issue_4717.txt +++ b/crates/compiler/test_mono/generated/anonymous_closure_in_polymorphic_expression_issue_4717.txt @@ -2,97 +2,101 @@ procedure Bool.11 (#Attr.2, #Attr.3): let Bool.24 : Int1 = lowlevel Eq #Attr.2 #Attr.3; ret Bool.24; -procedure List.26 (List.159, List.160, List.161): - let List.536 : [C U64, C U64] = CallByName List.93 List.159 List.160 List.161; - let List.539 : U8 = 1i64; - let List.540 : U8 = GetTagId List.536; - let List.541 : Int1 = lowlevel Eq List.539 List.540; - if List.541 then - let List.162 : U64 = UnionAtIndex (Id 1) (Index 0) List.536; - ret List.162; +procedure List.26 (List.161, List.162, List.163): + let List.541 : [C U64, C U64] = CallByName List.93 List.161 List.162 List.163; + let List.544 : U8 = 1i64; + let List.545 : U8 = GetTagId List.541; + let List.546 : Int1 = lowlevel Eq List.544 List.545; + if List.546 then + let List.164 : U64 = UnionAtIndex (Id 1) (Index 0) List.541; + ret List.164; else - let List.163 : U64 = UnionAtIndex (Id 0) (Index 0) List.536; - ret List.163; + let List.165 : U64 = UnionAtIndex (Id 0) (Index 0) List.541; + ret List.165; -procedure List.29 (List.304, List.305): - let List.535 : U64 = CallByName List.6 List.304; - let List.306 : U64 = CallByName Num.77 List.535 List.305; - let List.521 : List U8 = CallByName List.43 List.304 List.306; - ret List.521; +procedure List.29 (List.306, List.307): + let List.540 : U64 = CallByName List.6 List.306; + let List.308 : U64 = CallByName Num.77 List.540 List.307; + let List.526 : List U8 = CallByName List.43 List.306 List.308; + ret List.526; -procedure List.43 (List.302, List.303): - let List.533 : U64 = CallByName List.6 List.302; - let List.532 : U64 = CallByName Num.77 List.533 List.303; - let List.523 : {U64, U64} = Struct {List.303, List.532}; - let List.522 : List U8 = CallByName List.49 List.302 List.523; - ret List.522; - -procedure List.49 (List.376, List.377): - let List.530 : U64 = StructAtIndex 0 List.377; - let List.531 : U64 = 0i64; - let List.528 : Int1 = CallByName Bool.11 List.530 List.531; - if List.528 then - dec List.376; - let List.529 : List U8 = Array []; - ret List.529; - else - let List.525 : U64 = StructAtIndex 1 List.377; - let List.526 : U64 = StructAtIndex 0 List.377; - let List.524 : List U8 = CallByName List.72 List.376 List.525 List.526; - ret List.524; - -procedure List.6 (#Attr.2): - let List.534 : U64 = lowlevel ListLen #Attr.2; - ret List.534; - -procedure List.66 (#Attr.2, #Attr.3): - let List.557 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.557; - -procedure List.72 (#Attr.2, #Attr.3, #Attr.4): - let List.527 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; +procedure List.43 (List.304, List.305): + let List.538 : U64 = CallByName List.6 List.304; + let List.537 : U64 = CallByName Num.77 List.538 List.305; + let List.528 : {U64, U64} = Struct {List.305, List.537}; + let List.527 : List U8 = CallByName List.49 List.304 List.528; ret List.527; +procedure List.49 (List.379, List.380): + let List.535 : U64 = StructAtIndex 0 List.380; + let List.536 : U64 = 0i64; + let List.533 : Int1 = CallByName Bool.11 List.535 List.536; + if List.533 then + dec List.379; + let List.534 : List U8 = Array []; + ret List.534; + else + let List.530 : U64 = StructAtIndex 1 List.380; + let List.531 : U64 = StructAtIndex 0 List.380; + let List.529 : List U8 = CallByName List.72 List.379 List.530 List.531; + ret List.529; + +procedure List.6 (#Attr.2): + let List.539 : U64 = lowlevel ListLen #Attr.2; + ret List.539; + +procedure List.66 (#Attr.2, #Attr.3): + let List.563 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.563; + +procedure List.72 (#Attr.2, #Attr.3, #Attr.4): + let List.532 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; + ret List.532; + procedure List.80 (#Derived_gen.0, #Derived_gen.1, #Derived_gen.2, #Derived_gen.3, #Derived_gen.4): - joinpoint List.545 List.439 List.440 List.441 List.442 List.443: - let List.547 : Int1 = CallByName Num.22 List.442 List.443; - if List.547 then - let List.556 : U8 = CallByName List.66 List.439 List.442; - let List.548 : [C U64, C U64] = CallByName Test.4 List.440 List.556; - let List.553 : U8 = 1i64; - let List.554 : U8 = GetTagId List.548; - let List.555 : Int1 = lowlevel Eq List.553 List.554; - if List.555 then - let List.444 : U64 = UnionAtIndex (Id 1) (Index 0) List.548; - let List.551 : U64 = 1i64; - let List.550 : U64 = CallByName Num.19 List.442 List.551; - jump List.545 List.439 List.444 List.441 List.550 List.443; + joinpoint List.550 List.442 List.443 List.444 List.445 List.446: + let List.552 : Int1 = CallByName Num.22 List.445 List.446; + if List.552 then + let List.562 : U8 = CallByName List.66 List.442 List.445; + let List.553 : [C U64, C U64] = CallByName Test.4 List.443 List.562; + let List.559 : U8 = 1i64; + let List.560 : U8 = GetTagId List.553; + let List.561 : Int1 = lowlevel Eq List.559 List.560; + if List.561 then + let List.447 : U64 = UnionAtIndex (Id 1) (Index 0) List.553; + let List.555 : U64 = CallByName List.96 List.445; + jump List.550 List.442 List.447 List.444 List.555 List.446; else - dec List.439; - let List.445 : U64 = UnionAtIndex (Id 0) (Index 0) List.548; - let List.552 : [C U64, C U64] = TagId(0) List.445; - ret List.552; + dec List.442; + let List.448 : U64 = UnionAtIndex (Id 0) (Index 0) List.553; + let List.558 : [C U64, C U64] = TagId(0) List.448; + ret List.558; else - dec List.439; - let List.546 : [C U64, C U64] = TagId(1) List.440; - ret List.546; + dec List.442; + let List.551 : [C U64, C U64] = TagId(1) List.443; + ret List.551; in - jump List.545 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4; + jump List.550 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4; -procedure List.93 (List.436, List.437, List.438): - let List.543 : U64 = 0i64; - let List.544 : U64 = CallByName List.6 List.436; - let List.542 : [C U64, C U64] = CallByName List.80 List.436 List.437 List.438 List.543 List.544; - ret List.542; +procedure List.93 (List.439, List.440, List.441): + let List.548 : U64 = 0i64; + let List.549 : U64 = CallByName List.6 List.439; + let List.547 : [C U64, C U64] = CallByName List.80 List.439 List.440 List.441 List.548 List.549; + ret List.547; -procedure Num.19 (#Attr.2, #Attr.3): - let Num.294 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.294; +procedure List.96 (List.463): + let List.557 : U64 = 1i64; + let List.556 : U64 = CallByName Num.51 List.463 List.557; + ret List.556; procedure Num.22 (#Attr.2, #Attr.3): let Num.295 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; ret Num.295; +procedure Num.51 (#Attr.2, #Attr.3): + let Num.294 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; + ret Num.294; + procedure Num.77 (#Attr.2, #Attr.3): let Num.293 : U64 = lowlevel NumSubSaturated #Attr.2 #Attr.3; ret Num.293; diff --git a/crates/compiler/test_mono/generated/call_function_in_empty_list.txt b/crates/compiler/test_mono/generated/call_function_in_empty_list.txt index 49843c03dd..ccc0b31927 100644 --- a/crates/compiler/test_mono/generated/call_function_in_empty_list.txt +++ b/crates/compiler/test_mono/generated/call_function_in_empty_list.txt @@ -1,7 +1,7 @@ procedure List.5 (#Attr.2, #Attr.3): - let List.521 : List {} = lowlevel ListMap { xs: `#Attr.#arg1` } #Attr.2 Test.2 #Attr.3; + let List.526 : List {} = lowlevel ListMap { xs: `#Attr.#arg1` } #Attr.2 Test.2 #Attr.3; decref #Attr.2; - ret List.521; + ret List.526; procedure Test.2 (Test.3): let Test.7 : {} = Struct {}; diff --git a/crates/compiler/test_mono/generated/call_function_in_empty_list_unbound.txt b/crates/compiler/test_mono/generated/call_function_in_empty_list_unbound.txt index ce2dbde965..9333feee95 100644 --- a/crates/compiler/test_mono/generated/call_function_in_empty_list_unbound.txt +++ b/crates/compiler/test_mono/generated/call_function_in_empty_list_unbound.txt @@ -1,7 +1,7 @@ procedure List.5 (#Attr.2, #Attr.3): - let List.521 : List [] = lowlevel ListMap { xs: `#Attr.#arg1` } #Attr.2 Test.2 #Attr.3; + let List.526 : List [] = lowlevel ListMap { xs: `#Attr.#arg1` } #Attr.2 Test.2 #Attr.3; decref #Attr.2; - ret List.521; + ret List.526; procedure Test.2 (Test.3): let Test.7 : {} = Struct {}; diff --git a/crates/compiler/test_mono/generated/capture_void_layout_task.txt b/crates/compiler/test_mono/generated/capture_void_layout_task.txt index bad0f8684c..824018fe4f 100644 --- a/crates/compiler/test_mono/generated/capture_void_layout_task.txt +++ b/crates/compiler/test_mono/generated/capture_void_layout_task.txt @@ -1,48 +1,52 @@ -procedure List.145 (List.146, List.147, List.144): - let List.540 : [C {}, C *self {{}, []}] = CallByName Test.29 List.146 List.147 List.144; - ret List.540; +procedure List.147 (List.148, List.149, List.146): + let List.546 : [C {}, C *self {{}, []}] = CallByName Test.29 List.148 List.149 List.146; + ret List.546; -procedure List.18 (List.142, List.143, List.144): - let List.521 : [C {}, C *self {{}, []}] = CallByName List.93 List.142 List.143 List.144; - ret List.521; +procedure List.18 (List.144, List.145, List.146): + let List.526 : [C {}, C *self {{}, []}] = CallByName List.93 List.144 List.145 List.146; + ret List.526; procedure List.6 (#Attr.2): - let List.538 : U64 = lowlevel ListLen #Attr.2; - ret List.538; + let List.544 : U64 = lowlevel ListLen #Attr.2; + ret List.544; procedure List.66 (#Attr.2, #Attr.3): - let List.537 : [] = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.537; + let List.543 : [] = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.543; procedure List.80 (#Derived_gen.13, #Derived_gen.14, #Derived_gen.15, #Derived_gen.16, #Derived_gen.17): - joinpoint List.527 List.439 List.440 List.441 List.442 List.443: - let List.529 : Int1 = CallByName Num.22 List.442 List.443; - if List.529 then - let List.536 : [] = CallByName List.66 List.439 List.442; - let List.530 : [C {}, C *self {{}, []}] = CallByName List.145 List.440 List.536 List.441; - let List.533 : U64 = 1i64; - let List.532 : U64 = CallByName Num.19 List.442 List.533; - jump List.527 List.439 List.530 List.441 List.532 List.443; + joinpoint List.532 List.442 List.443 List.444 List.445 List.446: + let List.534 : Int1 = CallByName Num.22 List.445 List.446; + if List.534 then + let List.542 : [] = CallByName List.66 List.442 List.445; + let List.535 : [C {}, C *self {{}, []}] = CallByName List.147 List.443 List.542 List.444; + let List.537 : U64 = CallByName List.96 List.445; + jump List.532 List.442 List.535 List.444 List.537 List.446; else - dec List.439; - ret List.440; + dec List.442; + ret List.443; in - jump List.527 #Derived_gen.13 #Derived_gen.14 #Derived_gen.15 #Derived_gen.16 #Derived_gen.17; + jump List.532 #Derived_gen.13 #Derived_gen.14 #Derived_gen.15 #Derived_gen.16 #Derived_gen.17; -procedure List.93 (List.436, List.437, List.438): - let List.525 : U64 = 0i64; - let List.526 : U64 = CallByName List.6 List.436; - let List.524 : [C {}, C *self {{}, []}] = CallByName List.80 List.436 List.437 List.438 List.525 List.526; - ret List.524; +procedure List.93 (List.439, List.440, List.441): + let List.530 : U64 = 0i64; + let List.531 : U64 = CallByName List.6 List.439; + let List.529 : [C {}, C *self {{}, []}] = CallByName List.80 List.439 List.440 List.441 List.530 List.531; + ret List.529; -procedure Num.19 (#Attr.2, #Attr.3): - let Num.292 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.292; +procedure List.96 (List.463): + let List.539 : U64 = 1i64; + let List.538 : U64 = CallByName Num.51 List.463 List.539; + ret List.538; procedure Num.22 (#Attr.2, #Attr.3): let Num.293 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; ret Num.293; +procedure Num.51 (#Attr.2, #Attr.3): + let Num.292 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; + ret Num.292; + procedure Test.10 (Test.66, #Attr.12): let Test.9 : {} = UnionAtIndex (Id 0) (Index 0) #Attr.12; let #Derived_gen.18 : Int1 = lowlevel RefCountIsUnique #Attr.12; diff --git a/crates/compiler/test_mono/generated/choose_correct_recursion_var_under_record.txt b/crates/compiler/test_mono/generated/choose_correct_recursion_var_under_record.txt index b52e46a91d..f2172509f2 100644 --- a/crates/compiler/test_mono/generated/choose_correct_recursion_var_under_record.txt +++ b/crates/compiler/test_mono/generated/choose_correct_recursion_var_under_record.txt @@ -2,49 +2,49 @@ procedure Bool.1 (): let Bool.24 : Int1 = false; ret Bool.24; -procedure List.2 (List.97, List.98): - let List.535 : U64 = CallByName List.6 List.97; - let List.531 : Int1 = CallByName Num.22 List.98 List.535; - if List.531 then - let List.533 : Str = CallByName List.66 List.97 List.98; - inc List.533; - dec List.97; - let List.532 : [C {}, C Str] = TagId(1) List.533; - ret List.532; +procedure List.2 (List.99, List.100): + let List.540 : U64 = CallByName List.6 List.99; + let List.536 : Int1 = CallByName Num.22 List.100 List.540; + if List.536 then + let List.538 : Str = CallByName List.66 List.99 List.100; + inc List.538; + dec List.99; + let List.537 : [C {}, C Str] = TagId(1) List.538; + ret List.537; else - dec List.97; - let List.530 : {} = Struct {}; - let List.529 : [C {}, C Str] = TagId(0) List.530; - ret List.529; + dec List.99; + let List.535 : {} = Struct {}; + let List.534 : [C {}, C Str] = TagId(0) List.535; + ret List.534; procedure List.5 (#Attr.2, #Attr.3): - let List.537 : List Str = lowlevel ListMap { xs: `#Attr.#arg1` } #Attr.2 Test.10 #Attr.3; + let List.542 : List Str = lowlevel ListMap { xs: `#Attr.#arg1` } #Attr.2 Test.10 #Attr.3; decref #Attr.2; - ret List.537; + ret List.542; procedure List.6 (#Attr.2): - let List.536 : U64 = lowlevel ListLen #Attr.2; - ret List.536; + let List.541 : U64 = lowlevel ListLen #Attr.2; + ret List.541; procedure List.66 (#Attr.2, #Attr.3): - let List.534 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.534; + let List.539 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.539; -procedure List.9 (List.293): - let List.528 : U64 = 0i64; - let List.521 : [C {}, C Str] = CallByName List.2 List.293 List.528; - let List.525 : U8 = 1i64; - let List.526 : U8 = GetTagId List.521; - let List.527 : Int1 = lowlevel Eq List.525 List.526; - if List.527 then - let List.294 : Str = UnionAtIndex (Id 1) (Index 0) List.521; - let List.522 : [C {}, C Str] = TagId(1) List.294; - ret List.522; +procedure List.9 (List.295): + let List.533 : U64 = 0i64; + let List.526 : [C {}, C Str] = CallByName List.2 List.295 List.533; + let List.530 : U8 = 1i64; + let List.531 : U8 = GetTagId List.526; + let List.532 : Int1 = lowlevel Eq List.530 List.531; + if List.532 then + let List.296 : Str = UnionAtIndex (Id 1) (Index 0) List.526; + let List.527 : [C {}, C Str] = TagId(1) List.296; + ret List.527; else - dec List.521; - let List.524 : {} = Struct {}; - let List.523 : [C {}, C Str] = TagId(0) List.524; - ret List.523; + dec List.526; + let List.529 : {} = Struct {}; + let List.528 : [C {}, C Str] = TagId(0) List.529; + ret List.528; procedure Num.22 (#Attr.2, #Attr.3): let Num.292 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/closure_in_list.txt b/crates/compiler/test_mono/generated/closure_in_list.txt index 5550ea1fda..be6512aa8e 100644 --- a/crates/compiler/test_mono/generated/closure_in_list.txt +++ b/crates/compiler/test_mono/generated/closure_in_list.txt @@ -1,6 +1,6 @@ procedure List.6 (#Attr.2): - let List.521 : U64 = lowlevel ListLen #Attr.2; - ret List.521; + let List.526 : U64 = lowlevel ListLen #Attr.2; + ret List.526; procedure Test.1 (Test.5): let Test.2 : I64 = 41i64; diff --git a/crates/compiler/test_mono/generated/compose_recursive_lambda_set_productive_nullable_wrapped.txt b/crates/compiler/test_mono/generated/compose_recursive_lambda_set_productive_nullable_wrapped.txt index cbd51527e7..e900422447 100644 --- a/crates/compiler/test_mono/generated/compose_recursive_lambda_set_productive_nullable_wrapped.txt +++ b/crates/compiler/test_mono/generated/compose_recursive_lambda_set_productive_nullable_wrapped.txt @@ -2,54 +2,58 @@ procedure Bool.2 (): let Bool.23 : Int1 = true; ret Bool.23; -procedure List.145 (List.146, List.147, List.144): - let List.540 : [, C *self Int1, C *self Int1] = CallByName Test.6 List.146 List.147 List.144; - ret List.540; +procedure List.147 (List.148, List.149, List.146): + let List.546 : [, C *self Int1, C *self Int1] = CallByName Test.6 List.148 List.149 List.146; + ret List.546; -procedure List.18 (List.142, List.143, List.144): - let List.521 : [, C *self Int1, C *self Int1] = CallByName List.93 List.142 List.143 List.144; - ret List.521; +procedure List.18 (List.144, List.145, List.146): + let List.526 : [, C *self Int1, C *self Int1] = CallByName List.93 List.144 List.145 List.146; + ret List.526; procedure List.6 (#Attr.2): - let List.538 : U64 = lowlevel ListLen #Attr.2; - ret List.538; + let List.544 : U64 = lowlevel ListLen #Attr.2; + ret List.544; procedure List.66 (#Attr.2, #Attr.3): - let List.537 : Int1 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.537; + let List.543 : Int1 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.543; procedure List.80 (#Derived_gen.3, #Derived_gen.4, #Derived_gen.5, #Derived_gen.6, #Derived_gen.7): - joinpoint List.527 List.439 List.440 List.441 List.442 List.443: - let List.529 : Int1 = CallByName Num.22 List.442 List.443; - if List.529 then - let List.536 : Int1 = CallByName List.66 List.439 List.442; - let List.530 : [, C *self Int1, C *self Int1] = CallByName List.145 List.440 List.536 List.441; - let List.533 : U64 = 1i64; - let List.532 : U64 = CallByName Num.19 List.442 List.533; - jump List.527 List.439 List.530 List.441 List.532 List.443; + joinpoint List.532 List.442 List.443 List.444 List.445 List.446: + let List.534 : Int1 = CallByName Num.22 List.445 List.446; + if List.534 then + let List.542 : Int1 = CallByName List.66 List.442 List.445; + let List.535 : [, C *self Int1, C *self Int1] = CallByName List.147 List.443 List.542 List.444; + let List.537 : U64 = CallByName List.96 List.445; + jump List.532 List.442 List.535 List.444 List.537 List.446; else - dec List.439; - ret List.440; + dec List.442; + ret List.443; in - jump List.527 #Derived_gen.3 #Derived_gen.4 #Derived_gen.5 #Derived_gen.6 #Derived_gen.7; + jump List.532 #Derived_gen.3 #Derived_gen.4 #Derived_gen.5 #Derived_gen.6 #Derived_gen.7; -procedure List.93 (List.436, List.437, List.438): - let List.525 : U64 = 0i64; - let List.526 : U64 = CallByName List.6 List.436; - let List.524 : [, C *self Int1, C *self Int1] = CallByName List.80 List.436 List.437 List.438 List.525 List.526; - ret List.524; +procedure List.93 (List.439, List.440, List.441): + let List.530 : U64 = 0i64; + let List.531 : U64 = CallByName List.6 List.439; + let List.529 : [, C *self Int1, C *self Int1] = CallByName List.80 List.439 List.440 List.441 List.530 List.531; + ret List.529; -procedure Num.19 (#Attr.2, #Attr.3): - let Num.292 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.292; +procedure List.96 (List.463): + let List.539 : U64 = 1i64; + let List.538 : U64 = CallByName Num.51 List.463 List.539; + ret List.538; procedure Num.22 (#Attr.2, #Attr.3): let Num.293 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; ret Num.293; +procedure Num.51 (#Attr.2, #Attr.3): + let Num.292 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; + ret Num.292; + procedure Str.3 (#Attr.2, #Attr.3): - let Str.291 : Str = lowlevel StrConcat #Attr.2 #Attr.3; - ret Str.291; + let Str.293 : Str = lowlevel StrConcat #Attr.2 #Attr.3; + ret Str.293; procedure Test.1 (Test.5): ret Test.5; diff --git a/crates/compiler/test_mono/generated/dict.txt b/crates/compiler/test_mono/generated/dict.txt index 693107f54b..2a0278ef10 100644 --- a/crates/compiler/test_mono/generated/dict.txt +++ b/crates/compiler/test_mono/generated/dict.txt @@ -24,67 +24,70 @@ procedure Dict.4 (Dict.562): dec #Derived_gen.6; ret Dict.100; -procedure List.11 (List.121, List.122): - let List.522 : List I8 = CallByName List.68 List.122; - let List.521 : List I8 = CallByName List.83 List.121 List.122 List.522; - ret List.521; +procedure List.11 (List.123, List.124): + let List.527 : List I8 = CallByName List.68 List.124; + let List.526 : List I8 = CallByName List.83 List.123 List.124 List.527; + ret List.526; -procedure List.11 (List.121, List.122): - let List.534 : List U64 = CallByName List.68 List.122; - let List.533 : List U64 = CallByName List.83 List.121 List.122 List.534; - ret List.533; +procedure List.11 (List.123, List.124): + let List.540 : List U64 = CallByName List.68 List.124; + let List.539 : List U64 = CallByName List.83 List.123 List.124 List.540; + ret List.539; procedure List.68 (#Attr.2): - let List.532 : List I8 = lowlevel ListWithCapacity #Attr.2; - ret List.532; + let List.538 : List I8 = lowlevel ListWithCapacity #Attr.2; + ret List.538; procedure List.68 (#Attr.2): - let List.544 : List U64 = lowlevel ListWithCapacity #Attr.2; - ret List.544; + let List.549 : List U64 = lowlevel ListWithCapacity #Attr.2; + ret List.549; procedure List.71 (#Attr.2, #Attr.3): - let List.529 : List I8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.529; + let List.534 : List I8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.534; procedure List.71 (#Attr.2, #Attr.3): - let List.541 : List U64 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.541; + let List.547 : List U64 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.547; procedure List.83 (#Derived_gen.0, #Derived_gen.1, #Derived_gen.2): - joinpoint List.523 List.123 List.124 List.125: - let List.531 : U64 = 0i64; - let List.525 : Int1 = CallByName Num.24 List.124 List.531; - if List.525 then - let List.530 : U64 = 1i64; - let List.527 : U64 = CallByName Num.20 List.124 List.530; - let List.528 : List I8 = CallByName List.71 List.125 List.123; - jump List.523 List.123 List.527 List.528; + joinpoint List.528 List.125 List.126 List.127: + let List.537 : U64 = 0i64; + let List.530 : Int1 = CallByName Num.24 List.126 List.537; + if List.530 then + let List.532 : U64 = CallByName List.97 List.126; + let List.533 : List I8 = CallByName List.71 List.127 List.125; + jump List.528 List.125 List.532 List.533; else - ret List.125; + ret List.127; in - jump List.523 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2; + jump List.528 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2; procedure List.83 (#Derived_gen.3, #Derived_gen.4, #Derived_gen.5): - joinpoint List.535 List.123 List.124 List.125: - let List.543 : U64 = 0i64; - let List.537 : Int1 = CallByName Num.24 List.124 List.543; - if List.537 then - let List.542 : U64 = 1i64; - let List.539 : U64 = CallByName Num.20 List.124 List.542; - let List.540 : List U64 = CallByName List.71 List.125 List.123; - jump List.535 List.123 List.539 List.540; + joinpoint List.541 List.125 List.126 List.127: + let List.548 : U64 = 0i64; + let List.543 : Int1 = CallByName Num.24 List.126 List.548; + if List.543 then + let List.545 : U64 = CallByName List.97 List.126; + let List.546 : List U64 = CallByName List.71 List.127 List.125; + jump List.541 List.125 List.545 List.546; else - ret List.125; + ret List.127; in - jump List.535 #Derived_gen.3 #Derived_gen.4 #Derived_gen.5; + jump List.541 #Derived_gen.3 #Derived_gen.4 #Derived_gen.5; -procedure Num.20 (#Attr.2, #Attr.3): - let Num.293 : U64 = lowlevel NumSub #Attr.2 #Attr.3; - ret Num.293; +procedure List.97 (List.464): + let List.536 : U64 = 1i64; + let List.535 : U64 = CallByName Num.75 List.464 List.536; + ret List.535; procedure Num.24 (#Attr.2, #Attr.3): - let Num.295 : Int1 = lowlevel NumGt #Attr.2 #Attr.3; - ret Num.295; + let Num.294 : Int1 = lowlevel NumGt #Attr.2 #Attr.3; + ret Num.294; + +procedure Num.75 (#Attr.2, #Attr.3): + let Num.292 : U64 = lowlevel NumSubWrap #Attr.2 #Attr.3; + ret Num.292; procedure Test.0 (): let Test.3 : {} = Struct {}; diff --git a/crates/compiler/test_mono/generated/empty_list_of_function_type.txt b/crates/compiler/test_mono/generated/empty_list_of_function_type.txt index 8f46084280..5ad7a34fc4 100644 --- a/crates/compiler/test_mono/generated/empty_list_of_function_type.txt +++ b/crates/compiler/test_mono/generated/empty_list_of_function_type.txt @@ -2,27 +2,27 @@ procedure Bool.1 (): let Bool.23 : Int1 = false; ret Bool.23; -procedure List.2 (List.97, List.98): - let List.527 : U64 = CallByName List.6 List.97; - let List.523 : Int1 = CallByName Num.22 List.98 List.527; - if List.523 then - let List.525 : {} = CallByName List.66 List.97 List.98; - dec List.97; - let List.524 : [C {}, C {}] = TagId(1) List.525; - ret List.524; +procedure List.2 (List.99, List.100): + let List.532 : U64 = CallByName List.6 List.99; + let List.528 : Int1 = CallByName Num.22 List.100 List.532; + if List.528 then + let List.530 : {} = CallByName List.66 List.99 List.100; + dec List.99; + let List.529 : [C {}, C {}] = TagId(1) List.530; + ret List.529; else - dec List.97; - let List.522 : {} = Struct {}; - let List.521 : [C {}, C {}] = TagId(0) List.522; - ret List.521; + dec List.99; + let List.527 : {} = Struct {}; + let List.526 : [C {}, C {}] = TagId(0) List.527; + ret List.526; procedure List.6 (#Attr.2): - let List.528 : U64 = lowlevel ListLen #Attr.2; - ret List.528; + let List.533 : U64 = lowlevel ListLen #Attr.2; + ret List.533; procedure List.66 (#Attr.2, #Attr.3): - let List.526 : {} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.526; + let List.531 : {} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.531; procedure Num.22 (#Attr.2, #Attr.3): let Num.292 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/encode.txt b/crates/compiler/test_mono/generated/encode.txt index ce0c8b5b66..e9a8057897 100644 --- a/crates/compiler/test_mono/generated/encode.txt +++ b/crates/compiler/test_mono/generated/encode.txt @@ -1,16 +1,16 @@ -procedure List.4 (List.113, List.114): - let List.524 : U64 = 1i64; - let List.522 : List U8 = CallByName List.70 List.113 List.524; - let List.521 : List U8 = CallByName List.71 List.522 List.114; - ret List.521; +procedure List.4 (List.115, List.116): + let List.529 : U64 = 1i64; + let List.527 : List U8 = CallByName List.70 List.115 List.529; + let List.526 : List U8 = CallByName List.71 List.527 List.116; + ret List.526; procedure List.70 (#Attr.2, #Attr.3): - let List.525 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.525; + let List.530 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.530; procedure List.71 (#Attr.2, #Attr.3): - let List.523 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.523; + let List.528 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.528; procedure Test.23 (Test.24, Test.35, Test.22): let Test.37 : List U8 = CallByName List.4 Test.24 Test.22; diff --git a/crates/compiler/test_mono/generated/encode_derived_nested_record_string.txt b/crates/compiler/test_mono/generated/encode_derived_nested_record_string.txt index da00523cb6..b5e95a69b3 100644 --- a/crates/compiler/test_mono/generated/encode_derived_nested_record_string.txt +++ b/crates/compiler/test_mono/generated/encode_derived_nested_record_string.txt @@ -78,321 +78,330 @@ procedure Encode.26 (Encode.105, Encode.106): ret Encode.108; procedure List.13 (#Attr.2, #Attr.3): - let List.689 : List Str = lowlevel ListPrepend #Attr.2 #Attr.3; - ret List.689; - -procedure List.145 (List.146, List.147, List.144): - let List.569 : {List U8, U64} = CallByName TotallyNotJson.237 List.146 List.147 List.144; - ret List.569; - -procedure List.145 (List.146, List.147, List.144): - let List.637 : {List U8, U64} = CallByName TotallyNotJson.237 List.146 List.147 List.144; - ret List.637; - -procedure List.145 (List.146, List.147, List.144): - let List.657 : List U8 = CallByName TotallyNotJson.215 List.146 List.147; - ret List.657; - -procedure List.18 (List.142, List.143, List.144): - let List.550 : {List U8, U64} = CallByName List.93 List.142 List.143 List.144; - ret List.550; - -procedure List.18 (List.142, List.143, List.144): - let List.618 : {List U8, U64} = CallByName List.93 List.142 List.143 List.144; - ret List.618; - -procedure List.18 (List.142, List.143, List.144): - let List.638 : List U8 = CallByName List.93 List.142 List.143 List.144; - ret List.638; - -procedure List.26 (List.159, List.160, List.161): - let List.706 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.93 List.159 List.160 List.161; - let List.709 : U8 = 1i64; - let List.710 : U8 = GetTagId List.706; - let List.711 : Int1 = lowlevel Eq List.709 List.710; - if List.711 then - let List.162 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.706; - ret List.162; - else - let List.163 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.706; - ret List.163; - -procedure List.31 (#Attr.2, #Attr.3): - let List.671 : List Str = lowlevel ListDropAt #Attr.2 #Attr.3; - ret List.671; - -procedure List.38 (List.298): - let List.679 : U64 = 0i64; - let List.678 : List Str = CallByName List.31 List.298 List.679; - ret List.678; - -procedure List.4 (List.113, List.114): - let List.614 : U64 = 1i64; - let List.613 : List Str = CallByName List.70 List.113 List.614; - let List.612 : List Str = CallByName List.71 List.613 List.114; - ret List.612; - -procedure List.4 (List.113, List.114): - let List.617 : U64 = 1i64; - let List.616 : List U8 = CallByName List.70 List.113 List.617; - let List.615 : List U8 = CallByName List.71 List.616 List.114; - ret List.615; - -procedure List.49 (List.376, List.377): - let List.698 : U64 = StructAtIndex 0 List.377; - let List.699 : U64 = 0i64; - let List.696 : Int1 = CallByName Bool.11 List.698 List.699; - if List.696 then - dec List.376; - let List.697 : List U8 = Array []; - ret List.697; - else - let List.693 : U64 = StructAtIndex 1 List.377; - let List.694 : U64 = StructAtIndex 0 List.377; - let List.692 : List U8 = CallByName List.72 List.376 List.693 List.694; - ret List.692; - -procedure List.52 (List.391, List.392): - let List.393 : U64 = CallByName List.6 List.391; - joinpoint List.704 List.394: - let List.702 : U64 = 0i64; - let List.701 : {U64, U64} = Struct {List.394, List.702}; - inc List.391; - let List.395 : List U8 = CallByName List.49 List.391 List.701; - let List.700 : U64 = CallByName Num.20 List.393 List.394; - let List.691 : {U64, U64} = Struct {List.700, List.394}; - let List.396 : List U8 = CallByName List.49 List.391 List.691; - let List.690 : {List U8, List U8} = Struct {List.395, List.396}; - ret List.690; - in - let List.705 : Int1 = CallByName Num.24 List.393 List.392; - if List.705 then - jump List.704 List.392; - else - jump List.704 List.393; - -procedure List.6 (#Attr.2): - let List.588 : U64 = lowlevel ListLen #Attr.2; - ret List.588; - -procedure List.6 (#Attr.2): - let List.685 : U64 = lowlevel ListLen #Attr.2; - ret List.685; - -procedure List.6 (#Attr.2): - let List.686 : U64 = lowlevel ListLen #Attr.2; - ret List.686; - -procedure List.6 (#Attr.2): - let List.688 : U64 = lowlevel ListLen #Attr.2; - ret List.688; - -procedure List.66 (#Attr.2, #Attr.3): - let List.566 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.566; - -procedure List.66 (#Attr.2, #Attr.3): - let List.634 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.634; - -procedure List.66 (#Attr.2, #Attr.3): - let List.654 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.654; - -procedure List.68 (#Attr.2): - let List.681 : List Str = lowlevel ListWithCapacity #Attr.2; - ret List.681; - -procedure List.68 (#Attr.2): - let List.683 : List U8 = lowlevel ListWithCapacity #Attr.2; - ret List.683; - -procedure List.70 (#Attr.2, #Attr.3): - let List.594 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.594; - -procedure List.70 (#Attr.2, #Attr.3): - let List.611 : List Str = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.611; - -procedure List.71 (#Attr.2, #Attr.3): - let List.592 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.592; - -procedure List.71 (#Attr.2, #Attr.3): - let List.609 : List Str = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.609; - -procedure List.72 (#Attr.2, #Attr.3, #Attr.4): - let List.695 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; + let List.695 : List Str = lowlevel ListPrepend #Attr.2 #Attr.3; ret List.695; -procedure List.8 (#Attr.2, #Attr.3): - let List.660 : List Str = lowlevel ListConcat #Attr.2 #Attr.3; - ret List.660; +procedure List.147 (List.148, List.149, List.146): + let List.575 : {List U8, U64} = CallByName TotallyNotJson.237 List.148 List.149 List.146; + ret List.575; -procedure List.8 (#Attr.2, #Attr.3): - let List.668 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; - ret List.668; +procedure List.147 (List.148, List.149, List.146): + let List.644 : {List U8, U64} = CallByName TotallyNotJson.237 List.148 List.149 List.146; + ret List.644; -procedure List.80 (#Derived_gen.30, #Derived_gen.31, #Derived_gen.32, #Derived_gen.33, #Derived_gen.34): - joinpoint List.715 List.439 List.440 List.441 List.442 List.443: - let List.717 : Int1 = CallByName Num.22 List.442 List.443; - if List.717 then - let List.726 : U8 = CallByName List.66 List.439 List.442; - let List.718 : [C {U64, Int1}, C {U64, Int1}] = CallByName TotallyNotJson.189 List.440 List.726; - let List.723 : U8 = 1i64; - let List.724 : U8 = GetTagId List.718; - let List.725 : Int1 = lowlevel Eq List.723 List.724; - if List.725 then - let List.444 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.718; - let List.721 : U64 = 1i64; - let List.720 : U64 = CallByName Num.19 List.442 List.721; - jump List.715 List.439 List.444 List.441 List.720 List.443; - else - dec List.439; - let List.445 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.718; - let List.722 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) List.445; - ret List.722; - else - dec List.439; - let List.716 : [C {U64, Int1}, C {U64, Int1}] = TagId(1) List.440; - ret List.716; - in - jump List.715 #Derived_gen.30 #Derived_gen.31 #Derived_gen.32 #Derived_gen.33 #Derived_gen.34; +procedure List.147 (List.148, List.149, List.146): + let List.663 : List U8 = CallByName TotallyNotJson.215 List.148 List.149; + ret List.663; -procedure List.80 (#Derived_gen.36, #Derived_gen.37, #Derived_gen.38, #Derived_gen.39, #Derived_gen.40): - joinpoint List.644 List.439 List.440 List.441 List.442 List.443: - let List.646 : Int1 = CallByName Num.22 List.442 List.443; - if List.646 then - let List.653 : U8 = CallByName List.66 List.439 List.442; - let List.647 : List U8 = CallByName List.145 List.440 List.653 List.441; - let List.650 : U64 = 1i64; - let List.649 : U64 = CallByName Num.19 List.442 List.650; - jump List.644 List.439 List.647 List.441 List.649 List.443; - else - dec List.439; - ret List.440; - in - jump List.644 #Derived_gen.36 #Derived_gen.37 #Derived_gen.38 #Derived_gen.39 #Derived_gen.40; +procedure List.18 (List.144, List.145, List.146): + let List.555 : {List U8, U64} = CallByName List.93 List.144 List.145 List.146; + ret List.555; -procedure List.80 (#Derived_gen.41, #Derived_gen.42, #Derived_gen.43, #Derived_gen.44, #Derived_gen.45): - joinpoint List.624 List.439 List.440 List.441 List.442 List.443: - let List.626 : Int1 = CallByName Num.22 List.442 List.443; - if List.626 then - let List.633 : {Str, Str} = CallByName List.66 List.439 List.442; - inc List.633; - let List.627 : {List U8, U64} = CallByName List.145 List.440 List.633 List.441; - let List.630 : U64 = 1i64; - let List.629 : U64 = CallByName Num.19 List.442 List.630; - jump List.624 List.439 List.627 List.441 List.629 List.443; - else - dec List.439; - ret List.440; - in - jump List.624 #Derived_gen.41 #Derived_gen.42 #Derived_gen.43 #Derived_gen.44 #Derived_gen.45; +procedure List.18 (List.144, List.145, List.146): + let List.624 : {List U8, U64} = CallByName List.93 List.144 List.145 List.146; + ret List.624; -procedure List.80 (#Derived_gen.52, #Derived_gen.53, #Derived_gen.54, #Derived_gen.55, #Derived_gen.56): - joinpoint List.556 List.439 List.440 List.441 List.442 List.443: - let List.558 : Int1 = CallByName Num.22 List.442 List.443; - if List.558 then - let List.565 : {Str, Str} = CallByName List.66 List.439 List.442; - inc List.565; - let List.559 : {List U8, U64} = CallByName List.145 List.440 List.565 List.441; - let List.562 : U64 = 1i64; - let List.561 : U64 = CallByName Num.19 List.442 List.562; - jump List.556 List.439 List.559 List.441 List.561 List.443; - else - dec List.439; - ret List.440; - in - jump List.556 #Derived_gen.52 #Derived_gen.53 #Derived_gen.54 #Derived_gen.55 #Derived_gen.56; +procedure List.18 (List.144, List.145, List.146): + let List.645 : List U8 = CallByName List.93 List.144 List.145 List.146; + ret List.645; -procedure List.93 (List.436, List.437, List.438): - let List.554 : U64 = 0i64; - let List.555 : U64 = CallByName List.6 List.436; - let List.553 : {List U8, U64} = CallByName List.80 List.436 List.437 List.438 List.554 List.555; - ret List.553; +procedure List.26 (List.161, List.162, List.163): + let List.712 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.93 List.161 List.162 List.163; + let List.715 : U8 = 1i64; + let List.716 : U8 = GetTagId List.712; + let List.717 : Int1 = lowlevel Eq List.715 List.716; + if List.717 then + let List.164 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.712; + ret List.164; + else + let List.165 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.712; + ret List.165; -procedure List.93 (List.436, List.437, List.438): - let List.622 : U64 = 0i64; - let List.623 : U64 = CallByName List.6 List.436; - let List.621 : {List U8, U64} = CallByName List.80 List.436 List.437 List.438 List.622 List.623; +procedure List.31 (#Attr.2, #Attr.3): + let List.677 : List Str = lowlevel ListDropAt #Attr.2 #Attr.3; + ret List.677; + +procedure List.38 (List.300): + let List.685 : U64 = 0i64; + let List.684 : List Str = CallByName List.31 List.300 List.685; + ret List.684; + +procedure List.4 (List.115, List.116): + let List.620 : U64 = 1i64; + let List.619 : List Str = CallByName List.70 List.115 List.620; + let List.618 : List Str = CallByName List.71 List.619 List.116; + ret List.618; + +procedure List.4 (List.115, List.116): + let List.623 : U64 = 1i64; + let List.622 : List U8 = CallByName List.70 List.115 List.623; + let List.621 : List U8 = CallByName List.71 List.622 List.116; ret List.621; -procedure List.93 (List.436, List.437, List.438): - let List.642 : U64 = 0i64; - let List.643 : U64 = CallByName List.6 List.436; - let List.641 : List U8 = CallByName List.80 List.436 List.437 List.438 List.642 List.643; +procedure List.49 (List.379, List.380): + let List.704 : U64 = StructAtIndex 0 List.380; + let List.705 : U64 = 0i64; + let List.702 : Int1 = CallByName Bool.11 List.704 List.705; + if List.702 then + dec List.379; + let List.703 : List U8 = Array []; + ret List.703; + else + let List.699 : U64 = StructAtIndex 1 List.380; + let List.700 : U64 = StructAtIndex 0 List.380; + let List.698 : List U8 = CallByName List.72 List.379 List.699 List.700; + ret List.698; + +procedure List.52 (List.394, List.395): + let List.396 : U64 = CallByName List.6 List.394; + joinpoint List.710 List.397: + let List.708 : U64 = 0i64; + let List.707 : {U64, U64} = Struct {List.397, List.708}; + inc List.394; + let List.398 : List U8 = CallByName List.49 List.394 List.707; + let List.706 : U64 = CallByName Num.75 List.396 List.397; + let List.697 : {U64, U64} = Struct {List.706, List.397}; + let List.399 : List U8 = CallByName List.49 List.394 List.697; + let List.696 : {List U8, List U8} = Struct {List.398, List.399}; + ret List.696; + in + let List.711 : Int1 = CallByName Num.24 List.396 List.395; + if List.711 then + jump List.710 List.395; + else + jump List.710 List.396; + +procedure List.6 (#Attr.2): + let List.594 : U64 = lowlevel ListLen #Attr.2; + ret List.594; + +procedure List.6 (#Attr.2): + let List.691 : U64 = lowlevel ListLen #Attr.2; + ret List.691; + +procedure List.6 (#Attr.2): + let List.692 : U64 = lowlevel ListLen #Attr.2; + ret List.692; + +procedure List.6 (#Attr.2): + let List.694 : U64 = lowlevel ListLen #Attr.2; + ret List.694; + +procedure List.66 (#Attr.2, #Attr.3): + let List.572 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.572; + +procedure List.66 (#Attr.2, #Attr.3): + let List.641 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; ret List.641; -procedure List.93 (List.436, List.437, List.438): - let List.713 : U64 = 0i64; - let List.714 : U64 = CallByName List.6 List.436; - let List.712 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.80 List.436 List.437 List.438 List.713 List.714; - ret List.712; +procedure List.66 (#Attr.2, #Attr.3): + let List.660 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.660; + +procedure List.68 (#Attr.2): + let List.687 : List Str = lowlevel ListWithCapacity #Attr.2; + ret List.687; + +procedure List.68 (#Attr.2): + let List.689 : List U8 = lowlevel ListWithCapacity #Attr.2; + ret List.689; + +procedure List.70 (#Attr.2, #Attr.3): + let List.600 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.600; + +procedure List.70 (#Attr.2, #Attr.3): + let List.617 : List Str = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.617; + +procedure List.71 (#Attr.2, #Attr.3): + let List.598 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.598; + +procedure List.71 (#Attr.2, #Attr.3): + let List.615 : List Str = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.615; + +procedure List.72 (#Attr.2, #Attr.3, #Attr.4): + let List.701 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; + ret List.701; + +procedure List.8 (#Attr.2, #Attr.3): + let List.666 : List Str = lowlevel ListConcat #Attr.2 #Attr.3; + ret List.666; + +procedure List.8 (#Attr.2, #Attr.3): + let List.674 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; + ret List.674; + +procedure List.80 (#Derived_gen.23, #Derived_gen.24, #Derived_gen.25, #Derived_gen.26, #Derived_gen.27): + joinpoint List.630 List.442 List.443 List.444 List.445 List.446: + let List.632 : Int1 = CallByName Num.22 List.445 List.446; + if List.632 then + let List.640 : {Str, Str} = CallByName List.66 List.442 List.445; + inc List.640; + let List.633 : {List U8, U64} = CallByName List.147 List.443 List.640 List.444; + let List.635 : U64 = CallByName List.96 List.445; + jump List.630 List.442 List.633 List.444 List.635 List.446; + else + dec List.442; + ret List.443; + in + jump List.630 #Derived_gen.23 #Derived_gen.24 #Derived_gen.25 #Derived_gen.26 #Derived_gen.27; + +procedure List.80 (#Derived_gen.36, #Derived_gen.37, #Derived_gen.38, #Derived_gen.39, #Derived_gen.40): + joinpoint List.651 List.442 List.443 List.444 List.445 List.446: + let List.653 : Int1 = CallByName Num.22 List.445 List.446; + if List.653 then + let List.659 : U8 = CallByName List.66 List.442 List.445; + let List.654 : List U8 = CallByName List.147 List.443 List.659 List.444; + let List.656 : U64 = CallByName List.96 List.445; + jump List.651 List.442 List.654 List.444 List.656 List.446; + else + dec List.442; + ret List.443; + in + jump List.651 #Derived_gen.36 #Derived_gen.37 #Derived_gen.38 #Derived_gen.39 #Derived_gen.40; + +procedure List.80 (#Derived_gen.47, #Derived_gen.48, #Derived_gen.49, #Derived_gen.50, #Derived_gen.51): + joinpoint List.721 List.442 List.443 List.444 List.445 List.446: + let List.723 : Int1 = CallByName Num.22 List.445 List.446; + if List.723 then + let List.731 : U8 = CallByName List.66 List.442 List.445; + let List.724 : [C {U64, Int1}, C {U64, Int1}] = CallByName TotallyNotJson.189 List.443 List.731; + let List.728 : U8 = 1i64; + let List.729 : U8 = GetTagId List.724; + let List.730 : Int1 = lowlevel Eq List.728 List.729; + if List.730 then + let List.447 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.724; + let List.726 : U64 = CallByName List.96 List.445; + jump List.721 List.442 List.447 List.444 List.726 List.446; + else + dec List.442; + let List.448 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.724; + let List.727 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) List.448; + ret List.727; + else + dec List.442; + let List.722 : [C {U64, Int1}, C {U64, Int1}] = TagId(1) List.443; + ret List.722; + in + jump List.721 #Derived_gen.47 #Derived_gen.48 #Derived_gen.49 #Derived_gen.50 #Derived_gen.51; + +procedure List.80 (#Derived_gen.52, #Derived_gen.53, #Derived_gen.54, #Derived_gen.55, #Derived_gen.56): + joinpoint List.561 List.442 List.443 List.444 List.445 List.446: + let List.563 : Int1 = CallByName Num.22 List.445 List.446; + if List.563 then + let List.571 : {Str, Str} = CallByName List.66 List.442 List.445; + inc List.571; + let List.564 : {List U8, U64} = CallByName List.147 List.443 List.571 List.444; + let List.566 : U64 = CallByName List.96 List.445; + jump List.561 List.442 List.564 List.444 List.566 List.446; + else + dec List.442; + ret List.443; + in + jump List.561 #Derived_gen.52 #Derived_gen.53 #Derived_gen.54 #Derived_gen.55 #Derived_gen.56; + +procedure List.93 (List.439, List.440, List.441): + let List.559 : U64 = 0i64; + let List.560 : U64 = CallByName List.6 List.439; + let List.558 : {List U8, U64} = CallByName List.80 List.439 List.440 List.441 List.559 List.560; + ret List.558; + +procedure List.93 (List.439, List.440, List.441): + let List.628 : U64 = 0i64; + let List.629 : U64 = CallByName List.6 List.439; + let List.627 : {List U8, U64} = CallByName List.80 List.439 List.440 List.441 List.628 List.629; + ret List.627; + +procedure List.93 (List.439, List.440, List.441): + let List.649 : U64 = 0i64; + let List.650 : U64 = CallByName List.6 List.439; + let List.648 : List U8 = CallByName List.80 List.439 List.440 List.441 List.649 List.650; + ret List.648; + +procedure List.93 (List.439, List.440, List.441): + let List.719 : U64 = 0i64; + let List.720 : U64 = CallByName List.6 List.439; + let List.718 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.80 List.439 List.440 List.441 List.719 List.720; + ret List.718; + +procedure List.96 (List.463): + let List.637 : U64 = 1i64; + let List.636 : U64 = CallByName Num.51 List.463 List.637; + ret List.636; procedure Num.127 (#Attr.2): let Num.307 : U8 = lowlevel NumIntCast #Attr.2; ret Num.307; procedure Num.19 (#Attr.2, #Attr.3): - let Num.316 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.316; + let Num.311 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.311; procedure Num.20 (#Attr.2, #Attr.3): - let Num.320 : U64 = lowlevel NumSub #Attr.2 #Attr.3; - ret Num.320; + let Num.308 : U64 = lowlevel NumSub #Attr.2 #Attr.3; + ret Num.308; procedure Num.21 (#Attr.2, #Attr.3): let Num.313 : U64 = lowlevel NumMul #Attr.2 #Attr.3; ret Num.313; procedure Num.22 (#Attr.2, #Attr.3): - let Num.319 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; - ret Num.319; + let Num.317 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + ret Num.317; procedure Num.24 (#Attr.2, #Attr.3): - let Num.321 : Int1 = lowlevel NumGt #Attr.2 #Attr.3; - ret Num.321; + let Num.319 : Int1 = lowlevel NumGt #Attr.2 #Attr.3; + ret Num.319; + +procedure Num.51 (#Attr.2, #Attr.3): + let Num.314 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; + ret Num.314; + +procedure Num.75 (#Attr.2, #Attr.3): + let Num.318 : U64 = lowlevel NumSubWrap #Attr.2 #Attr.3; + ret Num.318; procedure Num.94 (#Attr.2, #Attr.3): let Num.312 : U64 = lowlevel NumDivCeilUnchecked #Attr.2 #Attr.3; ret Num.312; procedure Str.12 (#Attr.2): - let Str.307 : List U8 = lowlevel StrToUtf8 #Attr.2; - ret Str.307; + let Str.309 : List U8 = lowlevel StrToUtf8 #Attr.2; + ret Str.309; procedure Str.4 (#Attr.2, #Attr.3): - let Str.310 : Str = lowlevel StrJoinWith #Attr.2 #Attr.3; - ret Str.310; + let Str.312 : Str = lowlevel StrJoinWith #Attr.2 #Attr.3; + ret Str.312; procedure Str.48 (#Attr.2, #Attr.3, #Attr.4): - let Str.298 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8Range #Attr.2 #Attr.3 #Attr.4; - ret Str.298; + let Str.300 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8Range #Attr.2 #Attr.3 #Attr.4; + ret Str.300; procedure Str.55 (#Attr.2): - let Str.313 : List Str = lowlevel StrGraphemes #Attr.2; - ret Str.313; + let Str.315 : List Str = lowlevel StrGraphemes #Attr.2; + ret Str.315; -procedure Str.9 (Str.79): - let Str.296 : U64 = 0i64; - let Str.297 : U64 = CallByName List.6 Str.79; - let Str.80 : {U64, Str, Int1, U8} = CallByName Str.48 Str.79 Str.296 Str.297; - let Str.293 : Int1 = StructAtIndex 2 Str.80; - if Str.293 then - let Str.295 : Str = StructAtIndex 1 Str.80; - let Str.294 : [C {U64, U8}, C Str] = TagId(1) Str.295; - ret Str.294; +procedure Str.9 (Str.80): + let Str.298 : U64 = 0i64; + let Str.299 : U64 = CallByName List.6 Str.80; + let Str.81 : {U64, Str, Int1, U8} = CallByName Str.48 Str.80 Str.298 Str.299; + let Str.295 : Int1 = StructAtIndex 2 Str.81; + if Str.295 then + let Str.297 : Str = StructAtIndex 1 Str.81; + let Str.296 : [C {U64, U8}, C Str] = TagId(1) Str.297; + ret Str.296; else - let Str.291 : U8 = StructAtIndex 3 Str.80; - let Str.292 : U64 = StructAtIndex 0 Str.80; - let #Derived_gen.57 : Str = StructAtIndex 1 Str.80; + let Str.293 : U8 = StructAtIndex 3 Str.81; + let Str.294 : U64 = StructAtIndex 0 Str.81; + let #Derived_gen.57 : Str = StructAtIndex 1 Str.81; dec #Derived_gen.57; - let Str.290 : {U64, U8} = Struct {Str.292, Str.291}; - let Str.289 : [C {U64, U8}, C Str] = TagId(0) Str.290; - ret Str.289; + let Str.292 : {U64, U8} = Struct {Str.294, Str.293}; + let Str.291 : [C {U64, U8}, C Str] = TagId(0) Str.292; + ret Str.291; procedure TotallyNotJson.100 (TotallyNotJson.850): let TotallyNotJson.1830 : Str = "a"; @@ -1393,7 +1402,7 @@ procedure TotallyNotJson.95 (TotallyNotJson.829): dec TotallyNotJson.1841; ret TotallyNotJson.1839; -procedure TotallyNotJson.96 (#Derived_gen.29): +procedure TotallyNotJson.96 (#Derived_gen.34): joinpoint TotallyNotJson.1847 TotallyNotJson.1168: let TotallyNotJson.834 : List Str = StructAtIndex 0 TotallyNotJson.1168; let TotallyNotJson.833 : List Str = StructAtIndex 1 TotallyNotJson.1168; @@ -1429,7 +1438,7 @@ procedure TotallyNotJson.96 (#Derived_gen.29): let TotallyNotJson.1848 : {List Str, List Str} = Struct {TotallyNotJson.834, TotallyNotJson.833}; ret TotallyNotJson.1848; in - jump TotallyNotJson.1847 #Derived_gen.29; + jump TotallyNotJson.1847 #Derived_gen.34; procedure TotallyNotJson.97 (TotallyNotJson.837): let TotallyNotJson.838 : List Str = CallByName Str.55 TotallyNotJson.837; diff --git a/crates/compiler/test_mono/generated/encode_derived_record_one_field_string.txt b/crates/compiler/test_mono/generated/encode_derived_record_one_field_string.txt index 81f7d70c33..77ae7816a6 100644 --- a/crates/compiler/test_mono/generated/encode_derived_record_one_field_string.txt +++ b/crates/compiler/test_mono/generated/encode_derived_record_one_field_string.txt @@ -51,283 +51,293 @@ procedure Encode.26 (Encode.105, Encode.106): ret Encode.108; procedure List.13 (#Attr.2, #Attr.3): - let List.621 : List Str = lowlevel ListPrepend #Attr.2 #Attr.3; - ret List.621; + let List.626 : List Str = lowlevel ListPrepend #Attr.2 #Attr.3; + ret List.626; -procedure List.145 (List.146, List.147, List.144): - let List.569 : {List U8, U64} = CallByName TotallyNotJson.237 List.146 List.147 List.144; - ret List.569; +procedure List.147 (List.148, List.149, List.146): + let List.575 : {List U8, U64} = CallByName TotallyNotJson.237 List.148 List.149 List.146; + ret List.575; -procedure List.145 (List.146, List.147, List.144): - let List.589 : List U8 = CallByName TotallyNotJson.215 List.146 List.147; - ret List.589; +procedure List.147 (List.148, List.149, List.146): + let List.594 : List U8 = CallByName TotallyNotJson.215 List.148 List.149; + ret List.594; -procedure List.18 (List.142, List.143, List.144): - let List.550 : {List U8, U64} = CallByName List.93 List.142 List.143 List.144; - ret List.550; +procedure List.18 (List.144, List.145, List.146): + let List.555 : {List U8, U64} = CallByName List.93 List.144 List.145 List.146; + ret List.555; -procedure List.18 (List.142, List.143, List.144): - let List.570 : List U8 = CallByName List.93 List.142 List.143 List.144; - ret List.570; +procedure List.18 (List.144, List.145, List.146): + let List.576 : List U8 = CallByName List.93 List.144 List.145 List.146; + ret List.576; -procedure List.26 (List.159, List.160, List.161): - let List.638 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.93 List.159 List.160 List.161; - let List.641 : U8 = 1i64; - let List.642 : U8 = GetTagId List.638; - let List.643 : Int1 = lowlevel Eq List.641 List.642; - if List.643 then - let List.162 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.638; - ret List.162; +procedure List.26 (List.161, List.162, List.163): + let List.643 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.93 List.161 List.162 List.163; + let List.646 : U8 = 1i64; + let List.647 : U8 = GetTagId List.643; + let List.648 : Int1 = lowlevel Eq List.646 List.647; + if List.648 then + let List.164 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.643; + ret List.164; else - let List.163 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.638; - ret List.163; + let List.165 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.643; + ret List.165; procedure List.31 (#Attr.2, #Attr.3): - let List.603 : List Str = lowlevel ListDropAt #Attr.2 #Attr.3; - ret List.603; + let List.608 : List Str = lowlevel ListDropAt #Attr.2 #Attr.3; + ret List.608; -procedure List.38 (List.298): - let List.611 : U64 = 0i64; - let List.610 : List Str = CallByName List.31 List.298 List.611; - ret List.610; - -procedure List.4 (List.113, List.114): - let List.546 : U64 = 1i64; - let List.545 : List Str = CallByName List.70 List.113 List.546; - let List.544 : List Str = CallByName List.71 List.545 List.114; - ret List.544; - -procedure List.4 (List.113, List.114): - let List.549 : U64 = 1i64; - let List.548 : List U8 = CallByName List.70 List.113 List.549; - let List.547 : List U8 = CallByName List.71 List.548 List.114; - ret List.547; - -procedure List.49 (List.376, List.377): - let List.630 : U64 = StructAtIndex 0 List.377; - let List.631 : U64 = 0i64; - let List.628 : Int1 = CallByName Bool.11 List.630 List.631; - if List.628 then - dec List.376; - let List.629 : List U8 = Array []; - ret List.629; - else - let List.625 : U64 = StructAtIndex 1 List.377; - let List.626 : U64 = StructAtIndex 0 List.377; - let List.624 : List U8 = CallByName List.72 List.376 List.625 List.626; - ret List.624; - -procedure List.52 (List.391, List.392): - let List.393 : U64 = CallByName List.6 List.391; - joinpoint List.636 List.394: - let List.634 : U64 = 0i64; - let List.633 : {U64, U64} = Struct {List.394, List.634}; - inc List.391; - let List.395 : List U8 = CallByName List.49 List.391 List.633; - let List.632 : U64 = CallByName Num.20 List.393 List.394; - let List.623 : {U64, U64} = Struct {List.632, List.394}; - let List.396 : List U8 = CallByName List.49 List.391 List.623; - let List.622 : {List U8, List U8} = Struct {List.395, List.396}; - ret List.622; - in - let List.637 : Int1 = CallByName Num.24 List.393 List.392; - if List.637 then - jump List.636 List.392; - else - jump List.636 List.393; - -procedure List.6 (#Attr.2): - let List.617 : U64 = lowlevel ListLen #Attr.2; - ret List.617; - -procedure List.6 (#Attr.2): - let List.618 : U64 = lowlevel ListLen #Attr.2; - ret List.618; - -procedure List.6 (#Attr.2): - let List.620 : U64 = lowlevel ListLen #Attr.2; - ret List.620; - -procedure List.66 (#Attr.2, #Attr.3): - let List.566 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.566; - -procedure List.66 (#Attr.2, #Attr.3): - let List.586 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.586; - -procedure List.68 (#Attr.2): - let List.613 : List Str = lowlevel ListWithCapacity #Attr.2; - ret List.613; - -procedure List.68 (#Attr.2): - let List.615 : List U8 = lowlevel ListWithCapacity #Attr.2; +procedure List.38 (List.300): + let List.616 : U64 = 0i64; + let List.615 : List Str = CallByName List.31 List.300 List.616; ret List.615; -procedure List.70 (#Attr.2, #Attr.3): - let List.526 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.526; +procedure List.4 (List.115, List.116): + let List.551 : U64 = 1i64; + let List.550 : List Str = CallByName List.70 List.115 List.551; + let List.549 : List Str = CallByName List.71 List.550 List.116; + ret List.549; + +procedure List.4 (List.115, List.116): + let List.554 : U64 = 1i64; + let List.553 : List U8 = CallByName List.70 List.115 List.554; + let List.552 : List U8 = CallByName List.71 List.553 List.116; + ret List.552; + +procedure List.49 (List.379, List.380): + let List.635 : U64 = StructAtIndex 0 List.380; + let List.636 : U64 = 0i64; + let List.633 : Int1 = CallByName Bool.11 List.635 List.636; + if List.633 then + dec List.379; + let List.634 : List U8 = Array []; + ret List.634; + else + let List.630 : U64 = StructAtIndex 1 List.380; + let List.631 : U64 = StructAtIndex 0 List.380; + let List.629 : List U8 = CallByName List.72 List.379 List.630 List.631; + ret List.629; + +procedure List.52 (List.394, List.395): + let List.396 : U64 = CallByName List.6 List.394; + joinpoint List.641 List.397: + let List.639 : U64 = 0i64; + let List.638 : {U64, U64} = Struct {List.397, List.639}; + inc List.394; + let List.398 : List U8 = CallByName List.49 List.394 List.638; + let List.637 : U64 = CallByName Num.75 List.396 List.397; + let List.628 : {U64, U64} = Struct {List.637, List.397}; + let List.399 : List U8 = CallByName List.49 List.394 List.628; + let List.627 : {List U8, List U8} = Struct {List.398, List.399}; + ret List.627; + in + let List.642 : Int1 = CallByName Num.24 List.396 List.395; + if List.642 then + jump List.641 List.395; + else + jump List.641 List.396; + +procedure List.6 (#Attr.2): + let List.622 : U64 = lowlevel ListLen #Attr.2; + ret List.622; + +procedure List.6 (#Attr.2): + let List.623 : U64 = lowlevel ListLen #Attr.2; + ret List.623; + +procedure List.6 (#Attr.2): + let List.625 : U64 = lowlevel ListLen #Attr.2; + ret List.625; + +procedure List.66 (#Attr.2, #Attr.3): + let List.572 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.572; + +procedure List.66 (#Attr.2, #Attr.3): + let List.591 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.591; + +procedure List.68 (#Attr.2): + let List.618 : List Str = lowlevel ListWithCapacity #Attr.2; + ret List.618; + +procedure List.68 (#Attr.2): + let List.620 : List U8 = lowlevel ListWithCapacity #Attr.2; + ret List.620; procedure List.70 (#Attr.2, #Attr.3): - let List.543 : List Str = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.543; + let List.531 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.531; + +procedure List.70 (#Attr.2, #Attr.3): + let List.548 : List Str = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.548; procedure List.71 (#Attr.2, #Attr.3): - let List.524 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.524; + let List.529 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.529; procedure List.71 (#Attr.2, #Attr.3): - let List.541 : List Str = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.541; + let List.546 : List Str = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.546; procedure List.72 (#Attr.2, #Attr.3, #Attr.4): - let List.627 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; - ret List.627; + let List.632 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; + ret List.632; procedure List.8 (#Attr.2, #Attr.3): - let List.592 : List Str = lowlevel ListConcat #Attr.2 #Attr.3; - ret List.592; + let List.597 : List Str = lowlevel ListConcat #Attr.2 #Attr.3; + ret List.597; procedure List.8 (#Attr.2, #Attr.3): - let List.600 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; - ret List.600; + let List.605 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; + ret List.605; procedure List.80 (#Derived_gen.10, #Derived_gen.11, #Derived_gen.12, #Derived_gen.13, #Derived_gen.14): - joinpoint List.647 List.439 List.440 List.441 List.442 List.443: - let List.649 : Int1 = CallByName Num.22 List.442 List.443; - if List.649 then - let List.658 : U8 = CallByName List.66 List.439 List.442; - let List.650 : [C {U64, Int1}, C {U64, Int1}] = CallByName TotallyNotJson.189 List.440 List.658; - let List.655 : U8 = 1i64; - let List.656 : U8 = GetTagId List.650; - let List.657 : Int1 = lowlevel Eq List.655 List.656; - if List.657 then - let List.444 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.650; - let List.653 : U64 = 1i64; - let List.652 : U64 = CallByName Num.19 List.442 List.653; - jump List.647 List.439 List.444 List.441 List.652 List.443; + joinpoint List.652 List.442 List.443 List.444 List.445 List.446: + let List.654 : Int1 = CallByName Num.22 List.445 List.446; + if List.654 then + let List.662 : U8 = CallByName List.66 List.442 List.445; + let List.655 : [C {U64, Int1}, C {U64, Int1}] = CallByName TotallyNotJson.189 List.443 List.662; + let List.659 : U8 = 1i64; + let List.660 : U8 = GetTagId List.655; + let List.661 : Int1 = lowlevel Eq List.659 List.660; + if List.661 then + let List.447 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.655; + let List.657 : U64 = CallByName List.96 List.445; + jump List.652 List.442 List.447 List.444 List.657 List.446; else - dec List.439; - let List.445 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.650; - let List.654 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) List.445; - ret List.654; + dec List.442; + let List.448 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.655; + let List.658 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) List.448; + ret List.658; else - dec List.439; - let List.648 : [C {U64, Int1}, C {U64, Int1}] = TagId(1) List.440; - ret List.648; + dec List.442; + let List.653 : [C {U64, Int1}, C {U64, Int1}] = TagId(1) List.443; + ret List.653; in - jump List.647 #Derived_gen.10 #Derived_gen.11 #Derived_gen.12 #Derived_gen.13 #Derived_gen.14; + jump List.652 #Derived_gen.10 #Derived_gen.11 #Derived_gen.12 #Derived_gen.13 #Derived_gen.14; -procedure List.80 (#Derived_gen.18, #Derived_gen.19, #Derived_gen.20, #Derived_gen.21, #Derived_gen.22): - joinpoint List.576 List.439 List.440 List.441 List.442 List.443: - let List.578 : Int1 = CallByName Num.22 List.442 List.443; - if List.578 then - let List.585 : U8 = CallByName List.66 List.439 List.442; - let List.579 : List U8 = CallByName List.145 List.440 List.585 List.441; - let List.582 : U64 = 1i64; - let List.581 : U64 = CallByName Num.19 List.442 List.582; - jump List.576 List.439 List.579 List.441 List.581 List.443; +procedure List.80 (#Derived_gen.25, #Derived_gen.26, #Derived_gen.27, #Derived_gen.28, #Derived_gen.29): + joinpoint List.582 List.442 List.443 List.444 List.445 List.446: + let List.584 : Int1 = CallByName Num.22 List.445 List.446; + if List.584 then + let List.590 : U8 = CallByName List.66 List.442 List.445; + let List.585 : List U8 = CallByName List.147 List.443 List.590 List.444; + let List.587 : U64 = CallByName List.96 List.445; + jump List.582 List.442 List.585 List.444 List.587 List.446; else - dec List.439; - ret List.440; + dec List.442; + ret List.443; in - jump List.576 #Derived_gen.18 #Derived_gen.19 #Derived_gen.20 #Derived_gen.21 #Derived_gen.22; + jump List.582 #Derived_gen.25 #Derived_gen.26 #Derived_gen.27 #Derived_gen.28 #Derived_gen.29; procedure List.80 (#Derived_gen.31, #Derived_gen.32, #Derived_gen.33, #Derived_gen.34, #Derived_gen.35): - joinpoint List.556 List.439 List.440 List.441 List.442 List.443: - let List.558 : Int1 = CallByName Num.22 List.442 List.443; - if List.558 then - let List.565 : {Str, Str} = CallByName List.66 List.439 List.442; - inc List.565; - let List.559 : {List U8, U64} = CallByName List.145 List.440 List.565 List.441; - let List.562 : U64 = 1i64; - let List.561 : U64 = CallByName Num.19 List.442 List.562; - jump List.556 List.439 List.559 List.441 List.561 List.443; + joinpoint List.561 List.442 List.443 List.444 List.445 List.446: + let List.563 : Int1 = CallByName Num.22 List.445 List.446; + if List.563 then + let List.571 : {Str, Str} = CallByName List.66 List.442 List.445; + inc List.571; + let List.564 : {List U8, U64} = CallByName List.147 List.443 List.571 List.444; + let List.566 : U64 = CallByName List.96 List.445; + jump List.561 List.442 List.564 List.444 List.566 List.446; else - dec List.439; - ret List.440; + dec List.442; + ret List.443; in - jump List.556 #Derived_gen.31 #Derived_gen.32 #Derived_gen.33 #Derived_gen.34 #Derived_gen.35; + jump List.561 #Derived_gen.31 #Derived_gen.32 #Derived_gen.33 #Derived_gen.34 #Derived_gen.35; -procedure List.93 (List.436, List.437, List.438): - let List.554 : U64 = 0i64; - let List.555 : U64 = CallByName List.6 List.436; - let List.553 : {List U8, U64} = CallByName List.80 List.436 List.437 List.438 List.554 List.555; - ret List.553; +procedure List.93 (List.439, List.440, List.441): + let List.559 : U64 = 0i64; + let List.560 : U64 = CallByName List.6 List.439; + let List.558 : {List U8, U64} = CallByName List.80 List.439 List.440 List.441 List.559 List.560; + ret List.558; -procedure List.93 (List.436, List.437, List.438): - let List.574 : U64 = 0i64; - let List.575 : U64 = CallByName List.6 List.436; - let List.573 : List U8 = CallByName List.80 List.436 List.437 List.438 List.574 List.575; - ret List.573; +procedure List.93 (List.439, List.440, List.441): + let List.580 : U64 = 0i64; + let List.581 : U64 = CallByName List.6 List.439; + let List.579 : List U8 = CallByName List.80 List.439 List.440 List.441 List.580 List.581; + ret List.579; -procedure List.93 (List.436, List.437, List.438): - let List.645 : U64 = 0i64; - let List.646 : U64 = CallByName List.6 List.436; - let List.644 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.80 List.436 List.437 List.438 List.645 List.646; - ret List.644; +procedure List.93 (List.439, List.440, List.441): + let List.650 : U64 = 0i64; + let List.651 : U64 = CallByName List.6 List.439; + let List.649 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.80 List.439 List.440 List.441 List.650 List.651; + ret List.649; + +procedure List.96 (List.463): + let List.568 : U64 = 1i64; + let List.567 : U64 = CallByName Num.51 List.463 List.568; + ret List.567; procedure Num.127 (#Attr.2): let Num.297 : U8 = lowlevel NumIntCast #Attr.2; ret Num.297; procedure Num.19 (#Attr.2, #Attr.3): - let Num.306 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.306; + let Num.301 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.301; procedure Num.20 (#Attr.2, #Attr.3): - let Num.310 : U64 = lowlevel NumSub #Attr.2 #Attr.3; - ret Num.310; + let Num.298 : U64 = lowlevel NumSub #Attr.2 #Attr.3; + ret Num.298; procedure Num.21 (#Attr.2, #Attr.3): let Num.303 : U64 = lowlevel NumMul #Attr.2 #Attr.3; ret Num.303; procedure Num.22 (#Attr.2, #Attr.3): - let Num.309 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; - ret Num.309; + let Num.307 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + ret Num.307; procedure Num.24 (#Attr.2, #Attr.3): - let Num.311 : Int1 = lowlevel NumGt #Attr.2 #Attr.3; - ret Num.311; + let Num.309 : Int1 = lowlevel NumGt #Attr.2 #Attr.3; + ret Num.309; + +procedure Num.51 (#Attr.2, #Attr.3): + let Num.304 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; + ret Num.304; + +procedure Num.75 (#Attr.2, #Attr.3): + let Num.308 : U64 = lowlevel NumSubWrap #Attr.2 #Attr.3; + ret Num.308; procedure Num.94 (#Attr.2, #Attr.3): let Num.302 : U64 = lowlevel NumDivCeilUnchecked #Attr.2 #Attr.3; ret Num.302; procedure Str.12 (#Attr.2): - let Str.300 : List U8 = lowlevel StrToUtf8 #Attr.2; - ret Str.300; + let Str.302 : List U8 = lowlevel StrToUtf8 #Attr.2; + ret Str.302; procedure Str.4 (#Attr.2, #Attr.3): - let Str.303 : Str = lowlevel StrJoinWith #Attr.2 #Attr.3; - ret Str.303; + let Str.305 : Str = lowlevel StrJoinWith #Attr.2 #Attr.3; + ret Str.305; procedure Str.48 (#Attr.2, #Attr.3, #Attr.4): - let Str.298 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8Range #Attr.2 #Attr.3 #Attr.4; - ret Str.298; + let Str.300 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8Range #Attr.2 #Attr.3 #Attr.4; + ret Str.300; procedure Str.55 (#Attr.2): - let Str.306 : List Str = lowlevel StrGraphemes #Attr.2; - ret Str.306; + let Str.308 : List Str = lowlevel StrGraphemes #Attr.2; + ret Str.308; -procedure Str.9 (Str.79): - let Str.296 : U64 = 0i64; - let Str.297 : U64 = CallByName List.6 Str.79; - let Str.80 : {U64, Str, Int1, U8} = CallByName Str.48 Str.79 Str.296 Str.297; - let Str.293 : Int1 = StructAtIndex 2 Str.80; - if Str.293 then - let Str.295 : Str = StructAtIndex 1 Str.80; - let Str.294 : [C {U64, U8}, C Str] = TagId(1) Str.295; - ret Str.294; +procedure Str.9 (Str.80): + let Str.298 : U64 = 0i64; + let Str.299 : U64 = CallByName List.6 Str.80; + let Str.81 : {U64, Str, Int1, U8} = CallByName Str.48 Str.80 Str.298 Str.299; + let Str.295 : Int1 = StructAtIndex 2 Str.81; + if Str.295 then + let Str.297 : Str = StructAtIndex 1 Str.81; + let Str.296 : [C {U64, U8}, C Str] = TagId(1) Str.297; + ret Str.296; else - let Str.291 : U8 = StructAtIndex 3 Str.80; - let Str.292 : U64 = StructAtIndex 0 Str.80; - let #Derived_gen.36 : Str = StructAtIndex 1 Str.80; + let Str.293 : U8 = StructAtIndex 3 Str.81; + let Str.294 : U64 = StructAtIndex 0 Str.81; + let #Derived_gen.36 : Str = StructAtIndex 1 Str.81; dec #Derived_gen.36; - let Str.290 : {U64, U8} = Struct {Str.292, Str.291}; - let Str.289 : [C {U64, U8}, C Str] = TagId(0) Str.290; - ret Str.289; + let Str.292 : {U64, U8} = Struct {Str.294, Str.293}; + let Str.291 : [C {U64, U8}, C Str] = TagId(0) Str.292; + ret Str.291; procedure TotallyNotJson.100 (TotallyNotJson.850): let TotallyNotJson.1479 : Str = "a"; @@ -1277,7 +1287,7 @@ procedure TotallyNotJson.95 (TotallyNotJson.829): dec TotallyNotJson.1489; ret TotallyNotJson.1488; -procedure TotallyNotJson.96 (#Derived_gen.26): +procedure TotallyNotJson.96 (#Derived_gen.21): joinpoint TotallyNotJson.1496 TotallyNotJson.1168: let TotallyNotJson.834 : List Str = StructAtIndex 0 TotallyNotJson.1168; let TotallyNotJson.833 : List Str = StructAtIndex 1 TotallyNotJson.1168; @@ -1313,7 +1323,7 @@ procedure TotallyNotJson.96 (#Derived_gen.26): let TotallyNotJson.1497 : {List Str, List Str} = Struct {TotallyNotJson.834, TotallyNotJson.833}; ret TotallyNotJson.1497; in - jump TotallyNotJson.1496 #Derived_gen.26; + jump TotallyNotJson.1496 #Derived_gen.21; procedure TotallyNotJson.97 (TotallyNotJson.837): let TotallyNotJson.838 : List Str = CallByName Str.55 TotallyNotJson.837; diff --git a/crates/compiler/test_mono/generated/encode_derived_record_two_field_strings.txt b/crates/compiler/test_mono/generated/encode_derived_record_two_field_strings.txt index 810705ef6f..21ddc6551b 100644 --- a/crates/compiler/test_mono/generated/encode_derived_record_two_field_strings.txt +++ b/crates/compiler/test_mono/generated/encode_derived_record_two_field_strings.txt @@ -58,283 +58,293 @@ procedure Encode.26 (Encode.105, Encode.106): ret Encode.108; procedure List.13 (#Attr.2, #Attr.3): - let List.621 : List Str = lowlevel ListPrepend #Attr.2 #Attr.3; - ret List.621; + let List.626 : List Str = lowlevel ListPrepend #Attr.2 #Attr.3; + ret List.626; -procedure List.145 (List.146, List.147, List.144): - let List.569 : {List U8, U64} = CallByName TotallyNotJson.237 List.146 List.147 List.144; - ret List.569; +procedure List.147 (List.148, List.149, List.146): + let List.575 : {List U8, U64} = CallByName TotallyNotJson.237 List.148 List.149 List.146; + ret List.575; -procedure List.145 (List.146, List.147, List.144): - let List.589 : List U8 = CallByName TotallyNotJson.215 List.146 List.147; - ret List.589; +procedure List.147 (List.148, List.149, List.146): + let List.594 : List U8 = CallByName TotallyNotJson.215 List.148 List.149; + ret List.594; -procedure List.18 (List.142, List.143, List.144): - let List.550 : {List U8, U64} = CallByName List.93 List.142 List.143 List.144; - ret List.550; +procedure List.18 (List.144, List.145, List.146): + let List.555 : {List U8, U64} = CallByName List.93 List.144 List.145 List.146; + ret List.555; -procedure List.18 (List.142, List.143, List.144): - let List.570 : List U8 = CallByName List.93 List.142 List.143 List.144; - ret List.570; +procedure List.18 (List.144, List.145, List.146): + let List.576 : List U8 = CallByName List.93 List.144 List.145 List.146; + ret List.576; -procedure List.26 (List.159, List.160, List.161): - let List.638 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.93 List.159 List.160 List.161; - let List.641 : U8 = 1i64; - let List.642 : U8 = GetTagId List.638; - let List.643 : Int1 = lowlevel Eq List.641 List.642; - if List.643 then - let List.162 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.638; - ret List.162; +procedure List.26 (List.161, List.162, List.163): + let List.643 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.93 List.161 List.162 List.163; + let List.646 : U8 = 1i64; + let List.647 : U8 = GetTagId List.643; + let List.648 : Int1 = lowlevel Eq List.646 List.647; + if List.648 then + let List.164 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.643; + ret List.164; else - let List.163 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.638; - ret List.163; + let List.165 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.643; + ret List.165; procedure List.31 (#Attr.2, #Attr.3): - let List.603 : List Str = lowlevel ListDropAt #Attr.2 #Attr.3; - ret List.603; + let List.608 : List Str = lowlevel ListDropAt #Attr.2 #Attr.3; + ret List.608; -procedure List.38 (List.298): - let List.611 : U64 = 0i64; - let List.610 : List Str = CallByName List.31 List.298 List.611; - ret List.610; - -procedure List.4 (List.113, List.114): - let List.546 : U64 = 1i64; - let List.545 : List Str = CallByName List.70 List.113 List.546; - let List.544 : List Str = CallByName List.71 List.545 List.114; - ret List.544; - -procedure List.4 (List.113, List.114): - let List.549 : U64 = 1i64; - let List.548 : List U8 = CallByName List.70 List.113 List.549; - let List.547 : List U8 = CallByName List.71 List.548 List.114; - ret List.547; - -procedure List.49 (List.376, List.377): - let List.630 : U64 = StructAtIndex 0 List.377; - let List.631 : U64 = 0i64; - let List.628 : Int1 = CallByName Bool.11 List.630 List.631; - if List.628 then - dec List.376; - let List.629 : List U8 = Array []; - ret List.629; - else - let List.625 : U64 = StructAtIndex 1 List.377; - let List.626 : U64 = StructAtIndex 0 List.377; - let List.624 : List U8 = CallByName List.72 List.376 List.625 List.626; - ret List.624; - -procedure List.52 (List.391, List.392): - let List.393 : U64 = CallByName List.6 List.391; - joinpoint List.636 List.394: - let List.634 : U64 = 0i64; - let List.633 : {U64, U64} = Struct {List.394, List.634}; - inc List.391; - let List.395 : List U8 = CallByName List.49 List.391 List.633; - let List.632 : U64 = CallByName Num.20 List.393 List.394; - let List.623 : {U64, U64} = Struct {List.632, List.394}; - let List.396 : List U8 = CallByName List.49 List.391 List.623; - let List.622 : {List U8, List U8} = Struct {List.395, List.396}; - ret List.622; - in - let List.637 : Int1 = CallByName Num.24 List.393 List.392; - if List.637 then - jump List.636 List.392; - else - jump List.636 List.393; - -procedure List.6 (#Attr.2): - let List.617 : U64 = lowlevel ListLen #Attr.2; - ret List.617; - -procedure List.6 (#Attr.2): - let List.618 : U64 = lowlevel ListLen #Attr.2; - ret List.618; - -procedure List.6 (#Attr.2): - let List.620 : U64 = lowlevel ListLen #Attr.2; - ret List.620; - -procedure List.66 (#Attr.2, #Attr.3): - let List.566 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.566; - -procedure List.66 (#Attr.2, #Attr.3): - let List.586 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.586; - -procedure List.68 (#Attr.2): - let List.613 : List Str = lowlevel ListWithCapacity #Attr.2; - ret List.613; - -procedure List.68 (#Attr.2): - let List.615 : List U8 = lowlevel ListWithCapacity #Attr.2; +procedure List.38 (List.300): + let List.616 : U64 = 0i64; + let List.615 : List Str = CallByName List.31 List.300 List.616; ret List.615; -procedure List.70 (#Attr.2, #Attr.3): - let List.526 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.526; +procedure List.4 (List.115, List.116): + let List.551 : U64 = 1i64; + let List.550 : List Str = CallByName List.70 List.115 List.551; + let List.549 : List Str = CallByName List.71 List.550 List.116; + ret List.549; + +procedure List.4 (List.115, List.116): + let List.554 : U64 = 1i64; + let List.553 : List U8 = CallByName List.70 List.115 List.554; + let List.552 : List U8 = CallByName List.71 List.553 List.116; + ret List.552; + +procedure List.49 (List.379, List.380): + let List.635 : U64 = StructAtIndex 0 List.380; + let List.636 : U64 = 0i64; + let List.633 : Int1 = CallByName Bool.11 List.635 List.636; + if List.633 then + dec List.379; + let List.634 : List U8 = Array []; + ret List.634; + else + let List.630 : U64 = StructAtIndex 1 List.380; + let List.631 : U64 = StructAtIndex 0 List.380; + let List.629 : List U8 = CallByName List.72 List.379 List.630 List.631; + ret List.629; + +procedure List.52 (List.394, List.395): + let List.396 : U64 = CallByName List.6 List.394; + joinpoint List.641 List.397: + let List.639 : U64 = 0i64; + let List.638 : {U64, U64} = Struct {List.397, List.639}; + inc List.394; + let List.398 : List U8 = CallByName List.49 List.394 List.638; + let List.637 : U64 = CallByName Num.75 List.396 List.397; + let List.628 : {U64, U64} = Struct {List.637, List.397}; + let List.399 : List U8 = CallByName List.49 List.394 List.628; + let List.627 : {List U8, List U8} = Struct {List.398, List.399}; + ret List.627; + in + let List.642 : Int1 = CallByName Num.24 List.396 List.395; + if List.642 then + jump List.641 List.395; + else + jump List.641 List.396; + +procedure List.6 (#Attr.2): + let List.622 : U64 = lowlevel ListLen #Attr.2; + ret List.622; + +procedure List.6 (#Attr.2): + let List.623 : U64 = lowlevel ListLen #Attr.2; + ret List.623; + +procedure List.6 (#Attr.2): + let List.625 : U64 = lowlevel ListLen #Attr.2; + ret List.625; + +procedure List.66 (#Attr.2, #Attr.3): + let List.572 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.572; + +procedure List.66 (#Attr.2, #Attr.3): + let List.591 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.591; + +procedure List.68 (#Attr.2): + let List.618 : List Str = lowlevel ListWithCapacity #Attr.2; + ret List.618; + +procedure List.68 (#Attr.2): + let List.620 : List U8 = lowlevel ListWithCapacity #Attr.2; + ret List.620; procedure List.70 (#Attr.2, #Attr.3): - let List.543 : List Str = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.543; + let List.531 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.531; + +procedure List.70 (#Attr.2, #Attr.3): + let List.548 : List Str = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.548; procedure List.71 (#Attr.2, #Attr.3): - let List.524 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.524; + let List.529 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.529; procedure List.71 (#Attr.2, #Attr.3): - let List.541 : List Str = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.541; + let List.546 : List Str = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.546; procedure List.72 (#Attr.2, #Attr.3, #Attr.4): - let List.627 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; - ret List.627; + let List.632 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; + ret List.632; procedure List.8 (#Attr.2, #Attr.3): - let List.592 : List Str = lowlevel ListConcat #Attr.2 #Attr.3; - ret List.592; + let List.597 : List Str = lowlevel ListConcat #Attr.2 #Attr.3; + ret List.597; procedure List.8 (#Attr.2, #Attr.3): - let List.600 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; - ret List.600; + let List.605 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; + ret List.605; procedure List.80 (#Derived_gen.14, #Derived_gen.15, #Derived_gen.16, #Derived_gen.17, #Derived_gen.18): - joinpoint List.647 List.439 List.440 List.441 List.442 List.443: - let List.649 : Int1 = CallByName Num.22 List.442 List.443; - if List.649 then - let List.658 : U8 = CallByName List.66 List.439 List.442; - let List.650 : [C {U64, Int1}, C {U64, Int1}] = CallByName TotallyNotJson.189 List.440 List.658; - let List.655 : U8 = 1i64; - let List.656 : U8 = GetTagId List.650; - let List.657 : Int1 = lowlevel Eq List.655 List.656; - if List.657 then - let List.444 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.650; - let List.653 : U64 = 1i64; - let List.652 : U64 = CallByName Num.19 List.442 List.653; - jump List.647 List.439 List.444 List.441 List.652 List.443; + joinpoint List.652 List.442 List.443 List.444 List.445 List.446: + let List.654 : Int1 = CallByName Num.22 List.445 List.446; + if List.654 then + let List.662 : U8 = CallByName List.66 List.442 List.445; + let List.655 : [C {U64, Int1}, C {U64, Int1}] = CallByName TotallyNotJson.189 List.443 List.662; + let List.659 : U8 = 1i64; + let List.660 : U8 = GetTagId List.655; + let List.661 : Int1 = lowlevel Eq List.659 List.660; + if List.661 then + let List.447 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.655; + let List.657 : U64 = CallByName List.96 List.445; + jump List.652 List.442 List.447 List.444 List.657 List.446; else - dec List.439; - let List.445 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.650; - let List.654 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) List.445; - ret List.654; + dec List.442; + let List.448 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.655; + let List.658 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) List.448; + ret List.658; else - dec List.439; - let List.648 : [C {U64, Int1}, C {U64, Int1}] = TagId(1) List.440; - ret List.648; + dec List.442; + let List.653 : [C {U64, Int1}, C {U64, Int1}] = TagId(1) List.443; + ret List.653; in - jump List.647 #Derived_gen.14 #Derived_gen.15 #Derived_gen.16 #Derived_gen.17 #Derived_gen.18; + jump List.652 #Derived_gen.14 #Derived_gen.15 #Derived_gen.16 #Derived_gen.17 #Derived_gen.18; -procedure List.80 (#Derived_gen.22, #Derived_gen.23, #Derived_gen.24, #Derived_gen.25, #Derived_gen.26): - joinpoint List.576 List.439 List.440 List.441 List.442 List.443: - let List.578 : Int1 = CallByName Num.22 List.442 List.443; - if List.578 then - let List.585 : U8 = CallByName List.66 List.439 List.442; - let List.579 : List U8 = CallByName List.145 List.440 List.585 List.441; - let List.582 : U64 = 1i64; - let List.581 : U64 = CallByName Num.19 List.442 List.582; - jump List.576 List.439 List.579 List.441 List.581 List.443; +procedure List.80 (#Derived_gen.29, #Derived_gen.30, #Derived_gen.31, #Derived_gen.32, #Derived_gen.33): + joinpoint List.582 List.442 List.443 List.444 List.445 List.446: + let List.584 : Int1 = CallByName Num.22 List.445 List.446; + if List.584 then + let List.590 : U8 = CallByName List.66 List.442 List.445; + let List.585 : List U8 = CallByName List.147 List.443 List.590 List.444; + let List.587 : U64 = CallByName List.96 List.445; + jump List.582 List.442 List.585 List.444 List.587 List.446; else - dec List.439; - ret List.440; + dec List.442; + ret List.443; in - jump List.576 #Derived_gen.22 #Derived_gen.23 #Derived_gen.24 #Derived_gen.25 #Derived_gen.26; + jump List.582 #Derived_gen.29 #Derived_gen.30 #Derived_gen.31 #Derived_gen.32 #Derived_gen.33; procedure List.80 (#Derived_gen.35, #Derived_gen.36, #Derived_gen.37, #Derived_gen.38, #Derived_gen.39): - joinpoint List.556 List.439 List.440 List.441 List.442 List.443: - let List.558 : Int1 = CallByName Num.22 List.442 List.443; - if List.558 then - let List.565 : {Str, Str} = CallByName List.66 List.439 List.442; - inc List.565; - let List.559 : {List U8, U64} = CallByName List.145 List.440 List.565 List.441; - let List.562 : U64 = 1i64; - let List.561 : U64 = CallByName Num.19 List.442 List.562; - jump List.556 List.439 List.559 List.441 List.561 List.443; + joinpoint List.561 List.442 List.443 List.444 List.445 List.446: + let List.563 : Int1 = CallByName Num.22 List.445 List.446; + if List.563 then + let List.571 : {Str, Str} = CallByName List.66 List.442 List.445; + inc List.571; + let List.564 : {List U8, U64} = CallByName List.147 List.443 List.571 List.444; + let List.566 : U64 = CallByName List.96 List.445; + jump List.561 List.442 List.564 List.444 List.566 List.446; else - dec List.439; - ret List.440; + dec List.442; + ret List.443; in - jump List.556 #Derived_gen.35 #Derived_gen.36 #Derived_gen.37 #Derived_gen.38 #Derived_gen.39; + jump List.561 #Derived_gen.35 #Derived_gen.36 #Derived_gen.37 #Derived_gen.38 #Derived_gen.39; -procedure List.93 (List.436, List.437, List.438): - let List.554 : U64 = 0i64; - let List.555 : U64 = CallByName List.6 List.436; - let List.553 : {List U8, U64} = CallByName List.80 List.436 List.437 List.438 List.554 List.555; - ret List.553; +procedure List.93 (List.439, List.440, List.441): + let List.559 : U64 = 0i64; + let List.560 : U64 = CallByName List.6 List.439; + let List.558 : {List U8, U64} = CallByName List.80 List.439 List.440 List.441 List.559 List.560; + ret List.558; -procedure List.93 (List.436, List.437, List.438): - let List.574 : U64 = 0i64; - let List.575 : U64 = CallByName List.6 List.436; - let List.573 : List U8 = CallByName List.80 List.436 List.437 List.438 List.574 List.575; - ret List.573; +procedure List.93 (List.439, List.440, List.441): + let List.580 : U64 = 0i64; + let List.581 : U64 = CallByName List.6 List.439; + let List.579 : List U8 = CallByName List.80 List.439 List.440 List.441 List.580 List.581; + ret List.579; -procedure List.93 (List.436, List.437, List.438): - let List.645 : U64 = 0i64; - let List.646 : U64 = CallByName List.6 List.436; - let List.644 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.80 List.436 List.437 List.438 List.645 List.646; - ret List.644; +procedure List.93 (List.439, List.440, List.441): + let List.650 : U64 = 0i64; + let List.651 : U64 = CallByName List.6 List.439; + let List.649 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.80 List.439 List.440 List.441 List.650 List.651; + ret List.649; + +procedure List.96 (List.463): + let List.568 : U64 = 1i64; + let List.567 : U64 = CallByName Num.51 List.463 List.568; + ret List.567; procedure Num.127 (#Attr.2): let Num.297 : U8 = lowlevel NumIntCast #Attr.2; ret Num.297; procedure Num.19 (#Attr.2, #Attr.3): - let Num.306 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.306; + let Num.301 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.301; procedure Num.20 (#Attr.2, #Attr.3): - let Num.310 : U64 = lowlevel NumSub #Attr.2 #Attr.3; - ret Num.310; + let Num.298 : U64 = lowlevel NumSub #Attr.2 #Attr.3; + ret Num.298; procedure Num.21 (#Attr.2, #Attr.3): let Num.303 : U64 = lowlevel NumMul #Attr.2 #Attr.3; ret Num.303; procedure Num.22 (#Attr.2, #Attr.3): - let Num.309 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; - ret Num.309; + let Num.307 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + ret Num.307; procedure Num.24 (#Attr.2, #Attr.3): - let Num.311 : Int1 = lowlevel NumGt #Attr.2 #Attr.3; - ret Num.311; + let Num.309 : Int1 = lowlevel NumGt #Attr.2 #Attr.3; + ret Num.309; + +procedure Num.51 (#Attr.2, #Attr.3): + let Num.304 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; + ret Num.304; + +procedure Num.75 (#Attr.2, #Attr.3): + let Num.308 : U64 = lowlevel NumSubWrap #Attr.2 #Attr.3; + ret Num.308; procedure Num.94 (#Attr.2, #Attr.3): let Num.302 : U64 = lowlevel NumDivCeilUnchecked #Attr.2 #Attr.3; ret Num.302; procedure Str.12 (#Attr.2): - let Str.300 : List U8 = lowlevel StrToUtf8 #Attr.2; - ret Str.300; + let Str.302 : List U8 = lowlevel StrToUtf8 #Attr.2; + ret Str.302; procedure Str.4 (#Attr.2, #Attr.3): - let Str.303 : Str = lowlevel StrJoinWith #Attr.2 #Attr.3; - ret Str.303; + let Str.305 : Str = lowlevel StrJoinWith #Attr.2 #Attr.3; + ret Str.305; procedure Str.48 (#Attr.2, #Attr.3, #Attr.4): - let Str.298 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8Range #Attr.2 #Attr.3 #Attr.4; - ret Str.298; + let Str.300 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8Range #Attr.2 #Attr.3 #Attr.4; + ret Str.300; procedure Str.55 (#Attr.2): - let Str.306 : List Str = lowlevel StrGraphemes #Attr.2; - ret Str.306; + let Str.308 : List Str = lowlevel StrGraphemes #Attr.2; + ret Str.308; -procedure Str.9 (Str.79): - let Str.296 : U64 = 0i64; - let Str.297 : U64 = CallByName List.6 Str.79; - let Str.80 : {U64, Str, Int1, U8} = CallByName Str.48 Str.79 Str.296 Str.297; - let Str.293 : Int1 = StructAtIndex 2 Str.80; - if Str.293 then - let Str.295 : Str = StructAtIndex 1 Str.80; - let Str.294 : [C {U64, U8}, C Str] = TagId(1) Str.295; - ret Str.294; +procedure Str.9 (Str.80): + let Str.298 : U64 = 0i64; + let Str.299 : U64 = CallByName List.6 Str.80; + let Str.81 : {U64, Str, Int1, U8} = CallByName Str.48 Str.80 Str.298 Str.299; + let Str.295 : Int1 = StructAtIndex 2 Str.81; + if Str.295 then + let Str.297 : Str = StructAtIndex 1 Str.81; + let Str.296 : [C {U64, U8}, C Str] = TagId(1) Str.297; + ret Str.296; else - let Str.291 : U8 = StructAtIndex 3 Str.80; - let Str.292 : U64 = StructAtIndex 0 Str.80; - let #Derived_gen.40 : Str = StructAtIndex 1 Str.80; + let Str.293 : U8 = StructAtIndex 3 Str.81; + let Str.294 : U64 = StructAtIndex 0 Str.81; + let #Derived_gen.40 : Str = StructAtIndex 1 Str.81; dec #Derived_gen.40; - let Str.290 : {U64, U8} = Struct {Str.292, Str.291}; - let Str.289 : [C {U64, U8}, C Str] = TagId(0) Str.290; - ret Str.289; + let Str.292 : {U64, U8} = Struct {Str.294, Str.293}; + let Str.291 : [C {U64, U8}, C Str] = TagId(0) Str.292; + ret Str.291; procedure TotallyNotJson.100 (TotallyNotJson.850): let TotallyNotJson.1479 : Str = "a"; @@ -1284,7 +1294,7 @@ procedure TotallyNotJson.95 (TotallyNotJson.829): dec TotallyNotJson.1489; ret TotallyNotJson.1488; -procedure TotallyNotJson.96 (#Derived_gen.30): +procedure TotallyNotJson.96 (#Derived_gen.25): joinpoint TotallyNotJson.1496 TotallyNotJson.1168: let TotallyNotJson.834 : List Str = StructAtIndex 0 TotallyNotJson.1168; let TotallyNotJson.833 : List Str = StructAtIndex 1 TotallyNotJson.1168; @@ -1320,7 +1330,7 @@ procedure TotallyNotJson.96 (#Derived_gen.30): let TotallyNotJson.1497 : {List Str, List Str} = Struct {TotallyNotJson.834, TotallyNotJson.833}; ret TotallyNotJson.1497; in - jump TotallyNotJson.1496 #Derived_gen.30; + jump TotallyNotJson.1496 #Derived_gen.25; procedure TotallyNotJson.97 (TotallyNotJson.837): let TotallyNotJson.838 : List Str = CallByName Str.55 TotallyNotJson.837; diff --git a/crates/compiler/test_mono/generated/encode_derived_string.txt b/crates/compiler/test_mono/generated/encode_derived_string.txt index 3d42e396c8..90db775eb5 100644 --- a/crates/compiler/test_mono/generated/encode_derived_string.txt +++ b/crates/compiler/test_mono/generated/encode_derived_string.txt @@ -15,181 +15,188 @@ procedure Encode.26 (Encode.105, Encode.106): let Encode.108 : List U8 = CallByName Encode.24 Encode.109 Encode.110 Encode.106; ret Encode.108; -procedure List.145 (List.146, List.147, List.144): - let List.552 : List U8 = CallByName TotallyNotJson.215 List.146 List.147; - ret List.552; - -procedure List.18 (List.142, List.143, List.144): - let List.534 : List U8 = CallByName List.93 List.142 List.143 List.144; - ret List.534; - -procedure List.26 (List.159, List.160, List.161): - let List.569 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.93 List.159 List.160 List.161; - let List.572 : U8 = 1i64; - let List.573 : U8 = GetTagId List.569; - let List.574 : Int1 = lowlevel Eq List.572 List.573; - if List.574 then - let List.162 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.569; - ret List.162; - else - let List.163 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.569; - ret List.163; - -procedure List.49 (List.376, List.377): - let List.561 : U64 = StructAtIndex 0 List.377; - let List.562 : U64 = 0i64; - let List.559 : Int1 = CallByName Bool.11 List.561 List.562; - if List.559 then - dec List.376; - let List.560 : List U8 = Array []; - ret List.560; - else - let List.556 : U64 = StructAtIndex 1 List.377; - let List.557 : U64 = StructAtIndex 0 List.377; - let List.555 : List U8 = CallByName List.72 List.376 List.556 List.557; - ret List.555; - -procedure List.52 (List.391, List.392): - let List.393 : U64 = CallByName List.6 List.391; - joinpoint List.567 List.394: - let List.565 : U64 = 0i64; - let List.564 : {U64, U64} = Struct {List.394, List.565}; - inc List.391; - let List.395 : List U8 = CallByName List.49 List.391 List.564; - let List.563 : U64 = CallByName Num.20 List.393 List.394; - let List.554 : {U64, U64} = Struct {List.563, List.394}; - let List.396 : List U8 = CallByName List.49 List.391 List.554; - let List.553 : {List U8, List U8} = Struct {List.395, List.396}; - ret List.553; - in - let List.568 : Int1 = CallByName Num.24 List.393 List.392; - if List.568 then - jump List.567 List.392; - else - jump List.567 List.393; - -procedure List.6 (#Attr.2): - let List.533 : U64 = lowlevel ListLen #Attr.2; - ret List.533; - -procedure List.66 (#Attr.2, #Attr.3): - let List.550 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.550; - -procedure List.68 (#Attr.2): - let List.531 : List U8 = lowlevel ListWithCapacity #Attr.2; - ret List.531; - -procedure List.72 (#Attr.2, #Attr.3, #Attr.4): - let List.558 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; +procedure List.147 (List.148, List.149, List.146): + let List.558 : List U8 = CallByName TotallyNotJson.215 List.148 List.149; ret List.558; +procedure List.18 (List.144, List.145, List.146): + let List.539 : List U8 = CallByName List.93 List.144 List.145 List.146; + ret List.539; + +procedure List.26 (List.161, List.162, List.163): + let List.575 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.93 List.161 List.162 List.163; + let List.578 : U8 = 1i64; + let List.579 : U8 = GetTagId List.575; + let List.580 : Int1 = lowlevel Eq List.578 List.579; + if List.580 then + let List.164 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.575; + ret List.164; + else + let List.165 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.575; + ret List.165; + +procedure List.49 (List.379, List.380): + let List.567 : U64 = StructAtIndex 0 List.380; + let List.568 : U64 = 0i64; + let List.565 : Int1 = CallByName Bool.11 List.567 List.568; + if List.565 then + dec List.379; + let List.566 : List U8 = Array []; + ret List.566; + else + let List.562 : U64 = StructAtIndex 1 List.380; + let List.563 : U64 = StructAtIndex 0 List.380; + let List.561 : List U8 = CallByName List.72 List.379 List.562 List.563; + ret List.561; + +procedure List.52 (List.394, List.395): + let List.396 : U64 = CallByName List.6 List.394; + joinpoint List.573 List.397: + let List.571 : U64 = 0i64; + let List.570 : {U64, U64} = Struct {List.397, List.571}; + inc List.394; + let List.398 : List U8 = CallByName List.49 List.394 List.570; + let List.569 : U64 = CallByName Num.75 List.396 List.397; + let List.560 : {U64, U64} = Struct {List.569, List.397}; + let List.399 : List U8 = CallByName List.49 List.394 List.560; + let List.559 : {List U8, List U8} = Struct {List.398, List.399}; + ret List.559; + in + let List.574 : Int1 = CallByName Num.24 List.396 List.395; + if List.574 then + jump List.573 List.395; + else + jump List.573 List.396; + +procedure List.6 (#Attr.2): + let List.538 : U64 = lowlevel ListLen #Attr.2; + ret List.538; + +procedure List.66 (#Attr.2, #Attr.3): + let List.556 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.556; + +procedure List.68 (#Attr.2): + let List.536 : List U8 = lowlevel ListWithCapacity #Attr.2; + ret List.536; + +procedure List.72 (#Attr.2, #Attr.3, #Attr.4): + let List.564 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; + ret List.564; + procedure List.8 (#Attr.2, #Attr.3): - let List.529 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; - ret List.529; + let List.534 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; + ret List.534; procedure List.80 (#Derived_gen.0, #Derived_gen.1, #Derived_gen.2, #Derived_gen.3, #Derived_gen.4): - joinpoint List.540 List.439 List.440 List.441 List.442 List.443: - let List.542 : Int1 = CallByName Num.22 List.442 List.443; - if List.542 then - let List.549 : U8 = CallByName List.66 List.439 List.442; - let List.543 : List U8 = CallByName List.145 List.440 List.549 List.441; - let List.546 : U64 = 1i64; - let List.545 : U64 = CallByName Num.19 List.442 List.546; - jump List.540 List.439 List.543 List.441 List.545 List.443; + joinpoint List.545 List.442 List.443 List.444 List.445 List.446: + let List.547 : Int1 = CallByName Num.22 List.445 List.446; + if List.547 then + let List.555 : U8 = CallByName List.66 List.442 List.445; + let List.548 : List U8 = CallByName List.147 List.443 List.555 List.444; + let List.550 : U64 = CallByName List.96 List.445; + jump List.545 List.442 List.548 List.444 List.550 List.446; else - dec List.439; - ret List.440; + dec List.442; + ret List.443; in - jump List.540 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4; + jump List.545 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4; procedure List.80 (#Derived_gen.8, #Derived_gen.9, #Derived_gen.10, #Derived_gen.11, #Derived_gen.12): - joinpoint List.578 List.439 List.440 List.441 List.442 List.443: - let List.580 : Int1 = CallByName Num.22 List.442 List.443; - if List.580 then - let List.589 : U8 = CallByName List.66 List.439 List.442; - let List.581 : [C {U64, Int1}, C {U64, Int1}] = CallByName TotallyNotJson.189 List.440 List.589; - let List.586 : U8 = 1i64; - let List.587 : U8 = GetTagId List.581; - let List.588 : Int1 = lowlevel Eq List.586 List.587; - if List.588 then - let List.444 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.581; - let List.584 : U64 = 1i64; - let List.583 : U64 = CallByName Num.19 List.442 List.584; - jump List.578 List.439 List.444 List.441 List.583 List.443; + joinpoint List.584 List.442 List.443 List.444 List.445 List.446: + let List.586 : Int1 = CallByName Num.22 List.445 List.446; + if List.586 then + let List.594 : U8 = CallByName List.66 List.442 List.445; + let List.587 : [C {U64, Int1}, C {U64, Int1}] = CallByName TotallyNotJson.189 List.443 List.594; + let List.591 : U8 = 1i64; + let List.592 : U8 = GetTagId List.587; + let List.593 : Int1 = lowlevel Eq List.591 List.592; + if List.593 then + let List.447 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.587; + let List.589 : U64 = CallByName List.96 List.445; + jump List.584 List.442 List.447 List.444 List.589 List.446; else - dec List.439; - let List.445 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.581; - let List.585 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) List.445; - ret List.585; + dec List.442; + let List.448 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.587; + let List.590 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) List.448; + ret List.590; else - dec List.439; - let List.579 : [C {U64, Int1}, C {U64, Int1}] = TagId(1) List.440; - ret List.579; + dec List.442; + let List.585 : [C {U64, Int1}, C {U64, Int1}] = TagId(1) List.443; + ret List.585; in - jump List.578 #Derived_gen.8 #Derived_gen.9 #Derived_gen.10 #Derived_gen.11 #Derived_gen.12; + jump List.584 #Derived_gen.8 #Derived_gen.9 #Derived_gen.10 #Derived_gen.11 #Derived_gen.12; -procedure List.93 (List.436, List.437, List.438): - let List.538 : U64 = 0i64; - let List.539 : U64 = CallByName List.6 List.436; - let List.537 : List U8 = CallByName List.80 List.436 List.437 List.438 List.538 List.539; - ret List.537; +procedure List.93 (List.439, List.440, List.441): + let List.543 : U64 = 0i64; + let List.544 : U64 = CallByName List.6 List.439; + let List.542 : List U8 = CallByName List.80 List.439 List.440 List.441 List.543 List.544; + ret List.542; -procedure List.93 (List.436, List.437, List.438): - let List.576 : U64 = 0i64; - let List.577 : U64 = CallByName List.6 List.436; - let List.575 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.80 List.436 List.437 List.438 List.576 List.577; - ret List.575; +procedure List.93 (List.439, List.440, List.441): + let List.582 : U64 = 0i64; + let List.583 : U64 = CallByName List.6 List.439; + let List.581 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.80 List.439 List.440 List.441 List.582 List.583; + ret List.581; + +procedure List.96 (List.463): + let List.552 : U64 = 1i64; + let List.551 : U64 = CallByName Num.51 List.463 List.552; + ret List.551; procedure Num.19 (#Attr.2, #Attr.3): - let Num.297 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.297; - -procedure Num.20 (#Attr.2, #Attr.3): - let Num.300 : U64 = lowlevel NumSub #Attr.2 #Attr.3; - ret Num.300; + let Num.293 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.293; procedure Num.21 (#Attr.2, #Attr.3): let Num.295 : U64 = lowlevel NumMul #Attr.2 #Attr.3; ret Num.295; procedure Num.22 (#Attr.2, #Attr.3): - let Num.299 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; - ret Num.299; + let Num.298 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + ret Num.298; procedure Num.24 (#Attr.2, #Attr.3): - let Num.301 : Int1 = lowlevel NumGt #Attr.2 #Attr.3; - ret Num.301; + let Num.300 : Int1 = lowlevel NumGt #Attr.2 #Attr.3; + ret Num.300; + +procedure Num.51 (#Attr.2, #Attr.3): + let Num.296 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; + ret Num.296; + +procedure Num.75 (#Attr.2, #Attr.3): + let Num.299 : U64 = lowlevel NumSubWrap #Attr.2 #Attr.3; + ret Num.299; procedure Num.94 (#Attr.2, #Attr.3): let Num.294 : U64 = lowlevel NumDivCeilUnchecked #Attr.2 #Attr.3; ret Num.294; procedure Str.12 (#Attr.2): - let Str.299 : List U8 = lowlevel StrToUtf8 #Attr.2; - ret Str.299; + let Str.301 : List U8 = lowlevel StrToUtf8 #Attr.2; + ret Str.301; procedure Str.48 (#Attr.2, #Attr.3, #Attr.4): - let Str.298 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8Range #Attr.2 #Attr.3 #Attr.4; - ret Str.298; + let Str.300 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8Range #Attr.2 #Attr.3 #Attr.4; + ret Str.300; -procedure Str.9 (Str.79): - let Str.296 : U64 = 0i64; - let Str.297 : U64 = CallByName List.6 Str.79; - let Str.80 : {U64, Str, Int1, U8} = CallByName Str.48 Str.79 Str.296 Str.297; - let Str.293 : Int1 = StructAtIndex 2 Str.80; - if Str.293 then - let Str.295 : Str = StructAtIndex 1 Str.80; - let Str.294 : [C {U64, U8}, C Str] = TagId(1) Str.295; - ret Str.294; +procedure Str.9 (Str.80): + let Str.298 : U64 = 0i64; + let Str.299 : U64 = CallByName List.6 Str.80; + let Str.81 : {U64, Str, Int1, U8} = CallByName Str.48 Str.80 Str.298 Str.299; + let Str.295 : Int1 = StructAtIndex 2 Str.81; + if Str.295 then + let Str.297 : Str = StructAtIndex 1 Str.81; + let Str.296 : [C {U64, U8}, C Str] = TagId(1) Str.297; + ret Str.296; else - let Str.291 : U8 = StructAtIndex 3 Str.80; - let Str.292 : U64 = StructAtIndex 0 Str.80; - let #Derived_gen.13 : Str = StructAtIndex 1 Str.80; + let Str.293 : U8 = StructAtIndex 3 Str.81; + let Str.294 : U64 = StructAtIndex 0 Str.81; + let #Derived_gen.13 : Str = StructAtIndex 1 Str.81; dec #Derived_gen.13; - let Str.290 : {U64, U8} = Struct {Str.292, Str.291}; - let Str.289 : [C {U64, U8}, C Str] = TagId(0) Str.290; - ret Str.289; + let Str.292 : {U64, U8} = Struct {Str.294, Str.293}; + let Str.291 : [C {U64, U8}, C Str] = TagId(0) Str.292; + ret Str.291; procedure TotallyNotJson.182 (TotallyNotJson.183, TotallyNotJson.1175, TotallyNotJson.181): let TotallyNotJson.1178 : List U8 = CallByName TotallyNotJson.26 TotallyNotJson.181; diff --git a/crates/compiler/test_mono/generated/encode_derived_tag_one_field_string.txt b/crates/compiler/test_mono/generated/encode_derived_tag_one_field_string.txt index d89fbb2e38..947daf976f 100644 --- a/crates/compiler/test_mono/generated/encode_derived_tag_one_field_string.txt +++ b/crates/compiler/test_mono/generated/encode_derived_tag_one_field_string.txt @@ -44,237 +44,247 @@ procedure Encode.26 (Encode.105, Encode.106): let Encode.108 : List U8 = CallByName Encode.24 Encode.109 Encode.110 Encode.106; ret Encode.108; -procedure List.145 (List.146, List.147, List.144): - let List.567 : {List U8, U64} = CallByName TotallyNotJson.267 List.146 List.147 List.144; - ret List.567; +procedure List.147 (List.148, List.149, List.146): + let List.573 : {List U8, U64} = CallByName TotallyNotJson.267 List.148 List.149 List.146; + ret List.573; -procedure List.145 (List.146, List.147, List.144): - let List.587 : List U8 = CallByName TotallyNotJson.215 List.146 List.147; - ret List.587; +procedure List.147 (List.148, List.149, List.146): + let List.592 : List U8 = CallByName TotallyNotJson.215 List.148 List.149; + ret List.592; -procedure List.18 (List.142, List.143, List.144): - let List.548 : {List U8, U64} = CallByName List.93 List.142 List.143 List.144; - ret List.548; +procedure List.18 (List.144, List.145, List.146): + let List.553 : {List U8, U64} = CallByName List.93 List.144 List.145 List.146; + ret List.553; -procedure List.18 (List.142, List.143, List.144): - let List.568 : List U8 = CallByName List.93 List.142 List.143 List.144; - ret List.568; +procedure List.18 (List.144, List.145, List.146): + let List.574 : List U8 = CallByName List.93 List.144 List.145 List.146; + ret List.574; -procedure List.26 (List.159, List.160, List.161): - let List.618 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.93 List.159 List.160 List.161; - let List.621 : U8 = 1i64; - let List.622 : U8 = GetTagId List.618; - let List.623 : Int1 = lowlevel Eq List.621 List.622; - if List.623 then - let List.162 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.618; - ret List.162; +procedure List.26 (List.161, List.162, List.163): + let List.623 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.93 List.161 List.162 List.163; + let List.626 : U8 = 1i64; + let List.627 : U8 = GetTagId List.623; + let List.628 : Int1 = lowlevel Eq List.626 List.627; + if List.628 then + let List.164 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.623; + ret List.164; else - let List.163 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.618; - ret List.163; + let List.165 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.623; + ret List.165; -procedure List.4 (List.113, List.114): - let List.547 : U64 = 1i64; - let List.546 : List U8 = CallByName List.70 List.113 List.547; - let List.545 : List U8 = CallByName List.71 List.546 List.114; - ret List.545; +procedure List.4 (List.115, List.116): + let List.552 : U64 = 1i64; + let List.551 : List U8 = CallByName List.70 List.115 List.552; + let List.550 : List U8 = CallByName List.71 List.551 List.116; + ret List.550; -procedure List.49 (List.376, List.377): - let List.610 : U64 = StructAtIndex 0 List.377; - let List.611 : U64 = 0i64; - let List.608 : Int1 = CallByName Bool.11 List.610 List.611; - if List.608 then - dec List.376; - let List.609 : List U8 = Array []; +procedure List.49 (List.379, List.380): + let List.615 : U64 = StructAtIndex 0 List.380; + let List.616 : U64 = 0i64; + let List.613 : Int1 = CallByName Bool.11 List.615 List.616; + if List.613 then + dec List.379; + let List.614 : List U8 = Array []; + ret List.614; + else + let List.610 : U64 = StructAtIndex 1 List.380; + let List.611 : U64 = StructAtIndex 0 List.380; + let List.609 : List U8 = CallByName List.72 List.379 List.610 List.611; ret List.609; - else - let List.605 : U64 = StructAtIndex 1 List.377; - let List.606 : U64 = StructAtIndex 0 List.377; - let List.604 : List U8 = CallByName List.72 List.376 List.605 List.606; - ret List.604; -procedure List.52 (List.391, List.392): - let List.393 : U64 = CallByName List.6 List.391; - joinpoint List.616 List.394: - let List.614 : U64 = 0i64; - let List.613 : {U64, U64} = Struct {List.394, List.614}; - inc List.391; - let List.395 : List U8 = CallByName List.49 List.391 List.613; - let List.612 : U64 = CallByName Num.20 List.393 List.394; - let List.603 : {U64, U64} = Struct {List.612, List.394}; - let List.396 : List U8 = CallByName List.49 List.391 List.603; - let List.602 : {List U8, List U8} = Struct {List.395, List.396}; - ret List.602; +procedure List.52 (List.394, List.395): + let List.396 : U64 = CallByName List.6 List.394; + joinpoint List.621 List.397: + let List.619 : U64 = 0i64; + let List.618 : {U64, U64} = Struct {List.397, List.619}; + inc List.394; + let List.398 : List U8 = CallByName List.49 List.394 List.618; + let List.617 : U64 = CallByName Num.75 List.396 List.397; + let List.608 : {U64, U64} = Struct {List.617, List.397}; + let List.399 : List U8 = CallByName List.49 List.394 List.608; + let List.607 : {List U8, List U8} = Struct {List.398, List.399}; + ret List.607; in - let List.617 : Int1 = CallByName Num.24 List.393 List.392; - if List.617 then - jump List.616 List.392; + let List.622 : Int1 = CallByName Num.24 List.396 List.395; + if List.622 then + jump List.621 List.395; else - jump List.616 List.393; + jump List.621 List.396; procedure List.6 (#Attr.2): - let List.588 : U64 = lowlevel ListLen #Attr.2; - ret List.588; + let List.593 : U64 = lowlevel ListLen #Attr.2; + ret List.593; procedure List.6 (#Attr.2): - let List.590 : U64 = lowlevel ListLen #Attr.2; - ret List.590; + let List.595 : U64 = lowlevel ListLen #Attr.2; + ret List.595; procedure List.66 (#Attr.2, #Attr.3): - let List.564 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.564; + let List.570 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.570; procedure List.66 (#Attr.2, #Attr.3): - let List.584 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.584; + let List.589 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.589; procedure List.68 (#Attr.2): - let List.601 : List U8 = lowlevel ListWithCapacity #Attr.2; - ret List.601; + let List.606 : List U8 = lowlevel ListWithCapacity #Attr.2; + ret List.606; procedure List.70 (#Attr.2, #Attr.3): - let List.526 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.526; + let List.531 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.531; procedure List.71 (#Attr.2, #Attr.3): - let List.524 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.524; + let List.529 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.529; procedure List.72 (#Attr.2, #Attr.3, #Attr.4): - let List.607 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; - ret List.607; + let List.612 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; + ret List.612; procedure List.8 (#Attr.2, #Attr.3): - let List.599 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; - ret List.599; + let List.604 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; + ret List.604; -procedure List.80 (#Derived_gen.16, #Derived_gen.17, #Derived_gen.18, #Derived_gen.19, #Derived_gen.20): - joinpoint List.627 List.439 List.440 List.441 List.442 List.443: - let List.629 : Int1 = CallByName Num.22 List.442 List.443; - if List.629 then - let List.638 : U8 = CallByName List.66 List.439 List.442; - let List.630 : [C {U64, Int1}, C {U64, Int1}] = CallByName TotallyNotJson.189 List.440 List.638; - let List.635 : U8 = 1i64; - let List.636 : U8 = GetTagId List.630; - let List.637 : Int1 = lowlevel Eq List.635 List.636; - if List.637 then - let List.444 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.630; - let List.633 : U64 = 1i64; - let List.632 : U64 = CallByName Num.19 List.442 List.633; - jump List.627 List.439 List.444 List.441 List.632 List.443; - else - dec List.439; - let List.445 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.630; - let List.634 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) List.445; - ret List.634; +procedure List.80 (#Derived_gen.13, #Derived_gen.14, #Derived_gen.15, #Derived_gen.16, #Derived_gen.17): + joinpoint List.580 List.442 List.443 List.444 List.445 List.446: + let List.582 : Int1 = CallByName Num.22 List.445 List.446; + if List.582 then + let List.588 : U8 = CallByName List.66 List.442 List.445; + let List.583 : List U8 = CallByName List.147 List.443 List.588 List.444; + let List.585 : U64 = CallByName List.96 List.445; + jump List.580 List.442 List.583 List.444 List.585 List.446; else - dec List.439; - let List.628 : [C {U64, Int1}, C {U64, Int1}] = TagId(1) List.440; - ret List.628; + dec List.442; + ret List.443; in - jump List.627 #Derived_gen.16 #Derived_gen.17 #Derived_gen.18 #Derived_gen.19 #Derived_gen.20; + jump List.580 #Derived_gen.13 #Derived_gen.14 #Derived_gen.15 #Derived_gen.16 #Derived_gen.17; -procedure List.80 (#Derived_gen.24, #Derived_gen.25, #Derived_gen.26, #Derived_gen.27, #Derived_gen.28): - joinpoint List.574 List.439 List.440 List.441 List.442 List.443: - let List.576 : Int1 = CallByName Num.22 List.442 List.443; - if List.576 then - let List.583 : U8 = CallByName List.66 List.439 List.442; - let List.577 : List U8 = CallByName List.145 List.440 List.583 List.441; - let List.580 : U64 = 1i64; - let List.579 : U64 = CallByName Num.19 List.442 List.580; - jump List.574 List.439 List.577 List.441 List.579 List.443; +procedure List.80 (#Derived_gen.21, #Derived_gen.22, #Derived_gen.23, #Derived_gen.24, #Derived_gen.25): + joinpoint List.559 List.442 List.443 List.444 List.445 List.446: + let List.561 : Int1 = CallByName Num.22 List.445 List.446; + if List.561 then + let List.569 : Str = CallByName List.66 List.442 List.445; + inc List.569; + let List.562 : {List U8, U64} = CallByName List.147 List.443 List.569 List.444; + let List.564 : U64 = CallByName List.96 List.445; + jump List.559 List.442 List.562 List.444 List.564 List.446; else - dec List.439; - ret List.440; + dec List.442; + ret List.443; in - jump List.574 #Derived_gen.24 #Derived_gen.25 #Derived_gen.26 #Derived_gen.27 #Derived_gen.28; + jump List.559 #Derived_gen.21 #Derived_gen.22 #Derived_gen.23 #Derived_gen.24 #Derived_gen.25; procedure List.80 (#Derived_gen.29, #Derived_gen.30, #Derived_gen.31, #Derived_gen.32, #Derived_gen.33): - joinpoint List.554 List.439 List.440 List.441 List.442 List.443: - let List.556 : Int1 = CallByName Num.22 List.442 List.443; - if List.556 then - let List.563 : Str = CallByName List.66 List.439 List.442; - inc List.563; - let List.557 : {List U8, U64} = CallByName List.145 List.440 List.563 List.441; - let List.560 : U64 = 1i64; - let List.559 : U64 = CallByName Num.19 List.442 List.560; - jump List.554 List.439 List.557 List.441 List.559 List.443; + joinpoint List.632 List.442 List.443 List.444 List.445 List.446: + let List.634 : Int1 = CallByName Num.22 List.445 List.446; + if List.634 then + let List.642 : U8 = CallByName List.66 List.442 List.445; + let List.635 : [C {U64, Int1}, C {U64, Int1}] = CallByName TotallyNotJson.189 List.443 List.642; + let List.639 : U8 = 1i64; + let List.640 : U8 = GetTagId List.635; + let List.641 : Int1 = lowlevel Eq List.639 List.640; + if List.641 then + let List.447 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.635; + let List.637 : U64 = CallByName List.96 List.445; + jump List.632 List.442 List.447 List.444 List.637 List.446; + else + dec List.442; + let List.448 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.635; + let List.638 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) List.448; + ret List.638; else - dec List.439; - ret List.440; + dec List.442; + let List.633 : [C {U64, Int1}, C {U64, Int1}] = TagId(1) List.443; + ret List.633; in - jump List.554 #Derived_gen.29 #Derived_gen.30 #Derived_gen.31 #Derived_gen.32 #Derived_gen.33; + jump List.632 #Derived_gen.29 #Derived_gen.30 #Derived_gen.31 #Derived_gen.32 #Derived_gen.33; -procedure List.93 (List.436, List.437, List.438): - let List.552 : U64 = 0i64; - let List.553 : U64 = CallByName List.6 List.436; - let List.551 : {List U8, U64} = CallByName List.80 List.436 List.437 List.438 List.552 List.553; - ret List.551; +procedure List.93 (List.439, List.440, List.441): + let List.557 : U64 = 0i64; + let List.558 : U64 = CallByName List.6 List.439; + let List.556 : {List U8, U64} = CallByName List.80 List.439 List.440 List.441 List.557 List.558; + ret List.556; -procedure List.93 (List.436, List.437, List.438): - let List.572 : U64 = 0i64; - let List.573 : U64 = CallByName List.6 List.436; - let List.571 : List U8 = CallByName List.80 List.436 List.437 List.438 List.572 List.573; - ret List.571; +procedure List.93 (List.439, List.440, List.441): + let List.578 : U64 = 0i64; + let List.579 : U64 = CallByName List.6 List.439; + let List.577 : List U8 = CallByName List.80 List.439 List.440 List.441 List.578 List.579; + ret List.577; -procedure List.93 (List.436, List.437, List.438): - let List.625 : U64 = 0i64; - let List.626 : U64 = CallByName List.6 List.436; - let List.624 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.80 List.436 List.437 List.438 List.625 List.626; - ret List.624; +procedure List.93 (List.439, List.440, List.441): + let List.630 : U64 = 0i64; + let List.631 : U64 = CallByName List.6 List.439; + let List.629 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.80 List.439 List.440 List.441 List.630 List.631; + ret List.629; + +procedure List.96 (List.463): + let List.566 : U64 = 1i64; + let List.565 : U64 = CallByName Num.51 List.463 List.566; + ret List.565; procedure Num.127 (#Attr.2): let Num.299 : U8 = lowlevel NumIntCast #Attr.2; ret Num.299; procedure Num.19 (#Attr.2, #Attr.3): - let Num.308 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.308; + let Num.303 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.303; procedure Num.20 (#Attr.2, #Attr.3): - let Num.312 : U64 = lowlevel NumSub #Attr.2 #Attr.3; - ret Num.312; + let Num.300 : U64 = lowlevel NumSub #Attr.2 #Attr.3; + ret Num.300; procedure Num.21 (#Attr.2, #Attr.3): let Num.305 : U64 = lowlevel NumMul #Attr.2 #Attr.3; ret Num.305; procedure Num.22 (#Attr.2, #Attr.3): - let Num.311 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; - ret Num.311; + let Num.309 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + ret Num.309; procedure Num.24 (#Attr.2, #Attr.3): - let Num.313 : Int1 = lowlevel NumGt #Attr.2 #Attr.3; - ret Num.313; + let Num.311 : Int1 = lowlevel NumGt #Attr.2 #Attr.3; + ret Num.311; + +procedure Num.51 (#Attr.2, #Attr.3): + let Num.306 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; + ret Num.306; + +procedure Num.75 (#Attr.2, #Attr.3): + let Num.310 : U64 = lowlevel NumSubWrap #Attr.2 #Attr.3; + ret Num.310; procedure Num.94 (#Attr.2, #Attr.3): let Num.304 : U64 = lowlevel NumDivCeilUnchecked #Attr.2 #Attr.3; ret Num.304; procedure Str.12 (#Attr.2): - let Str.300 : List U8 = lowlevel StrToUtf8 #Attr.2; - ret Str.300; + let Str.302 : List U8 = lowlevel StrToUtf8 #Attr.2; + ret Str.302; procedure Str.48 (#Attr.2, #Attr.3, #Attr.4): - let Str.298 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8Range #Attr.2 #Attr.3 #Attr.4; - ret Str.298; + let Str.300 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8Range #Attr.2 #Attr.3 #Attr.4; + ret Str.300; -procedure Str.9 (Str.79): - let Str.296 : U64 = 0i64; - let Str.297 : U64 = CallByName List.6 Str.79; - let Str.80 : {U64, Str, Int1, U8} = CallByName Str.48 Str.79 Str.296 Str.297; - let Str.293 : Int1 = StructAtIndex 2 Str.80; - if Str.293 then - let Str.295 : Str = StructAtIndex 1 Str.80; - let Str.294 : [C {U64, U8}, C Str] = TagId(1) Str.295; - ret Str.294; +procedure Str.9 (Str.80): + let Str.298 : U64 = 0i64; + let Str.299 : U64 = CallByName List.6 Str.80; + let Str.81 : {U64, Str, Int1, U8} = CallByName Str.48 Str.80 Str.298 Str.299; + let Str.295 : Int1 = StructAtIndex 2 Str.81; + if Str.295 then + let Str.297 : Str = StructAtIndex 1 Str.81; + let Str.296 : [C {U64, U8}, C Str] = TagId(1) Str.297; + ret Str.296; else - let Str.291 : U8 = StructAtIndex 3 Str.80; - let Str.292 : U64 = StructAtIndex 0 Str.80; - let #Derived_gen.34 : Str = StructAtIndex 1 Str.80; + let Str.293 : U8 = StructAtIndex 3 Str.81; + let Str.294 : U64 = StructAtIndex 0 Str.81; + let #Derived_gen.34 : Str = StructAtIndex 1 Str.81; dec #Derived_gen.34; - let Str.290 : {U64, U8} = Struct {Str.292, Str.291}; - let Str.289 : [C {U64, U8}, C Str] = TagId(0) Str.290; - ret Str.289; + let Str.292 : {U64, U8} = Struct {Str.294, Str.293}; + let Str.291 : [C {U64, U8}, C Str] = TagId(0) Str.292; + ret Str.291; procedure TotallyNotJson.182 (TotallyNotJson.183, TotallyNotJson.1216, TotallyNotJson.181): let TotallyNotJson.1219 : List U8 = CallByName TotallyNotJson.26 TotallyNotJson.181; diff --git a/crates/compiler/test_mono/generated/encode_derived_tag_two_payloads_string.txt b/crates/compiler/test_mono/generated/encode_derived_tag_two_payloads_string.txt index 93524dfb6b..28405e9664 100644 --- a/crates/compiler/test_mono/generated/encode_derived_tag_two_payloads_string.txt +++ b/crates/compiler/test_mono/generated/encode_derived_tag_two_payloads_string.txt @@ -47,237 +47,247 @@ procedure Encode.26 (Encode.105, Encode.106): let Encode.108 : List U8 = CallByName Encode.24 Encode.109 Encode.110 Encode.106; ret Encode.108; -procedure List.145 (List.146, List.147, List.144): - let List.567 : {List U8, U64} = CallByName TotallyNotJson.267 List.146 List.147 List.144; - ret List.567; +procedure List.147 (List.148, List.149, List.146): + let List.573 : {List U8, U64} = CallByName TotallyNotJson.267 List.148 List.149 List.146; + ret List.573; -procedure List.145 (List.146, List.147, List.144): - let List.587 : List U8 = CallByName TotallyNotJson.215 List.146 List.147; - ret List.587; +procedure List.147 (List.148, List.149, List.146): + let List.592 : List U8 = CallByName TotallyNotJson.215 List.148 List.149; + ret List.592; -procedure List.18 (List.142, List.143, List.144): - let List.548 : {List U8, U64} = CallByName List.93 List.142 List.143 List.144; - ret List.548; +procedure List.18 (List.144, List.145, List.146): + let List.553 : {List U8, U64} = CallByName List.93 List.144 List.145 List.146; + ret List.553; -procedure List.18 (List.142, List.143, List.144): - let List.568 : List U8 = CallByName List.93 List.142 List.143 List.144; - ret List.568; +procedure List.18 (List.144, List.145, List.146): + let List.574 : List U8 = CallByName List.93 List.144 List.145 List.146; + ret List.574; -procedure List.26 (List.159, List.160, List.161): - let List.618 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.93 List.159 List.160 List.161; - let List.621 : U8 = 1i64; - let List.622 : U8 = GetTagId List.618; - let List.623 : Int1 = lowlevel Eq List.621 List.622; - if List.623 then - let List.162 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.618; - ret List.162; +procedure List.26 (List.161, List.162, List.163): + let List.623 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.93 List.161 List.162 List.163; + let List.626 : U8 = 1i64; + let List.627 : U8 = GetTagId List.623; + let List.628 : Int1 = lowlevel Eq List.626 List.627; + if List.628 then + let List.164 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.623; + ret List.164; else - let List.163 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.618; - ret List.163; + let List.165 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.623; + ret List.165; -procedure List.4 (List.113, List.114): - let List.547 : U64 = 1i64; - let List.546 : List U8 = CallByName List.70 List.113 List.547; - let List.545 : List U8 = CallByName List.71 List.546 List.114; - ret List.545; +procedure List.4 (List.115, List.116): + let List.552 : U64 = 1i64; + let List.551 : List U8 = CallByName List.70 List.115 List.552; + let List.550 : List U8 = CallByName List.71 List.551 List.116; + ret List.550; -procedure List.49 (List.376, List.377): - let List.610 : U64 = StructAtIndex 0 List.377; - let List.611 : U64 = 0i64; - let List.608 : Int1 = CallByName Bool.11 List.610 List.611; - if List.608 then - dec List.376; - let List.609 : List U8 = Array []; +procedure List.49 (List.379, List.380): + let List.615 : U64 = StructAtIndex 0 List.380; + let List.616 : U64 = 0i64; + let List.613 : Int1 = CallByName Bool.11 List.615 List.616; + if List.613 then + dec List.379; + let List.614 : List U8 = Array []; + ret List.614; + else + let List.610 : U64 = StructAtIndex 1 List.380; + let List.611 : U64 = StructAtIndex 0 List.380; + let List.609 : List U8 = CallByName List.72 List.379 List.610 List.611; ret List.609; - else - let List.605 : U64 = StructAtIndex 1 List.377; - let List.606 : U64 = StructAtIndex 0 List.377; - let List.604 : List U8 = CallByName List.72 List.376 List.605 List.606; - ret List.604; -procedure List.52 (List.391, List.392): - let List.393 : U64 = CallByName List.6 List.391; - joinpoint List.616 List.394: - let List.614 : U64 = 0i64; - let List.613 : {U64, U64} = Struct {List.394, List.614}; - inc List.391; - let List.395 : List U8 = CallByName List.49 List.391 List.613; - let List.612 : U64 = CallByName Num.20 List.393 List.394; - let List.603 : {U64, U64} = Struct {List.612, List.394}; - let List.396 : List U8 = CallByName List.49 List.391 List.603; - let List.602 : {List U8, List U8} = Struct {List.395, List.396}; - ret List.602; +procedure List.52 (List.394, List.395): + let List.396 : U64 = CallByName List.6 List.394; + joinpoint List.621 List.397: + let List.619 : U64 = 0i64; + let List.618 : {U64, U64} = Struct {List.397, List.619}; + inc List.394; + let List.398 : List U8 = CallByName List.49 List.394 List.618; + let List.617 : U64 = CallByName Num.75 List.396 List.397; + let List.608 : {U64, U64} = Struct {List.617, List.397}; + let List.399 : List U8 = CallByName List.49 List.394 List.608; + let List.607 : {List U8, List U8} = Struct {List.398, List.399}; + ret List.607; in - let List.617 : Int1 = CallByName Num.24 List.393 List.392; - if List.617 then - jump List.616 List.392; + let List.622 : Int1 = CallByName Num.24 List.396 List.395; + if List.622 then + jump List.621 List.395; else - jump List.616 List.393; + jump List.621 List.396; procedure List.6 (#Attr.2): - let List.588 : U64 = lowlevel ListLen #Attr.2; - ret List.588; + let List.593 : U64 = lowlevel ListLen #Attr.2; + ret List.593; procedure List.6 (#Attr.2): - let List.590 : U64 = lowlevel ListLen #Attr.2; - ret List.590; + let List.595 : U64 = lowlevel ListLen #Attr.2; + ret List.595; procedure List.66 (#Attr.2, #Attr.3): - let List.564 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.564; + let List.570 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.570; procedure List.66 (#Attr.2, #Attr.3): - let List.584 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.584; + let List.589 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.589; procedure List.68 (#Attr.2): - let List.601 : List U8 = lowlevel ListWithCapacity #Attr.2; - ret List.601; + let List.606 : List U8 = lowlevel ListWithCapacity #Attr.2; + ret List.606; procedure List.70 (#Attr.2, #Attr.3): - let List.526 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.526; + let List.531 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.531; procedure List.71 (#Attr.2, #Attr.3): - let List.524 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.524; + let List.529 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.529; procedure List.72 (#Attr.2, #Attr.3, #Attr.4): - let List.607 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; - ret List.607; + let List.612 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; + ret List.612; procedure List.8 (#Attr.2, #Attr.3): - let List.599 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; - ret List.599; + let List.604 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; + ret List.604; procedure List.80 (#Derived_gen.11, #Derived_gen.12, #Derived_gen.13, #Derived_gen.14, #Derived_gen.15): - joinpoint List.627 List.439 List.440 List.441 List.442 List.443: - let List.629 : Int1 = CallByName Num.22 List.442 List.443; - if List.629 then - let List.638 : U8 = CallByName List.66 List.439 List.442; - let List.630 : [C {U64, Int1}, C {U64, Int1}] = CallByName TotallyNotJson.189 List.440 List.638; - let List.635 : U8 = 1i64; - let List.636 : U8 = GetTagId List.630; - let List.637 : Int1 = lowlevel Eq List.635 List.636; - if List.637 then - let List.444 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.630; - let List.633 : U64 = 1i64; - let List.632 : U64 = CallByName Num.19 List.442 List.633; - jump List.627 List.439 List.444 List.441 List.632 List.443; + joinpoint List.632 List.442 List.443 List.444 List.445 List.446: + let List.634 : Int1 = CallByName Num.22 List.445 List.446; + if List.634 then + let List.642 : U8 = CallByName List.66 List.442 List.445; + let List.635 : [C {U64, Int1}, C {U64, Int1}] = CallByName TotallyNotJson.189 List.443 List.642; + let List.639 : U8 = 1i64; + let List.640 : U8 = GetTagId List.635; + let List.641 : Int1 = lowlevel Eq List.639 List.640; + if List.641 then + let List.447 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.635; + let List.637 : U64 = CallByName List.96 List.445; + jump List.632 List.442 List.447 List.444 List.637 List.446; else - dec List.439; - let List.445 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.630; - let List.634 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) List.445; - ret List.634; + dec List.442; + let List.448 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.635; + let List.638 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) List.448; + ret List.638; else - dec List.439; - let List.628 : [C {U64, Int1}, C {U64, Int1}] = TagId(1) List.440; - ret List.628; + dec List.442; + let List.633 : [C {U64, Int1}, C {U64, Int1}] = TagId(1) List.443; + ret List.633; in - jump List.627 #Derived_gen.11 #Derived_gen.12 #Derived_gen.13 #Derived_gen.14 #Derived_gen.15; + jump List.632 #Derived_gen.11 #Derived_gen.12 #Derived_gen.13 #Derived_gen.14 #Derived_gen.15; procedure List.80 (#Derived_gen.19, #Derived_gen.20, #Derived_gen.21, #Derived_gen.22, #Derived_gen.23): - joinpoint List.554 List.439 List.440 List.441 List.442 List.443: - let List.556 : Int1 = CallByName Num.22 List.442 List.443; - if List.556 then - let List.563 : Str = CallByName List.66 List.439 List.442; - inc List.563; - let List.557 : {List U8, U64} = CallByName List.145 List.440 List.563 List.441; - let List.560 : U64 = 1i64; - let List.559 : U64 = CallByName Num.19 List.442 List.560; - jump List.554 List.439 List.557 List.441 List.559 List.443; + joinpoint List.559 List.442 List.443 List.444 List.445 List.446: + let List.561 : Int1 = CallByName Num.22 List.445 List.446; + if List.561 then + let List.569 : Str = CallByName List.66 List.442 List.445; + inc List.569; + let List.562 : {List U8, U64} = CallByName List.147 List.443 List.569 List.444; + let List.564 : U64 = CallByName List.96 List.445; + jump List.559 List.442 List.562 List.444 List.564 List.446; else - dec List.439; - ret List.440; + dec List.442; + ret List.443; in - jump List.554 #Derived_gen.19 #Derived_gen.20 #Derived_gen.21 #Derived_gen.22 #Derived_gen.23; + jump List.559 #Derived_gen.19 #Derived_gen.20 #Derived_gen.21 #Derived_gen.22 #Derived_gen.23; -procedure List.80 (#Derived_gen.24, #Derived_gen.25, #Derived_gen.26, #Derived_gen.27, #Derived_gen.28): - joinpoint List.574 List.439 List.440 List.441 List.442 List.443: - let List.576 : Int1 = CallByName Num.22 List.442 List.443; - if List.576 then - let List.583 : U8 = CallByName List.66 List.439 List.442; - let List.577 : List U8 = CallByName List.145 List.440 List.583 List.441; - let List.580 : U64 = 1i64; - let List.579 : U64 = CallByName Num.19 List.442 List.580; - jump List.574 List.439 List.577 List.441 List.579 List.443; +procedure List.80 (#Derived_gen.30, #Derived_gen.31, #Derived_gen.32, #Derived_gen.33, #Derived_gen.34): + joinpoint List.580 List.442 List.443 List.444 List.445 List.446: + let List.582 : Int1 = CallByName Num.22 List.445 List.446; + if List.582 then + let List.588 : U8 = CallByName List.66 List.442 List.445; + let List.583 : List U8 = CallByName List.147 List.443 List.588 List.444; + let List.585 : U64 = CallByName List.96 List.445; + jump List.580 List.442 List.583 List.444 List.585 List.446; else - dec List.439; - ret List.440; + dec List.442; + ret List.443; in - jump List.574 #Derived_gen.24 #Derived_gen.25 #Derived_gen.26 #Derived_gen.27 #Derived_gen.28; + jump List.580 #Derived_gen.30 #Derived_gen.31 #Derived_gen.32 #Derived_gen.33 #Derived_gen.34; -procedure List.93 (List.436, List.437, List.438): - let List.552 : U64 = 0i64; - let List.553 : U64 = CallByName List.6 List.436; - let List.551 : {List U8, U64} = CallByName List.80 List.436 List.437 List.438 List.552 List.553; - ret List.551; +procedure List.93 (List.439, List.440, List.441): + let List.557 : U64 = 0i64; + let List.558 : U64 = CallByName List.6 List.439; + let List.556 : {List U8, U64} = CallByName List.80 List.439 List.440 List.441 List.557 List.558; + ret List.556; -procedure List.93 (List.436, List.437, List.438): - let List.572 : U64 = 0i64; - let List.573 : U64 = CallByName List.6 List.436; - let List.571 : List U8 = CallByName List.80 List.436 List.437 List.438 List.572 List.573; - ret List.571; +procedure List.93 (List.439, List.440, List.441): + let List.578 : U64 = 0i64; + let List.579 : U64 = CallByName List.6 List.439; + let List.577 : List U8 = CallByName List.80 List.439 List.440 List.441 List.578 List.579; + ret List.577; -procedure List.93 (List.436, List.437, List.438): - let List.625 : U64 = 0i64; - let List.626 : U64 = CallByName List.6 List.436; - let List.624 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.80 List.436 List.437 List.438 List.625 List.626; - ret List.624; +procedure List.93 (List.439, List.440, List.441): + let List.630 : U64 = 0i64; + let List.631 : U64 = CallByName List.6 List.439; + let List.629 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.80 List.439 List.440 List.441 List.630 List.631; + ret List.629; + +procedure List.96 (List.463): + let List.566 : U64 = 1i64; + let List.565 : U64 = CallByName Num.51 List.463 List.566; + ret List.565; procedure Num.127 (#Attr.2): let Num.299 : U8 = lowlevel NumIntCast #Attr.2; ret Num.299; procedure Num.19 (#Attr.2, #Attr.3): - let Num.308 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.308; + let Num.303 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.303; procedure Num.20 (#Attr.2, #Attr.3): - let Num.312 : U64 = lowlevel NumSub #Attr.2 #Attr.3; - ret Num.312; + let Num.300 : U64 = lowlevel NumSub #Attr.2 #Attr.3; + ret Num.300; procedure Num.21 (#Attr.2, #Attr.3): let Num.305 : U64 = lowlevel NumMul #Attr.2 #Attr.3; ret Num.305; procedure Num.22 (#Attr.2, #Attr.3): - let Num.311 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; - ret Num.311; + let Num.309 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + ret Num.309; procedure Num.24 (#Attr.2, #Attr.3): - let Num.313 : Int1 = lowlevel NumGt #Attr.2 #Attr.3; - ret Num.313; + let Num.311 : Int1 = lowlevel NumGt #Attr.2 #Attr.3; + ret Num.311; + +procedure Num.51 (#Attr.2, #Attr.3): + let Num.306 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; + ret Num.306; + +procedure Num.75 (#Attr.2, #Attr.3): + let Num.310 : U64 = lowlevel NumSubWrap #Attr.2 #Attr.3; + ret Num.310; procedure Num.94 (#Attr.2, #Attr.3): let Num.304 : U64 = lowlevel NumDivCeilUnchecked #Attr.2 #Attr.3; ret Num.304; procedure Str.12 (#Attr.2): - let Str.300 : List U8 = lowlevel StrToUtf8 #Attr.2; - ret Str.300; + let Str.302 : List U8 = lowlevel StrToUtf8 #Attr.2; + ret Str.302; procedure Str.48 (#Attr.2, #Attr.3, #Attr.4): - let Str.298 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8Range #Attr.2 #Attr.3 #Attr.4; - ret Str.298; + let Str.300 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8Range #Attr.2 #Attr.3 #Attr.4; + ret Str.300; -procedure Str.9 (Str.79): - let Str.296 : U64 = 0i64; - let Str.297 : U64 = CallByName List.6 Str.79; - let Str.80 : {U64, Str, Int1, U8} = CallByName Str.48 Str.79 Str.296 Str.297; - let Str.293 : Int1 = StructAtIndex 2 Str.80; - if Str.293 then - let Str.295 : Str = StructAtIndex 1 Str.80; - let Str.294 : [C {U64, U8}, C Str] = TagId(1) Str.295; - ret Str.294; +procedure Str.9 (Str.80): + let Str.298 : U64 = 0i64; + let Str.299 : U64 = CallByName List.6 Str.80; + let Str.81 : {U64, Str, Int1, U8} = CallByName Str.48 Str.80 Str.298 Str.299; + let Str.295 : Int1 = StructAtIndex 2 Str.81; + if Str.295 then + let Str.297 : Str = StructAtIndex 1 Str.81; + let Str.296 : [C {U64, U8}, C Str] = TagId(1) Str.297; + ret Str.296; else - let Str.291 : U8 = StructAtIndex 3 Str.80; - let Str.292 : U64 = StructAtIndex 0 Str.80; - let #Derived_gen.35 : Str = StructAtIndex 1 Str.80; + let Str.293 : U8 = StructAtIndex 3 Str.81; + let Str.294 : U64 = StructAtIndex 0 Str.81; + let #Derived_gen.35 : Str = StructAtIndex 1 Str.81; dec #Derived_gen.35; - let Str.290 : {U64, U8} = Struct {Str.292, Str.291}; - let Str.289 : [C {U64, U8}, C Str] = TagId(0) Str.290; - ret Str.289; + let Str.292 : {U64, U8} = Struct {Str.294, Str.293}; + let Str.291 : [C {U64, U8}, C Str] = TagId(0) Str.292; + ret Str.291; procedure TotallyNotJson.182 (TotallyNotJson.183, TotallyNotJson.1216, TotallyNotJson.181): let TotallyNotJson.1219 : List U8 = CallByName TotallyNotJson.26 TotallyNotJson.181; diff --git a/crates/compiler/test_mono/generated/ir_int_add.txt b/crates/compiler/test_mono/generated/ir_int_add.txt index 2e4de96845..468ef440b5 100644 --- a/crates/compiler/test_mono/generated/ir_int_add.txt +++ b/crates/compiler/test_mono/generated/ir_int_add.txt @@ -1,6 +1,6 @@ procedure List.6 (#Attr.2): - let List.521 : U64 = lowlevel ListLen #Attr.2; - ret List.521; + let List.526 : U64 = lowlevel ListLen #Attr.2; + ret List.526; procedure Num.19 (#Attr.2, #Attr.3): let Num.294 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/issue_2583_specialize_errors_behind_unified_branches.txt b/crates/compiler/test_mono/generated/issue_2583_specialize_errors_behind_unified_branches.txt index 96c021a84b..0674ea784d 100644 --- a/crates/compiler/test_mono/generated/issue_2583_specialize_errors_behind_unified_branches.txt +++ b/crates/compiler/test_mono/generated/issue_2583_specialize_errors_behind_unified_branches.txt @@ -6,69 +6,69 @@ procedure Bool.2 (): let Bool.23 : Int1 = true; ret Bool.23; -procedure List.2 (List.97, List.98): - let List.535 : U64 = CallByName List.6 List.97; - let List.531 : Int1 = CallByName Num.22 List.98 List.535; - if List.531 then - let List.533 : I64 = CallByName List.66 List.97 List.98; - dec List.97; - let List.532 : [C {}, C I64] = TagId(1) List.533; - ret List.532; +procedure List.2 (List.99, List.100): + let List.540 : U64 = CallByName List.6 List.99; + let List.536 : Int1 = CallByName Num.22 List.100 List.540; + if List.536 then + let List.538 : I64 = CallByName List.66 List.99 List.100; + dec List.99; + let List.537 : [C {}, C I64] = TagId(1) List.538; + ret List.537; else - dec List.97; - let List.530 : {} = Struct {}; - let List.529 : [C {}, C I64] = TagId(0) List.530; - ret List.529; + dec List.99; + let List.535 : {} = Struct {}; + let List.534 : [C {}, C I64] = TagId(0) List.535; + ret List.534; procedure List.6 (#Attr.2): - let List.536 : U64 = lowlevel ListLen #Attr.2; - ret List.536; + let List.541 : U64 = lowlevel ListLen #Attr.2; + ret List.541; procedure List.66 (#Attr.2, #Attr.3): - let List.534 : I64 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.534; + let List.539 : I64 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.539; -procedure List.9 (List.293): - let List.528 : U64 = 0i64; - let List.521 : [C {}, C I64] = CallByName List.2 List.293 List.528; - let List.525 : U8 = 1i64; - let List.526 : U8 = GetTagId List.521; - let List.527 : Int1 = lowlevel Eq List.525 List.526; - if List.527 then - let List.294 : I64 = UnionAtIndex (Id 1) (Index 0) List.521; - let List.522 : [C Int1, C I64] = TagId(1) List.294; - ret List.522; +procedure List.9 (List.295): + let List.533 : U64 = 0i64; + let List.526 : [C {}, C I64] = CallByName List.2 List.295 List.533; + let List.530 : U8 = 1i64; + let List.531 : U8 = GetTagId List.526; + let List.532 : Int1 = lowlevel Eq List.530 List.531; + if List.532 then + let List.296 : I64 = UnionAtIndex (Id 1) (Index 0) List.526; + let List.527 : [C Int1, C I64] = TagId(1) List.296; + ret List.527; else - let List.524 : Int1 = true; - let List.523 : [C Int1, C I64] = TagId(0) List.524; - ret List.523; + let List.529 : Int1 = true; + let List.528 : [C Int1, C I64] = TagId(0) List.529; + ret List.528; procedure Num.22 (#Attr.2, #Attr.3): let Num.292 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; ret Num.292; -procedure Str.27 (Str.99): - let Str.289 : [C Int1, C I64] = CallByName Str.72 Str.99; - ret Str.289; +procedure Str.27 (Str.100): + let Str.291 : [C Int1, C I64] = CallByName Str.72 Str.100; + ret Str.291; procedure Str.47 (#Attr.2): - let Str.297 : {I64, U8} = lowlevel StrToNum #Attr.2; - ret Str.297; + let Str.299 : {I64, U8} = lowlevel StrToNum #Attr.2; + ret Str.299; -procedure Str.72 (Str.235): - let Str.236 : {I64, U8} = CallByName Str.47 Str.235; - dec Str.235; - let Str.295 : U8 = StructAtIndex 1 Str.236; - let Str.296 : U8 = 0i64; - let Str.292 : Int1 = CallByName Bool.11 Str.295 Str.296; - if Str.292 then - let Str.294 : I64 = StructAtIndex 0 Str.236; - let Str.293 : [C Int1, C I64] = TagId(1) Str.294; - ret Str.293; +procedure Str.72 (Str.236): + let Str.237 : {I64, U8} = CallByName Str.47 Str.236; + dec Str.236; + let Str.297 : U8 = StructAtIndex 1 Str.237; + let Str.298 : U8 = 0i64; + let Str.294 : Int1 = CallByName Bool.11 Str.297 Str.298; + if Str.294 then + let Str.296 : I64 = StructAtIndex 0 Str.237; + let Str.295 : [C Int1, C I64] = TagId(1) Str.296; + ret Str.295; else - let Str.291 : Int1 = false; - let Str.290 : [C Int1, C I64] = TagId(0) Str.291; - ret Str.290; + let Str.293 : Int1 = false; + let Str.292 : [C Int1, C I64] = TagId(0) Str.293; + ret Str.292; procedure Test.0 (): let Test.3 : Int1 = CallByName Bool.2; diff --git a/crates/compiler/test_mono/generated/issue_4749.txt b/crates/compiler/test_mono/generated/issue_4749.txt index 61797ec653..2d513bf108 100644 --- a/crates/compiler/test_mono/generated/issue_4749.txt +++ b/crates/compiler/test_mono/generated/issue_4749.txt @@ -64,144 +64,148 @@ procedure Decode.27 (Decode.107, Decode.108): let Decode.123 : [C [C List U8, C ], C Str] = TagId(0) Decode.124; ret Decode.123; -procedure List.1 (List.96): - let List.588 : U64 = CallByName List.6 List.96; - dec List.96; - let List.589 : U64 = 0i64; - let List.587 : Int1 = CallByName Bool.11 List.588 List.589; - ret List.587; +procedure List.1 (List.98): + let List.593 : U64 = CallByName List.6 List.98; + dec List.98; + let List.594 : U64 = 0i64; + let List.592 : Int1 = CallByName Bool.11 List.593 List.594; + ret List.592; -procedure List.2 (List.97, List.98): - let List.571 : U64 = CallByName List.6 List.97; - let List.568 : Int1 = CallByName Num.22 List.98 List.571; - if List.568 then - let List.570 : U8 = CallByName List.66 List.97 List.98; - dec List.97; - let List.569 : [C {}, C U8] = TagId(1) List.570; - ret List.569; +procedure List.2 (List.99, List.100): + let List.576 : U64 = CallByName List.6 List.99; + let List.573 : Int1 = CallByName Num.22 List.100 List.576; + if List.573 then + let List.575 : U8 = CallByName List.66 List.99 List.100; + dec List.99; + let List.574 : [C {}, C U8] = TagId(1) List.575; + ret List.574; else - dec List.97; - let List.567 : {} = Struct {}; - let List.566 : [C {}, C U8] = TagId(0) List.567; - ret List.566; + dec List.99; + let List.572 : {} = Struct {}; + let List.571 : [C {}, C U8] = TagId(0) List.572; + ret List.571; -procedure List.26 (List.159, List.160, List.161): - let List.590 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = CallByName List.93 List.159 List.160 List.161; - let List.593 : U8 = 1i64; - let List.594 : U8 = GetTagId List.590; - let List.595 : Int1 = lowlevel Eq List.593 List.594; - if List.595 then - let List.162 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = UnionAtIndex (Id 1) (Index 0) List.590; - ret List.162; +procedure List.26 (List.161, List.162, List.163): + let List.595 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = CallByName List.93 List.161 List.162 List.163; + let List.598 : U8 = 1i64; + let List.599 : U8 = GetTagId List.595; + let List.600 : Int1 = lowlevel Eq List.598 List.599; + if List.600 then + let List.164 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = UnionAtIndex (Id 1) (Index 0) List.595; + ret List.164; else - let List.163 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = UnionAtIndex (Id 0) (Index 0) List.590; - ret List.163; + let List.165 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = UnionAtIndex (Id 0) (Index 0) List.595; + ret List.165; -procedure List.29 (List.304, List.305): - let List.545 : U64 = CallByName List.6 List.304; - let List.306 : U64 = CallByName Num.77 List.545 List.305; - let List.544 : List U8 = CallByName List.43 List.304 List.306; - ret List.544; +procedure List.29 (List.306, List.307): + let List.550 : U64 = CallByName List.6 List.306; + let List.308 : U64 = CallByName Num.77 List.550 List.307; + let List.549 : List U8 = CallByName List.43 List.306 List.308; + ret List.549; procedure List.31 (#Attr.2, #Attr.3): - let List.558 : List U8 = lowlevel ListDropAt #Attr.2 #Attr.3; + let List.563 : List U8 = lowlevel ListDropAt #Attr.2 #Attr.3; + ret List.563; + +procedure List.38 (List.300): + let List.562 : U64 = 0i64; + let List.561 : List U8 = CallByName List.31 List.300 List.562; + ret List.561; + +procedure List.4 (List.115, List.116): + let List.560 : U64 = 1i64; + let List.559 : List U8 = CallByName List.70 List.115 List.560; + let List.558 : List U8 = CallByName List.71 List.559 List.116; ret List.558; -procedure List.38 (List.298): - let List.557 : U64 = 0i64; - let List.556 : List U8 = CallByName List.31 List.298 List.557; - ret List.556; - -procedure List.4 (List.113, List.114): - let List.555 : U64 = 1i64; - let List.554 : List U8 = CallByName List.70 List.113 List.555; - let List.553 : List U8 = CallByName List.71 List.554 List.114; - ret List.553; - -procedure List.43 (List.302, List.303): - let List.537 : U64 = CallByName List.6 List.302; - let List.536 : U64 = CallByName Num.77 List.537 List.303; - let List.527 : {U64, U64} = Struct {List.303, List.536}; - let List.526 : List U8 = CallByName List.49 List.302 List.527; - ret List.526; - -procedure List.49 (List.376, List.377): - let List.584 : U64 = StructAtIndex 0 List.377; - let List.585 : U64 = 0i64; - let List.582 : Int1 = CallByName Bool.11 List.584 List.585; - if List.582 then - dec List.376; - let List.583 : List U8 = Array []; - ret List.583; - else - let List.580 : U64 = StructAtIndex 1 List.377; - let List.581 : U64 = StructAtIndex 0 List.377; - let List.579 : List U8 = CallByName List.72 List.376 List.580 List.581; - ret List.579; - -procedure List.6 (#Attr.2): - let List.611 : U64 = lowlevel ListLen #Attr.2; - ret List.611; - -procedure List.66 (#Attr.2, #Attr.3): - let List.564 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.564; - -procedure List.70 (#Attr.2, #Attr.3): - let List.552 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.552; - -procedure List.71 (#Attr.2, #Attr.3): - let List.550 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.550; - -procedure List.72 (#Attr.2, #Attr.3, #Attr.4): - let List.531 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; +procedure List.43 (List.304, List.305): + let List.542 : U64 = CallByName List.6 List.304; + let List.541 : U64 = CallByName Num.77 List.542 List.305; + let List.532 : {U64, U64} = Struct {List.305, List.541}; + let List.531 : List U8 = CallByName List.49 List.304 List.532; ret List.531; +procedure List.49 (List.379, List.380): + let List.589 : U64 = StructAtIndex 0 List.380; + let List.590 : U64 = 0i64; + let List.587 : Int1 = CallByName Bool.11 List.589 List.590; + if List.587 then + dec List.379; + let List.588 : List U8 = Array []; + ret List.588; + else + let List.585 : U64 = StructAtIndex 1 List.380; + let List.586 : U64 = StructAtIndex 0 List.380; + let List.584 : List U8 = CallByName List.72 List.379 List.585 List.586; + ret List.584; + +procedure List.6 (#Attr.2): + let List.617 : U64 = lowlevel ListLen #Attr.2; + ret List.617; + +procedure List.66 (#Attr.2, #Attr.3): + let List.569 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.569; + +procedure List.70 (#Attr.2, #Attr.3): + let List.557 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.557; + +procedure List.71 (#Attr.2, #Attr.3): + let List.555 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.555; + +procedure List.72 (#Attr.2, #Attr.3, #Attr.4): + let List.536 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; + ret List.536; + procedure List.8 (#Attr.2, #Attr.3): - let List.547 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; - ret List.547; + let List.552 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; + ret List.552; procedure List.80 (#Derived_gen.0, #Derived_gen.1, #Derived_gen.2, #Derived_gen.3, #Derived_gen.4): - joinpoint List.599 List.439 List.440 List.441 List.442 List.443: - let List.601 : Int1 = CallByName Num.22 List.442 List.443; - if List.601 then - let List.610 : U8 = CallByName List.66 List.439 List.442; - let List.602 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = CallByName TotallyNotJson.62 List.440 List.610; - let List.607 : U8 = 1i64; - let List.608 : U8 = GetTagId List.602; - let List.609 : Int1 = lowlevel Eq List.607 List.608; - if List.609 then - let List.444 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = UnionAtIndex (Id 1) (Index 0) List.602; - let List.605 : U64 = 1i64; - let List.604 : U64 = CallByName Num.19 List.442 List.605; - jump List.599 List.439 List.444 List.441 List.604 List.443; + joinpoint List.604 List.442 List.443 List.444 List.445 List.446: + let List.606 : Int1 = CallByName Num.22 List.445 List.446; + if List.606 then + let List.616 : U8 = CallByName List.66 List.442 List.445; + let List.607 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = CallByName TotallyNotJson.62 List.443 List.616; + let List.613 : U8 = 1i64; + let List.614 : U8 = GetTagId List.607; + let List.615 : Int1 = lowlevel Eq List.613 List.614; + if List.615 then + let List.447 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = UnionAtIndex (Id 1) (Index 0) List.607; + let List.609 : U64 = CallByName List.96 List.445; + jump List.604 List.442 List.447 List.444 List.609 List.446; else - dec List.439; - let List.445 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = UnionAtIndex (Id 0) (Index 0) List.602; - let List.606 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = TagId(0) List.445; - ret List.606; + dec List.442; + let List.448 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = UnionAtIndex (Id 0) (Index 0) List.607; + let List.612 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = TagId(0) List.448; + ret List.612; else - dec List.439; - let List.600 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = TagId(1) List.440; - ret List.600; + dec List.442; + let List.605 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = TagId(1) List.443; + ret List.605; in - jump List.599 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4; + jump List.604 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4; -procedure List.93 (List.436, List.437, List.438): - let List.597 : U64 = 0i64; - let List.598 : U64 = CallByName List.6 List.436; - let List.596 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = CallByName List.80 List.436 List.437 List.438 List.597 List.598; - ret List.596; +procedure List.93 (List.439, List.440, List.441): + let List.602 : U64 = 0i64; + let List.603 : U64 = CallByName List.6 List.439; + let List.601 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = CallByName List.80 List.439 List.440 List.441 List.602 List.603; + ret List.601; + +procedure List.96 (List.463): + let List.611 : U64 = 1i64; + let List.610 : U64 = CallByName Num.51 List.463 List.611; + ret List.610; procedure Num.19 (#Attr.2, #Attr.3): let Num.295 : U8 = lowlevel NumAdd #Attr.2 #Attr.3; ret Num.295; procedure Num.19 (#Attr.2, #Attr.3): - let Num.329 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.329; + let Num.304 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.304; procedure Num.20 (#Attr.2, #Attr.3): let Num.307 : U8 = lowlevel NumSub #Attr.2 #Attr.3; @@ -219,6 +223,10 @@ procedure Num.25 (#Attr.2, #Attr.3): let Num.319 : Int1 = lowlevel NumGte #Attr.2 #Attr.3; ret Num.319; +procedure Num.51 (#Attr.2, #Attr.3): + let Num.329 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; + ret Num.329; + procedure Num.71 (#Attr.2, #Attr.3): let Num.292 : U8 = lowlevel NumBitwiseOr #Attr.2 #Attr.3; ret Num.292; @@ -232,26 +240,26 @@ procedure Num.77 (#Attr.2, #Attr.3): ret Num.325; procedure Str.48 (#Attr.2, #Attr.3, #Attr.4): - let Str.298 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8Range #Attr.2 #Attr.3 #Attr.4; - ret Str.298; + let Str.300 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8Range #Attr.2 #Attr.3 #Attr.4; + ret Str.300; -procedure Str.9 (Str.79): - let Str.296 : U64 = 0i64; - let Str.297 : U64 = CallByName List.6 Str.79; - let Str.80 : {U64, Str, Int1, U8} = CallByName Str.48 Str.79 Str.296 Str.297; - let Str.293 : Int1 = StructAtIndex 2 Str.80; - if Str.293 then - let Str.295 : Str = StructAtIndex 1 Str.80; - let Str.294 : [C {U64, U8}, C Str] = TagId(1) Str.295; - ret Str.294; +procedure Str.9 (Str.80): + let Str.298 : U64 = 0i64; + let Str.299 : U64 = CallByName List.6 Str.80; + let Str.81 : {U64, Str, Int1, U8} = CallByName Str.48 Str.80 Str.298 Str.299; + let Str.295 : Int1 = StructAtIndex 2 Str.81; + if Str.295 then + let Str.297 : Str = StructAtIndex 1 Str.81; + let Str.296 : [C {U64, U8}, C Str] = TagId(1) Str.297; + ret Str.296; else - let Str.291 : U8 = StructAtIndex 3 Str.80; - let Str.292 : U64 = StructAtIndex 0 Str.80; - let #Derived_gen.6 : Str = StructAtIndex 1 Str.80; + let Str.293 : U8 = StructAtIndex 3 Str.81; + let Str.294 : U64 = StructAtIndex 0 Str.81; + let #Derived_gen.6 : Str = StructAtIndex 1 Str.81; dec #Derived_gen.6; - let Str.290 : {U64, U8} = Struct {Str.292, Str.291}; - let Str.289 : [C {U64, U8}, C Str] = TagId(0) Str.290; - ret Str.289; + let Str.292 : {U64, U8} = Struct {Str.294, Str.293}; + let Str.291 : [C {U64, U8}, C Str] = TagId(0) Str.292; + ret Str.291; procedure Test.3 (): let Test.0 : List U8 = Array [82i64, 111i64, 99i64]; diff --git a/crates/compiler/test_mono/generated/issue_4770.txt b/crates/compiler/test_mono/generated/issue_4770.txt index 7c010f6334..8b0d25dace 100644 --- a/crates/compiler/test_mono/generated/issue_4770.txt +++ b/crates/compiler/test_mono/generated/issue_4770.txt @@ -6,84 +6,84 @@ procedure Bool.2 (): let Bool.24 : Int1 = true; ret Bool.24; -procedure List.194 (List.523, List.195, List.193): - let List.553 : Int1 = CallByName Test.1 List.195; - if List.553 then - let List.555 : {} = Struct {}; - let List.554 : [C {}, C {}] = TagId(1) List.555; - ret List.554; +procedure List.196 (List.528, List.197, List.195): + let List.559 : Int1 = CallByName Test.1 List.197; + if List.559 then + let List.561 : {} = Struct {}; + let List.560 : [C {}, C {}] = TagId(1) List.561; + ret List.560; else - let List.552 : {} = Struct {}; - let List.551 : [C {}, C {}] = TagId(0) List.552; - ret List.551; + let List.558 : {} = Struct {}; + let List.557 : [C {}, C {}] = TagId(0) List.558; + ret List.557; procedure List.23 (#Attr.2, #Attr.3, #Attr.4): - let List.556 : List {[C I64, C List *self], [C I64, C List *self]} = lowlevel ListMap2 { xs: `#Attr.#arg1`, ys: `#Attr.#arg2` } #Attr.2 #Attr.3 Test.15 #Attr.4; + let List.562 : List {[C I64, C List *self], [C I64, C List *self]} = lowlevel ListMap2 { xs: `#Attr.#arg1`, ys: `#Attr.#arg2` } #Attr.2 #Attr.3 Test.15 #Attr.4; decref #Attr.3; decref #Attr.2; + ret List.562; + +procedure List.56 (List.194, List.195): + let List.537 : {} = Struct {}; + let List.529 : [C {}, C {}] = CallByName List.93 List.194 List.537 List.195; + let List.534 : U8 = 1i64; + let List.535 : U8 = GetTagId List.529; + let List.536 : Int1 = lowlevel Eq List.534 List.535; + if List.536 then + let List.530 : Int1 = CallByName Bool.2; + ret List.530; + else + let List.531 : Int1 = CallByName Bool.1; + ret List.531; + +procedure List.6 (#Attr.2): + let List.527 : U64 = lowlevel ListLen #Attr.2; + ret List.527; + +procedure List.6 (#Attr.2): + let List.556 : U64 = lowlevel ListLen #Attr.2; ret List.556; -procedure List.56 (List.192, List.193): - let List.532 : {} = Struct {}; - let List.524 : [C {}, C {}] = CallByName List.93 List.192 List.532 List.193; - let List.529 : U8 = 1i64; - let List.530 : U8 = GetTagId List.524; - let List.531 : Int1 = lowlevel Eq List.529 List.530; - if List.531 then - let List.525 : Int1 = CallByName Bool.2; - ret List.525; - else - let List.526 : Int1 = CallByName Bool.1; - ret List.526; - -procedure List.6 (#Attr.2): - let List.522 : U64 = lowlevel ListLen #Attr.2; - ret List.522; - -procedure List.6 (#Attr.2): - let List.550 : U64 = lowlevel ListLen #Attr.2; - ret List.550; - procedure List.66 (#Attr.2, #Attr.3): - let List.549 : {[C I64, C List *self], [C I64, C List *self]} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.549; + let List.555 : {[C I64, C List *self], [C I64, C List *self]} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.555; procedure List.80 (#Derived_gen.1, #Derived_gen.2, #Derived_gen.3, #Derived_gen.4, #Derived_gen.5): - joinpoint List.537 List.439 List.440 List.441 List.442 List.443: - let List.539 : Int1 = CallByName Num.22 List.442 List.443; - if List.539 then - let List.548 : {[C I64, C List *self], [C I64, C List *self]} = CallByName List.66 List.439 List.442; - inc List.548; - let List.540 : [C {}, C {}] = CallByName List.194 List.440 List.548 List.441; - let List.545 : U8 = 1i64; - let List.546 : U8 = GetTagId List.540; - let List.547 : Int1 = lowlevel Eq List.545 List.546; - if List.547 then - let List.444 : {} = UnionAtIndex (Id 1) (Index 0) List.540; - let List.543 : U64 = 1i64; - let List.542 : U64 = CallByName Num.19 List.442 List.543; - jump List.537 List.439 List.444 List.441 List.542 List.443; + joinpoint List.542 List.442 List.443 List.444 List.445 List.446: + let List.544 : Int1 = CallByName Num.22 List.445 List.446; + if List.544 then + let List.554 : {[C I64, C List *self], [C I64, C List *self]} = CallByName List.66 List.442 List.445; + inc List.554; + let List.545 : [C {}, C {}] = CallByName List.196 List.443 List.554 List.444; + let List.551 : U8 = 1i64; + let List.552 : U8 = GetTagId List.545; + let List.553 : Int1 = lowlevel Eq List.551 List.552; + if List.553 then + let List.447 : {} = UnionAtIndex (Id 1) (Index 0) List.545; + let List.547 : U64 = CallByName List.96 List.445; + jump List.542 List.442 List.447 List.444 List.547 List.446; else - dec List.439; - let List.445 : {} = UnionAtIndex (Id 0) (Index 0) List.540; - let List.544 : [C {}, C {}] = TagId(0) List.445; - ret List.544; + dec List.442; + let List.448 : {} = UnionAtIndex (Id 0) (Index 0) List.545; + let List.550 : [C {}, C {}] = TagId(0) List.448; + ret List.550; else - dec List.439; - let List.538 : [C {}, C {}] = TagId(1) List.440; - ret List.538; + dec List.442; + let List.543 : [C {}, C {}] = TagId(1) List.443; + ret List.543; in - jump List.537 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4 #Derived_gen.5; + jump List.542 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4 #Derived_gen.5; -procedure List.93 (List.436, List.437, List.438): - let List.535 : U64 = 0i64; - let List.536 : U64 = CallByName List.6 List.436; - let List.534 : [C {}, C {}] = CallByName List.80 List.436 List.437 List.438 List.535 List.536; - ret List.534; +procedure List.93 (List.439, List.440, List.441): + let List.540 : U64 = 0i64; + let List.541 : U64 = CallByName List.6 List.439; + let List.539 : [C {}, C {}] = CallByName List.80 List.439 List.440 List.441 List.540 List.541; + ret List.539; -procedure Num.19 (#Attr.2, #Attr.3): - let Num.294 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.294; +procedure List.96 (List.463): + let List.549 : U64 = 1i64; + let List.548 : U64 = CallByName Num.51 List.463 List.549; + ret List.548; procedure Num.22 (#Attr.2, #Attr.3): let Num.292 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; @@ -93,6 +93,10 @@ procedure Num.22 (#Attr.2, #Attr.3): let Num.295 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; ret Num.295; +procedure Num.51 (#Attr.2, #Attr.3): + let Num.294 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; + ret Num.294; + procedure Test.1 (#Derived_gen.0): joinpoint Test.26 Test.6: let Test.65 : [C I64, C List *self] = StructAtIndex 1 Test.6; diff --git a/crates/compiler/test_mono/generated/issue_4772_weakened_monomorphic_destructure.txt b/crates/compiler/test_mono/generated/issue_4772_weakened_monomorphic_destructure.txt index 368ce7bef1..366e1528bf 100644 --- a/crates/compiler/test_mono/generated/issue_4772_weakened_monomorphic_destructure.txt +++ b/crates/compiler/test_mono/generated/issue_4772_weakened_monomorphic_destructure.txt @@ -38,144 +38,148 @@ procedure Decode.26 (Decode.105, Decode.106): let Decode.122 : {List U8, [C {}, C Str]} = CallByName Decode.25 Decode.105 Decode.123 Decode.106; ret Decode.122; -procedure List.1 (List.96): - let List.584 : U64 = CallByName List.6 List.96; - dec List.96; - let List.585 : U64 = 0i64; - let List.583 : Int1 = CallByName Bool.11 List.584 List.585; - ret List.583; +procedure List.1 (List.98): + let List.589 : U64 = CallByName List.6 List.98; + dec List.98; + let List.590 : U64 = 0i64; + let List.588 : Int1 = CallByName Bool.11 List.589 List.590; + ret List.588; -procedure List.2 (List.97, List.98): - let List.567 : U64 = CallByName List.6 List.97; - let List.564 : Int1 = CallByName Num.22 List.98 List.567; - if List.564 then - let List.566 : U8 = CallByName List.66 List.97 List.98; - dec List.97; - let List.565 : [C {}, C U8] = TagId(1) List.566; - ret List.565; +procedure List.2 (List.99, List.100): + let List.572 : U64 = CallByName List.6 List.99; + let List.569 : Int1 = CallByName Num.22 List.100 List.572; + if List.569 then + let List.571 : U8 = CallByName List.66 List.99 List.100; + dec List.99; + let List.570 : [C {}, C U8] = TagId(1) List.571; + ret List.570; else - dec List.97; - let List.563 : {} = Struct {}; - let List.562 : [C {}, C U8] = TagId(0) List.563; - ret List.562; + dec List.99; + let List.568 : {} = Struct {}; + let List.567 : [C {}, C U8] = TagId(0) List.568; + ret List.567; -procedure List.26 (List.159, List.160, List.161): - let List.586 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = CallByName List.93 List.159 List.160 List.161; - let List.589 : U8 = 1i64; - let List.590 : U8 = GetTagId List.586; - let List.591 : Int1 = lowlevel Eq List.589 List.590; - if List.591 then - let List.162 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = UnionAtIndex (Id 1) (Index 0) List.586; - ret List.162; +procedure List.26 (List.161, List.162, List.163): + let List.591 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = CallByName List.93 List.161 List.162 List.163; + let List.594 : U8 = 1i64; + let List.595 : U8 = GetTagId List.591; + let List.596 : Int1 = lowlevel Eq List.594 List.595; + if List.596 then + let List.164 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = UnionAtIndex (Id 1) (Index 0) List.591; + ret List.164; else - let List.163 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = UnionAtIndex (Id 0) (Index 0) List.586; - ret List.163; + let List.165 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = UnionAtIndex (Id 0) (Index 0) List.591; + ret List.165; -procedure List.29 (List.304, List.305): - let List.541 : U64 = CallByName List.6 List.304; - let List.306 : U64 = CallByName Num.77 List.541 List.305; - let List.540 : List U8 = CallByName List.43 List.304 List.306; - ret List.540; +procedure List.29 (List.306, List.307): + let List.546 : U64 = CallByName List.6 List.306; + let List.308 : U64 = CallByName Num.77 List.546 List.307; + let List.545 : List U8 = CallByName List.43 List.306 List.308; + ret List.545; procedure List.31 (#Attr.2, #Attr.3): - let List.554 : List U8 = lowlevel ListDropAt #Attr.2 #Attr.3; + let List.559 : List U8 = lowlevel ListDropAt #Attr.2 #Attr.3; + ret List.559; + +procedure List.38 (List.300): + let List.558 : U64 = 0i64; + let List.557 : List U8 = CallByName List.31 List.300 List.558; + ret List.557; + +procedure List.4 (List.115, List.116): + let List.556 : U64 = 1i64; + let List.555 : List U8 = CallByName List.70 List.115 List.556; + let List.554 : List U8 = CallByName List.71 List.555 List.116; ret List.554; -procedure List.38 (List.298): - let List.553 : U64 = 0i64; - let List.552 : List U8 = CallByName List.31 List.298 List.553; - ret List.552; - -procedure List.4 (List.113, List.114): - let List.551 : U64 = 1i64; - let List.550 : List U8 = CallByName List.70 List.113 List.551; - let List.549 : List U8 = CallByName List.71 List.550 List.114; - ret List.549; - -procedure List.43 (List.302, List.303): - let List.533 : U64 = CallByName List.6 List.302; - let List.532 : U64 = CallByName Num.77 List.533 List.303; - let List.523 : {U64, U64} = Struct {List.303, List.532}; - let List.522 : List U8 = CallByName List.49 List.302 List.523; - ret List.522; - -procedure List.49 (List.376, List.377): - let List.580 : U64 = StructAtIndex 0 List.377; - let List.581 : U64 = 0i64; - let List.578 : Int1 = CallByName Bool.11 List.580 List.581; - if List.578 then - dec List.376; - let List.579 : List U8 = Array []; - ret List.579; - else - let List.576 : U64 = StructAtIndex 1 List.377; - let List.577 : U64 = StructAtIndex 0 List.377; - let List.575 : List U8 = CallByName List.72 List.376 List.576 List.577; - ret List.575; - -procedure List.6 (#Attr.2): - let List.607 : U64 = lowlevel ListLen #Attr.2; - ret List.607; - -procedure List.66 (#Attr.2, #Attr.3): - let List.560 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.560; - -procedure List.70 (#Attr.2, #Attr.3): - let List.548 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.548; - -procedure List.71 (#Attr.2, #Attr.3): - let List.546 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.546; - -procedure List.72 (#Attr.2, #Attr.3, #Attr.4): - let List.527 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; +procedure List.43 (List.304, List.305): + let List.538 : U64 = CallByName List.6 List.304; + let List.537 : U64 = CallByName Num.77 List.538 List.305; + let List.528 : {U64, U64} = Struct {List.305, List.537}; + let List.527 : List U8 = CallByName List.49 List.304 List.528; ret List.527; +procedure List.49 (List.379, List.380): + let List.585 : U64 = StructAtIndex 0 List.380; + let List.586 : U64 = 0i64; + let List.583 : Int1 = CallByName Bool.11 List.585 List.586; + if List.583 then + dec List.379; + let List.584 : List U8 = Array []; + ret List.584; + else + let List.581 : U64 = StructAtIndex 1 List.380; + let List.582 : U64 = StructAtIndex 0 List.380; + let List.580 : List U8 = CallByName List.72 List.379 List.581 List.582; + ret List.580; + +procedure List.6 (#Attr.2): + let List.613 : U64 = lowlevel ListLen #Attr.2; + ret List.613; + +procedure List.66 (#Attr.2, #Attr.3): + let List.565 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.565; + +procedure List.70 (#Attr.2, #Attr.3): + let List.553 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.553; + +procedure List.71 (#Attr.2, #Attr.3): + let List.551 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.551; + +procedure List.72 (#Attr.2, #Attr.3, #Attr.4): + let List.532 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; + ret List.532; + procedure List.8 (#Attr.2, #Attr.3): - let List.543 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; - ret List.543; + let List.548 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; + ret List.548; procedure List.80 (#Derived_gen.0, #Derived_gen.1, #Derived_gen.2, #Derived_gen.3, #Derived_gen.4): - joinpoint List.595 List.439 List.440 List.441 List.442 List.443: - let List.597 : Int1 = CallByName Num.22 List.442 List.443; - if List.597 then - let List.606 : U8 = CallByName List.66 List.439 List.442; - let List.598 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = CallByName TotallyNotJson.62 List.440 List.606; - let List.603 : U8 = 1i64; - let List.604 : U8 = GetTagId List.598; - let List.605 : Int1 = lowlevel Eq List.603 List.604; - if List.605 then - let List.444 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = UnionAtIndex (Id 1) (Index 0) List.598; - let List.601 : U64 = 1i64; - let List.600 : U64 = CallByName Num.19 List.442 List.601; - jump List.595 List.439 List.444 List.441 List.600 List.443; + joinpoint List.600 List.442 List.443 List.444 List.445 List.446: + let List.602 : Int1 = CallByName Num.22 List.445 List.446; + if List.602 then + let List.612 : U8 = CallByName List.66 List.442 List.445; + let List.603 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = CallByName TotallyNotJson.62 List.443 List.612; + let List.609 : U8 = 1i64; + let List.610 : U8 = GetTagId List.603; + let List.611 : Int1 = lowlevel Eq List.609 List.610; + if List.611 then + let List.447 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = UnionAtIndex (Id 1) (Index 0) List.603; + let List.605 : U64 = CallByName List.96 List.445; + jump List.600 List.442 List.447 List.444 List.605 List.446; else - dec List.439; - let List.445 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = UnionAtIndex (Id 0) (Index 0) List.598; - let List.602 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = TagId(0) List.445; - ret List.602; + dec List.442; + let List.448 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = UnionAtIndex (Id 0) (Index 0) List.603; + let List.608 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = TagId(0) List.448; + ret List.608; else - dec List.439; - let List.596 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = TagId(1) List.440; - ret List.596; + dec List.442; + let List.601 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = TagId(1) List.443; + ret List.601; in - jump List.595 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4; + jump List.600 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4; -procedure List.93 (List.436, List.437, List.438): - let List.593 : U64 = 0i64; - let List.594 : U64 = CallByName List.6 List.436; - let List.592 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = CallByName List.80 List.436 List.437 List.438 List.593 List.594; - ret List.592; +procedure List.93 (List.439, List.440, List.441): + let List.598 : U64 = 0i64; + let List.599 : U64 = CallByName List.6 List.439; + let List.597 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = CallByName List.80 List.439 List.440 List.441 List.598 List.599; + ret List.597; + +procedure List.96 (List.463): + let List.607 : U64 = 1i64; + let List.606 : U64 = CallByName Num.51 List.463 List.607; + ret List.606; procedure Num.19 (#Attr.2, #Attr.3): let Num.295 : U8 = lowlevel NumAdd #Attr.2 #Attr.3; ret Num.295; procedure Num.19 (#Attr.2, #Attr.3): - let Num.329 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.329; + let Num.304 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.304; procedure Num.20 (#Attr.2, #Attr.3): let Num.307 : U8 = lowlevel NumSub #Attr.2 #Attr.3; @@ -193,6 +197,10 @@ procedure Num.25 (#Attr.2, #Attr.3): let Num.319 : Int1 = lowlevel NumGte #Attr.2 #Attr.3; ret Num.319; +procedure Num.51 (#Attr.2, #Attr.3): + let Num.329 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; + ret Num.329; + procedure Num.71 (#Attr.2, #Attr.3): let Num.292 : U8 = lowlevel NumBitwiseOr #Attr.2 #Attr.3; ret Num.292; @@ -206,53 +214,53 @@ procedure Num.77 (#Attr.2, #Attr.3): ret Num.325; procedure Str.12 (#Attr.2): - let Str.298 : List U8 = lowlevel StrToUtf8 #Attr.2; - ret Str.298; + let Str.300 : List U8 = lowlevel StrToUtf8 #Attr.2; + ret Str.300; -procedure Str.27 (Str.99): - let Str.289 : [C {}, C I64] = CallByName Str.72 Str.99; - ret Str.289; +procedure Str.27 (Str.100): + let Str.291 : [C {}, C I64] = CallByName Str.72 Str.100; + ret Str.291; procedure Str.47 (#Attr.2): - let Str.297 : {I64, U8} = lowlevel StrToNum #Attr.2; - ret Str.297; + let Str.299 : {I64, U8} = lowlevel StrToNum #Attr.2; + ret Str.299; procedure Str.48 (#Attr.2, #Attr.3, #Attr.4): - let Str.308 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8Range #Attr.2 #Attr.3 #Attr.4; - ret Str.308; + let Str.310 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8Range #Attr.2 #Attr.3 #Attr.4; + ret Str.310; -procedure Str.72 (Str.235): - let Str.236 : {I64, U8} = CallByName Str.47 Str.235; - dec Str.235; - let Str.295 : U8 = StructAtIndex 1 Str.236; - let Str.296 : U8 = 0i64; - let Str.292 : Int1 = CallByName Bool.11 Str.295 Str.296; - if Str.292 then - let Str.294 : I64 = StructAtIndex 0 Str.236; - let Str.293 : [C {}, C I64] = TagId(1) Str.294; - ret Str.293; +procedure Str.72 (Str.236): + let Str.237 : {I64, U8} = CallByName Str.47 Str.236; + dec Str.236; + let Str.297 : U8 = StructAtIndex 1 Str.237; + let Str.298 : U8 = 0i64; + let Str.294 : Int1 = CallByName Bool.11 Str.297 Str.298; + if Str.294 then + let Str.296 : I64 = StructAtIndex 0 Str.237; + let Str.295 : [C {}, C I64] = TagId(1) Str.296; + ret Str.295; else - let Str.291 : {} = Struct {}; - let Str.290 : [C {}, C I64] = TagId(0) Str.291; - ret Str.290; + let Str.293 : {} = Struct {}; + let Str.292 : [C {}, C I64] = TagId(0) Str.293; + ret Str.292; -procedure Str.9 (Str.79): - let Str.306 : U64 = 0i64; - let Str.307 : U64 = CallByName List.6 Str.79; - let Str.80 : {U64, Str, Int1, U8} = CallByName Str.48 Str.79 Str.306 Str.307; - let Str.303 : Int1 = StructAtIndex 2 Str.80; - if Str.303 then - let Str.305 : Str = StructAtIndex 1 Str.80; - let Str.304 : [C {U64, U8}, C Str] = TagId(1) Str.305; - ret Str.304; +procedure Str.9 (Str.80): + let Str.308 : U64 = 0i64; + let Str.309 : U64 = CallByName List.6 Str.80; + let Str.81 : {U64, Str, Int1, U8} = CallByName Str.48 Str.80 Str.308 Str.309; + let Str.305 : Int1 = StructAtIndex 2 Str.81; + if Str.305 then + let Str.307 : Str = StructAtIndex 1 Str.81; + let Str.306 : [C {U64, U8}, C Str] = TagId(1) Str.307; + ret Str.306; else - let Str.301 : U8 = StructAtIndex 3 Str.80; - let Str.302 : U64 = StructAtIndex 0 Str.80; - let #Derived_gen.7 : Str = StructAtIndex 1 Str.80; + let Str.303 : U8 = StructAtIndex 3 Str.81; + let Str.304 : U64 = StructAtIndex 0 Str.81; + let #Derived_gen.7 : Str = StructAtIndex 1 Str.81; dec #Derived_gen.7; - let Str.300 : {U64, U8} = Struct {Str.302, Str.301}; - let Str.299 : [C {U64, U8}, C Str] = TagId(0) Str.300; - ret Str.299; + let Str.302 : {U64, U8} = Struct {Str.304, Str.303}; + let Str.301 : [C {U64, U8}, C Str] = TagId(0) Str.302; + ret Str.301; procedure Test.0 (): let Test.37 : Str = "-1234"; diff --git a/crates/compiler/test_mono/generated/layout_cache_structure_with_multiple_recursive_structures.txt b/crates/compiler/test_mono/generated/layout_cache_structure_with_multiple_recursive_structures.txt index d94a1b57be..3d9194e4d5 100644 --- a/crates/compiler/test_mono/generated/layout_cache_structure_with_multiple_recursive_structures.txt +++ b/crates/compiler/test_mono/generated/layout_cache_structure_with_multiple_recursive_structures.txt @@ -1,49 +1,53 @@ -procedure List.145 (List.146, List.147, List.144): - let List.540 : [, C {[C *self, ], *self}] = CallByName Test.7 List.146 List.147; - ret List.540; +procedure List.147 (List.148, List.149, List.146): + let List.546 : [, C {[C *self, ], *self}] = CallByName Test.7 List.148 List.149; + ret List.546; -procedure List.18 (List.142, List.143, List.144): - let List.521 : [, C {[C *self, ], *self}] = CallByName List.93 List.142 List.143 List.144; - ret List.521; +procedure List.18 (List.144, List.145, List.146): + let List.526 : [, C {[C *self, ], *self}] = CallByName List.93 List.144 List.145 List.146; + ret List.526; procedure List.6 (#Attr.2): - let List.538 : U64 = lowlevel ListLen #Attr.2; - ret List.538; + let List.544 : U64 = lowlevel ListLen #Attr.2; + ret List.544; procedure List.66 (#Attr.2, #Attr.3): - let List.537 : [C *self, ] = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.537; + let List.543 : [C *self, ] = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.543; procedure List.80 (#Derived_gen.0, #Derived_gen.1, #Derived_gen.2, #Derived_gen.3, #Derived_gen.4): - joinpoint List.527 List.439 List.440 List.441 List.442 List.443: - let List.529 : Int1 = CallByName Num.22 List.442 List.443; - if List.529 then - let List.536 : [C *self, ] = CallByName List.66 List.439 List.442; - inc List.536; - let List.530 : [, C {[C *self, ], *self}] = CallByName List.145 List.440 List.536 List.441; - let List.533 : U64 = 1i64; - let List.532 : U64 = CallByName Num.19 List.442 List.533; - jump List.527 List.439 List.530 List.441 List.532 List.443; + joinpoint List.532 List.442 List.443 List.444 List.445 List.446: + let List.534 : Int1 = CallByName Num.22 List.445 List.446; + if List.534 then + let List.542 : [C *self, ] = CallByName List.66 List.442 List.445; + inc List.542; + let List.535 : [, C {[C *self, ], *self}] = CallByName List.147 List.443 List.542 List.444; + let List.537 : U64 = CallByName List.96 List.445; + jump List.532 List.442 List.535 List.444 List.537 List.446; else - dec List.439; - ret List.440; + dec List.442; + ret List.443; in - jump List.527 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4; + jump List.532 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4; -procedure List.93 (List.436, List.437, List.438): - let List.525 : U64 = 0i64; - let List.526 : U64 = CallByName List.6 List.436; - let List.524 : [, C {[C *self, ], *self}] = CallByName List.80 List.436 List.437 List.438 List.525 List.526; - ret List.524; +procedure List.93 (List.439, List.440, List.441): + let List.530 : U64 = 0i64; + let List.531 : U64 = CallByName List.6 List.439; + let List.529 : [, C {[C *self, ], *self}] = CallByName List.80 List.439 List.440 List.441 List.530 List.531; + ret List.529; -procedure Num.19 (#Attr.2, #Attr.3): - let Num.292 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.292; +procedure List.96 (List.463): + let List.539 : U64 = 1i64; + let List.538 : U64 = CallByName Num.51 List.463 List.539; + ret List.538; procedure Num.22 (#Attr.2, #Attr.3): let Num.293 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; ret Num.293; +procedure Num.51 (#Attr.2, #Attr.3): + let Num.292 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; + ret Num.292; + procedure Test.7 (Test.11, Test.12): let Test.17 : {[C *self, ], [, C {[C *self, ], *self}]} = Struct {Test.12, Test.11}; let Test.16 : [, C {[C *self, ], *self}] = TagId(0) Test.17; diff --git a/crates/compiler/test_mono/generated/list_append.txt b/crates/compiler/test_mono/generated/list_append.txt index e13262740b..e710310e16 100644 --- a/crates/compiler/test_mono/generated/list_append.txt +++ b/crates/compiler/test_mono/generated/list_append.txt @@ -1,16 +1,16 @@ -procedure List.4 (List.113, List.114): - let List.524 : U64 = 1i64; - let List.522 : List I64 = CallByName List.70 List.113 List.524; - let List.521 : List I64 = CallByName List.71 List.522 List.114; - ret List.521; +procedure List.4 (List.115, List.116): + let List.529 : U64 = 1i64; + let List.527 : List I64 = CallByName List.70 List.115 List.529; + let List.526 : List I64 = CallByName List.71 List.527 List.116; + ret List.526; procedure List.70 (#Attr.2, #Attr.3): - let List.525 : List I64 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.525; + let List.530 : List I64 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.530; procedure List.71 (#Attr.2, #Attr.3): - let List.523 : List I64 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.523; + let List.528 : List I64 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.528; procedure Test.0 (): let Test.2 : List I64 = Array [1i64]; diff --git a/crates/compiler/test_mono/generated/list_append_closure.txt b/crates/compiler/test_mono/generated/list_append_closure.txt index e61910787a..2c6b4360d5 100644 --- a/crates/compiler/test_mono/generated/list_append_closure.txt +++ b/crates/compiler/test_mono/generated/list_append_closure.txt @@ -1,16 +1,16 @@ -procedure List.4 (List.113, List.114): - let List.524 : U64 = 1i64; - let List.522 : List I64 = CallByName List.70 List.113 List.524; - let List.521 : List I64 = CallByName List.71 List.522 List.114; - ret List.521; +procedure List.4 (List.115, List.116): + let List.529 : U64 = 1i64; + let List.527 : List I64 = CallByName List.70 List.115 List.529; + let List.526 : List I64 = CallByName List.71 List.527 List.116; + ret List.526; procedure List.70 (#Attr.2, #Attr.3): - let List.525 : List I64 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.525; + let List.530 : List I64 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.530; procedure List.71 (#Attr.2, #Attr.3): - let List.523 : List I64 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.523; + let List.528 : List I64 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.528; procedure Test.1 (Test.2): let Test.6 : I64 = 42i64; diff --git a/crates/compiler/test_mono/generated/list_cannot_update_inplace.txt b/crates/compiler/test_mono/generated/list_cannot_update_inplace.txt index feb8f2d3b7..59d57db5eb 100644 --- a/crates/compiler/test_mono/generated/list_cannot_update_inplace.txt +++ b/crates/compiler/test_mono/generated/list_cannot_update_inplace.txt @@ -1,25 +1,25 @@ -procedure List.3 (List.105, List.106, List.107): - let List.524 : {List I64, I64} = CallByName List.64 List.105 List.106 List.107; - let List.523 : List I64 = StructAtIndex 0 List.524; - ret List.523; +procedure List.3 (List.107, List.108, List.109): + let List.529 : {List I64, I64} = CallByName List.64 List.107 List.108 List.109; + let List.528 : List I64 = StructAtIndex 0 List.529; + ret List.528; procedure List.6 (#Attr.2): - let List.522 : U64 = lowlevel ListLen #Attr.2; - ret List.522; + let List.527 : U64 = lowlevel ListLen #Attr.2; + ret List.527; -procedure List.64 (List.102, List.103, List.104): - let List.529 : U64 = CallByName List.6 List.102; - let List.526 : Int1 = CallByName Num.22 List.103 List.529; - if List.526 then - let List.527 : {List I64, I64} = CallByName List.67 List.102 List.103 List.104; - ret List.527; +procedure List.64 (List.104, List.105, List.106): + let List.534 : U64 = CallByName List.6 List.104; + let List.531 : Int1 = CallByName Num.22 List.105 List.534; + if List.531 then + let List.532 : {List I64, I64} = CallByName List.67 List.104 List.105 List.106; + ret List.532; else - let List.525 : {List I64, I64} = Struct {List.102, List.104}; - ret List.525; + let List.530 : {List I64, I64} = Struct {List.104, List.106}; + ret List.530; procedure List.67 (#Attr.2, #Attr.3, #Attr.4): - let List.528 : {List I64, I64} = lowlevel ListReplaceUnsafe #Attr.2 #Attr.3 #Attr.4; - ret List.528; + let List.533 : {List I64, I64} = lowlevel ListReplaceUnsafe #Attr.2 #Attr.3 #Attr.4; + ret List.533; procedure Num.19 (#Attr.2, #Attr.3): let Num.292 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/list_get.txt b/crates/compiler/test_mono/generated/list_get.txt index 02404934e9..0098beac1b 100644 --- a/crates/compiler/test_mono/generated/list_get.txt +++ b/crates/compiler/test_mono/generated/list_get.txt @@ -1,24 +1,24 @@ -procedure List.2 (List.97, List.98): - let List.527 : U64 = CallByName List.6 List.97; - let List.523 : Int1 = CallByName Num.22 List.98 List.527; - if List.523 then - let List.525 : I64 = CallByName List.66 List.97 List.98; - dec List.97; - let List.524 : [C {}, C I64] = TagId(1) List.525; - ret List.524; +procedure List.2 (List.99, List.100): + let List.532 : U64 = CallByName List.6 List.99; + let List.528 : Int1 = CallByName Num.22 List.100 List.532; + if List.528 then + let List.530 : I64 = CallByName List.66 List.99 List.100; + dec List.99; + let List.529 : [C {}, C I64] = TagId(1) List.530; + ret List.529; else - dec List.97; - let List.522 : {} = Struct {}; - let List.521 : [C {}, C I64] = TagId(0) List.522; - ret List.521; + dec List.99; + let List.527 : {} = Struct {}; + let List.526 : [C {}, C I64] = TagId(0) List.527; + ret List.526; procedure List.6 (#Attr.2): - let List.528 : U64 = lowlevel ListLen #Attr.2; - ret List.528; + let List.533 : U64 = lowlevel ListLen #Attr.2; + ret List.533; procedure List.66 (#Attr.2, #Attr.3): - let List.526 : I64 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.526; + let List.531 : I64 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.531; procedure Num.22 (#Attr.2, #Attr.3): let Num.292 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/list_len.txt b/crates/compiler/test_mono/generated/list_len.txt index 9691dc2b48..308a475770 100644 --- a/crates/compiler/test_mono/generated/list_len.txt +++ b/crates/compiler/test_mono/generated/list_len.txt @@ -1,10 +1,10 @@ procedure List.6 (#Attr.2): - let List.521 : U64 = lowlevel ListLen #Attr.2; - ret List.521; + let List.526 : U64 = lowlevel ListLen #Attr.2; + ret List.526; procedure List.6 (#Attr.2): - let List.522 : U64 = lowlevel ListLen #Attr.2; - ret List.522; + let List.527 : U64 = lowlevel ListLen #Attr.2; + ret List.527; procedure Num.19 (#Attr.2, #Attr.3): let Num.292 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/list_map_closure_borrows.txt b/crates/compiler/test_mono/generated/list_map_closure_borrows.txt index c5d65f94a7..6a074e2669 100644 --- a/crates/compiler/test_mono/generated/list_map_closure_borrows.txt +++ b/crates/compiler/test_mono/generated/list_map_closure_borrows.txt @@ -1,42 +1,42 @@ -procedure List.2 (List.97, List.98): - let List.527 : U64 = CallByName List.6 List.97; - let List.523 : Int1 = CallByName Num.22 List.98 List.527; - if List.523 then - let List.525 : Str = CallByName List.66 List.97 List.98; - inc List.525; - dec List.97; - let List.524 : [C {}, C Str] = TagId(1) List.525; - ret List.524; +procedure List.2 (List.99, List.100): + let List.532 : U64 = CallByName List.6 List.99; + let List.528 : Int1 = CallByName Num.22 List.100 List.532; + if List.528 then + let List.530 : Str = CallByName List.66 List.99 List.100; + inc List.530; + dec List.99; + let List.529 : [C {}, C Str] = TagId(1) List.530; + ret List.529; else - dec List.97; - let List.522 : {} = Struct {}; - let List.521 : [C {}, C Str] = TagId(0) List.522; - ret List.521; + dec List.99; + let List.527 : {} = Struct {}; + let List.526 : [C {}, C Str] = TagId(0) List.527; + ret List.526; procedure List.5 (#Attr.2, #Attr.3): - let List.529 : List Str = lowlevel ListMap { xs: `#Attr.#arg1` } #Attr.2 Test.3 #Attr.3; + let List.534 : List Str = lowlevel ListMap { xs: `#Attr.#arg1` } #Attr.2 Test.3 #Attr.3; decref #Attr.2; - ret List.529; + ret List.534; procedure List.6 (#Attr.2): - let List.528 : U64 = lowlevel ListLen #Attr.2; - ret List.528; + let List.533 : U64 = lowlevel ListLen #Attr.2; + ret List.533; procedure List.66 (#Attr.2, #Attr.3): - let List.526 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.526; + let List.531 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.531; procedure Num.22 (#Attr.2, #Attr.3): let Num.292 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; ret Num.292; procedure Str.16 (#Attr.2, #Attr.3): - let Str.289 : Str = lowlevel StrRepeat #Attr.2 #Attr.3; - ret Str.289; + let Str.291 : Str = lowlevel StrRepeat #Attr.2 #Attr.3; + ret Str.291; procedure Str.3 (#Attr.2, #Attr.3): - let Str.290 : Str = lowlevel StrConcat #Attr.2 #Attr.3; - ret Str.290; + let Str.292 : Str = lowlevel StrConcat #Attr.2 #Attr.3; + ret Str.292; procedure Test.1 (): let Test.21 : Str = "lllllllllllllllllllllooooooooooong"; diff --git a/crates/compiler/test_mono/generated/list_map_closure_owns.txt b/crates/compiler/test_mono/generated/list_map_closure_owns.txt index a384497df2..956a6c7e76 100644 --- a/crates/compiler/test_mono/generated/list_map_closure_owns.txt +++ b/crates/compiler/test_mono/generated/list_map_closure_owns.txt @@ -1,38 +1,38 @@ -procedure List.2 (List.97, List.98): - let List.527 : U64 = CallByName List.6 List.97; - let List.523 : Int1 = CallByName Num.22 List.98 List.527; - if List.523 then - let List.525 : Str = CallByName List.66 List.97 List.98; - inc List.525; - dec List.97; - let List.524 : [C {}, C Str] = TagId(1) List.525; - ret List.524; +procedure List.2 (List.99, List.100): + let List.532 : U64 = CallByName List.6 List.99; + let List.528 : Int1 = CallByName Num.22 List.100 List.532; + if List.528 then + let List.530 : Str = CallByName List.66 List.99 List.100; + inc List.530; + dec List.99; + let List.529 : [C {}, C Str] = TagId(1) List.530; + ret List.529; else - dec List.97; - let List.522 : {} = Struct {}; - let List.521 : [C {}, C Str] = TagId(0) List.522; - ret List.521; + dec List.99; + let List.527 : {} = Struct {}; + let List.526 : [C {}, C Str] = TagId(0) List.527; + ret List.526; procedure List.5 (#Attr.2, #Attr.3): - let List.529 : List Str = lowlevel ListMap { xs: `#Attr.#arg1` } #Attr.2 Test.3 #Attr.3; + let List.534 : List Str = lowlevel ListMap { xs: `#Attr.#arg1` } #Attr.2 Test.3 #Attr.3; decref #Attr.2; - ret List.529; + ret List.534; procedure List.6 (#Attr.2): - let List.528 : U64 = lowlevel ListLen #Attr.2; - ret List.528; + let List.533 : U64 = lowlevel ListLen #Attr.2; + ret List.533; procedure List.66 (#Attr.2, #Attr.3): - let List.526 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.526; + let List.531 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.531; procedure Num.22 (#Attr.2, #Attr.3): let Num.292 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; ret Num.292; procedure Str.3 (#Attr.2, #Attr.3): - let Str.290 : Str = lowlevel StrConcat #Attr.2 #Attr.3; - ret Str.290; + let Str.292 : Str = lowlevel StrConcat #Attr.2 #Attr.3; + ret Str.292; procedure Test.1 (): let Test.21 : Str = "lllllllllllllllllllllooooooooooong"; diff --git a/crates/compiler/test_mono/generated/list_map_take_capturing_or_noncapturing.txt b/crates/compiler/test_mono/generated/list_map_take_capturing_or_noncapturing.txt index 6054fd9062..513956b5b0 100644 --- a/crates/compiler/test_mono/generated/list_map_take_capturing_or_noncapturing.txt +++ b/crates/compiler/test_mono/generated/list_map_take_capturing_or_noncapturing.txt @@ -1,23 +1,23 @@ procedure List.5 (#Attr.2, #Attr.3): - let List.522 : U8 = GetTagId #Attr.3; - joinpoint List.523 List.521: - ret List.521; + let List.527 : U8 = GetTagId #Attr.3; + joinpoint List.528 List.526: + ret List.526; in - switch List.522: + switch List.527: case 0: - let List.524 : List U8 = lowlevel ListMap { xs: `#Attr.#arg1` } #Attr.2 Test.4 #Attr.3; + let List.529 : List U8 = lowlevel ListMap { xs: `#Attr.#arg1` } #Attr.2 Test.4 #Attr.3; decref #Attr.2; - jump List.523 List.524; + jump List.528 List.529; case 1: - let List.525 : List U8 = lowlevel ListMap { xs: `#Attr.#arg1` } #Attr.2 Test.6 #Attr.3; + let List.530 : List U8 = lowlevel ListMap { xs: `#Attr.#arg1` } #Attr.2 Test.6 #Attr.3; decref #Attr.2; - jump List.523 List.525; + jump List.528 List.530; default: - let List.526 : List U8 = lowlevel ListMap { xs: `#Attr.#arg1` } #Attr.2 Test.8 #Attr.3; + let List.531 : List U8 = lowlevel ListMap { xs: `#Attr.#arg1` } #Attr.2 Test.8 #Attr.3; decref #Attr.2; - jump List.523 List.526; + jump List.528 List.531; procedure Num.19 (#Attr.2, #Attr.3): diff --git a/crates/compiler/test_mono/generated/list_pass_to_function.txt b/crates/compiler/test_mono/generated/list_pass_to_function.txt index e2b7c8a453..07b42d5d6c 100644 --- a/crates/compiler/test_mono/generated/list_pass_to_function.txt +++ b/crates/compiler/test_mono/generated/list_pass_to_function.txt @@ -1,25 +1,25 @@ -procedure List.3 (List.105, List.106, List.107): - let List.522 : {List I64, I64} = CallByName List.64 List.105 List.106 List.107; - let List.521 : List I64 = StructAtIndex 0 List.522; - ret List.521; +procedure List.3 (List.107, List.108, List.109): + let List.527 : {List I64, I64} = CallByName List.64 List.107 List.108 List.109; + let List.526 : List I64 = StructAtIndex 0 List.527; + ret List.526; procedure List.6 (#Attr.2): - let List.528 : U64 = lowlevel ListLen #Attr.2; - ret List.528; + let List.533 : U64 = lowlevel ListLen #Attr.2; + ret List.533; -procedure List.64 (List.102, List.103, List.104): - let List.527 : U64 = CallByName List.6 List.102; - let List.524 : Int1 = CallByName Num.22 List.103 List.527; - if List.524 then - let List.525 : {List I64, I64} = CallByName List.67 List.102 List.103 List.104; - ret List.525; +procedure List.64 (List.104, List.105, List.106): + let List.532 : U64 = CallByName List.6 List.104; + let List.529 : Int1 = CallByName Num.22 List.105 List.532; + if List.529 then + let List.530 : {List I64, I64} = CallByName List.67 List.104 List.105 List.106; + ret List.530; else - let List.523 : {List I64, I64} = Struct {List.102, List.104}; - ret List.523; + let List.528 : {List I64, I64} = Struct {List.104, List.106}; + ret List.528; procedure List.67 (#Attr.2, #Attr.3, #Attr.4): - let List.526 : {List I64, I64} = lowlevel ListReplaceUnsafe #Attr.2 #Attr.3 #Attr.4; - ret List.526; + let List.531 : {List I64, I64} = lowlevel ListReplaceUnsafe #Attr.2 #Attr.3 #Attr.4; + ret List.531; procedure Num.22 (#Attr.2, #Attr.3): let Num.292 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/list_sort_asc.txt b/crates/compiler/test_mono/generated/list_sort_asc.txt index 92a0c599c1..974d7f357f 100644 --- a/crates/compiler/test_mono/generated/list_sort_asc.txt +++ b/crates/compiler/test_mono/generated/list_sort_asc.txt @@ -1,11 +1,11 @@ procedure List.28 (#Attr.2, #Attr.3): - let List.523 : List I64 = lowlevel ListSortWith { xs: `#Attr.#arg1` } #Attr.2 Num.46 #Attr.3; - ret List.523; + let List.528 : List I64 = lowlevel ListSortWith { xs: `#Attr.#arg1` } #Attr.2 Num.46 #Attr.3; + ret List.528; -procedure List.59 (List.288): - let List.522 : {} = Struct {}; - let List.521 : List I64 = CallByName List.28 List.288 List.522; - ret List.521; +procedure List.59 (List.290): + let List.527 : {} = Struct {}; + let List.526 : List I64 = CallByName List.28 List.290 List.527; + ret List.526; procedure Num.46 (#Attr.2, #Attr.3): let Num.292 : U8 = lowlevel NumCompare #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/polymorphic_expression_unification.txt b/crates/compiler/test_mono/generated/polymorphic_expression_unification.txt index 6e6d11abec..ce2daa3f29 100644 --- a/crates/compiler/test_mono/generated/polymorphic_expression_unification.txt +++ b/crates/compiler/test_mono/generated/polymorphic_expression_unification.txt @@ -3,8 +3,8 @@ procedure Bool.11 (#Attr.2, #Attr.3): ret Bool.23; procedure Str.3 (#Attr.2, #Attr.3): - let Str.290 : Str = lowlevel StrConcat #Attr.2 #Attr.3; - ret Str.290; + let Str.292 : Str = lowlevel StrConcat #Attr.2 #Attr.3; + ret Str.292; procedure Test.2 (Test.7): let Test.24 : Str = ".trace(\""; diff --git a/crates/compiler/test_mono/generated/quicksort_swap.txt b/crates/compiler/test_mono/generated/quicksort_swap.txt index b592bcc4e6..3c7f411048 100644 --- a/crates/compiler/test_mono/generated/quicksort_swap.txt +++ b/crates/compiler/test_mono/generated/quicksort_swap.txt @@ -1,43 +1,43 @@ -procedure List.2 (List.97, List.98): - let List.543 : U64 = CallByName List.6 List.97; - let List.540 : Int1 = CallByName Num.22 List.98 List.543; - if List.540 then - let List.542 : I64 = CallByName List.66 List.97 List.98; - dec List.97; - let List.541 : [C {}, C I64] = TagId(1) List.542; - ret List.541; +procedure List.2 (List.99, List.100): + let List.548 : U64 = CallByName List.6 List.99; + let List.545 : Int1 = CallByName Num.22 List.100 List.548; + if List.545 then + let List.547 : I64 = CallByName List.66 List.99 List.100; + dec List.99; + let List.546 : [C {}, C I64] = TagId(1) List.547; + ret List.546; else - dec List.97; - let List.539 : {} = Struct {}; - let List.538 : [C {}, C I64] = TagId(0) List.539; - ret List.538; + dec List.99; + let List.544 : {} = Struct {}; + let List.543 : [C {}, C I64] = TagId(0) List.544; + ret List.543; -procedure List.3 (List.105, List.106, List.107): - let List.530 : {List I64, I64} = CallByName List.64 List.105 List.106 List.107; - let List.529 : List I64 = StructAtIndex 0 List.530; - ret List.529; +procedure List.3 (List.107, List.108, List.109): + let List.535 : {List I64, I64} = CallByName List.64 List.107 List.108 List.109; + let List.534 : List I64 = StructAtIndex 0 List.535; + ret List.534; procedure List.6 (#Attr.2): - let List.528 : U64 = lowlevel ListLen #Attr.2; - ret List.528; + let List.533 : U64 = lowlevel ListLen #Attr.2; + ret List.533; -procedure List.64 (List.102, List.103, List.104): - let List.527 : U64 = CallByName List.6 List.102; - let List.524 : Int1 = CallByName Num.22 List.103 List.527; - if List.524 then - let List.525 : {List I64, I64} = CallByName List.67 List.102 List.103 List.104; - ret List.525; +procedure List.64 (List.104, List.105, List.106): + let List.532 : U64 = CallByName List.6 List.104; + let List.529 : Int1 = CallByName Num.22 List.105 List.532; + if List.529 then + let List.530 : {List I64, I64} = CallByName List.67 List.104 List.105 List.106; + ret List.530; else - let List.523 : {List I64, I64} = Struct {List.102, List.104}; - ret List.523; + let List.528 : {List I64, I64} = Struct {List.104, List.106}; + ret List.528; procedure List.66 (#Attr.2, #Attr.3): - let List.536 : I64 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.536; + let List.541 : I64 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.541; procedure List.67 (#Attr.2, #Attr.3, #Attr.4): - let List.526 : {List I64, I64} = lowlevel ListReplaceUnsafe #Attr.2 #Attr.3 #Attr.4; - ret List.526; + let List.531 : {List I64, I64} = lowlevel ListReplaceUnsafe #Attr.2 #Attr.3 #Attr.4; + ret List.531; procedure Num.22 (#Attr.2, #Attr.3): let Num.294 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/record_update.txt b/crates/compiler/test_mono/generated/record_update.txt index e5b9598325..863b63e41c 100644 --- a/crates/compiler/test_mono/generated/record_update.txt +++ b/crates/compiler/test_mono/generated/record_update.txt @@ -1,25 +1,25 @@ -procedure List.3 (List.105, List.106, List.107): - let List.530 : {List U64, U64} = CallByName List.64 List.105 List.106 List.107; - let List.529 : List U64 = StructAtIndex 0 List.530; - ret List.529; +procedure List.3 (List.107, List.108, List.109): + let List.535 : {List U64, U64} = CallByName List.64 List.107 List.108 List.109; + let List.534 : List U64 = StructAtIndex 0 List.535; + ret List.534; procedure List.6 (#Attr.2): - let List.528 : U64 = lowlevel ListLen #Attr.2; - ret List.528; + let List.533 : U64 = lowlevel ListLen #Attr.2; + ret List.533; -procedure List.64 (List.102, List.103, List.104): - let List.527 : U64 = CallByName List.6 List.102; - let List.524 : Int1 = CallByName Num.22 List.103 List.527; - if List.524 then - let List.525 : {List U64, U64} = CallByName List.67 List.102 List.103 List.104; - ret List.525; +procedure List.64 (List.104, List.105, List.106): + let List.532 : U64 = CallByName List.6 List.104; + let List.529 : Int1 = CallByName Num.22 List.105 List.532; + if List.529 then + let List.530 : {List U64, U64} = CallByName List.67 List.104 List.105 List.106; + ret List.530; else - let List.523 : {List U64, U64} = Struct {List.102, List.104}; - ret List.523; + let List.528 : {List U64, U64} = Struct {List.104, List.106}; + ret List.528; procedure List.67 (#Attr.2, #Attr.3, #Attr.4): - let List.526 : {List U64, U64} = lowlevel ListReplaceUnsafe #Attr.2 #Attr.3 #Attr.4; - ret List.526; + let List.531 : {List U64, U64} = lowlevel ListReplaceUnsafe #Attr.2 #Attr.3 #Attr.4; + ret List.531; procedure Num.22 (#Attr.2, #Attr.3): let Num.292 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/recursive_function_and_union_with_inference_hole.txt b/crates/compiler/test_mono/generated/recursive_function_and_union_with_inference_hole.txt index 2e772fba51..22d1fc88c4 100644 --- a/crates/compiler/test_mono/generated/recursive_function_and_union_with_inference_hole.txt +++ b/crates/compiler/test_mono/generated/recursive_function_and_union_with_inference_hole.txt @@ -1,7 +1,7 @@ procedure List.5 (#Attr.2, #Attr.3): - let List.521 : List [C List *self] = lowlevel ListMap { xs: `#Attr.#arg1` } #Attr.2 Test.2 #Attr.3; + let List.526 : List [C List *self] = lowlevel ListMap { xs: `#Attr.#arg1` } #Attr.2 Test.2 #Attr.3; decref #Attr.2; - ret List.521; + ret List.526; procedure Test.2 (Test.5): let Test.6 : List [C List *self] = UnionAtIndex (Id 0) (Index 0) Test.5; diff --git a/crates/compiler/test_mono/generated/recursively_build_effect.txt b/crates/compiler/test_mono/generated/recursively_build_effect.txt index cac652954a..ad5154b2d9 100644 --- a/crates/compiler/test_mono/generated/recursively_build_effect.txt +++ b/crates/compiler/test_mono/generated/recursively_build_effect.txt @@ -3,8 +3,8 @@ procedure Num.20 (#Attr.2, #Attr.3): ret Num.292; procedure Str.3 (#Attr.2, #Attr.3): - let Str.291 : Str = lowlevel StrConcat #Attr.2 #Attr.3; - ret Str.291; + let Str.293 : Str = lowlevel StrConcat #Attr.2 #Attr.3; + ret Str.293; procedure Test.11 (Test.29, #Attr.12): let Test.10 : {} = UnionAtIndex (Id 0) (Index 0) #Attr.12; diff --git a/crates/compiler/test_mono/generated/rigids.txt b/crates/compiler/test_mono/generated/rigids.txt index 5ba8e329d0..4a5367feb3 100644 --- a/crates/compiler/test_mono/generated/rigids.txt +++ b/crates/compiler/test_mono/generated/rigids.txt @@ -1,43 +1,43 @@ -procedure List.2 (List.97, List.98): - let List.543 : U64 = CallByName List.6 List.97; - let List.540 : Int1 = CallByName Num.22 List.98 List.543; - if List.540 then - let List.542 : I64 = CallByName List.66 List.97 List.98; - dec List.97; - let List.541 : [C {}, C I64] = TagId(1) List.542; - ret List.541; +procedure List.2 (List.99, List.100): + let List.548 : U64 = CallByName List.6 List.99; + let List.545 : Int1 = CallByName Num.22 List.100 List.548; + if List.545 then + let List.547 : I64 = CallByName List.66 List.99 List.100; + dec List.99; + let List.546 : [C {}, C I64] = TagId(1) List.547; + ret List.546; else - dec List.97; - let List.539 : {} = Struct {}; - let List.538 : [C {}, C I64] = TagId(0) List.539; - ret List.538; + dec List.99; + let List.544 : {} = Struct {}; + let List.543 : [C {}, C I64] = TagId(0) List.544; + ret List.543; -procedure List.3 (List.105, List.106, List.107): - let List.530 : {List I64, I64} = CallByName List.64 List.105 List.106 List.107; - let List.529 : List I64 = StructAtIndex 0 List.530; - ret List.529; +procedure List.3 (List.107, List.108, List.109): + let List.535 : {List I64, I64} = CallByName List.64 List.107 List.108 List.109; + let List.534 : List I64 = StructAtIndex 0 List.535; + ret List.534; procedure List.6 (#Attr.2): - let List.528 : U64 = lowlevel ListLen #Attr.2; - ret List.528; + let List.533 : U64 = lowlevel ListLen #Attr.2; + ret List.533; -procedure List.64 (List.102, List.103, List.104): - let List.527 : U64 = CallByName List.6 List.102; - let List.524 : Int1 = CallByName Num.22 List.103 List.527; - if List.524 then - let List.525 : {List I64, I64} = CallByName List.67 List.102 List.103 List.104; - ret List.525; +procedure List.64 (List.104, List.105, List.106): + let List.532 : U64 = CallByName List.6 List.104; + let List.529 : Int1 = CallByName Num.22 List.105 List.532; + if List.529 then + let List.530 : {List I64, I64} = CallByName List.67 List.104 List.105 List.106; + ret List.530; else - let List.523 : {List I64, I64} = Struct {List.102, List.104}; - ret List.523; + let List.528 : {List I64, I64} = Struct {List.104, List.106}; + ret List.528; procedure List.66 (#Attr.2, #Attr.3): - let List.536 : I64 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.536; + let List.541 : I64 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.541; procedure List.67 (#Attr.2, #Attr.3, #Attr.4): - let List.526 : {List I64, I64} = lowlevel ListReplaceUnsafe #Attr.2 #Attr.3 #Attr.4; - ret List.526; + let List.531 : {List I64, I64} = lowlevel ListReplaceUnsafe #Attr.2 #Attr.3 #Attr.4; + ret List.531; procedure Num.22 (#Attr.2, #Attr.3): let Num.294 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/unspecialized_lambda_set_unification_does_not_duplicate_identical_concrete_types.txt b/crates/compiler/test_mono/generated/unspecialized_lambda_set_unification_does_not_duplicate_identical_concrete_types.txt index ebeec28457..c39e2964ad 100644 --- a/crates/compiler/test_mono/generated/unspecialized_lambda_set_unification_does_not_duplicate_identical_concrete_types.txt +++ b/crates/compiler/test_mono/generated/unspecialized_lambda_set_unification_does_not_duplicate_identical_concrete_types.txt @@ -33,215 +33,225 @@ procedure Encode.26 (Encode.105, Encode.106): let Encode.108 : List U8 = CallByName Encode.24 Encode.109 Encode.110 Encode.106; ret Encode.108; -procedure List.145 (List.146, List.147, List.144): - let List.566 : {List U8, U64} = CallByName TotallyNotJson.267 List.146 List.147 List.144; - ret List.566; +procedure List.147 (List.148, List.149, List.146): + let List.572 : {List U8, U64} = CallByName TotallyNotJson.267 List.148 List.149 List.146; + ret List.572; -procedure List.145 (List.146, List.147, List.144): - let List.586 : List U8 = CallByName TotallyNotJson.215 List.146 List.147; - ret List.586; +procedure List.147 (List.148, List.149, List.146): + let List.591 : List U8 = CallByName TotallyNotJson.215 List.148 List.149; + ret List.591; -procedure List.18 (List.142, List.143, List.144): - let List.547 : {List U8, U64} = CallByName List.93 List.142 List.143 List.144; - ret List.547; +procedure List.18 (List.144, List.145, List.146): + let List.552 : {List U8, U64} = CallByName List.93 List.144 List.145 List.146; + ret List.552; -procedure List.18 (List.142, List.143, List.144): - let List.567 : List U8 = CallByName List.93 List.142 List.143 List.144; - ret List.567; +procedure List.18 (List.144, List.145, List.146): + let List.573 : List U8 = CallByName List.93 List.144 List.145 List.146; + ret List.573; -procedure List.26 (List.159, List.160, List.161): - let List.617 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.93 List.159 List.160 List.161; - let List.620 : U8 = 1i64; - let List.621 : U8 = GetTagId List.617; - let List.622 : Int1 = lowlevel Eq List.620 List.621; - if List.622 then - let List.162 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.617; - ret List.162; +procedure List.26 (List.161, List.162, List.163): + let List.622 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.93 List.161 List.162 List.163; + let List.625 : U8 = 1i64; + let List.626 : U8 = GetTagId List.622; + let List.627 : Int1 = lowlevel Eq List.625 List.626; + if List.627 then + let List.164 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.622; + ret List.164; else - let List.163 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.617; - ret List.163; + let List.165 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.622; + ret List.165; -procedure List.4 (List.113, List.114): - let List.546 : U64 = 1i64; - let List.545 : List U8 = CallByName List.70 List.113 List.546; - let List.544 : List U8 = CallByName List.71 List.545 List.114; - ret List.544; +procedure List.4 (List.115, List.116): + let List.551 : U64 = 1i64; + let List.550 : List U8 = CallByName List.70 List.115 List.551; + let List.549 : List U8 = CallByName List.71 List.550 List.116; + ret List.549; -procedure List.49 (List.376, List.377): - let List.609 : U64 = StructAtIndex 0 List.377; - let List.610 : U64 = 0i64; - let List.607 : Int1 = CallByName Bool.11 List.609 List.610; - if List.607 then - dec List.376; - let List.608 : List U8 = Array []; +procedure List.49 (List.379, List.380): + let List.614 : U64 = StructAtIndex 0 List.380; + let List.615 : U64 = 0i64; + let List.612 : Int1 = CallByName Bool.11 List.614 List.615; + if List.612 then + dec List.379; + let List.613 : List U8 = Array []; + ret List.613; + else + let List.609 : U64 = StructAtIndex 1 List.380; + let List.610 : U64 = StructAtIndex 0 List.380; + let List.608 : List U8 = CallByName List.72 List.379 List.609 List.610; ret List.608; - else - let List.604 : U64 = StructAtIndex 1 List.377; - let List.605 : U64 = StructAtIndex 0 List.377; - let List.603 : List U8 = CallByName List.72 List.376 List.604 List.605; - ret List.603; -procedure List.52 (List.391, List.392): - let List.393 : U64 = CallByName List.6 List.391; - joinpoint List.615 List.394: - let List.613 : U64 = 0i64; - let List.612 : {U64, U64} = Struct {List.394, List.613}; - inc List.391; - let List.395 : List U8 = CallByName List.49 List.391 List.612; - let List.611 : U64 = CallByName Num.20 List.393 List.394; - let List.602 : {U64, U64} = Struct {List.611, List.394}; - let List.396 : List U8 = CallByName List.49 List.391 List.602; - let List.601 : {List U8, List U8} = Struct {List.395, List.396}; - ret List.601; +procedure List.52 (List.394, List.395): + let List.396 : U64 = CallByName List.6 List.394; + joinpoint List.620 List.397: + let List.618 : U64 = 0i64; + let List.617 : {U64, U64} = Struct {List.397, List.618}; + inc List.394; + let List.398 : List U8 = CallByName List.49 List.394 List.617; + let List.616 : U64 = CallByName Num.75 List.396 List.397; + let List.607 : {U64, U64} = Struct {List.616, List.397}; + let List.399 : List U8 = CallByName List.49 List.394 List.607; + let List.606 : {List U8, List U8} = Struct {List.398, List.399}; + ret List.606; in - let List.616 : Int1 = CallByName Num.24 List.393 List.392; - if List.616 then - jump List.615 List.392; + let List.621 : Int1 = CallByName Num.24 List.396 List.395; + if List.621 then + jump List.620 List.395; else - jump List.615 List.393; + jump List.620 List.396; procedure List.6 (#Attr.2): - let List.587 : U64 = lowlevel ListLen #Attr.2; - ret List.587; + let List.592 : U64 = lowlevel ListLen #Attr.2; + ret List.592; procedure List.6 (#Attr.2): - let List.589 : U64 = lowlevel ListLen #Attr.2; - ret List.589; + let List.594 : U64 = lowlevel ListLen #Attr.2; + ret List.594; procedure List.66 (#Attr.2, #Attr.3): - let List.563 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.563; + let List.569 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.569; procedure List.66 (#Attr.2, #Attr.3): - let List.583 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.583; + let List.588 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.588; procedure List.68 (#Attr.2): - let List.600 : List U8 = lowlevel ListWithCapacity #Attr.2; - ret List.600; + let List.605 : List U8 = lowlevel ListWithCapacity #Attr.2; + ret List.605; procedure List.70 (#Attr.2, #Attr.3): - let List.525 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.525; + let List.530 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.530; procedure List.71 (#Attr.2, #Attr.3): - let List.523 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.523; + let List.528 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.528; procedure List.72 (#Attr.2, #Attr.3, #Attr.4): - let List.606 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; - ret List.606; + let List.611 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; + ret List.611; procedure List.8 (#Attr.2, #Attr.3): - let List.598 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; - ret List.598; + let List.603 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; + ret List.603; + +procedure List.80 (#Derived_gen.14, #Derived_gen.15, #Derived_gen.16, #Derived_gen.17, #Derived_gen.18): + joinpoint List.631 List.442 List.443 List.444 List.445 List.446: + let List.633 : Int1 = CallByName Num.22 List.445 List.446; + if List.633 then + let List.641 : U8 = CallByName List.66 List.442 List.445; + let List.634 : [C {U64, Int1}, C {U64, Int1}] = CallByName TotallyNotJson.189 List.443 List.641; + let List.638 : U8 = 1i64; + let List.639 : U8 = GetTagId List.634; + let List.640 : Int1 = lowlevel Eq List.638 List.639; + if List.640 then + let List.447 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.634; + let List.636 : U64 = CallByName List.96 List.445; + jump List.631 List.442 List.447 List.444 List.636 List.446; + else + dec List.442; + let List.448 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.634; + let List.637 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) List.448; + ret List.637; + else + dec List.442; + let List.632 : [C {U64, Int1}, C {U64, Int1}] = TagId(1) List.443; + ret List.632; + in + jump List.631 #Derived_gen.14 #Derived_gen.15 #Derived_gen.16 #Derived_gen.17 #Derived_gen.18; procedure List.80 (#Derived_gen.19, #Derived_gen.20, #Derived_gen.21, #Derived_gen.22, #Derived_gen.23): - joinpoint List.553 List.439 List.440 List.441 List.442 List.443: - let List.555 : Int1 = CallByName Num.22 List.442 List.443; - if List.555 then - let List.562 : Str = CallByName List.66 List.439 List.442; - inc List.562; - let List.556 : {List U8, U64} = CallByName List.145 List.440 List.562 List.441; - let List.559 : U64 = 1i64; - let List.558 : U64 = CallByName Num.19 List.442 List.559; - jump List.553 List.439 List.556 List.441 List.558 List.443; + joinpoint List.558 List.442 List.443 List.444 List.445 List.446: + let List.560 : Int1 = CallByName Num.22 List.445 List.446; + if List.560 then + let List.568 : Str = CallByName List.66 List.442 List.445; + inc List.568; + let List.561 : {List U8, U64} = CallByName List.147 List.443 List.568 List.444; + let List.563 : U64 = CallByName List.96 List.445; + jump List.558 List.442 List.561 List.444 List.563 List.446; else - dec List.439; - ret List.440; + dec List.442; + ret List.443; in - jump List.553 #Derived_gen.19 #Derived_gen.20 #Derived_gen.21 #Derived_gen.22 #Derived_gen.23; + jump List.558 #Derived_gen.19 #Derived_gen.20 #Derived_gen.21 #Derived_gen.22 #Derived_gen.23; -procedure List.80 (#Derived_gen.3, #Derived_gen.4, #Derived_gen.5, #Derived_gen.6, #Derived_gen.7): - joinpoint List.573 List.439 List.440 List.441 List.442 List.443: - let List.575 : Int1 = CallByName Num.22 List.442 List.443; - if List.575 then - let List.582 : U8 = CallByName List.66 List.439 List.442; - let List.576 : List U8 = CallByName List.145 List.440 List.582 List.441; - let List.579 : U64 = 1i64; - let List.578 : U64 = CallByName Num.19 List.442 List.579; - jump List.573 List.439 List.576 List.441 List.578 List.443; +procedure List.80 (#Derived_gen.9, #Derived_gen.10, #Derived_gen.11, #Derived_gen.12, #Derived_gen.13): + joinpoint List.579 List.442 List.443 List.444 List.445 List.446: + let List.581 : Int1 = CallByName Num.22 List.445 List.446; + if List.581 then + let List.587 : U8 = CallByName List.66 List.442 List.445; + let List.582 : List U8 = CallByName List.147 List.443 List.587 List.444; + let List.584 : U64 = CallByName List.96 List.445; + jump List.579 List.442 List.582 List.444 List.584 List.446; else - dec List.439; - ret List.440; + dec List.442; + ret List.443; in - jump List.573 #Derived_gen.3 #Derived_gen.4 #Derived_gen.5 #Derived_gen.6 #Derived_gen.7; + jump List.579 #Derived_gen.9 #Derived_gen.10 #Derived_gen.11 #Derived_gen.12 #Derived_gen.13; -procedure List.80 (#Derived_gen.8, #Derived_gen.9, #Derived_gen.10, #Derived_gen.11, #Derived_gen.12): - joinpoint List.626 List.439 List.440 List.441 List.442 List.443: - let List.628 : Int1 = CallByName Num.22 List.442 List.443; - if List.628 then - let List.637 : U8 = CallByName List.66 List.439 List.442; - let List.629 : [C {U64, Int1}, C {U64, Int1}] = CallByName TotallyNotJson.189 List.440 List.637; - let List.634 : U8 = 1i64; - let List.635 : U8 = GetTagId List.629; - let List.636 : Int1 = lowlevel Eq List.634 List.635; - if List.636 then - let List.444 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.629; - let List.632 : U64 = 1i64; - let List.631 : U64 = CallByName Num.19 List.442 List.632; - jump List.626 List.439 List.444 List.441 List.631 List.443; - else - dec List.439; - let List.445 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.629; - let List.633 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) List.445; - ret List.633; - else - dec List.439; - let List.627 : [C {U64, Int1}, C {U64, Int1}] = TagId(1) List.440; - ret List.627; - in - jump List.626 #Derived_gen.8 #Derived_gen.9 #Derived_gen.10 #Derived_gen.11 #Derived_gen.12; +procedure List.93 (List.439, List.440, List.441): + let List.556 : U64 = 0i64; + let List.557 : U64 = CallByName List.6 List.439; + let List.555 : {List U8, U64} = CallByName List.80 List.439 List.440 List.441 List.556 List.557; + ret List.555; -procedure List.93 (List.436, List.437, List.438): - let List.551 : U64 = 0i64; - let List.552 : U64 = CallByName List.6 List.436; - let List.550 : {List U8, U64} = CallByName List.80 List.436 List.437 List.438 List.551 List.552; - ret List.550; +procedure List.93 (List.439, List.440, List.441): + let List.577 : U64 = 0i64; + let List.578 : U64 = CallByName List.6 List.439; + let List.576 : List U8 = CallByName List.80 List.439 List.440 List.441 List.577 List.578; + ret List.576; -procedure List.93 (List.436, List.437, List.438): - let List.571 : U64 = 0i64; - let List.572 : U64 = CallByName List.6 List.436; - let List.570 : List U8 = CallByName List.80 List.436 List.437 List.438 List.571 List.572; - ret List.570; +procedure List.93 (List.439, List.440, List.441): + let List.629 : U64 = 0i64; + let List.630 : U64 = CallByName List.6 List.439; + let List.628 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.80 List.439 List.440 List.441 List.629 List.630; + ret List.628; -procedure List.93 (List.436, List.437, List.438): - let List.624 : U64 = 0i64; - let List.625 : U64 = CallByName List.6 List.436; - let List.623 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.80 List.436 List.437 List.438 List.624 List.625; - ret List.623; +procedure List.96 (List.463): + let List.565 : U64 = 1i64; + let List.564 : U64 = CallByName Num.51 List.463 List.565; + ret List.564; procedure Num.127 (#Attr.2): let Num.299 : U8 = lowlevel NumIntCast #Attr.2; ret Num.299; procedure Num.19 (#Attr.2, #Attr.3): - let Num.308 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.308; + let Num.303 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.303; procedure Num.20 (#Attr.2, #Attr.3): - let Num.312 : U64 = lowlevel NumSub #Attr.2 #Attr.3; - ret Num.312; + let Num.300 : U64 = lowlevel NumSub #Attr.2 #Attr.3; + ret Num.300; procedure Num.21 (#Attr.2, #Attr.3): let Num.305 : U64 = lowlevel NumMul #Attr.2 #Attr.3; ret Num.305; procedure Num.22 (#Attr.2, #Attr.3): - let Num.311 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; - ret Num.311; + let Num.309 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + ret Num.309; procedure Num.24 (#Attr.2, #Attr.3): - let Num.313 : Int1 = lowlevel NumGt #Attr.2 #Attr.3; - ret Num.313; + let Num.311 : Int1 = lowlevel NumGt #Attr.2 #Attr.3; + ret Num.311; + +procedure Num.51 (#Attr.2, #Attr.3): + let Num.306 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; + ret Num.306; + +procedure Num.75 (#Attr.2, #Attr.3): + let Num.310 : U64 = lowlevel NumSubWrap #Attr.2 #Attr.3; + ret Num.310; procedure Num.94 (#Attr.2, #Attr.3): let Num.304 : U64 = lowlevel NumDivCeilUnchecked #Attr.2 #Attr.3; ret Num.304; procedure Str.12 (#Attr.2): - let Str.290 : List U8 = lowlevel StrToUtf8 #Attr.2; - ret Str.290; + let Str.292 : List U8 = lowlevel StrToUtf8 #Attr.2; + ret Str.292; procedure Test.2 (Test.10): let Test.15 : {Str, Str} = CallByName Encode.23 Test.10; diff --git a/crates/compiler/test_mono/generated/unspecialized_lambda_set_unification_keeps_all_concrete_types_without_unification_of_unifiable.txt b/crates/compiler/test_mono/generated/unspecialized_lambda_set_unification_keeps_all_concrete_types_without_unification_of_unifiable.txt index cf967c3b4d..9eaaa78431 100644 --- a/crates/compiler/test_mono/generated/unspecialized_lambda_set_unification_keeps_all_concrete_types_without_unification_of_unifiable.txt +++ b/crates/compiler/test_mono/generated/unspecialized_lambda_set_unification_keeps_all_concrete_types_without_unification_of_unifiable.txt @@ -81,106 +81,105 @@ procedure Encode.26 (Encode.105, Encode.106): let Encode.108 : List U8 = CallByName Encode.24 Encode.109 Encode.110 Encode.106; ret Encode.108; -procedure List.145 (List.146, List.147, List.144): - let List.566 : {List U8, U64} = CallByName TotallyNotJson.267 List.146 List.147 List.144; - ret List.566; +procedure List.147 (List.148, List.149, List.146): + let List.572 : {List U8, U64} = CallByName TotallyNotJson.267 List.148 List.149 List.146; + ret List.572; -procedure List.145 (List.146, List.147, List.144): - let List.614 : {List U8, U64} = CallByName TotallyNotJson.267 List.146 List.147 List.144; - ret List.614; +procedure List.147 (List.148, List.149, List.146): + let List.621 : {List U8, U64} = CallByName TotallyNotJson.267 List.148 List.149 List.146; + ret List.621; -procedure List.18 (List.142, List.143, List.144): - let List.547 : {List U8, U64} = CallByName List.93 List.142 List.143 List.144; - ret List.547; +procedure List.18 (List.144, List.145, List.146): + let List.552 : {List U8, U64} = CallByName List.93 List.144 List.145 List.146; + ret List.552; -procedure List.18 (List.142, List.143, List.144): - let List.595 : {List U8, U64} = CallByName List.93 List.142 List.143 List.144; - ret List.595; +procedure List.18 (List.144, List.145, List.146): + let List.601 : {List U8, U64} = CallByName List.93 List.144 List.145 List.146; + ret List.601; -procedure List.4 (List.113, List.114): - let List.594 : U64 = 1i64; - let List.593 : List U8 = CallByName List.70 List.113 List.594; - let List.592 : List U8 = CallByName List.71 List.593 List.114; - ret List.592; +procedure List.4 (List.115, List.116): + let List.600 : U64 = 1i64; + let List.599 : List U8 = CallByName List.70 List.115 List.600; + let List.598 : List U8 = CallByName List.71 List.599 List.116; + ret List.598; procedure List.6 (#Attr.2): - let List.567 : U64 = lowlevel ListLen #Attr.2; - ret List.567; - -procedure List.6 (#Attr.2): - let List.615 : U64 = lowlevel ListLen #Attr.2; - ret List.615; - -procedure List.66 (#Attr.2, #Attr.3): - let List.563 : [C {}, C {}] = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.563; - -procedure List.66 (#Attr.2, #Attr.3): - let List.611 : [] = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.611; - -procedure List.70 (#Attr.2, #Attr.3): - let List.573 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; + let List.573 : U64 = lowlevel ListLen #Attr.2; ret List.573; +procedure List.6 (#Attr.2): + let List.622 : U64 = lowlevel ListLen #Attr.2; + ret List.622; + +procedure List.66 (#Attr.2, #Attr.3): + let List.569 : [C {}, C {}] = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.569; + +procedure List.66 (#Attr.2, #Attr.3): + let List.618 : [] = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.618; + +procedure List.70 (#Attr.2, #Attr.3): + let List.579 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.579; + procedure List.71 (#Attr.2, #Attr.3): - let List.571 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.571; + let List.577 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.577; procedure List.8 (#Attr.2, #Attr.3): - let List.616 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; - ret List.616; + let List.623 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; + ret List.623; -procedure List.80 (#Derived_gen.18, #Derived_gen.19, #Derived_gen.20, #Derived_gen.21, #Derived_gen.22): - joinpoint List.601 List.439 List.440 List.441 List.442 List.443: - let List.603 : Int1 = CallByName Num.22 List.442 List.443; - if List.603 then - let List.610 : [] = CallByName List.66 List.439 List.442; - let List.604 : {List U8, U64} = CallByName List.145 List.440 List.610 List.441; - let List.607 : U64 = 1i64; - let List.606 : U64 = CallByName Num.19 List.442 List.607; - jump List.601 List.439 List.604 List.441 List.606 List.443; +procedure List.80 (#Derived_gen.33, #Derived_gen.34, #Derived_gen.35, #Derived_gen.36, #Derived_gen.37): + joinpoint List.558 List.442 List.443 List.444 List.445 List.446: + let List.560 : Int1 = CallByName Num.22 List.445 List.446; + if List.560 then + let List.568 : [C {}, C {}] = CallByName List.66 List.442 List.445; + let List.561 : {List U8, U64} = CallByName List.147 List.443 List.568 List.444; + let List.563 : U64 = CallByName List.96 List.445; + jump List.558 List.442 List.561 List.444 List.563 List.446; else - dec List.439; - ret List.440; + dec List.442; + ret List.443; in - jump List.601 #Derived_gen.18 #Derived_gen.19 #Derived_gen.20 #Derived_gen.21 #Derived_gen.22; + jump List.558 #Derived_gen.33 #Derived_gen.34 #Derived_gen.35 #Derived_gen.36 #Derived_gen.37; procedure List.80 (#Derived_gen.38, #Derived_gen.39, #Derived_gen.40, #Derived_gen.41, #Derived_gen.42): - joinpoint List.553 List.439 List.440 List.441 List.442 List.443: - let List.555 : Int1 = CallByName Num.22 List.442 List.443; - if List.555 then - let List.562 : [C {}, C {}] = CallByName List.66 List.439 List.442; - let List.556 : {List U8, U64} = CallByName List.145 List.440 List.562 List.441; - let List.559 : U64 = 1i64; - let List.558 : U64 = CallByName Num.19 List.442 List.559; - jump List.553 List.439 List.556 List.441 List.558 List.443; + joinpoint List.607 List.442 List.443 List.444 List.445 List.446: + let List.609 : Int1 = CallByName Num.22 List.445 List.446; + if List.609 then + let List.617 : [] = CallByName List.66 List.442 List.445; + let List.610 : {List U8, U64} = CallByName List.147 List.443 List.617 List.444; + let List.612 : U64 = CallByName List.96 List.445; + jump List.607 List.442 List.610 List.444 List.612 List.446; else - dec List.439; - ret List.440; + dec List.442; + ret List.443; in - jump List.553 #Derived_gen.38 #Derived_gen.39 #Derived_gen.40 #Derived_gen.41 #Derived_gen.42; + jump List.607 #Derived_gen.38 #Derived_gen.39 #Derived_gen.40 #Derived_gen.41 #Derived_gen.42; -procedure List.93 (List.436, List.437, List.438): - let List.551 : U64 = 0i64; - let List.552 : U64 = CallByName List.6 List.436; - let List.550 : {List U8, U64} = CallByName List.80 List.436 List.437 List.438 List.551 List.552; - ret List.550; +procedure List.93 (List.439, List.440, List.441): + let List.556 : U64 = 0i64; + let List.557 : U64 = CallByName List.6 List.439; + let List.555 : {List U8, U64} = CallByName List.80 List.439 List.440 List.441 List.556 List.557; + ret List.555; -procedure List.93 (List.436, List.437, List.438): - let List.599 : U64 = 0i64; - let List.600 : U64 = CallByName List.6 List.436; - let List.598 : {List U8, U64} = CallByName List.80 List.436 List.437 List.438 List.599 List.600; - ret List.598; +procedure List.93 (List.439, List.440, List.441): + let List.605 : U64 = 0i64; + let List.606 : U64 = CallByName List.6 List.439; + let List.604 : {List U8, U64} = CallByName List.80 List.439 List.440 List.441 List.605 List.606; + ret List.604; + +procedure List.96 (List.463): + let List.614 : U64 = 1i64; + let List.613 : U64 = CallByName Num.51 List.463 List.614; + ret List.613; procedure Num.127 (#Attr.2): let Num.311 : U8 = lowlevel NumIntCast #Attr.2; ret Num.311; -procedure Num.19 (#Attr.2, #Attr.3): - let Num.314 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.314; - procedure Num.20 (#Attr.2, #Attr.3): let Num.312 : U64 = lowlevel NumSub #Attr.2 #Attr.3; ret Num.312; @@ -193,9 +192,13 @@ procedure Num.24 (#Attr.2, #Attr.3): let Num.313 : Int1 = lowlevel NumGt #Attr.2 #Attr.3; ret Num.313; +procedure Num.51 (#Attr.2, #Attr.3): + let Num.314 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; + ret Num.314; + procedure Str.12 (#Attr.2): - let Str.290 : List U8 = lowlevel StrToUtf8 #Attr.2; - ret Str.290; + let Str.292 : List U8 = lowlevel StrToUtf8 #Attr.2; + ret Str.292; procedure Test.2 (Test.11): let Test.18 : {{}, {}} = CallByName Encode.23 Test.11; diff --git a/crates/compiler/test_mono/generated/weakening_avoids_overspecialization.txt b/crates/compiler/test_mono/generated/weakening_avoids_overspecialization.txt index 1396a444e3..ac41c56890 100644 --- a/crates/compiler/test_mono/generated/weakening_avoids_overspecialization.txt +++ b/crates/compiler/test_mono/generated/weakening_avoids_overspecialization.txt @@ -2,97 +2,101 @@ procedure Bool.11 (#Attr.2, #Attr.3): let Bool.24 : Int1 = lowlevel Eq #Attr.2 #Attr.3; ret Bool.24; -procedure List.26 (List.159, List.160, List.161): - let List.536 : [C U64, C U64] = CallByName List.93 List.159 List.160 List.161; - let List.539 : U8 = 1i64; - let List.540 : U8 = GetTagId List.536; - let List.541 : Int1 = lowlevel Eq List.539 List.540; - if List.541 then - let List.162 : U64 = UnionAtIndex (Id 1) (Index 0) List.536; - ret List.162; +procedure List.26 (List.161, List.162, List.163): + let List.541 : [C U64, C U64] = CallByName List.93 List.161 List.162 List.163; + let List.544 : U8 = 1i64; + let List.545 : U8 = GetTagId List.541; + let List.546 : Int1 = lowlevel Eq List.544 List.545; + if List.546 then + let List.164 : U64 = UnionAtIndex (Id 1) (Index 0) List.541; + ret List.164; else - let List.163 : U64 = UnionAtIndex (Id 0) (Index 0) List.536; - ret List.163; + let List.165 : U64 = UnionAtIndex (Id 0) (Index 0) List.541; + ret List.165; -procedure List.29 (List.304, List.305): - let List.535 : U64 = CallByName List.6 List.304; - let List.306 : U64 = CallByName Num.77 List.535 List.305; - let List.521 : List U8 = CallByName List.43 List.304 List.306; - ret List.521; +procedure List.29 (List.306, List.307): + let List.540 : U64 = CallByName List.6 List.306; + let List.308 : U64 = CallByName Num.77 List.540 List.307; + let List.526 : List U8 = CallByName List.43 List.306 List.308; + ret List.526; -procedure List.43 (List.302, List.303): - let List.533 : U64 = CallByName List.6 List.302; - let List.532 : U64 = CallByName Num.77 List.533 List.303; - let List.523 : {U64, U64} = Struct {List.303, List.532}; - let List.522 : List U8 = CallByName List.49 List.302 List.523; - ret List.522; - -procedure List.49 (List.376, List.377): - let List.530 : U64 = StructAtIndex 0 List.377; - let List.531 : U64 = 0i64; - let List.528 : Int1 = CallByName Bool.11 List.530 List.531; - if List.528 then - dec List.376; - let List.529 : List U8 = Array []; - ret List.529; - else - let List.525 : U64 = StructAtIndex 1 List.377; - let List.526 : U64 = StructAtIndex 0 List.377; - let List.524 : List U8 = CallByName List.72 List.376 List.525 List.526; - ret List.524; - -procedure List.6 (#Attr.2): - let List.534 : U64 = lowlevel ListLen #Attr.2; - ret List.534; - -procedure List.66 (#Attr.2, #Attr.3): - let List.557 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.557; - -procedure List.72 (#Attr.2, #Attr.3, #Attr.4): - let List.527 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; +procedure List.43 (List.304, List.305): + let List.538 : U64 = CallByName List.6 List.304; + let List.537 : U64 = CallByName Num.77 List.538 List.305; + let List.528 : {U64, U64} = Struct {List.305, List.537}; + let List.527 : List U8 = CallByName List.49 List.304 List.528; ret List.527; +procedure List.49 (List.379, List.380): + let List.535 : U64 = StructAtIndex 0 List.380; + let List.536 : U64 = 0i64; + let List.533 : Int1 = CallByName Bool.11 List.535 List.536; + if List.533 then + dec List.379; + let List.534 : List U8 = Array []; + ret List.534; + else + let List.530 : U64 = StructAtIndex 1 List.380; + let List.531 : U64 = StructAtIndex 0 List.380; + let List.529 : List U8 = CallByName List.72 List.379 List.530 List.531; + ret List.529; + +procedure List.6 (#Attr.2): + let List.539 : U64 = lowlevel ListLen #Attr.2; + ret List.539; + +procedure List.66 (#Attr.2, #Attr.3): + let List.563 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.563; + +procedure List.72 (#Attr.2, #Attr.3, #Attr.4): + let List.532 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; + ret List.532; + procedure List.80 (#Derived_gen.0, #Derived_gen.1, #Derived_gen.2, #Derived_gen.3, #Derived_gen.4): - joinpoint List.545 List.439 List.440 List.441 List.442 List.443: - let List.547 : Int1 = CallByName Num.22 List.442 List.443; - if List.547 then - let List.556 : U8 = CallByName List.66 List.439 List.442; - let List.548 : [C U64, C U64] = CallByName Test.3 List.440 List.556; - let List.553 : U8 = 1i64; - let List.554 : U8 = GetTagId List.548; - let List.555 : Int1 = lowlevel Eq List.553 List.554; - if List.555 then - let List.444 : U64 = UnionAtIndex (Id 1) (Index 0) List.548; - let List.551 : U64 = 1i64; - let List.550 : U64 = CallByName Num.19 List.442 List.551; - jump List.545 List.439 List.444 List.441 List.550 List.443; + joinpoint List.550 List.442 List.443 List.444 List.445 List.446: + let List.552 : Int1 = CallByName Num.22 List.445 List.446; + if List.552 then + let List.562 : U8 = CallByName List.66 List.442 List.445; + let List.553 : [C U64, C U64] = CallByName Test.3 List.443 List.562; + let List.559 : U8 = 1i64; + let List.560 : U8 = GetTagId List.553; + let List.561 : Int1 = lowlevel Eq List.559 List.560; + if List.561 then + let List.447 : U64 = UnionAtIndex (Id 1) (Index 0) List.553; + let List.555 : U64 = CallByName List.96 List.445; + jump List.550 List.442 List.447 List.444 List.555 List.446; else - dec List.439; - let List.445 : U64 = UnionAtIndex (Id 0) (Index 0) List.548; - let List.552 : [C U64, C U64] = TagId(0) List.445; - ret List.552; + dec List.442; + let List.448 : U64 = UnionAtIndex (Id 0) (Index 0) List.553; + let List.558 : [C U64, C U64] = TagId(0) List.448; + ret List.558; else - dec List.439; - let List.546 : [C U64, C U64] = TagId(1) List.440; - ret List.546; + dec List.442; + let List.551 : [C U64, C U64] = TagId(1) List.443; + ret List.551; in - jump List.545 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4; + jump List.550 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4; -procedure List.93 (List.436, List.437, List.438): - let List.543 : U64 = 0i64; - let List.544 : U64 = CallByName List.6 List.436; - let List.542 : [C U64, C U64] = CallByName List.80 List.436 List.437 List.438 List.543 List.544; - ret List.542; +procedure List.93 (List.439, List.440, List.441): + let List.548 : U64 = 0i64; + let List.549 : U64 = CallByName List.6 List.439; + let List.547 : [C U64, C U64] = CallByName List.80 List.439 List.440 List.441 List.548 List.549; + ret List.547; -procedure Num.19 (#Attr.2, #Attr.3): - let Num.294 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.294; +procedure List.96 (List.463): + let List.557 : U64 = 1i64; + let List.556 : U64 = CallByName Num.51 List.463 List.557; + ret List.556; procedure Num.22 (#Attr.2, #Attr.3): let Num.295 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; ret Num.295; +procedure Num.51 (#Attr.2, #Attr.3): + let Num.294 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; + ret Num.294; + procedure Num.77 (#Attr.2, #Attr.3): let Num.293 : U64 = lowlevel NumSubSaturated #Attr.2 #Attr.3; ret Num.293; From bac445b39b472793b0b02e0cda549d41152a040f Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Tue, 15 Aug 2023 02:15:56 -0400 Subject: [PATCH 118/176] Simplify List.walk (e.g. for dev backend) --- crates/compiler/builtins/roc/List.roc | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/crates/compiler/builtins/roc/List.roc b/crates/compiler/builtins/roc/List.roc index 9c91295c6c..2c9bc92ec6 100644 --- a/crates/compiler/builtins/roc/List.roc +++ b/crates/compiler/builtins/roc/List.roc @@ -459,9 +459,18 @@ contains = \list, needle -> ## Note that in other languages, `walk` is sometimes called `reduce`, ## `fold`, `foldLeft`, or `foldl`. walk : List elem, state, (state, elem -> state) -> state -walk = \list, state, func -> - walkHelp : _, _ -> [Continue _, Break []] - walkHelp = \currentState, element -> Continue (func currentState element) +walk = \list, init, func -> + walkHelp list init func 0 (List.len list) + +## internal helper +walkHelp : List elem, s, (s, elem -> s), Nat, Nat -> s +walkHelp = \list, state, f, index, length -> + if index < length then + nextState = f state (List.getUnsafe list index) + + walkHelp list nextState f (Num.addWrap index 1) length + else + state when List.iterate list state walkHelp is Continue newState -> newState From c3b556ffbcf41345ad725aa5369e82c29956fb5a Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Tue, 15 Aug 2023 02:16:14 -0400 Subject: [PATCH 119/176] Add List.walkWithIndex --- crates/compiler/builtins/roc/List.roc | 17 +++++++++++++++-- crates/compiler/module/src/symbol.rs | 1 + 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/crates/compiler/builtins/roc/List.roc b/crates/compiler/builtins/roc/List.roc index 2c9bc92ec6..ffc44082e5 100644 --- a/crates/compiler/builtins/roc/List.roc +++ b/crates/compiler/builtins/roc/List.roc @@ -28,6 +28,7 @@ interface List map2, map3, product, + walkWithIndex, walkUntil, walkFrom, walkFromUntil, @@ -472,8 +473,20 @@ walkHelp = \list, state, f, index, length -> else state - when List.iterate list state walkHelp is - Continue newState -> newState +## Like [walk], but at each step the function also receives the index of the current element. +walkWithIndex : List elem, state, (state, elem, Nat -> state) -> state +walkWithIndex = \list, init, func -> + walkWithIndexHelp list init func 0 (List.len list) + +## internal helper +walkWithIndexHelp : List elem, s, (s, elem, Nat -> s), Nat, Nat -> s +walkWithIndexHelp = \list, state, f, index, length -> + if index < length then + nextState = f state (List.getUnsafe list index) index + + walkWithIndexHelp list nextState f (Num.addWrap index 1) length + else + state ## Note that in other languages, `walkBackwards` is sometimes called `reduceRight`, ## `fold`, `foldRight`, or `foldr`. diff --git a/crates/compiler/module/src/symbol.rs b/crates/compiler/module/src/symbol.rs index 868a7fb7f2..30ce7c3199 100644 --- a/crates/compiler/module/src/symbol.rs +++ b/crates/compiler/module/src/symbol.rs @@ -1431,6 +1431,7 @@ define_builtins! { 80 LIST_ITER_HELP: "iterHelp" 81 LIST_RELEASE_EXCESS_CAPACITY: "releaseExcessCapacity" 82 LIST_UPDATE: "update" + 83 LIST_WALK_WITH_INDEX: "walkWithIndex" } 7 RESULT: "Result" => { 0 RESULT_RESULT: "Result" exposed_type=true // the Result.Result type alias From 3ea195db12ec67738649691cf69ecde1080727e6 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Tue, 15 Aug 2023 02:24:42 -0400 Subject: [PATCH 120/176] Use List.walkWithIndex in some places --- crates/glue/platform/Types.roc | 5 ++-- crates/glue/src/RustGlue.roc | 44 ++++++++++++---------------------- 2 files changed, 17 insertions(+), 32 deletions(-) diff --git a/crates/glue/platform/Types.roc b/crates/glue/platform/Types.roc index 9d2f4d3819..eca34dc9fc 100644 --- a/crates/glue/platform/Types.roc +++ b/crates/glue/platform/Types.roc @@ -33,11 +33,10 @@ entryPoints = \@Types { entrypoints } -> entrypoints walkShapes : Types, state, (state, Shape, TypeId -> state) -> state walkShapes = \@Types { types: shapes }, originalState, update -> - List.walk shapes { index: 0, state: originalState } \{ index, state }, elem -> + List.walkWithIndex shapes originalState \state, elem, index -> id = InternalTypeId.fromNat index - { index: index + 1, state: update state elem id } - |> .state + update state elem id shape : Types, TypeId -> Shape shape = \@Types types, id -> diff --git a/crates/glue/src/RustGlue.roc b/crates/glue/src/RustGlue.roc index 8c5d6a4718..ee7241e882 100644 --- a/crates/glue/src/RustGlue.roc +++ b/crates/glue/src/RustGlue.roc @@ -339,7 +339,7 @@ generateEnumeration = \buf, types, enumType, name, tags, tagBytes -> buf |> generateDeriveStr types enumType ExcludeDebug |> Str.concat "#[repr(u\(reprBits))]\npub enum \(escapedName) {\n" - |> \b -> walkWithIndex tags b generateEnumTags + |> \b -> List.walkWithIndex tags b generateEnumTags |> # Enums require a custom debug impl to ensure naming is identical on all platforms. Str.concat @@ -354,7 +354,7 @@ generateEnumeration = \buf, types, enumType, name, tags, tagBytes -> |> \b -> List.walk tags b (generateEnumTagsDebug name) |> Str.concat "\(indent)\(indent)}\n\(indent)}\n}\n\n" -generateEnumTags = \accum, index, name -> +generateEnumTags = \accum, name, index -> indexStr = Num.toStr index Str.concat accum "\(indent)\(name) = \(indexStr),\n" @@ -1969,15 +1969,6 @@ roundUpToAlignment = \width, alignment -> else width -walkWithIndex = \list, originalState, f -> - stateWithId = - List.walk list { id: 0nat, state: originalState } \{ id, state }, elem -> - nextState = f state id elem - - { id: id + 1, state: nextState } - - stateWithId.state - archName = \arch -> when arch is Aarch32 -> @@ -2099,23 +2090,18 @@ isUnit = \shape -> toArgStr : List TypeId, Types, (TypeId, Shape, Nat -> Str) -> Str toArgStr = \args, types, fmt -> - answer = List.walk args { state: "", index: 0 } \{ state, index }, argId -> - newState = - shape = Types.shape types argId + List.walkWithIndex args "" \state, argId, index -> + shape = Types.shape types argId - # Drop `()` args; they aren't FFI-safe, and nothing will get passed anyway. - if isUnit shape then - state + # Drop `()` args; they aren't FFI-safe, and nothing will get passed anyway. + if isUnit shape then + state + else + argStr = fmt argId shape index + + if Str.isEmpty state then + argStr # Don't prepend a comma if this is the first one else - argStr = fmt argId shape index - - if Str.isEmpty state then - argStr # Don't prepend a comma if this is the first one - else - state - |> Str.concat ", " - |> Str.concat argStr - - { state: newState, index: index + 1 } - - answer.state + state + |> Str.concat ", " + |> Str.concat argStr From b2d3db3ce9096f2946861382692b7972b31a72ec Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Tue, 15 Aug 2023 02:26:34 -0400 Subject: [PATCH 121/176] Fix naming collision in List.roc --- crates/compiler/builtins/roc/List.roc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/compiler/builtins/roc/List.roc b/crates/compiler/builtins/roc/List.roc index ffc44082e5..f2ea1fd3b5 100644 --- a/crates/compiler/builtins/roc/List.roc +++ b/crates/compiler/builtins/roc/List.roc @@ -532,10 +532,10 @@ walkBackwardsUntil = \list, initial, func -> ## Walks to the end of the list from a specified starting index walkFrom : List elem, Nat, state, (state, elem -> state) -> state walkFrom = \list, index, state, func -> - walkHelp : _, _ -> [Continue _, Break []] - walkHelp = \currentState, element -> Continue (func currentState element) + step : _, _ -> [Continue _, Break []] + step = \currentState, element -> Continue (func currentState element) - when List.iterHelp list state walkHelp index (List.len list) is + when List.iterHelp list state step index (List.len list) is Continue new -> new ## A combination of [List.walkFrom] and [List.walkUntil] From af357a5cbdf3ea7c03f7940e0b997cd96efe950d Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Tue, 15 Aug 2023 02:30:21 -0400 Subject: [PATCH 122/176] Update mono tests --- ...e_in_polymorphic_expression_issue_4717.txt | 138 +++--- .../generated/call_function_in_empty_list.txt | 4 +- .../call_function_in_empty_list_unbound.txt | 4 +- .../generated/capture_void_layout_task.txt | 58 +-- ...ose_correct_recursion_var_under_record.txt | 66 +-- .../test_mono/generated/closure_in_list.txt | 4 +- ...lambda_set_productive_nullable_wrapped.txt | 58 +-- crates/compiler/test_mono/generated/dict.txt | 76 +-- .../generated/empty_list_of_function_type.txt | 32 +- .../compiler/test_mono/generated/encode.txt | 18 +- .../encode_derived_nested_record_string.txt | 464 +++++++++--------- ...encode_derived_record_one_field_string.txt | 390 +++++++-------- ...ncode_derived_record_two_field_strings.txt | 390 +++++++-------- .../generated/encode_derived_string.txt | 214 ++++---- .../encode_derived_tag_one_field_string.txt | 346 +++++++------ ...encode_derived_tag_two_payloads_string.txt | 346 +++++++------ .../test_mono/generated/ir_int_add.txt | 4 +- ...cialize_errors_behind_unified_branches.txt | 58 +-- .../test_mono/generated/issue_4749.txt | 218 ++++---- .../test_mono/generated/issue_4770.txt | 110 ++--- ..._4772_weakened_monomorphic_destructure.txt | 218 ++++---- ...ure_with_multiple_recursive_structures.txt | 60 +-- .../test_mono/generated/list_append.txt | 18 +- .../generated/list_append_closure.txt | 18 +- .../generated/list_cannot_update_inplace.txt | 32 +- .../compiler/test_mono/generated/list_get.txt | 32 +- .../compiler/test_mono/generated/list_len.txt | 8 +- .../generated/list_map_closure_borrows.txt | 38 +- .../generated/list_map_closure_owns.txt | 38 +- ...ist_map_take_capturing_or_noncapturing.txt | 20 +- .../generated/list_pass_to_function.txt | 32 +- .../test_mono/generated/list_sort_asc.txt | 12 +- .../test_mono/generated/quicksort_swap.txt | 60 +-- .../test_mono/generated/record_update.txt | 32 +- ...function_and_union_with_inference_hole.txt | 4 +- .../compiler/test_mono/generated/rigids.txt | 60 +-- ...not_duplicate_identical_concrete_types.txt | 346 +++++++------ ...types_without_unification_of_unifiable.txt | 130 +++-- .../weakening_avoids_overspecialization.txt | 138 +++--- 39 files changed, 2085 insertions(+), 2209 deletions(-) diff --git a/crates/compiler/test_mono/generated/anonymous_closure_in_polymorphic_expression_issue_4717.txt b/crates/compiler/test_mono/generated/anonymous_closure_in_polymorphic_expression_issue_4717.txt index f3eca0d0aa..80c61edd00 100644 --- a/crates/compiler/test_mono/generated/anonymous_closure_in_polymorphic_expression_issue_4717.txt +++ b/crates/compiler/test_mono/generated/anonymous_closure_in_polymorphic_expression_issue_4717.txt @@ -2,88 +2,88 @@ procedure Bool.11 (#Attr.2, #Attr.3): let Bool.24 : Int1 = lowlevel Eq #Attr.2 #Attr.3; ret Bool.24; -procedure List.26 (List.159, List.160, List.161): - let List.536 : [C U64, C U64] = CallByName List.93 List.159 List.160 List.161; - let List.539 : U8 = 1i64; - let List.540 : U8 = GetTagId List.536; - let List.541 : Int1 = lowlevel Eq List.539 List.540; - if List.541 then - let List.162 : U64 = UnionAtIndex (Id 1) (Index 0) List.536; - ret List.162; +procedure List.26 (List.172, List.173, List.174): + let List.549 : [C U64, C U64] = CallByName List.96 List.172 List.173 List.174; + let List.552 : U8 = 1i64; + let List.553 : U8 = GetTagId List.549; + let List.554 : Int1 = lowlevel Eq List.552 List.553; + if List.554 then + let List.175 : U64 = UnionAtIndex (Id 1) (Index 0) List.549; + ret List.175; else - let List.163 : U64 = UnionAtIndex (Id 0) (Index 0) List.536; - ret List.163; + let List.176 : U64 = UnionAtIndex (Id 0) (Index 0) List.549; + ret List.176; -procedure List.29 (List.304, List.305): - let List.535 : U64 = CallByName List.6 List.304; - let List.306 : U64 = CallByName Num.77 List.535 List.305; - let List.521 : List U8 = CallByName List.43 List.304 List.306; - ret List.521; - -procedure List.43 (List.302, List.303): - let List.533 : U64 = CallByName List.6 List.302; - let List.532 : U64 = CallByName Num.77 List.533 List.303; - let List.523 : {U64, U64} = Struct {List.303, List.532}; - let List.522 : List U8 = CallByName List.49 List.302 List.523; - ret List.522; - -procedure List.49 (List.376, List.377): - let List.530 : U64 = StructAtIndex 0 List.377; - let List.531 : U64 = 0i64; - let List.528 : Int1 = CallByName Bool.11 List.530 List.531; - if List.528 then - dec List.376; - let List.529 : List U8 = Array []; - ret List.529; - else - let List.525 : U64 = StructAtIndex 1 List.377; - let List.526 : U64 = StructAtIndex 0 List.377; - let List.524 : List U8 = CallByName List.72 List.376 List.525 List.526; - ret List.524; - -procedure List.6 (#Attr.2): - let List.534 : U64 = lowlevel ListLen #Attr.2; +procedure List.29 (List.317, List.318): + let List.548 : U64 = CallByName List.6 List.317; + let List.319 : U64 = CallByName Num.77 List.548 List.318; + let List.534 : List U8 = CallByName List.43 List.317 List.319; ret List.534; +procedure List.43 (List.315, List.316): + let List.546 : U64 = CallByName List.6 List.315; + let List.545 : U64 = CallByName Num.77 List.546 List.316; + let List.536 : {U64, U64} = Struct {List.316, List.545}; + let List.535 : List U8 = CallByName List.49 List.315 List.536; + ret List.535; + +procedure List.49 (List.389, List.390): + let List.543 : U64 = StructAtIndex 0 List.390; + let List.544 : U64 = 0i64; + let List.541 : Int1 = CallByName Bool.11 List.543 List.544; + if List.541 then + dec List.389; + let List.542 : List U8 = Array []; + ret List.542; + else + let List.538 : U64 = StructAtIndex 1 List.390; + let List.539 : U64 = StructAtIndex 0 List.390; + let List.537 : List U8 = CallByName List.72 List.389 List.538 List.539; + ret List.537; + +procedure List.6 (#Attr.2): + let List.547 : U64 = lowlevel ListLen #Attr.2; + ret List.547; + procedure List.66 (#Attr.2, #Attr.3): - let List.557 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.557; + let List.570 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.570; procedure List.72 (#Attr.2, #Attr.3, #Attr.4): - let List.527 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; - ret List.527; + let List.540 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; + ret List.540; procedure List.80 (#Derived_gen.0, #Derived_gen.1, #Derived_gen.2, #Derived_gen.3, #Derived_gen.4): - joinpoint List.545 List.439 List.440 List.441 List.442 List.443: - let List.547 : Int1 = CallByName Num.22 List.442 List.443; - if List.547 then - let List.556 : U8 = CallByName List.66 List.439 List.442; - let List.548 : [C U64, C U64] = CallByName Test.4 List.440 List.556; - let List.553 : U8 = 1i64; - let List.554 : U8 = GetTagId List.548; - let List.555 : Int1 = lowlevel Eq List.553 List.554; - if List.555 then - let List.444 : U64 = UnionAtIndex (Id 1) (Index 0) List.548; - let List.551 : U64 = 1i64; - let List.550 : U64 = CallByName Num.19 List.442 List.551; - jump List.545 List.439 List.444 List.441 List.550 List.443; + joinpoint List.558 List.452 List.453 List.454 List.455 List.456: + let List.560 : Int1 = CallByName Num.22 List.455 List.456; + if List.560 then + let List.569 : U8 = CallByName List.66 List.452 List.455; + let List.561 : [C U64, C U64] = CallByName Test.4 List.453 List.569; + let List.566 : U8 = 1i64; + let List.567 : U8 = GetTagId List.561; + let List.568 : Int1 = lowlevel Eq List.566 List.567; + if List.568 then + let List.457 : U64 = UnionAtIndex (Id 1) (Index 0) List.561; + let List.564 : U64 = 1i64; + let List.563 : U64 = CallByName Num.19 List.455 List.564; + jump List.558 List.452 List.457 List.454 List.563 List.456; else - dec List.439; - let List.445 : U64 = UnionAtIndex (Id 0) (Index 0) List.548; - let List.552 : [C U64, C U64] = TagId(0) List.445; - ret List.552; + dec List.452; + let List.458 : U64 = UnionAtIndex (Id 0) (Index 0) List.561; + let List.565 : [C U64, C U64] = TagId(0) List.458; + ret List.565; else - dec List.439; - let List.546 : [C U64, C U64] = TagId(1) List.440; - ret List.546; + dec List.452; + let List.559 : [C U64, C U64] = TagId(1) List.453; + ret List.559; in - jump List.545 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4; + jump List.558 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4; -procedure List.93 (List.436, List.437, List.438): - let List.543 : U64 = 0i64; - let List.544 : U64 = CallByName List.6 List.436; - let List.542 : [C U64, C U64] = CallByName List.80 List.436 List.437 List.438 List.543 List.544; - ret List.542; +procedure List.96 (List.449, List.450, List.451): + let List.556 : U64 = 0i64; + let List.557 : U64 = CallByName List.6 List.449; + let List.555 : [C U64, C U64] = CallByName List.80 List.449 List.450 List.451 List.556 List.557; + ret List.555; procedure Num.19 (#Attr.2, #Attr.3): let Num.294 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/call_function_in_empty_list.txt b/crates/compiler/test_mono/generated/call_function_in_empty_list.txt index 49843c03dd..45aeaa938b 100644 --- a/crates/compiler/test_mono/generated/call_function_in_empty_list.txt +++ b/crates/compiler/test_mono/generated/call_function_in_empty_list.txt @@ -1,7 +1,7 @@ procedure List.5 (#Attr.2, #Attr.3): - let List.521 : List {} = lowlevel ListMap { xs: `#Attr.#arg1` } #Attr.2 Test.2 #Attr.3; + let List.534 : List {} = lowlevel ListMap { xs: `#Attr.#arg1` } #Attr.2 Test.2 #Attr.3; decref #Attr.2; - ret List.521; + ret List.534; procedure Test.2 (Test.3): let Test.7 : {} = Struct {}; diff --git a/crates/compiler/test_mono/generated/call_function_in_empty_list_unbound.txt b/crates/compiler/test_mono/generated/call_function_in_empty_list_unbound.txt index ce2dbde965..81fed2ee41 100644 --- a/crates/compiler/test_mono/generated/call_function_in_empty_list_unbound.txt +++ b/crates/compiler/test_mono/generated/call_function_in_empty_list_unbound.txt @@ -1,7 +1,7 @@ procedure List.5 (#Attr.2, #Attr.3): - let List.521 : List [] = lowlevel ListMap { xs: `#Attr.#arg1` } #Attr.2 Test.2 #Attr.3; + let List.534 : List [] = lowlevel ListMap { xs: `#Attr.#arg1` } #Attr.2 Test.2 #Attr.3; decref #Attr.2; - ret List.521; + ret List.534; procedure Test.2 (Test.3): let Test.7 : {} = Struct {}; diff --git a/crates/compiler/test_mono/generated/capture_void_layout_task.txt b/crates/compiler/test_mono/generated/capture_void_layout_task.txt index bad0f8684c..4e4936d56f 100644 --- a/crates/compiler/test_mono/generated/capture_void_layout_task.txt +++ b/crates/compiler/test_mono/generated/capture_void_layout_task.txt @@ -1,48 +1,40 @@ -procedure List.145 (List.146, List.147, List.144): - let List.540 : [C {}, C *self {{}, []}] = CallByName Test.29 List.146 List.147 List.144; - ret List.540; - -procedure List.18 (List.142, List.143, List.144): - let List.521 : [C {}, C *self {{}, []}] = CallByName List.93 List.142 List.143 List.144; - ret List.521; +procedure List.18 (List.145, List.146, List.147): + let List.535 : U64 = 0i64; + let List.536 : U64 = CallByName List.6 List.145; + let List.534 : [C {}, C *self {{}, []}] = CallByName List.86 List.145 List.146 List.147 List.535 List.536; + ret List.534; procedure List.6 (#Attr.2): - let List.538 : U64 = lowlevel ListLen #Attr.2; - ret List.538; + let List.545 : U64 = lowlevel ListLen #Attr.2; + ret List.545; procedure List.66 (#Attr.2, #Attr.3): - let List.537 : [] = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.537; + let List.544 : [] = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.544; -procedure List.80 (#Derived_gen.13, #Derived_gen.14, #Derived_gen.15, #Derived_gen.16, #Derived_gen.17): - joinpoint List.527 List.439 List.440 List.441 List.442 List.443: - let List.529 : Int1 = CallByName Num.22 List.442 List.443; - if List.529 then - let List.536 : [] = CallByName List.66 List.439 List.442; - let List.530 : [C {}, C *self {{}, []}] = CallByName List.145 List.440 List.536 List.441; - let List.533 : U64 = 1i64; - let List.532 : U64 = CallByName Num.19 List.442 List.533; - jump List.527 List.439 List.530 List.441 List.532 List.443; +procedure List.86 (#Derived_gen.11, #Derived_gen.12, #Derived_gen.13, #Derived_gen.14, #Derived_gen.15): + joinpoint List.537 List.148 List.149 List.150 List.151 List.152: + let List.539 : Int1 = CallByName Num.22 List.151 List.152; + if List.539 then + let List.543 : [] = CallByName List.66 List.148 List.151; + let List.153 : [C {}, C *self {{}, []}] = CallByName Test.29 List.149 List.543 List.150; + let List.542 : U64 = 1i64; + let List.541 : U64 = CallByName Num.51 List.151 List.542; + jump List.537 List.148 List.153 List.150 List.541 List.152; else - dec List.439; - ret List.440; + dec List.148; + ret List.149; in - jump List.527 #Derived_gen.13 #Derived_gen.14 #Derived_gen.15 #Derived_gen.16 #Derived_gen.17; - -procedure List.93 (List.436, List.437, List.438): - let List.525 : U64 = 0i64; - let List.526 : U64 = CallByName List.6 List.436; - let List.524 : [C {}, C *self {{}, []}] = CallByName List.80 List.436 List.437 List.438 List.525 List.526; - ret List.524; - -procedure Num.19 (#Attr.2, #Attr.3): - let Num.292 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.292; + jump List.537 #Derived_gen.11 #Derived_gen.12 #Derived_gen.13 #Derived_gen.14 #Derived_gen.15; procedure Num.22 (#Attr.2, #Attr.3): let Num.293 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; ret Num.293; +procedure Num.51 (#Attr.2, #Attr.3): + let Num.292 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; + ret Num.292; + procedure Test.10 (Test.66, #Attr.12): let Test.9 : {} = UnionAtIndex (Id 0) (Index 0) #Attr.12; let #Derived_gen.18 : Int1 = lowlevel RefCountIsUnique #Attr.12; diff --git a/crates/compiler/test_mono/generated/choose_correct_recursion_var_under_record.txt b/crates/compiler/test_mono/generated/choose_correct_recursion_var_under_record.txt index b52e46a91d..e95566f7c8 100644 --- a/crates/compiler/test_mono/generated/choose_correct_recursion_var_under_record.txt +++ b/crates/compiler/test_mono/generated/choose_correct_recursion_var_under_record.txt @@ -2,49 +2,49 @@ procedure Bool.1 (): let Bool.24 : Int1 = false; ret Bool.24; -procedure List.2 (List.97, List.98): - let List.535 : U64 = CallByName List.6 List.97; - let List.531 : Int1 = CallByName Num.22 List.98 List.535; - if List.531 then - let List.533 : Str = CallByName List.66 List.97 List.98; - inc List.533; - dec List.97; - let List.532 : [C {}, C Str] = TagId(1) List.533; - ret List.532; +procedure List.2 (List.100, List.101): + let List.548 : U64 = CallByName List.6 List.100; + let List.544 : Int1 = CallByName Num.22 List.101 List.548; + if List.544 then + let List.546 : Str = CallByName List.66 List.100 List.101; + inc List.546; + dec List.100; + let List.545 : [C {}, C Str] = TagId(1) List.546; + ret List.545; else - dec List.97; - let List.530 : {} = Struct {}; - let List.529 : [C {}, C Str] = TagId(0) List.530; - ret List.529; + dec List.100; + let List.543 : {} = Struct {}; + let List.542 : [C {}, C Str] = TagId(0) List.543; + ret List.542; procedure List.5 (#Attr.2, #Attr.3): - let List.537 : List Str = lowlevel ListMap { xs: `#Attr.#arg1` } #Attr.2 Test.10 #Attr.3; + let List.550 : List Str = lowlevel ListMap { xs: `#Attr.#arg1` } #Attr.2 Test.10 #Attr.3; decref #Attr.2; - ret List.537; + ret List.550; procedure List.6 (#Attr.2): - let List.536 : U64 = lowlevel ListLen #Attr.2; - ret List.536; + let List.549 : U64 = lowlevel ListLen #Attr.2; + ret List.549; procedure List.66 (#Attr.2, #Attr.3): - let List.534 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.534; + let List.547 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.547; -procedure List.9 (List.293): - let List.528 : U64 = 0i64; - let List.521 : [C {}, C Str] = CallByName List.2 List.293 List.528; - let List.525 : U8 = 1i64; - let List.526 : U8 = GetTagId List.521; - let List.527 : Int1 = lowlevel Eq List.525 List.526; - if List.527 then - let List.294 : Str = UnionAtIndex (Id 1) (Index 0) List.521; - let List.522 : [C {}, C Str] = TagId(1) List.294; - ret List.522; +procedure List.9 (List.306): + let List.541 : U64 = 0i64; + let List.534 : [C {}, C Str] = CallByName List.2 List.306 List.541; + let List.538 : U8 = 1i64; + let List.539 : U8 = GetTagId List.534; + let List.540 : Int1 = lowlevel Eq List.538 List.539; + if List.540 then + let List.307 : Str = UnionAtIndex (Id 1) (Index 0) List.534; + let List.535 : [C {}, C Str] = TagId(1) List.307; + ret List.535; else - dec List.521; - let List.524 : {} = Struct {}; - let List.523 : [C {}, C Str] = TagId(0) List.524; - ret List.523; + dec List.534; + let List.537 : {} = Struct {}; + let List.536 : [C {}, C Str] = TagId(0) List.537; + ret List.536; procedure Num.22 (#Attr.2, #Attr.3): let Num.292 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/closure_in_list.txt b/crates/compiler/test_mono/generated/closure_in_list.txt index 5550ea1fda..8d385ca609 100644 --- a/crates/compiler/test_mono/generated/closure_in_list.txt +++ b/crates/compiler/test_mono/generated/closure_in_list.txt @@ -1,6 +1,6 @@ procedure List.6 (#Attr.2): - let List.521 : U64 = lowlevel ListLen #Attr.2; - ret List.521; + let List.534 : U64 = lowlevel ListLen #Attr.2; + ret List.534; procedure Test.1 (Test.5): let Test.2 : I64 = 41i64; diff --git a/crates/compiler/test_mono/generated/compose_recursive_lambda_set_productive_nullable_wrapped.txt b/crates/compiler/test_mono/generated/compose_recursive_lambda_set_productive_nullable_wrapped.txt index cbd51527e7..0d8c2406cc 100644 --- a/crates/compiler/test_mono/generated/compose_recursive_lambda_set_productive_nullable_wrapped.txt +++ b/crates/compiler/test_mono/generated/compose_recursive_lambda_set_productive_nullable_wrapped.txt @@ -2,51 +2,43 @@ procedure Bool.2 (): let Bool.23 : Int1 = true; ret Bool.23; -procedure List.145 (List.146, List.147, List.144): - let List.540 : [, C *self Int1, C *self Int1] = CallByName Test.6 List.146 List.147 List.144; - ret List.540; - -procedure List.18 (List.142, List.143, List.144): - let List.521 : [, C *self Int1, C *self Int1] = CallByName List.93 List.142 List.143 List.144; - ret List.521; +procedure List.18 (List.145, List.146, List.147): + let List.535 : U64 = 0i64; + let List.536 : U64 = CallByName List.6 List.145; + let List.534 : [, C *self Int1, C *self Int1] = CallByName List.86 List.145 List.146 List.147 List.535 List.536; + ret List.534; procedure List.6 (#Attr.2): - let List.538 : U64 = lowlevel ListLen #Attr.2; - ret List.538; + let List.545 : U64 = lowlevel ListLen #Attr.2; + ret List.545; procedure List.66 (#Attr.2, #Attr.3): - let List.537 : Int1 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.537; + let List.544 : Int1 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.544; -procedure List.80 (#Derived_gen.3, #Derived_gen.4, #Derived_gen.5, #Derived_gen.6, #Derived_gen.7): - joinpoint List.527 List.439 List.440 List.441 List.442 List.443: - let List.529 : Int1 = CallByName Num.22 List.442 List.443; - if List.529 then - let List.536 : Int1 = CallByName List.66 List.439 List.442; - let List.530 : [, C *self Int1, C *self Int1] = CallByName List.145 List.440 List.536 List.441; - let List.533 : U64 = 1i64; - let List.532 : U64 = CallByName Num.19 List.442 List.533; - jump List.527 List.439 List.530 List.441 List.532 List.443; +procedure List.86 (#Derived_gen.5, #Derived_gen.6, #Derived_gen.7, #Derived_gen.8, #Derived_gen.9): + joinpoint List.537 List.148 List.149 List.150 List.151 List.152: + let List.539 : Int1 = CallByName Num.22 List.151 List.152; + if List.539 then + let List.543 : Int1 = CallByName List.66 List.148 List.151; + let List.153 : [, C *self Int1, C *self Int1] = CallByName Test.6 List.149 List.543 List.150; + let List.542 : U64 = 1i64; + let List.541 : U64 = CallByName Num.51 List.151 List.542; + jump List.537 List.148 List.153 List.150 List.541 List.152; else - dec List.439; - ret List.440; + dec List.148; + ret List.149; in - jump List.527 #Derived_gen.3 #Derived_gen.4 #Derived_gen.5 #Derived_gen.6 #Derived_gen.7; - -procedure List.93 (List.436, List.437, List.438): - let List.525 : U64 = 0i64; - let List.526 : U64 = CallByName List.6 List.436; - let List.524 : [, C *self Int1, C *self Int1] = CallByName List.80 List.436 List.437 List.438 List.525 List.526; - ret List.524; - -procedure Num.19 (#Attr.2, #Attr.3): - let Num.292 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.292; + jump List.537 #Derived_gen.5 #Derived_gen.6 #Derived_gen.7 #Derived_gen.8 #Derived_gen.9; procedure Num.22 (#Attr.2, #Attr.3): let Num.293 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; ret Num.293; +procedure Num.51 (#Attr.2, #Attr.3): + let Num.292 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; + ret Num.292; + procedure Str.3 (#Attr.2, #Attr.3): let Str.291 : Str = lowlevel StrConcat #Attr.2 #Attr.3; ret Str.291; diff --git a/crates/compiler/test_mono/generated/dict.txt b/crates/compiler/test_mono/generated/dict.txt index 693107f54b..57ba3417f8 100644 --- a/crates/compiler/test_mono/generated/dict.txt +++ b/crates/compiler/test_mono/generated/dict.txt @@ -24,59 +24,59 @@ procedure Dict.4 (Dict.562): dec #Derived_gen.6; ret Dict.100; -procedure List.11 (List.121, List.122): - let List.522 : List I8 = CallByName List.68 List.122; - let List.521 : List I8 = CallByName List.83 List.121 List.122 List.522; - ret List.521; +procedure List.11 (List.124, List.125): + let List.535 : List I8 = CallByName List.68 List.125; + let List.534 : List I8 = CallByName List.84 List.124 List.125 List.535; + ret List.534; -procedure List.11 (List.121, List.122): - let List.534 : List U64 = CallByName List.68 List.122; - let List.533 : List U64 = CallByName List.83 List.121 List.122 List.534; - ret List.533; +procedure List.11 (List.124, List.125): + let List.547 : List U64 = CallByName List.68 List.125; + let List.546 : List U64 = CallByName List.84 List.124 List.125 List.547; + ret List.546; procedure List.68 (#Attr.2): - let List.532 : List I8 = lowlevel ListWithCapacity #Attr.2; - ret List.532; + let List.545 : List I8 = lowlevel ListWithCapacity #Attr.2; + ret List.545; procedure List.68 (#Attr.2): - let List.544 : List U64 = lowlevel ListWithCapacity #Attr.2; - ret List.544; + let List.557 : List U64 = lowlevel ListWithCapacity #Attr.2; + ret List.557; procedure List.71 (#Attr.2, #Attr.3): - let List.529 : List I8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.529; + let List.542 : List I8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.542; procedure List.71 (#Attr.2, #Attr.3): - let List.541 : List U64 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.541; + let List.554 : List U64 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.554; -procedure List.83 (#Derived_gen.0, #Derived_gen.1, #Derived_gen.2): - joinpoint List.523 List.123 List.124 List.125: - let List.531 : U64 = 0i64; - let List.525 : Int1 = CallByName Num.24 List.124 List.531; - if List.525 then - let List.530 : U64 = 1i64; - let List.527 : U64 = CallByName Num.20 List.124 List.530; - let List.528 : List I8 = CallByName List.71 List.125 List.123; - jump List.523 List.123 List.527 List.528; +procedure List.84 (#Derived_gen.0, #Derived_gen.1, #Derived_gen.2): + joinpoint List.536 List.126 List.127 List.128: + let List.544 : U64 = 0i64; + let List.538 : Int1 = CallByName Num.24 List.127 List.544; + if List.538 then + let List.543 : U64 = 1i64; + let List.540 : U64 = CallByName Num.20 List.127 List.543; + let List.541 : List I8 = CallByName List.71 List.128 List.126; + jump List.536 List.126 List.540 List.541; else - ret List.125; + ret List.128; in - jump List.523 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2; + jump List.536 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2; -procedure List.83 (#Derived_gen.3, #Derived_gen.4, #Derived_gen.5): - joinpoint List.535 List.123 List.124 List.125: - let List.543 : U64 = 0i64; - let List.537 : Int1 = CallByName Num.24 List.124 List.543; - if List.537 then - let List.542 : U64 = 1i64; - let List.539 : U64 = CallByName Num.20 List.124 List.542; - let List.540 : List U64 = CallByName List.71 List.125 List.123; - jump List.535 List.123 List.539 List.540; +procedure List.84 (#Derived_gen.3, #Derived_gen.4, #Derived_gen.5): + joinpoint List.548 List.126 List.127 List.128: + let List.556 : U64 = 0i64; + let List.550 : Int1 = CallByName Num.24 List.127 List.556; + if List.550 then + let List.555 : U64 = 1i64; + let List.552 : U64 = CallByName Num.20 List.127 List.555; + let List.553 : List U64 = CallByName List.71 List.128 List.126; + jump List.548 List.126 List.552 List.553; else - ret List.125; + ret List.128; in - jump List.535 #Derived_gen.3 #Derived_gen.4 #Derived_gen.5; + jump List.548 #Derived_gen.3 #Derived_gen.4 #Derived_gen.5; procedure Num.20 (#Attr.2, #Attr.3): let Num.293 : U64 = lowlevel NumSub #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/empty_list_of_function_type.txt b/crates/compiler/test_mono/generated/empty_list_of_function_type.txt index 8f46084280..1a0af13250 100644 --- a/crates/compiler/test_mono/generated/empty_list_of_function_type.txt +++ b/crates/compiler/test_mono/generated/empty_list_of_function_type.txt @@ -2,27 +2,27 @@ procedure Bool.1 (): let Bool.23 : Int1 = false; ret Bool.23; -procedure List.2 (List.97, List.98): - let List.527 : U64 = CallByName List.6 List.97; - let List.523 : Int1 = CallByName Num.22 List.98 List.527; - if List.523 then - let List.525 : {} = CallByName List.66 List.97 List.98; - dec List.97; - let List.524 : [C {}, C {}] = TagId(1) List.525; - ret List.524; +procedure List.2 (List.100, List.101): + let List.540 : U64 = CallByName List.6 List.100; + let List.536 : Int1 = CallByName Num.22 List.101 List.540; + if List.536 then + let List.538 : {} = CallByName List.66 List.100 List.101; + dec List.100; + let List.537 : [C {}, C {}] = TagId(1) List.538; + ret List.537; else - dec List.97; - let List.522 : {} = Struct {}; - let List.521 : [C {}, C {}] = TagId(0) List.522; - ret List.521; + dec List.100; + let List.535 : {} = Struct {}; + let List.534 : [C {}, C {}] = TagId(0) List.535; + ret List.534; procedure List.6 (#Attr.2): - let List.528 : U64 = lowlevel ListLen #Attr.2; - ret List.528; + let List.541 : U64 = lowlevel ListLen #Attr.2; + ret List.541; procedure List.66 (#Attr.2, #Attr.3): - let List.526 : {} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.526; + let List.539 : {} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.539; procedure Num.22 (#Attr.2, #Attr.3): let Num.292 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/encode.txt b/crates/compiler/test_mono/generated/encode.txt index ce0c8b5b66..f565038bd3 100644 --- a/crates/compiler/test_mono/generated/encode.txt +++ b/crates/compiler/test_mono/generated/encode.txt @@ -1,16 +1,16 @@ -procedure List.4 (List.113, List.114): - let List.524 : U64 = 1i64; - let List.522 : List U8 = CallByName List.70 List.113 List.524; - let List.521 : List U8 = CallByName List.71 List.522 List.114; - ret List.521; +procedure List.4 (List.116, List.117): + let List.537 : U64 = 1i64; + let List.535 : List U8 = CallByName List.70 List.116 List.537; + let List.534 : List U8 = CallByName List.71 List.535 List.117; + ret List.534; procedure List.70 (#Attr.2, #Attr.3): - let List.525 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.525; + let List.538 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.538; procedure List.71 (#Attr.2, #Attr.3): - let List.523 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.523; + let List.536 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.536; procedure Test.23 (Test.24, Test.35, Test.22): let Test.37 : List U8 = CallByName List.4 Test.24 Test.22; diff --git a/crates/compiler/test_mono/generated/encode_derived_nested_record_string.txt b/crates/compiler/test_mono/generated/encode_derived_nested_record_string.txt index da00523cb6..362ac797f1 100644 --- a/crates/compiler/test_mono/generated/encode_derived_nested_record_string.txt +++ b/crates/compiler/test_mono/generated/encode_derived_nested_record_string.txt @@ -78,283 +78,263 @@ procedure Encode.26 (Encode.105, Encode.106): ret Encode.108; procedure List.13 (#Attr.2, #Attr.3): - let List.689 : List Str = lowlevel ListPrepend #Attr.2 #Attr.3; - ret List.689; - -procedure List.145 (List.146, List.147, List.144): - let List.569 : {List U8, U64} = CallByName TotallyNotJson.237 List.146 List.147 List.144; - ret List.569; - -procedure List.145 (List.146, List.147, List.144): - let List.637 : {List U8, U64} = CallByName TotallyNotJson.237 List.146 List.147 List.144; - ret List.637; - -procedure List.145 (List.146, List.147, List.144): - let List.657 : List U8 = CallByName TotallyNotJson.215 List.146 List.147; - ret List.657; - -procedure List.18 (List.142, List.143, List.144): - let List.550 : {List U8, U64} = CallByName List.93 List.142 List.143 List.144; - ret List.550; - -procedure List.18 (List.142, List.143, List.144): - let List.618 : {List U8, U64} = CallByName List.93 List.142 List.143 List.144; - ret List.618; - -procedure List.18 (List.142, List.143, List.144): - let List.638 : List U8 = CallByName List.93 List.142 List.143 List.144; - ret List.638; - -procedure List.26 (List.159, List.160, List.161): - let List.706 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.93 List.159 List.160 List.161; - let List.709 : U8 = 1i64; - let List.710 : U8 = GetTagId List.706; - let List.711 : Int1 = lowlevel Eq List.709 List.710; - if List.711 then - let List.162 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.706; - ret List.162; - else - let List.163 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.706; - ret List.163; - -procedure List.31 (#Attr.2, #Attr.3): - let List.671 : List Str = lowlevel ListDropAt #Attr.2 #Attr.3; - ret List.671; - -procedure List.38 (List.298): - let List.679 : U64 = 0i64; - let List.678 : List Str = CallByName List.31 List.298 List.679; + let List.678 : List Str = lowlevel ListPrepend #Attr.2 #Attr.3; ret List.678; -procedure List.4 (List.113, List.114): - let List.614 : U64 = 1i64; - let List.613 : List Str = CallByName List.70 List.113 List.614; - let List.612 : List Str = CallByName List.71 List.613 List.114; - ret List.612; +procedure List.18 (List.145, List.146, List.147): + let List.564 : U64 = 0i64; + let List.565 : U64 = CallByName List.6 List.145; + let List.563 : {List U8, U64} = CallByName List.86 List.145 List.146 List.147 List.564 List.565; + ret List.563; -procedure List.4 (List.113, List.114): - let List.617 : U64 = 1i64; - let List.616 : List U8 = CallByName List.70 List.113 List.617; - let List.615 : List U8 = CallByName List.71 List.616 List.114; - ret List.615; +procedure List.18 (List.145, List.146, List.147): + let List.624 : U64 = 0i64; + let List.625 : U64 = CallByName List.6 List.145; + let List.623 : {List U8, U64} = CallByName List.86 List.145 List.146 List.147 List.624 List.625; + ret List.623; -procedure List.49 (List.376, List.377): - let List.698 : U64 = StructAtIndex 0 List.377; - let List.699 : U64 = 0i64; - let List.696 : Int1 = CallByName Bool.11 List.698 List.699; - if List.696 then - dec List.376; - let List.697 : List U8 = Array []; - ret List.697; +procedure List.18 (List.145, List.146, List.147): + let List.636 : U64 = 0i64; + let List.637 : U64 = CallByName List.6 List.145; + let List.635 : List U8 = CallByName List.86 List.145 List.146 List.147 List.636 List.637; + ret List.635; + +procedure List.26 (List.172, List.173, List.174): + let List.695 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.96 List.172 List.173 List.174; + let List.698 : U8 = 1i64; + let List.699 : U8 = GetTagId List.695; + let List.700 : Int1 = lowlevel Eq List.698 List.699; + if List.700 then + let List.175 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.695; + ret List.175; else - let List.693 : U64 = StructAtIndex 1 List.377; - let List.694 : U64 = StructAtIndex 0 List.377; - let List.692 : List U8 = CallByName List.72 List.376 List.693 List.694; - ret List.692; + let List.176 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.695; + ret List.176; -procedure List.52 (List.391, List.392): - let List.393 : U64 = CallByName List.6 List.391; - joinpoint List.704 List.394: - let List.702 : U64 = 0i64; - let List.701 : {U64, U64} = Struct {List.394, List.702}; - inc List.391; - let List.395 : List U8 = CallByName List.49 List.391 List.701; - let List.700 : U64 = CallByName Num.20 List.393 List.394; - let List.691 : {U64, U64} = Struct {List.700, List.394}; - let List.396 : List U8 = CallByName List.49 List.391 List.691; - let List.690 : {List U8, List U8} = Struct {List.395, List.396}; - ret List.690; - in - let List.705 : Int1 = CallByName Num.24 List.393 List.392; - if List.705 then - jump List.704 List.392; - else - jump List.704 List.393; - -procedure List.6 (#Attr.2): - let List.588 : U64 = lowlevel ListLen #Attr.2; - ret List.588; - -procedure List.6 (#Attr.2): - let List.685 : U64 = lowlevel ListLen #Attr.2; - ret List.685; - -procedure List.6 (#Attr.2): - let List.686 : U64 = lowlevel ListLen #Attr.2; - ret List.686; - -procedure List.6 (#Attr.2): - let List.688 : U64 = lowlevel ListLen #Attr.2; - ret List.688; - -procedure List.66 (#Attr.2, #Attr.3): - let List.566 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.566; - -procedure List.66 (#Attr.2, #Attr.3): - let List.634 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.634; - -procedure List.66 (#Attr.2, #Attr.3): - let List.654 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.654; - -procedure List.68 (#Attr.2): - let List.681 : List Str = lowlevel ListWithCapacity #Attr.2; - ret List.681; - -procedure List.68 (#Attr.2): - let List.683 : List U8 = lowlevel ListWithCapacity #Attr.2; - ret List.683; - -procedure List.70 (#Attr.2, #Attr.3): - let List.594 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.594; - -procedure List.70 (#Attr.2, #Attr.3): - let List.611 : List Str = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.611; - -procedure List.71 (#Attr.2, #Attr.3): - let List.592 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.592; - -procedure List.71 (#Attr.2, #Attr.3): - let List.609 : List Str = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.609; - -procedure List.72 (#Attr.2, #Attr.3, #Attr.4): - let List.695 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; - ret List.695; - -procedure List.8 (#Attr.2, #Attr.3): - let List.660 : List Str = lowlevel ListConcat #Attr.2 #Attr.3; +procedure List.31 (#Attr.2, #Attr.3): + let List.660 : List Str = lowlevel ListDropAt #Attr.2 #Attr.3; ret List.660; +procedure List.38 (List.311): + let List.668 : U64 = 0i64; + let List.667 : List Str = CallByName List.31 List.311 List.668; + ret List.667; + +procedure List.4 (List.116, List.117): + let List.619 : U64 = 1i64; + let List.618 : List Str = CallByName List.70 List.116 List.619; + let List.617 : List Str = CallByName List.71 List.618 List.117; + ret List.617; + +procedure List.4 (List.116, List.117): + let List.622 : U64 = 1i64; + let List.621 : List U8 = CallByName List.70 List.116 List.622; + let List.620 : List U8 = CallByName List.71 List.621 List.117; + ret List.620; + +procedure List.49 (List.389, List.390): + let List.687 : U64 = StructAtIndex 0 List.390; + let List.688 : U64 = 0i64; + let List.685 : Int1 = CallByName Bool.11 List.687 List.688; + if List.685 then + dec List.389; + let List.686 : List U8 = Array []; + ret List.686; + else + let List.682 : U64 = StructAtIndex 1 List.390; + let List.683 : U64 = StructAtIndex 0 List.390; + let List.681 : List U8 = CallByName List.72 List.389 List.682 List.683; + ret List.681; + +procedure List.52 (List.404, List.405): + let List.406 : U64 = CallByName List.6 List.404; + joinpoint List.693 List.407: + let List.691 : U64 = 0i64; + let List.690 : {U64, U64} = Struct {List.407, List.691}; + inc List.404; + let List.408 : List U8 = CallByName List.49 List.404 List.690; + let List.689 : U64 = CallByName Num.20 List.406 List.407; + let List.680 : {U64, U64} = Struct {List.689, List.407}; + let List.409 : List U8 = CallByName List.49 List.404 List.680; + let List.679 : {List U8, List U8} = Struct {List.408, List.409}; + ret List.679; + in + let List.694 : Int1 = CallByName Num.24 List.406 List.405; + if List.694 then + jump List.693 List.405; + else + jump List.693 List.406; + +procedure List.6 (#Attr.2): + let List.593 : U64 = lowlevel ListLen #Attr.2; + ret List.593; + +procedure List.6 (#Attr.2): + let List.674 : U64 = lowlevel ListLen #Attr.2; + ret List.674; + +procedure List.6 (#Attr.2): + let List.675 : U64 = lowlevel ListLen #Attr.2; + ret List.675; + +procedure List.6 (#Attr.2): + let List.677 : U64 = lowlevel ListLen #Attr.2; + ret List.677; + +procedure List.66 (#Attr.2, #Attr.3): + let List.573 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.573; + +procedure List.66 (#Attr.2, #Attr.3): + let List.633 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.633; + +procedure List.66 (#Attr.2, #Attr.3): + let List.645 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.645; + +procedure List.68 (#Attr.2): + let List.670 : List Str = lowlevel ListWithCapacity #Attr.2; + ret List.670; + +procedure List.68 (#Attr.2): + let List.672 : List U8 = lowlevel ListWithCapacity #Attr.2; + ret List.672; + +procedure List.70 (#Attr.2, #Attr.3): + let List.599 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.599; + +procedure List.70 (#Attr.2, #Attr.3): + let List.616 : List Str = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.616; + +procedure List.71 (#Attr.2, #Attr.3): + let List.597 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.597; + +procedure List.71 (#Attr.2, #Attr.3): + let List.614 : List Str = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.614; + +procedure List.72 (#Attr.2, #Attr.3, #Attr.4): + let List.684 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; + ret List.684; + procedure List.8 (#Attr.2, #Attr.3): - let List.668 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; - ret List.668; + let List.649 : List Str = lowlevel ListConcat #Attr.2 #Attr.3; + ret List.649; -procedure List.80 (#Derived_gen.30, #Derived_gen.31, #Derived_gen.32, #Derived_gen.33, #Derived_gen.34): - joinpoint List.715 List.439 List.440 List.441 List.442 List.443: - let List.717 : Int1 = CallByName Num.22 List.442 List.443; - if List.717 then - let List.726 : U8 = CallByName List.66 List.439 List.442; - let List.718 : [C {U64, Int1}, C {U64, Int1}] = CallByName TotallyNotJson.189 List.440 List.726; - let List.723 : U8 = 1i64; - let List.724 : U8 = GetTagId List.718; - let List.725 : Int1 = lowlevel Eq List.723 List.724; - if List.725 then - let List.444 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.718; - let List.721 : U64 = 1i64; - let List.720 : U64 = CallByName Num.19 List.442 List.721; - jump List.715 List.439 List.444 List.441 List.720 List.443; +procedure List.8 (#Attr.2, #Attr.3): + let List.657 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; + ret List.657; + +procedure List.80 (#Derived_gen.25, #Derived_gen.26, #Derived_gen.27, #Derived_gen.28, #Derived_gen.29): + joinpoint List.704 List.452 List.453 List.454 List.455 List.456: + let List.706 : Int1 = CallByName Num.22 List.455 List.456; + if List.706 then + let List.715 : U8 = CallByName List.66 List.452 List.455; + let List.707 : [C {U64, Int1}, C {U64, Int1}] = CallByName TotallyNotJson.189 List.453 List.715; + let List.712 : U8 = 1i64; + let List.713 : U8 = GetTagId List.707; + let List.714 : Int1 = lowlevel Eq List.712 List.713; + if List.714 then + let List.457 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.707; + let List.710 : U64 = 1i64; + let List.709 : U64 = CallByName Num.19 List.455 List.710; + jump List.704 List.452 List.457 List.454 List.709 List.456; else - dec List.439; - let List.445 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.718; - let List.722 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) List.445; - ret List.722; + dec List.452; + let List.458 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.707; + let List.711 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) List.458; + ret List.711; else - dec List.439; - let List.716 : [C {U64, Int1}, C {U64, Int1}] = TagId(1) List.440; - ret List.716; + dec List.452; + let List.705 : [C {U64, Int1}, C {U64, Int1}] = TagId(1) List.453; + ret List.705; in - jump List.715 #Derived_gen.30 #Derived_gen.31 #Derived_gen.32 #Derived_gen.33 #Derived_gen.34; + jump List.704 #Derived_gen.25 #Derived_gen.26 #Derived_gen.27 #Derived_gen.28 #Derived_gen.29; -procedure List.80 (#Derived_gen.36, #Derived_gen.37, #Derived_gen.38, #Derived_gen.39, #Derived_gen.40): - joinpoint List.644 List.439 List.440 List.441 List.442 List.443: - let List.646 : Int1 = CallByName Num.22 List.442 List.443; - if List.646 then - let List.653 : U8 = CallByName List.66 List.439 List.442; - let List.647 : List U8 = CallByName List.145 List.440 List.653 List.441; - let List.650 : U64 = 1i64; - let List.649 : U64 = CallByName Num.19 List.442 List.650; - jump List.644 List.439 List.647 List.441 List.649 List.443; +procedure List.86 (#Derived_gen.30, #Derived_gen.31, #Derived_gen.32, #Derived_gen.33, #Derived_gen.34): + joinpoint List.566 List.148 List.149 List.150 List.151 List.152: + let List.568 : Int1 = CallByName Num.22 List.151 List.152; + if List.568 then + let List.572 : {Str, Str} = CallByName List.66 List.148 List.151; + inc List.572; + let List.153 : {List U8, U64} = CallByName TotallyNotJson.237 List.149 List.572 List.150; + let List.571 : U64 = 1i64; + let List.570 : U64 = CallByName Num.51 List.151 List.571; + jump List.566 List.148 List.153 List.150 List.570 List.152; else - dec List.439; - ret List.440; + dec List.148; + ret List.149; in - jump List.644 #Derived_gen.36 #Derived_gen.37 #Derived_gen.38 #Derived_gen.39 #Derived_gen.40; + jump List.566 #Derived_gen.30 #Derived_gen.31 #Derived_gen.32 #Derived_gen.33 #Derived_gen.34; -procedure List.80 (#Derived_gen.41, #Derived_gen.42, #Derived_gen.43, #Derived_gen.44, #Derived_gen.45): - joinpoint List.624 List.439 List.440 List.441 List.442 List.443: - let List.626 : Int1 = CallByName Num.22 List.442 List.443; - if List.626 then - let List.633 : {Str, Str} = CallByName List.66 List.439 List.442; - inc List.633; - let List.627 : {List U8, U64} = CallByName List.145 List.440 List.633 List.441; - let List.630 : U64 = 1i64; - let List.629 : U64 = CallByName Num.19 List.442 List.630; - jump List.624 List.439 List.627 List.441 List.629 List.443; +procedure List.86 (#Derived_gen.44, #Derived_gen.45, #Derived_gen.46, #Derived_gen.47, #Derived_gen.48): + joinpoint List.638 List.148 List.149 List.150 List.151 List.152: + let List.640 : Int1 = CallByName Num.22 List.151 List.152; + if List.640 then + let List.644 : U8 = CallByName List.66 List.148 List.151; + let List.153 : List U8 = CallByName TotallyNotJson.215 List.149 List.644; + let List.643 : U64 = 1i64; + let List.642 : U64 = CallByName Num.51 List.151 List.643; + jump List.638 List.148 List.153 List.150 List.642 List.152; else - dec List.439; - ret List.440; + dec List.148; + ret List.149; in - jump List.624 #Derived_gen.41 #Derived_gen.42 #Derived_gen.43 #Derived_gen.44 #Derived_gen.45; + jump List.638 #Derived_gen.44 #Derived_gen.45 #Derived_gen.46 #Derived_gen.47 #Derived_gen.48; -procedure List.80 (#Derived_gen.52, #Derived_gen.53, #Derived_gen.54, #Derived_gen.55, #Derived_gen.56): - joinpoint List.556 List.439 List.440 List.441 List.442 List.443: - let List.558 : Int1 = CallByName Num.22 List.442 List.443; - if List.558 then - let List.565 : {Str, Str} = CallByName List.66 List.439 List.442; - inc List.565; - let List.559 : {List U8, U64} = CallByName List.145 List.440 List.565 List.441; - let List.562 : U64 = 1i64; - let List.561 : U64 = CallByName Num.19 List.442 List.562; - jump List.556 List.439 List.559 List.441 List.561 List.443; +procedure List.86 (#Derived_gen.49, #Derived_gen.50, #Derived_gen.51, #Derived_gen.52, #Derived_gen.53): + joinpoint List.626 List.148 List.149 List.150 List.151 List.152: + let List.628 : Int1 = CallByName Num.22 List.151 List.152; + if List.628 then + let List.632 : {Str, Str} = CallByName List.66 List.148 List.151; + inc List.632; + let List.153 : {List U8, U64} = CallByName TotallyNotJson.237 List.149 List.632 List.150; + let List.631 : U64 = 1i64; + let List.630 : U64 = CallByName Num.51 List.151 List.631; + jump List.626 List.148 List.153 List.150 List.630 List.152; else - dec List.439; - ret List.440; + dec List.148; + ret List.149; in - jump List.556 #Derived_gen.52 #Derived_gen.53 #Derived_gen.54 #Derived_gen.55 #Derived_gen.56; + jump List.626 #Derived_gen.49 #Derived_gen.50 #Derived_gen.51 #Derived_gen.52 #Derived_gen.53; -procedure List.93 (List.436, List.437, List.438): - let List.554 : U64 = 0i64; - let List.555 : U64 = CallByName List.6 List.436; - let List.553 : {List U8, U64} = CallByName List.80 List.436 List.437 List.438 List.554 List.555; - ret List.553; - -procedure List.93 (List.436, List.437, List.438): - let List.622 : U64 = 0i64; - let List.623 : U64 = CallByName List.6 List.436; - let List.621 : {List U8, U64} = CallByName List.80 List.436 List.437 List.438 List.622 List.623; - ret List.621; - -procedure List.93 (List.436, List.437, List.438): - let List.642 : U64 = 0i64; - let List.643 : U64 = CallByName List.6 List.436; - let List.641 : List U8 = CallByName List.80 List.436 List.437 List.438 List.642 List.643; - ret List.641; - -procedure List.93 (List.436, List.437, List.438): - let List.713 : U64 = 0i64; - let List.714 : U64 = CallByName List.6 List.436; - let List.712 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.80 List.436 List.437 List.438 List.713 List.714; - ret List.712; +procedure List.96 (List.449, List.450, List.451): + let List.702 : U64 = 0i64; + let List.703 : U64 = CallByName List.6 List.449; + let List.701 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.80 List.449 List.450 List.451 List.702 List.703; + ret List.701; procedure Num.127 (#Attr.2): let Num.307 : U8 = lowlevel NumIntCast #Attr.2; ret Num.307; procedure Num.19 (#Attr.2, #Attr.3): - let Num.316 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.316; + let Num.321 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.321; procedure Num.20 (#Attr.2, #Attr.3): - let Num.320 : U64 = lowlevel NumSub #Attr.2 #Attr.3; - ret Num.320; + let Num.319 : U64 = lowlevel NumSub #Attr.2 #Attr.3; + ret Num.319; procedure Num.21 (#Attr.2, #Attr.3): let Num.313 : U64 = lowlevel NumMul #Attr.2 #Attr.3; ret Num.313; procedure Num.22 (#Attr.2, #Attr.3): - let Num.319 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; - ret Num.319; + let Num.318 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + ret Num.318; procedure Num.24 (#Attr.2, #Attr.3): - let Num.321 : Int1 = lowlevel NumGt #Attr.2 #Attr.3; - ret Num.321; + let Num.320 : Int1 = lowlevel NumGt #Attr.2 #Attr.3; + ret Num.320; + +procedure Num.51 (#Attr.2, #Attr.3): + let Num.315 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; + ret Num.315; procedure Num.94 (#Attr.2, #Attr.3): let Num.312 : U64 = lowlevel NumDivCeilUnchecked #Attr.2 #Attr.3; @@ -1393,7 +1373,7 @@ procedure TotallyNotJson.95 (TotallyNotJson.829): dec TotallyNotJson.1841; ret TotallyNotJson.1839; -procedure TotallyNotJson.96 (#Derived_gen.29): +procedure TotallyNotJson.96 (#Derived_gen.23): joinpoint TotallyNotJson.1847 TotallyNotJson.1168: let TotallyNotJson.834 : List Str = StructAtIndex 0 TotallyNotJson.1168; let TotallyNotJson.833 : List Str = StructAtIndex 1 TotallyNotJson.1168; @@ -1429,7 +1409,7 @@ procedure TotallyNotJson.96 (#Derived_gen.29): let TotallyNotJson.1848 : {List Str, List Str} = Struct {TotallyNotJson.834, TotallyNotJson.833}; ret TotallyNotJson.1848; in - jump TotallyNotJson.1847 #Derived_gen.29; + jump TotallyNotJson.1847 #Derived_gen.23; procedure TotallyNotJson.97 (TotallyNotJson.837): let TotallyNotJson.838 : List Str = CallByName Str.55 TotallyNotJson.837; @@ -1446,7 +1426,7 @@ procedure TotallyNotJson.97 (TotallyNotJson.837): dec TotallyNotJson.1562; ret TotallyNotJson.1560; -procedure TotallyNotJson.98 (#Derived_gen.35): +procedure TotallyNotJson.98 (#Derived_gen.24): joinpoint TotallyNotJson.1568 TotallyNotJson.1169: let TotallyNotJson.842 : List Str = StructAtIndex 0 TotallyNotJson.1169; let TotallyNotJson.841 : List Str = StructAtIndex 1 TotallyNotJson.1169; @@ -1482,7 +1462,7 @@ procedure TotallyNotJson.98 (#Derived_gen.35): let TotallyNotJson.1569 : {List Str, List Str} = Struct {TotallyNotJson.842, TotallyNotJson.841}; ret TotallyNotJson.1569; in - jump TotallyNotJson.1568 #Derived_gen.35; + jump TotallyNotJson.1568 #Derived_gen.24; procedure Test.0 (): let Test.12 : Str = "bar"; diff --git a/crates/compiler/test_mono/generated/encode_derived_record_one_field_string.txt b/crates/compiler/test_mono/generated/encode_derived_record_one_field_string.txt index 81f7d70c33..a427b317fb 100644 --- a/crates/compiler/test_mono/generated/encode_derived_record_one_field_string.txt +++ b/crates/compiler/test_mono/generated/encode_derived_record_one_field_string.txt @@ -51,245 +51,233 @@ procedure Encode.26 (Encode.105, Encode.106): ret Encode.108; procedure List.13 (#Attr.2, #Attr.3): - let List.621 : List Str = lowlevel ListPrepend #Attr.2 #Attr.3; - ret List.621; + let List.618 : List Str = lowlevel ListPrepend #Attr.2 #Attr.3; + ret List.618; -procedure List.145 (List.146, List.147, List.144): - let List.569 : {List U8, U64} = CallByName TotallyNotJson.237 List.146 List.147 List.144; - ret List.569; +procedure List.18 (List.145, List.146, List.147): + let List.564 : U64 = 0i64; + let List.565 : U64 = CallByName List.6 List.145; + let List.563 : {List U8, U64} = CallByName List.86 List.145 List.146 List.147 List.564 List.565; + ret List.563; -procedure List.145 (List.146, List.147, List.144): - let List.589 : List U8 = CallByName TotallyNotJson.215 List.146 List.147; - ret List.589; +procedure List.18 (List.145, List.146, List.147): + let List.576 : U64 = 0i64; + let List.577 : U64 = CallByName List.6 List.145; + let List.575 : List U8 = CallByName List.86 List.145 List.146 List.147 List.576 List.577; + ret List.575; -procedure List.18 (List.142, List.143, List.144): - let List.550 : {List U8, U64} = CallByName List.93 List.142 List.143 List.144; - ret List.550; - -procedure List.18 (List.142, List.143, List.144): - let List.570 : List U8 = CallByName List.93 List.142 List.143 List.144; - ret List.570; - -procedure List.26 (List.159, List.160, List.161): - let List.638 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.93 List.159 List.160 List.161; - let List.641 : U8 = 1i64; - let List.642 : U8 = GetTagId List.638; - let List.643 : Int1 = lowlevel Eq List.641 List.642; - if List.643 then - let List.162 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.638; - ret List.162; +procedure List.26 (List.172, List.173, List.174): + let List.635 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.96 List.172 List.173 List.174; + let List.638 : U8 = 1i64; + let List.639 : U8 = GetTagId List.635; + let List.640 : Int1 = lowlevel Eq List.638 List.639; + if List.640 then + let List.175 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.635; + ret List.175; else - let List.163 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.638; - ret List.163; + let List.176 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.635; + ret List.176; procedure List.31 (#Attr.2, #Attr.3): - let List.603 : List Str = lowlevel ListDropAt #Attr.2 #Attr.3; - ret List.603; + let List.600 : List Str = lowlevel ListDropAt #Attr.2 #Attr.3; + ret List.600; -procedure List.38 (List.298): - let List.611 : U64 = 0i64; - let List.610 : List Str = CallByName List.31 List.298 List.611; - ret List.610; +procedure List.38 (List.311): + let List.608 : U64 = 0i64; + let List.607 : List Str = CallByName List.31 List.311 List.608; + ret List.607; -procedure List.4 (List.113, List.114): - let List.546 : U64 = 1i64; - let List.545 : List Str = CallByName List.70 List.113 List.546; - let List.544 : List Str = CallByName List.71 List.545 List.114; - ret List.544; +procedure List.4 (List.116, List.117): + let List.559 : U64 = 1i64; + let List.558 : List Str = CallByName List.70 List.116 List.559; + let List.557 : List Str = CallByName List.71 List.558 List.117; + ret List.557; -procedure List.4 (List.113, List.114): - let List.549 : U64 = 1i64; - let List.548 : List U8 = CallByName List.70 List.113 List.549; - let List.547 : List U8 = CallByName List.71 List.548 List.114; - ret List.547; +procedure List.4 (List.116, List.117): + let List.562 : U64 = 1i64; + let List.561 : List U8 = CallByName List.70 List.116 List.562; + let List.560 : List U8 = CallByName List.71 List.561 List.117; + ret List.560; -procedure List.49 (List.376, List.377): - let List.630 : U64 = StructAtIndex 0 List.377; - let List.631 : U64 = 0i64; - let List.628 : Int1 = CallByName Bool.11 List.630 List.631; - if List.628 then - dec List.376; - let List.629 : List U8 = Array []; - ret List.629; +procedure List.49 (List.389, List.390): + let List.627 : U64 = StructAtIndex 0 List.390; + let List.628 : U64 = 0i64; + let List.625 : Int1 = CallByName Bool.11 List.627 List.628; + if List.625 then + dec List.389; + let List.626 : List U8 = Array []; + ret List.626; else - let List.625 : U64 = StructAtIndex 1 List.377; - let List.626 : U64 = StructAtIndex 0 List.377; - let List.624 : List U8 = CallByName List.72 List.376 List.625 List.626; - ret List.624; + let List.622 : U64 = StructAtIndex 1 List.390; + let List.623 : U64 = StructAtIndex 0 List.390; + let List.621 : List U8 = CallByName List.72 List.389 List.622 List.623; + ret List.621; -procedure List.52 (List.391, List.392): - let List.393 : U64 = CallByName List.6 List.391; - joinpoint List.636 List.394: - let List.634 : U64 = 0i64; - let List.633 : {U64, U64} = Struct {List.394, List.634}; - inc List.391; - let List.395 : List U8 = CallByName List.49 List.391 List.633; - let List.632 : U64 = CallByName Num.20 List.393 List.394; - let List.623 : {U64, U64} = Struct {List.632, List.394}; - let List.396 : List U8 = CallByName List.49 List.391 List.623; - let List.622 : {List U8, List U8} = Struct {List.395, List.396}; - ret List.622; +procedure List.52 (List.404, List.405): + let List.406 : U64 = CallByName List.6 List.404; + joinpoint List.633 List.407: + let List.631 : U64 = 0i64; + let List.630 : {U64, U64} = Struct {List.407, List.631}; + inc List.404; + let List.408 : List U8 = CallByName List.49 List.404 List.630; + let List.629 : U64 = CallByName Num.20 List.406 List.407; + let List.620 : {U64, U64} = Struct {List.629, List.407}; + let List.409 : List U8 = CallByName List.49 List.404 List.620; + let List.619 : {List U8, List U8} = Struct {List.408, List.409}; + ret List.619; in - let List.637 : Int1 = CallByName Num.24 List.393 List.392; - if List.637 then - jump List.636 List.392; + let List.634 : Int1 = CallByName Num.24 List.406 List.405; + if List.634 then + jump List.633 List.405; else - jump List.636 List.393; + jump List.633 List.406; + +procedure List.6 (#Attr.2): + let List.614 : U64 = lowlevel ListLen #Attr.2; + ret List.614; + +procedure List.6 (#Attr.2): + let List.615 : U64 = lowlevel ListLen #Attr.2; + ret List.615; procedure List.6 (#Attr.2): let List.617 : U64 = lowlevel ListLen #Attr.2; ret List.617; -procedure List.6 (#Attr.2): - let List.618 : U64 = lowlevel ListLen #Attr.2; - ret List.618; - -procedure List.6 (#Attr.2): - let List.620 : U64 = lowlevel ListLen #Attr.2; - ret List.620; - procedure List.66 (#Attr.2, #Attr.3): - let List.566 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.566; - -procedure List.66 (#Attr.2, #Attr.3): - let List.586 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.586; - -procedure List.68 (#Attr.2): - let List.613 : List Str = lowlevel ListWithCapacity #Attr.2; - ret List.613; - -procedure List.68 (#Attr.2): - let List.615 : List U8 = lowlevel ListWithCapacity #Attr.2; - ret List.615; - -procedure List.70 (#Attr.2, #Attr.3): - let List.526 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.526; - -procedure List.70 (#Attr.2, #Attr.3): - let List.543 : List Str = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.543; - -procedure List.71 (#Attr.2, #Attr.3): - let List.524 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.524; - -procedure List.71 (#Attr.2, #Attr.3): - let List.541 : List Str = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.541; - -procedure List.72 (#Attr.2, #Attr.3, #Attr.4): - let List.627 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; - ret List.627; - -procedure List.8 (#Attr.2, #Attr.3): - let List.592 : List Str = lowlevel ListConcat #Attr.2 #Attr.3; - ret List.592; - -procedure List.8 (#Attr.2, #Attr.3): - let List.600 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; - ret List.600; - -procedure List.80 (#Derived_gen.10, #Derived_gen.11, #Derived_gen.12, #Derived_gen.13, #Derived_gen.14): - joinpoint List.647 List.439 List.440 List.441 List.442 List.443: - let List.649 : Int1 = CallByName Num.22 List.442 List.443; - if List.649 then - let List.658 : U8 = CallByName List.66 List.439 List.442; - let List.650 : [C {U64, Int1}, C {U64, Int1}] = CallByName TotallyNotJson.189 List.440 List.658; - let List.655 : U8 = 1i64; - let List.656 : U8 = GetTagId List.650; - let List.657 : Int1 = lowlevel Eq List.655 List.656; - if List.657 then - let List.444 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.650; - let List.653 : U64 = 1i64; - let List.652 : U64 = CallByName Num.19 List.442 List.653; - jump List.647 List.439 List.444 List.441 List.652 List.443; - else - dec List.439; - let List.445 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.650; - let List.654 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) List.445; - ret List.654; - else - dec List.439; - let List.648 : [C {U64, Int1}, C {U64, Int1}] = TagId(1) List.440; - ret List.648; - in - jump List.647 #Derived_gen.10 #Derived_gen.11 #Derived_gen.12 #Derived_gen.13 #Derived_gen.14; - -procedure List.80 (#Derived_gen.18, #Derived_gen.19, #Derived_gen.20, #Derived_gen.21, #Derived_gen.22): - joinpoint List.576 List.439 List.440 List.441 List.442 List.443: - let List.578 : Int1 = CallByName Num.22 List.442 List.443; - if List.578 then - let List.585 : U8 = CallByName List.66 List.439 List.442; - let List.579 : List U8 = CallByName List.145 List.440 List.585 List.441; - let List.582 : U64 = 1i64; - let List.581 : U64 = CallByName Num.19 List.442 List.582; - jump List.576 List.439 List.579 List.441 List.581 List.443; - else - dec List.439; - ret List.440; - in - jump List.576 #Derived_gen.18 #Derived_gen.19 #Derived_gen.20 #Derived_gen.21 #Derived_gen.22; - -procedure List.80 (#Derived_gen.31, #Derived_gen.32, #Derived_gen.33, #Derived_gen.34, #Derived_gen.35): - joinpoint List.556 List.439 List.440 List.441 List.442 List.443: - let List.558 : Int1 = CallByName Num.22 List.442 List.443; - if List.558 then - let List.565 : {Str, Str} = CallByName List.66 List.439 List.442; - inc List.565; - let List.559 : {List U8, U64} = CallByName List.145 List.440 List.565 List.441; - let List.562 : U64 = 1i64; - let List.561 : U64 = CallByName Num.19 List.442 List.562; - jump List.556 List.439 List.559 List.441 List.561 List.443; - else - dec List.439; - ret List.440; - in - jump List.556 #Derived_gen.31 #Derived_gen.32 #Derived_gen.33 #Derived_gen.34 #Derived_gen.35; - -procedure List.93 (List.436, List.437, List.438): - let List.554 : U64 = 0i64; - let List.555 : U64 = CallByName List.6 List.436; - let List.553 : {List U8, U64} = CallByName List.80 List.436 List.437 List.438 List.554 List.555; - ret List.553; - -procedure List.93 (List.436, List.437, List.438): - let List.574 : U64 = 0i64; - let List.575 : U64 = CallByName List.6 List.436; - let List.573 : List U8 = CallByName List.80 List.436 List.437 List.438 List.574 List.575; + let List.573 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; ret List.573; -procedure List.93 (List.436, List.437, List.438): - let List.645 : U64 = 0i64; - let List.646 : U64 = CallByName List.6 List.436; - let List.644 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.80 List.436 List.437 List.438 List.645 List.646; - ret List.644; +procedure List.66 (#Attr.2, #Attr.3): + let List.585 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.585; + +procedure List.68 (#Attr.2): + let List.610 : List Str = lowlevel ListWithCapacity #Attr.2; + ret List.610; + +procedure List.68 (#Attr.2): + let List.612 : List U8 = lowlevel ListWithCapacity #Attr.2; + ret List.612; + +procedure List.70 (#Attr.2, #Attr.3): + let List.539 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.539; + +procedure List.70 (#Attr.2, #Attr.3): + let List.556 : List Str = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.556; + +procedure List.71 (#Attr.2, #Attr.3): + let List.537 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.537; + +procedure List.71 (#Attr.2, #Attr.3): + let List.554 : List Str = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.554; + +procedure List.72 (#Attr.2, #Attr.3, #Attr.4): + let List.624 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; + ret List.624; + +procedure List.8 (#Attr.2, #Attr.3): + let List.589 : List Str = lowlevel ListConcat #Attr.2 #Attr.3; + ret List.589; + +procedure List.8 (#Attr.2, #Attr.3): + let List.597 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; + ret List.597; + +procedure List.80 (#Derived_gen.10, #Derived_gen.11, #Derived_gen.12, #Derived_gen.13, #Derived_gen.14): + joinpoint List.644 List.452 List.453 List.454 List.455 List.456: + let List.646 : Int1 = CallByName Num.22 List.455 List.456; + if List.646 then + let List.655 : U8 = CallByName List.66 List.452 List.455; + let List.647 : [C {U64, Int1}, C {U64, Int1}] = CallByName TotallyNotJson.189 List.453 List.655; + let List.652 : U8 = 1i64; + let List.653 : U8 = GetTagId List.647; + let List.654 : Int1 = lowlevel Eq List.652 List.653; + if List.654 then + let List.457 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.647; + let List.650 : U64 = 1i64; + let List.649 : U64 = CallByName Num.19 List.455 List.650; + jump List.644 List.452 List.457 List.454 List.649 List.456; + else + dec List.452; + let List.458 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.647; + let List.651 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) List.458; + ret List.651; + else + dec List.452; + let List.645 : [C {U64, Int1}, C {U64, Int1}] = TagId(1) List.453; + ret List.645; + in + jump List.644 #Derived_gen.10 #Derived_gen.11 #Derived_gen.12 #Derived_gen.13 #Derived_gen.14; + +procedure List.86 (#Derived_gen.15, #Derived_gen.16, #Derived_gen.17, #Derived_gen.18, #Derived_gen.19): + joinpoint List.566 List.148 List.149 List.150 List.151 List.152: + let List.568 : Int1 = CallByName Num.22 List.151 List.152; + if List.568 then + let List.572 : {Str, Str} = CallByName List.66 List.148 List.151; + inc List.572; + let List.153 : {List U8, U64} = CallByName TotallyNotJson.237 List.149 List.572 List.150; + let List.571 : U64 = 1i64; + let List.570 : U64 = CallByName Num.51 List.151 List.571; + jump List.566 List.148 List.153 List.150 List.570 List.152; + else + dec List.148; + ret List.149; + in + jump List.566 #Derived_gen.15 #Derived_gen.16 #Derived_gen.17 #Derived_gen.18 #Derived_gen.19; + +procedure List.86 (#Derived_gen.31, #Derived_gen.32, #Derived_gen.33, #Derived_gen.34, #Derived_gen.35): + joinpoint List.578 List.148 List.149 List.150 List.151 List.152: + let List.580 : Int1 = CallByName Num.22 List.151 List.152; + if List.580 then + let List.584 : U8 = CallByName List.66 List.148 List.151; + let List.153 : List U8 = CallByName TotallyNotJson.215 List.149 List.584; + let List.583 : U64 = 1i64; + let List.582 : U64 = CallByName Num.51 List.151 List.583; + jump List.578 List.148 List.153 List.150 List.582 List.152; + else + dec List.148; + ret List.149; + in + jump List.578 #Derived_gen.31 #Derived_gen.32 #Derived_gen.33 #Derived_gen.34 #Derived_gen.35; + +procedure List.96 (List.449, List.450, List.451): + let List.642 : U64 = 0i64; + let List.643 : U64 = CallByName List.6 List.449; + let List.641 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.80 List.449 List.450 List.451 List.642 List.643; + ret List.641; procedure Num.127 (#Attr.2): let Num.297 : U8 = lowlevel NumIntCast #Attr.2; ret Num.297; procedure Num.19 (#Attr.2, #Attr.3): - let Num.306 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.306; + let Num.311 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.311; procedure Num.20 (#Attr.2, #Attr.3): - let Num.310 : U64 = lowlevel NumSub #Attr.2 #Attr.3; - ret Num.310; + let Num.309 : U64 = lowlevel NumSub #Attr.2 #Attr.3; + ret Num.309; procedure Num.21 (#Attr.2, #Attr.3): let Num.303 : U64 = lowlevel NumMul #Attr.2 #Attr.3; ret Num.303; procedure Num.22 (#Attr.2, #Attr.3): - let Num.309 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; - ret Num.309; + let Num.308 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + ret Num.308; procedure Num.24 (#Attr.2, #Attr.3): - let Num.311 : Int1 = lowlevel NumGt #Attr.2 #Attr.3; - ret Num.311; + let Num.310 : Int1 = lowlevel NumGt #Attr.2 #Attr.3; + ret Num.310; + +procedure Num.51 (#Attr.2, #Attr.3): + let Num.305 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; + ret Num.305; procedure Num.94 (#Attr.2, #Attr.3): let Num.302 : U64 = lowlevel NumDivCeilUnchecked #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/encode_derived_record_two_field_strings.txt b/crates/compiler/test_mono/generated/encode_derived_record_two_field_strings.txt index 810705ef6f..f993bf4681 100644 --- a/crates/compiler/test_mono/generated/encode_derived_record_two_field_strings.txt +++ b/crates/compiler/test_mono/generated/encode_derived_record_two_field_strings.txt @@ -58,245 +58,233 @@ procedure Encode.26 (Encode.105, Encode.106): ret Encode.108; procedure List.13 (#Attr.2, #Attr.3): - let List.621 : List Str = lowlevel ListPrepend #Attr.2 #Attr.3; - ret List.621; + let List.618 : List Str = lowlevel ListPrepend #Attr.2 #Attr.3; + ret List.618; -procedure List.145 (List.146, List.147, List.144): - let List.569 : {List U8, U64} = CallByName TotallyNotJson.237 List.146 List.147 List.144; - ret List.569; +procedure List.18 (List.145, List.146, List.147): + let List.564 : U64 = 0i64; + let List.565 : U64 = CallByName List.6 List.145; + let List.563 : {List U8, U64} = CallByName List.86 List.145 List.146 List.147 List.564 List.565; + ret List.563; -procedure List.145 (List.146, List.147, List.144): - let List.589 : List U8 = CallByName TotallyNotJson.215 List.146 List.147; - ret List.589; +procedure List.18 (List.145, List.146, List.147): + let List.576 : U64 = 0i64; + let List.577 : U64 = CallByName List.6 List.145; + let List.575 : List U8 = CallByName List.86 List.145 List.146 List.147 List.576 List.577; + ret List.575; -procedure List.18 (List.142, List.143, List.144): - let List.550 : {List U8, U64} = CallByName List.93 List.142 List.143 List.144; - ret List.550; - -procedure List.18 (List.142, List.143, List.144): - let List.570 : List U8 = CallByName List.93 List.142 List.143 List.144; - ret List.570; - -procedure List.26 (List.159, List.160, List.161): - let List.638 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.93 List.159 List.160 List.161; - let List.641 : U8 = 1i64; - let List.642 : U8 = GetTagId List.638; - let List.643 : Int1 = lowlevel Eq List.641 List.642; - if List.643 then - let List.162 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.638; - ret List.162; +procedure List.26 (List.172, List.173, List.174): + let List.635 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.96 List.172 List.173 List.174; + let List.638 : U8 = 1i64; + let List.639 : U8 = GetTagId List.635; + let List.640 : Int1 = lowlevel Eq List.638 List.639; + if List.640 then + let List.175 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.635; + ret List.175; else - let List.163 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.638; - ret List.163; + let List.176 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.635; + ret List.176; procedure List.31 (#Attr.2, #Attr.3): - let List.603 : List Str = lowlevel ListDropAt #Attr.2 #Attr.3; - ret List.603; + let List.600 : List Str = lowlevel ListDropAt #Attr.2 #Attr.3; + ret List.600; -procedure List.38 (List.298): - let List.611 : U64 = 0i64; - let List.610 : List Str = CallByName List.31 List.298 List.611; - ret List.610; +procedure List.38 (List.311): + let List.608 : U64 = 0i64; + let List.607 : List Str = CallByName List.31 List.311 List.608; + ret List.607; -procedure List.4 (List.113, List.114): - let List.546 : U64 = 1i64; - let List.545 : List Str = CallByName List.70 List.113 List.546; - let List.544 : List Str = CallByName List.71 List.545 List.114; - ret List.544; +procedure List.4 (List.116, List.117): + let List.559 : U64 = 1i64; + let List.558 : List Str = CallByName List.70 List.116 List.559; + let List.557 : List Str = CallByName List.71 List.558 List.117; + ret List.557; -procedure List.4 (List.113, List.114): - let List.549 : U64 = 1i64; - let List.548 : List U8 = CallByName List.70 List.113 List.549; - let List.547 : List U8 = CallByName List.71 List.548 List.114; - ret List.547; +procedure List.4 (List.116, List.117): + let List.562 : U64 = 1i64; + let List.561 : List U8 = CallByName List.70 List.116 List.562; + let List.560 : List U8 = CallByName List.71 List.561 List.117; + ret List.560; -procedure List.49 (List.376, List.377): - let List.630 : U64 = StructAtIndex 0 List.377; - let List.631 : U64 = 0i64; - let List.628 : Int1 = CallByName Bool.11 List.630 List.631; - if List.628 then - dec List.376; - let List.629 : List U8 = Array []; - ret List.629; +procedure List.49 (List.389, List.390): + let List.627 : U64 = StructAtIndex 0 List.390; + let List.628 : U64 = 0i64; + let List.625 : Int1 = CallByName Bool.11 List.627 List.628; + if List.625 then + dec List.389; + let List.626 : List U8 = Array []; + ret List.626; else - let List.625 : U64 = StructAtIndex 1 List.377; - let List.626 : U64 = StructAtIndex 0 List.377; - let List.624 : List U8 = CallByName List.72 List.376 List.625 List.626; - ret List.624; + let List.622 : U64 = StructAtIndex 1 List.390; + let List.623 : U64 = StructAtIndex 0 List.390; + let List.621 : List U8 = CallByName List.72 List.389 List.622 List.623; + ret List.621; -procedure List.52 (List.391, List.392): - let List.393 : U64 = CallByName List.6 List.391; - joinpoint List.636 List.394: - let List.634 : U64 = 0i64; - let List.633 : {U64, U64} = Struct {List.394, List.634}; - inc List.391; - let List.395 : List U8 = CallByName List.49 List.391 List.633; - let List.632 : U64 = CallByName Num.20 List.393 List.394; - let List.623 : {U64, U64} = Struct {List.632, List.394}; - let List.396 : List U8 = CallByName List.49 List.391 List.623; - let List.622 : {List U8, List U8} = Struct {List.395, List.396}; - ret List.622; +procedure List.52 (List.404, List.405): + let List.406 : U64 = CallByName List.6 List.404; + joinpoint List.633 List.407: + let List.631 : U64 = 0i64; + let List.630 : {U64, U64} = Struct {List.407, List.631}; + inc List.404; + let List.408 : List U8 = CallByName List.49 List.404 List.630; + let List.629 : U64 = CallByName Num.20 List.406 List.407; + let List.620 : {U64, U64} = Struct {List.629, List.407}; + let List.409 : List U8 = CallByName List.49 List.404 List.620; + let List.619 : {List U8, List U8} = Struct {List.408, List.409}; + ret List.619; in - let List.637 : Int1 = CallByName Num.24 List.393 List.392; - if List.637 then - jump List.636 List.392; + let List.634 : Int1 = CallByName Num.24 List.406 List.405; + if List.634 then + jump List.633 List.405; else - jump List.636 List.393; + jump List.633 List.406; + +procedure List.6 (#Attr.2): + let List.614 : U64 = lowlevel ListLen #Attr.2; + ret List.614; + +procedure List.6 (#Attr.2): + let List.615 : U64 = lowlevel ListLen #Attr.2; + ret List.615; procedure List.6 (#Attr.2): let List.617 : U64 = lowlevel ListLen #Attr.2; ret List.617; -procedure List.6 (#Attr.2): - let List.618 : U64 = lowlevel ListLen #Attr.2; - ret List.618; - -procedure List.6 (#Attr.2): - let List.620 : U64 = lowlevel ListLen #Attr.2; - ret List.620; - procedure List.66 (#Attr.2, #Attr.3): - let List.566 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.566; - -procedure List.66 (#Attr.2, #Attr.3): - let List.586 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.586; - -procedure List.68 (#Attr.2): - let List.613 : List Str = lowlevel ListWithCapacity #Attr.2; - ret List.613; - -procedure List.68 (#Attr.2): - let List.615 : List U8 = lowlevel ListWithCapacity #Attr.2; - ret List.615; - -procedure List.70 (#Attr.2, #Attr.3): - let List.526 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.526; - -procedure List.70 (#Attr.2, #Attr.3): - let List.543 : List Str = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.543; - -procedure List.71 (#Attr.2, #Attr.3): - let List.524 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.524; - -procedure List.71 (#Attr.2, #Attr.3): - let List.541 : List Str = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.541; - -procedure List.72 (#Attr.2, #Attr.3, #Attr.4): - let List.627 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; - ret List.627; - -procedure List.8 (#Attr.2, #Attr.3): - let List.592 : List Str = lowlevel ListConcat #Attr.2 #Attr.3; - ret List.592; - -procedure List.8 (#Attr.2, #Attr.3): - let List.600 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; - ret List.600; - -procedure List.80 (#Derived_gen.14, #Derived_gen.15, #Derived_gen.16, #Derived_gen.17, #Derived_gen.18): - joinpoint List.647 List.439 List.440 List.441 List.442 List.443: - let List.649 : Int1 = CallByName Num.22 List.442 List.443; - if List.649 then - let List.658 : U8 = CallByName List.66 List.439 List.442; - let List.650 : [C {U64, Int1}, C {U64, Int1}] = CallByName TotallyNotJson.189 List.440 List.658; - let List.655 : U8 = 1i64; - let List.656 : U8 = GetTagId List.650; - let List.657 : Int1 = lowlevel Eq List.655 List.656; - if List.657 then - let List.444 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.650; - let List.653 : U64 = 1i64; - let List.652 : U64 = CallByName Num.19 List.442 List.653; - jump List.647 List.439 List.444 List.441 List.652 List.443; - else - dec List.439; - let List.445 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.650; - let List.654 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) List.445; - ret List.654; - else - dec List.439; - let List.648 : [C {U64, Int1}, C {U64, Int1}] = TagId(1) List.440; - ret List.648; - in - jump List.647 #Derived_gen.14 #Derived_gen.15 #Derived_gen.16 #Derived_gen.17 #Derived_gen.18; - -procedure List.80 (#Derived_gen.22, #Derived_gen.23, #Derived_gen.24, #Derived_gen.25, #Derived_gen.26): - joinpoint List.576 List.439 List.440 List.441 List.442 List.443: - let List.578 : Int1 = CallByName Num.22 List.442 List.443; - if List.578 then - let List.585 : U8 = CallByName List.66 List.439 List.442; - let List.579 : List U8 = CallByName List.145 List.440 List.585 List.441; - let List.582 : U64 = 1i64; - let List.581 : U64 = CallByName Num.19 List.442 List.582; - jump List.576 List.439 List.579 List.441 List.581 List.443; - else - dec List.439; - ret List.440; - in - jump List.576 #Derived_gen.22 #Derived_gen.23 #Derived_gen.24 #Derived_gen.25 #Derived_gen.26; - -procedure List.80 (#Derived_gen.35, #Derived_gen.36, #Derived_gen.37, #Derived_gen.38, #Derived_gen.39): - joinpoint List.556 List.439 List.440 List.441 List.442 List.443: - let List.558 : Int1 = CallByName Num.22 List.442 List.443; - if List.558 then - let List.565 : {Str, Str} = CallByName List.66 List.439 List.442; - inc List.565; - let List.559 : {List U8, U64} = CallByName List.145 List.440 List.565 List.441; - let List.562 : U64 = 1i64; - let List.561 : U64 = CallByName Num.19 List.442 List.562; - jump List.556 List.439 List.559 List.441 List.561 List.443; - else - dec List.439; - ret List.440; - in - jump List.556 #Derived_gen.35 #Derived_gen.36 #Derived_gen.37 #Derived_gen.38 #Derived_gen.39; - -procedure List.93 (List.436, List.437, List.438): - let List.554 : U64 = 0i64; - let List.555 : U64 = CallByName List.6 List.436; - let List.553 : {List U8, U64} = CallByName List.80 List.436 List.437 List.438 List.554 List.555; - ret List.553; - -procedure List.93 (List.436, List.437, List.438): - let List.574 : U64 = 0i64; - let List.575 : U64 = CallByName List.6 List.436; - let List.573 : List U8 = CallByName List.80 List.436 List.437 List.438 List.574 List.575; + let List.573 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; ret List.573; -procedure List.93 (List.436, List.437, List.438): - let List.645 : U64 = 0i64; - let List.646 : U64 = CallByName List.6 List.436; - let List.644 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.80 List.436 List.437 List.438 List.645 List.646; - ret List.644; +procedure List.66 (#Attr.2, #Attr.3): + let List.585 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.585; + +procedure List.68 (#Attr.2): + let List.610 : List Str = lowlevel ListWithCapacity #Attr.2; + ret List.610; + +procedure List.68 (#Attr.2): + let List.612 : List U8 = lowlevel ListWithCapacity #Attr.2; + ret List.612; + +procedure List.70 (#Attr.2, #Attr.3): + let List.539 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.539; + +procedure List.70 (#Attr.2, #Attr.3): + let List.556 : List Str = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.556; + +procedure List.71 (#Attr.2, #Attr.3): + let List.537 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.537; + +procedure List.71 (#Attr.2, #Attr.3): + let List.554 : List Str = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.554; + +procedure List.72 (#Attr.2, #Attr.3, #Attr.4): + let List.624 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; + ret List.624; + +procedure List.8 (#Attr.2, #Attr.3): + let List.589 : List Str = lowlevel ListConcat #Attr.2 #Attr.3; + ret List.589; + +procedure List.8 (#Attr.2, #Attr.3): + let List.597 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; + ret List.597; + +procedure List.80 (#Derived_gen.14, #Derived_gen.15, #Derived_gen.16, #Derived_gen.17, #Derived_gen.18): + joinpoint List.644 List.452 List.453 List.454 List.455 List.456: + let List.646 : Int1 = CallByName Num.22 List.455 List.456; + if List.646 then + let List.655 : U8 = CallByName List.66 List.452 List.455; + let List.647 : [C {U64, Int1}, C {U64, Int1}] = CallByName TotallyNotJson.189 List.453 List.655; + let List.652 : U8 = 1i64; + let List.653 : U8 = GetTagId List.647; + let List.654 : Int1 = lowlevel Eq List.652 List.653; + if List.654 then + let List.457 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.647; + let List.650 : U64 = 1i64; + let List.649 : U64 = CallByName Num.19 List.455 List.650; + jump List.644 List.452 List.457 List.454 List.649 List.456; + else + dec List.452; + let List.458 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.647; + let List.651 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) List.458; + ret List.651; + else + dec List.452; + let List.645 : [C {U64, Int1}, C {U64, Int1}] = TagId(1) List.453; + ret List.645; + in + jump List.644 #Derived_gen.14 #Derived_gen.15 #Derived_gen.16 #Derived_gen.17 #Derived_gen.18; + +procedure List.86 (#Derived_gen.19, #Derived_gen.20, #Derived_gen.21, #Derived_gen.22, #Derived_gen.23): + joinpoint List.566 List.148 List.149 List.150 List.151 List.152: + let List.568 : Int1 = CallByName Num.22 List.151 List.152; + if List.568 then + let List.572 : {Str, Str} = CallByName List.66 List.148 List.151; + inc List.572; + let List.153 : {List U8, U64} = CallByName TotallyNotJson.237 List.149 List.572 List.150; + let List.571 : U64 = 1i64; + let List.570 : U64 = CallByName Num.51 List.151 List.571; + jump List.566 List.148 List.153 List.150 List.570 List.152; + else + dec List.148; + ret List.149; + in + jump List.566 #Derived_gen.19 #Derived_gen.20 #Derived_gen.21 #Derived_gen.22 #Derived_gen.23; + +procedure List.86 (#Derived_gen.35, #Derived_gen.36, #Derived_gen.37, #Derived_gen.38, #Derived_gen.39): + joinpoint List.578 List.148 List.149 List.150 List.151 List.152: + let List.580 : Int1 = CallByName Num.22 List.151 List.152; + if List.580 then + let List.584 : U8 = CallByName List.66 List.148 List.151; + let List.153 : List U8 = CallByName TotallyNotJson.215 List.149 List.584; + let List.583 : U64 = 1i64; + let List.582 : U64 = CallByName Num.51 List.151 List.583; + jump List.578 List.148 List.153 List.150 List.582 List.152; + else + dec List.148; + ret List.149; + in + jump List.578 #Derived_gen.35 #Derived_gen.36 #Derived_gen.37 #Derived_gen.38 #Derived_gen.39; + +procedure List.96 (List.449, List.450, List.451): + let List.642 : U64 = 0i64; + let List.643 : U64 = CallByName List.6 List.449; + let List.641 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.80 List.449 List.450 List.451 List.642 List.643; + ret List.641; procedure Num.127 (#Attr.2): let Num.297 : U8 = lowlevel NumIntCast #Attr.2; ret Num.297; procedure Num.19 (#Attr.2, #Attr.3): - let Num.306 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.306; + let Num.311 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.311; procedure Num.20 (#Attr.2, #Attr.3): - let Num.310 : U64 = lowlevel NumSub #Attr.2 #Attr.3; - ret Num.310; + let Num.309 : U64 = lowlevel NumSub #Attr.2 #Attr.3; + ret Num.309; procedure Num.21 (#Attr.2, #Attr.3): let Num.303 : U64 = lowlevel NumMul #Attr.2 #Attr.3; ret Num.303; procedure Num.22 (#Attr.2, #Attr.3): - let Num.309 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; - ret Num.309; + let Num.308 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + ret Num.308; procedure Num.24 (#Attr.2, #Attr.3): - let Num.311 : Int1 = lowlevel NumGt #Attr.2 #Attr.3; - ret Num.311; + let Num.310 : Int1 = lowlevel NumGt #Attr.2 #Attr.3; + ret Num.310; + +procedure Num.51 (#Attr.2, #Attr.3): + let Num.305 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; + ret Num.305; procedure Num.94 (#Attr.2, #Attr.3): let Num.302 : U64 = lowlevel NumDivCeilUnchecked #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/encode_derived_string.txt b/crates/compiler/test_mono/generated/encode_derived_string.txt index 3d42e396c8..477da1b469 100644 --- a/crates/compiler/test_mono/generated/encode_derived_string.txt +++ b/crates/compiler/test_mono/generated/encode_derived_string.txt @@ -15,151 +15,147 @@ procedure Encode.26 (Encode.105, Encode.106): let Encode.108 : List U8 = CallByName Encode.24 Encode.109 Encode.110 Encode.106; ret Encode.108; -procedure List.145 (List.146, List.147, List.144): - let List.552 : List U8 = CallByName TotallyNotJson.215 List.146 List.147; - ret List.552; +procedure List.18 (List.145, List.146, List.147): + let List.548 : U64 = 0i64; + let List.549 : U64 = CallByName List.6 List.145; + let List.547 : List U8 = CallByName List.86 List.145 List.146 List.147 List.548 List.549; + ret List.547; -procedure List.18 (List.142, List.143, List.144): - let List.534 : List U8 = CallByName List.93 List.142 List.143 List.144; - ret List.534; - -procedure List.26 (List.159, List.160, List.161): - let List.569 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.93 List.159 List.160 List.161; - let List.572 : U8 = 1i64; - let List.573 : U8 = GetTagId List.569; - let List.574 : Int1 = lowlevel Eq List.572 List.573; - if List.574 then - let List.162 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.569; - ret List.162; +procedure List.26 (List.172, List.173, List.174): + let List.574 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.96 List.172 List.173 List.174; + let List.577 : U8 = 1i64; + let List.578 : U8 = GetTagId List.574; + let List.579 : Int1 = lowlevel Eq List.577 List.578; + if List.579 then + let List.175 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.574; + ret List.175; else - let List.163 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.569; - ret List.163; + let List.176 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.574; + ret List.176; -procedure List.49 (List.376, List.377): - let List.561 : U64 = StructAtIndex 0 List.377; - let List.562 : U64 = 0i64; - let List.559 : Int1 = CallByName Bool.11 List.561 List.562; - if List.559 then - dec List.376; - let List.560 : List U8 = Array []; +procedure List.49 (List.389, List.390): + let List.566 : U64 = StructAtIndex 0 List.390; + let List.567 : U64 = 0i64; + let List.564 : Int1 = CallByName Bool.11 List.566 List.567; + if List.564 then + dec List.389; + let List.565 : List U8 = Array []; + ret List.565; + else + let List.561 : U64 = StructAtIndex 1 List.390; + let List.562 : U64 = StructAtIndex 0 List.390; + let List.560 : List U8 = CallByName List.72 List.389 List.561 List.562; ret List.560; - else - let List.556 : U64 = StructAtIndex 1 List.377; - let List.557 : U64 = StructAtIndex 0 List.377; - let List.555 : List U8 = CallByName List.72 List.376 List.556 List.557; - ret List.555; -procedure List.52 (List.391, List.392): - let List.393 : U64 = CallByName List.6 List.391; - joinpoint List.567 List.394: - let List.565 : U64 = 0i64; - let List.564 : {U64, U64} = Struct {List.394, List.565}; - inc List.391; - let List.395 : List U8 = CallByName List.49 List.391 List.564; - let List.563 : U64 = CallByName Num.20 List.393 List.394; - let List.554 : {U64, U64} = Struct {List.563, List.394}; - let List.396 : List U8 = CallByName List.49 List.391 List.554; - let List.553 : {List U8, List U8} = Struct {List.395, List.396}; - ret List.553; +procedure List.52 (List.404, List.405): + let List.406 : U64 = CallByName List.6 List.404; + joinpoint List.572 List.407: + let List.570 : U64 = 0i64; + let List.569 : {U64, U64} = Struct {List.407, List.570}; + inc List.404; + let List.408 : List U8 = CallByName List.49 List.404 List.569; + let List.568 : U64 = CallByName Num.20 List.406 List.407; + let List.559 : {U64, U64} = Struct {List.568, List.407}; + let List.409 : List U8 = CallByName List.49 List.404 List.559; + let List.558 : {List U8, List U8} = Struct {List.408, List.409}; + ret List.558; in - let List.568 : Int1 = CallByName Num.24 List.393 List.392; - if List.568 then - jump List.567 List.392; + let List.573 : Int1 = CallByName Num.24 List.406 List.405; + if List.573 then + jump List.572 List.405; else - jump List.567 List.393; + jump List.572 List.406; procedure List.6 (#Attr.2): - let List.533 : U64 = lowlevel ListLen #Attr.2; - ret List.533; + let List.546 : U64 = lowlevel ListLen #Attr.2; + ret List.546; procedure List.66 (#Attr.2, #Attr.3): - let List.550 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.550; + let List.557 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.557; procedure List.68 (#Attr.2): - let List.531 : List U8 = lowlevel ListWithCapacity #Attr.2; - ret List.531; + let List.544 : List U8 = lowlevel ListWithCapacity #Attr.2; + ret List.544; procedure List.72 (#Attr.2, #Attr.3, #Attr.4): - let List.558 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; - ret List.558; + let List.563 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; + ret List.563; procedure List.8 (#Attr.2, #Attr.3): - let List.529 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; - ret List.529; - -procedure List.80 (#Derived_gen.0, #Derived_gen.1, #Derived_gen.2, #Derived_gen.3, #Derived_gen.4): - joinpoint List.540 List.439 List.440 List.441 List.442 List.443: - let List.542 : Int1 = CallByName Num.22 List.442 List.443; - if List.542 then - let List.549 : U8 = CallByName List.66 List.439 List.442; - let List.543 : List U8 = CallByName List.145 List.440 List.549 List.441; - let List.546 : U64 = 1i64; - let List.545 : U64 = CallByName Num.19 List.442 List.546; - jump List.540 List.439 List.543 List.441 List.545 List.443; - else - dec List.439; - ret List.440; - in - jump List.540 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4; + let List.542 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; + ret List.542; procedure List.80 (#Derived_gen.8, #Derived_gen.9, #Derived_gen.10, #Derived_gen.11, #Derived_gen.12): - joinpoint List.578 List.439 List.440 List.441 List.442 List.443: - let List.580 : Int1 = CallByName Num.22 List.442 List.443; - if List.580 then - let List.589 : U8 = CallByName List.66 List.439 List.442; - let List.581 : [C {U64, Int1}, C {U64, Int1}] = CallByName TotallyNotJson.189 List.440 List.589; - let List.586 : U8 = 1i64; - let List.587 : U8 = GetTagId List.581; - let List.588 : Int1 = lowlevel Eq List.586 List.587; - if List.588 then - let List.444 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.581; - let List.584 : U64 = 1i64; - let List.583 : U64 = CallByName Num.19 List.442 List.584; - jump List.578 List.439 List.444 List.441 List.583 List.443; + joinpoint List.583 List.452 List.453 List.454 List.455 List.456: + let List.585 : Int1 = CallByName Num.22 List.455 List.456; + if List.585 then + let List.594 : U8 = CallByName List.66 List.452 List.455; + let List.586 : [C {U64, Int1}, C {U64, Int1}] = CallByName TotallyNotJson.189 List.453 List.594; + let List.591 : U8 = 1i64; + let List.592 : U8 = GetTagId List.586; + let List.593 : Int1 = lowlevel Eq List.591 List.592; + if List.593 then + let List.457 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.586; + let List.589 : U64 = 1i64; + let List.588 : U64 = CallByName Num.19 List.455 List.589; + jump List.583 List.452 List.457 List.454 List.588 List.456; else - dec List.439; - let List.445 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.581; - let List.585 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) List.445; - ret List.585; + dec List.452; + let List.458 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.586; + let List.590 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) List.458; + ret List.590; else - dec List.439; - let List.579 : [C {U64, Int1}, C {U64, Int1}] = TagId(1) List.440; - ret List.579; + dec List.452; + let List.584 : [C {U64, Int1}, C {U64, Int1}] = TagId(1) List.453; + ret List.584; in - jump List.578 #Derived_gen.8 #Derived_gen.9 #Derived_gen.10 #Derived_gen.11 #Derived_gen.12; + jump List.583 #Derived_gen.8 #Derived_gen.9 #Derived_gen.10 #Derived_gen.11 #Derived_gen.12; -procedure List.93 (List.436, List.437, List.438): - let List.538 : U64 = 0i64; - let List.539 : U64 = CallByName List.6 List.436; - let List.537 : List U8 = CallByName List.80 List.436 List.437 List.438 List.538 List.539; - ret List.537; +procedure List.86 (#Derived_gen.3, #Derived_gen.4, #Derived_gen.5, #Derived_gen.6, #Derived_gen.7): + joinpoint List.550 List.148 List.149 List.150 List.151 List.152: + let List.552 : Int1 = CallByName Num.22 List.151 List.152; + if List.552 then + let List.556 : U8 = CallByName List.66 List.148 List.151; + let List.153 : List U8 = CallByName TotallyNotJson.215 List.149 List.556; + let List.555 : U64 = 1i64; + let List.554 : U64 = CallByName Num.51 List.151 List.555; + jump List.550 List.148 List.153 List.150 List.554 List.152; + else + dec List.148; + ret List.149; + in + jump List.550 #Derived_gen.3 #Derived_gen.4 #Derived_gen.5 #Derived_gen.6 #Derived_gen.7; -procedure List.93 (List.436, List.437, List.438): - let List.576 : U64 = 0i64; - let List.577 : U64 = CallByName List.6 List.436; - let List.575 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.80 List.436 List.437 List.438 List.576 List.577; - ret List.575; +procedure List.96 (List.449, List.450, List.451): + let List.581 : U64 = 0i64; + let List.582 : U64 = CallByName List.6 List.449; + let List.580 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.80 List.449 List.450 List.451 List.581 List.582; + ret List.580; procedure Num.19 (#Attr.2, #Attr.3): - let Num.297 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.297; + let Num.301 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.301; procedure Num.20 (#Attr.2, #Attr.3): - let Num.300 : U64 = lowlevel NumSub #Attr.2 #Attr.3; - ret Num.300; + let Num.299 : U64 = lowlevel NumSub #Attr.2 #Attr.3; + ret Num.299; procedure Num.21 (#Attr.2, #Attr.3): let Num.295 : U64 = lowlevel NumMul #Attr.2 #Attr.3; ret Num.295; procedure Num.22 (#Attr.2, #Attr.3): - let Num.299 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; - ret Num.299; + let Num.298 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + ret Num.298; procedure Num.24 (#Attr.2, #Attr.3): - let Num.301 : Int1 = lowlevel NumGt #Attr.2 #Attr.3; - ret Num.301; + let Num.300 : Int1 = lowlevel NumGt #Attr.2 #Attr.3; + ret Num.300; + +procedure Num.51 (#Attr.2, #Attr.3): + let Num.296 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; + ret Num.296; procedure Num.94 (#Attr.2, #Attr.3): let Num.294 : U64 = lowlevel NumDivCeilUnchecked #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/encode_derived_tag_one_field_string.txt b/crates/compiler/test_mono/generated/encode_derived_tag_one_field_string.txt index d89fbb2e38..20c4f9265f 100644 --- a/crates/compiler/test_mono/generated/encode_derived_tag_one_field_string.txt +++ b/crates/compiler/test_mono/generated/encode_derived_tag_one_field_string.txt @@ -44,207 +44,195 @@ procedure Encode.26 (Encode.105, Encode.106): let Encode.108 : List U8 = CallByName Encode.24 Encode.109 Encode.110 Encode.106; ret Encode.108; -procedure List.145 (List.146, List.147, List.144): - let List.567 : {List U8, U64} = CallByName TotallyNotJson.267 List.146 List.147 List.144; - ret List.567; +procedure List.18 (List.145, List.146, List.147): + let List.562 : U64 = 0i64; + let List.563 : U64 = CallByName List.6 List.145; + let List.561 : {List U8, U64} = CallByName List.86 List.145 List.146 List.147 List.562 List.563; + ret List.561; -procedure List.145 (List.146, List.147, List.144): - let List.587 : List U8 = CallByName TotallyNotJson.215 List.146 List.147; +procedure List.18 (List.145, List.146, List.147): + let List.574 : U64 = 0i64; + let List.575 : U64 = CallByName List.6 List.145; + let List.573 : List U8 = CallByName List.86 List.145 List.146 List.147 List.574 List.575; + ret List.573; + +procedure List.26 (List.172, List.173, List.174): + let List.615 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.96 List.172 List.173 List.174; + let List.618 : U8 = 1i64; + let List.619 : U8 = GetTagId List.615; + let List.620 : Int1 = lowlevel Eq List.618 List.619; + if List.620 then + let List.175 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.615; + ret List.175; + else + let List.176 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.615; + ret List.176; + +procedure List.4 (List.116, List.117): + let List.560 : U64 = 1i64; + let List.559 : List U8 = CallByName List.70 List.116 List.560; + let List.558 : List U8 = CallByName List.71 List.559 List.117; + ret List.558; + +procedure List.49 (List.389, List.390): + let List.607 : U64 = StructAtIndex 0 List.390; + let List.608 : U64 = 0i64; + let List.605 : Int1 = CallByName Bool.11 List.607 List.608; + if List.605 then + dec List.389; + let List.606 : List U8 = Array []; + ret List.606; + else + let List.602 : U64 = StructAtIndex 1 List.390; + let List.603 : U64 = StructAtIndex 0 List.390; + let List.601 : List U8 = CallByName List.72 List.389 List.602 List.603; + ret List.601; + +procedure List.52 (List.404, List.405): + let List.406 : U64 = CallByName List.6 List.404; + joinpoint List.613 List.407: + let List.611 : U64 = 0i64; + let List.610 : {U64, U64} = Struct {List.407, List.611}; + inc List.404; + let List.408 : List U8 = CallByName List.49 List.404 List.610; + let List.609 : U64 = CallByName Num.20 List.406 List.407; + let List.600 : {U64, U64} = Struct {List.609, List.407}; + let List.409 : List U8 = CallByName List.49 List.404 List.600; + let List.599 : {List U8, List U8} = Struct {List.408, List.409}; + ret List.599; + in + let List.614 : Int1 = CallByName Num.24 List.406 List.405; + if List.614 then + jump List.613 List.405; + else + jump List.613 List.406; + +procedure List.6 (#Attr.2): + let List.585 : U64 = lowlevel ListLen #Attr.2; + ret List.585; + +procedure List.6 (#Attr.2): + let List.587 : U64 = lowlevel ListLen #Attr.2; ret List.587; -procedure List.18 (List.142, List.143, List.144): - let List.548 : {List U8, U64} = CallByName List.93 List.142 List.143 List.144; - ret List.548; - -procedure List.18 (List.142, List.143, List.144): - let List.568 : List U8 = CallByName List.93 List.142 List.143 List.144; - ret List.568; - -procedure List.26 (List.159, List.160, List.161): - let List.618 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.93 List.159 List.160 List.161; - let List.621 : U8 = 1i64; - let List.622 : U8 = GetTagId List.618; - let List.623 : Int1 = lowlevel Eq List.621 List.622; - if List.623 then - let List.162 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.618; - ret List.162; - else - let List.163 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.618; - ret List.163; - -procedure List.4 (List.113, List.114): - let List.547 : U64 = 1i64; - let List.546 : List U8 = CallByName List.70 List.113 List.547; - let List.545 : List U8 = CallByName List.71 List.546 List.114; - ret List.545; - -procedure List.49 (List.376, List.377): - let List.610 : U64 = StructAtIndex 0 List.377; - let List.611 : U64 = 0i64; - let List.608 : Int1 = CallByName Bool.11 List.610 List.611; - if List.608 then - dec List.376; - let List.609 : List U8 = Array []; - ret List.609; - else - let List.605 : U64 = StructAtIndex 1 List.377; - let List.606 : U64 = StructAtIndex 0 List.377; - let List.604 : List U8 = CallByName List.72 List.376 List.605 List.606; - ret List.604; - -procedure List.52 (List.391, List.392): - let List.393 : U64 = CallByName List.6 List.391; - joinpoint List.616 List.394: - let List.614 : U64 = 0i64; - let List.613 : {U64, U64} = Struct {List.394, List.614}; - inc List.391; - let List.395 : List U8 = CallByName List.49 List.391 List.613; - let List.612 : U64 = CallByName Num.20 List.393 List.394; - let List.603 : {U64, U64} = Struct {List.612, List.394}; - let List.396 : List U8 = CallByName List.49 List.391 List.603; - let List.602 : {List U8, List U8} = Struct {List.395, List.396}; - ret List.602; - in - let List.617 : Int1 = CallByName Num.24 List.393 List.392; - if List.617 then - jump List.616 List.392; - else - jump List.616 List.393; - -procedure List.6 (#Attr.2): - let List.588 : U64 = lowlevel ListLen #Attr.2; - ret List.588; - -procedure List.6 (#Attr.2): - let List.590 : U64 = lowlevel ListLen #Attr.2; - ret List.590; - procedure List.66 (#Attr.2, #Attr.3): - let List.564 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.564; - -procedure List.66 (#Attr.2, #Attr.3): - let List.584 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.584; - -procedure List.68 (#Attr.2): - let List.601 : List U8 = lowlevel ListWithCapacity #Attr.2; - ret List.601; - -procedure List.70 (#Attr.2, #Attr.3): - let List.526 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.526; - -procedure List.71 (#Attr.2, #Attr.3): - let List.524 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.524; - -procedure List.72 (#Attr.2, #Attr.3, #Attr.4): - let List.607 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; - ret List.607; - -procedure List.8 (#Attr.2, #Attr.3): - let List.599 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; - ret List.599; - -procedure List.80 (#Derived_gen.16, #Derived_gen.17, #Derived_gen.18, #Derived_gen.19, #Derived_gen.20): - joinpoint List.627 List.439 List.440 List.441 List.442 List.443: - let List.629 : Int1 = CallByName Num.22 List.442 List.443; - if List.629 then - let List.638 : U8 = CallByName List.66 List.439 List.442; - let List.630 : [C {U64, Int1}, C {U64, Int1}] = CallByName TotallyNotJson.189 List.440 List.638; - let List.635 : U8 = 1i64; - let List.636 : U8 = GetTagId List.630; - let List.637 : Int1 = lowlevel Eq List.635 List.636; - if List.637 then - let List.444 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.630; - let List.633 : U64 = 1i64; - let List.632 : U64 = CallByName Num.19 List.442 List.633; - jump List.627 List.439 List.444 List.441 List.632 List.443; - else - dec List.439; - let List.445 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.630; - let List.634 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) List.445; - ret List.634; - else - dec List.439; - let List.628 : [C {U64, Int1}, C {U64, Int1}] = TagId(1) List.440; - ret List.628; - in - jump List.627 #Derived_gen.16 #Derived_gen.17 #Derived_gen.18 #Derived_gen.19 #Derived_gen.20; - -procedure List.80 (#Derived_gen.24, #Derived_gen.25, #Derived_gen.26, #Derived_gen.27, #Derived_gen.28): - joinpoint List.574 List.439 List.440 List.441 List.442 List.443: - let List.576 : Int1 = CallByName Num.22 List.442 List.443; - if List.576 then - let List.583 : U8 = CallByName List.66 List.439 List.442; - let List.577 : List U8 = CallByName List.145 List.440 List.583 List.441; - let List.580 : U64 = 1i64; - let List.579 : U64 = CallByName Num.19 List.442 List.580; - jump List.574 List.439 List.577 List.441 List.579 List.443; - else - dec List.439; - ret List.440; - in - jump List.574 #Derived_gen.24 #Derived_gen.25 #Derived_gen.26 #Derived_gen.27 #Derived_gen.28; - -procedure List.80 (#Derived_gen.29, #Derived_gen.30, #Derived_gen.31, #Derived_gen.32, #Derived_gen.33): - joinpoint List.554 List.439 List.440 List.441 List.442 List.443: - let List.556 : Int1 = CallByName Num.22 List.442 List.443; - if List.556 then - let List.563 : Str = CallByName List.66 List.439 List.442; - inc List.563; - let List.557 : {List U8, U64} = CallByName List.145 List.440 List.563 List.441; - let List.560 : U64 = 1i64; - let List.559 : U64 = CallByName Num.19 List.442 List.560; - jump List.554 List.439 List.557 List.441 List.559 List.443; - else - dec List.439; - ret List.440; - in - jump List.554 #Derived_gen.29 #Derived_gen.30 #Derived_gen.31 #Derived_gen.32 #Derived_gen.33; - -procedure List.93 (List.436, List.437, List.438): - let List.552 : U64 = 0i64; - let List.553 : U64 = CallByName List.6 List.436; - let List.551 : {List U8, U64} = CallByName List.80 List.436 List.437 List.438 List.552 List.553; - ret List.551; - -procedure List.93 (List.436, List.437, List.438): - let List.572 : U64 = 0i64; - let List.573 : U64 = CallByName List.6 List.436; - let List.571 : List U8 = CallByName List.80 List.436 List.437 List.438 List.572 List.573; + let List.571 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; ret List.571; -procedure List.93 (List.436, List.437, List.438): - let List.625 : U64 = 0i64; - let List.626 : U64 = CallByName List.6 List.436; - let List.624 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.80 List.436 List.437 List.438 List.625 List.626; - ret List.624; +procedure List.66 (#Attr.2, #Attr.3): + let List.583 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.583; + +procedure List.68 (#Attr.2): + let List.598 : List U8 = lowlevel ListWithCapacity #Attr.2; + ret List.598; + +procedure List.70 (#Attr.2, #Attr.3): + let List.539 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.539; + +procedure List.71 (#Attr.2, #Attr.3): + let List.537 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.537; + +procedure List.72 (#Attr.2, #Attr.3, #Attr.4): + let List.604 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; + ret List.604; + +procedure List.8 (#Attr.2, #Attr.3): + let List.596 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; + ret List.596; + +procedure List.80 (#Derived_gen.16, #Derived_gen.17, #Derived_gen.18, #Derived_gen.19, #Derived_gen.20): + joinpoint List.624 List.452 List.453 List.454 List.455 List.456: + let List.626 : Int1 = CallByName Num.22 List.455 List.456; + if List.626 then + let List.635 : U8 = CallByName List.66 List.452 List.455; + let List.627 : [C {U64, Int1}, C {U64, Int1}] = CallByName TotallyNotJson.189 List.453 List.635; + let List.632 : U8 = 1i64; + let List.633 : U8 = GetTagId List.627; + let List.634 : Int1 = lowlevel Eq List.632 List.633; + if List.634 then + let List.457 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.627; + let List.630 : U64 = 1i64; + let List.629 : U64 = CallByName Num.19 List.455 List.630; + jump List.624 List.452 List.457 List.454 List.629 List.456; + else + dec List.452; + let List.458 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.627; + let List.631 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) List.458; + ret List.631; + else + dec List.452; + let List.625 : [C {U64, Int1}, C {U64, Int1}] = TagId(1) List.453; + ret List.625; + in + jump List.624 #Derived_gen.16 #Derived_gen.17 #Derived_gen.18 #Derived_gen.19 #Derived_gen.20; + +procedure List.86 (#Derived_gen.21, #Derived_gen.22, #Derived_gen.23, #Derived_gen.24, #Derived_gen.25): + joinpoint List.576 List.148 List.149 List.150 List.151 List.152: + let List.578 : Int1 = CallByName Num.22 List.151 List.152; + if List.578 then + let List.582 : U8 = CallByName List.66 List.148 List.151; + let List.153 : List U8 = CallByName TotallyNotJson.215 List.149 List.582; + let List.581 : U64 = 1i64; + let List.580 : U64 = CallByName Num.51 List.151 List.581; + jump List.576 List.148 List.153 List.150 List.580 List.152; + else + dec List.148; + ret List.149; + in + jump List.576 #Derived_gen.21 #Derived_gen.22 #Derived_gen.23 #Derived_gen.24 #Derived_gen.25; + +procedure List.86 (#Derived_gen.29, #Derived_gen.30, #Derived_gen.31, #Derived_gen.32, #Derived_gen.33): + joinpoint List.564 List.148 List.149 List.150 List.151 List.152: + let List.566 : Int1 = CallByName Num.22 List.151 List.152; + if List.566 then + let List.570 : Str = CallByName List.66 List.148 List.151; + inc List.570; + let List.153 : {List U8, U64} = CallByName TotallyNotJson.267 List.149 List.570 List.150; + let List.569 : U64 = 1i64; + let List.568 : U64 = CallByName Num.51 List.151 List.569; + jump List.564 List.148 List.153 List.150 List.568 List.152; + else + dec List.148; + ret List.149; + in + jump List.564 #Derived_gen.29 #Derived_gen.30 #Derived_gen.31 #Derived_gen.32 #Derived_gen.33; + +procedure List.96 (List.449, List.450, List.451): + let List.622 : U64 = 0i64; + let List.623 : U64 = CallByName List.6 List.449; + let List.621 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.80 List.449 List.450 List.451 List.622 List.623; + ret List.621; procedure Num.127 (#Attr.2): let Num.299 : U8 = lowlevel NumIntCast #Attr.2; ret Num.299; procedure Num.19 (#Attr.2, #Attr.3): - let Num.308 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.308; + let Num.313 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.313; procedure Num.20 (#Attr.2, #Attr.3): - let Num.312 : U64 = lowlevel NumSub #Attr.2 #Attr.3; - ret Num.312; + let Num.311 : U64 = lowlevel NumSub #Attr.2 #Attr.3; + ret Num.311; procedure Num.21 (#Attr.2, #Attr.3): let Num.305 : U64 = lowlevel NumMul #Attr.2 #Attr.3; ret Num.305; procedure Num.22 (#Attr.2, #Attr.3): - let Num.311 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; - ret Num.311; + let Num.310 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + ret Num.310; procedure Num.24 (#Attr.2, #Attr.3): - let Num.313 : Int1 = lowlevel NumGt #Attr.2 #Attr.3; - ret Num.313; + let Num.312 : Int1 = lowlevel NumGt #Attr.2 #Attr.3; + ret Num.312; + +procedure Num.51 (#Attr.2, #Attr.3): + let Num.307 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; + ret Num.307; procedure Num.94 (#Attr.2, #Attr.3): let Num.304 : U64 = lowlevel NumDivCeilUnchecked #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/encode_derived_tag_two_payloads_string.txt b/crates/compiler/test_mono/generated/encode_derived_tag_two_payloads_string.txt index 93524dfb6b..cd57254375 100644 --- a/crates/compiler/test_mono/generated/encode_derived_tag_two_payloads_string.txt +++ b/crates/compiler/test_mono/generated/encode_derived_tag_two_payloads_string.txt @@ -47,207 +47,195 @@ procedure Encode.26 (Encode.105, Encode.106): let Encode.108 : List U8 = CallByName Encode.24 Encode.109 Encode.110 Encode.106; ret Encode.108; -procedure List.145 (List.146, List.147, List.144): - let List.567 : {List U8, U64} = CallByName TotallyNotJson.267 List.146 List.147 List.144; - ret List.567; +procedure List.18 (List.145, List.146, List.147): + let List.562 : U64 = 0i64; + let List.563 : U64 = CallByName List.6 List.145; + let List.561 : {List U8, U64} = CallByName List.86 List.145 List.146 List.147 List.562 List.563; + ret List.561; -procedure List.145 (List.146, List.147, List.144): - let List.587 : List U8 = CallByName TotallyNotJson.215 List.146 List.147; +procedure List.18 (List.145, List.146, List.147): + let List.574 : U64 = 0i64; + let List.575 : U64 = CallByName List.6 List.145; + let List.573 : List U8 = CallByName List.86 List.145 List.146 List.147 List.574 List.575; + ret List.573; + +procedure List.26 (List.172, List.173, List.174): + let List.615 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.96 List.172 List.173 List.174; + let List.618 : U8 = 1i64; + let List.619 : U8 = GetTagId List.615; + let List.620 : Int1 = lowlevel Eq List.618 List.619; + if List.620 then + let List.175 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.615; + ret List.175; + else + let List.176 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.615; + ret List.176; + +procedure List.4 (List.116, List.117): + let List.560 : U64 = 1i64; + let List.559 : List U8 = CallByName List.70 List.116 List.560; + let List.558 : List U8 = CallByName List.71 List.559 List.117; + ret List.558; + +procedure List.49 (List.389, List.390): + let List.607 : U64 = StructAtIndex 0 List.390; + let List.608 : U64 = 0i64; + let List.605 : Int1 = CallByName Bool.11 List.607 List.608; + if List.605 then + dec List.389; + let List.606 : List U8 = Array []; + ret List.606; + else + let List.602 : U64 = StructAtIndex 1 List.390; + let List.603 : U64 = StructAtIndex 0 List.390; + let List.601 : List U8 = CallByName List.72 List.389 List.602 List.603; + ret List.601; + +procedure List.52 (List.404, List.405): + let List.406 : U64 = CallByName List.6 List.404; + joinpoint List.613 List.407: + let List.611 : U64 = 0i64; + let List.610 : {U64, U64} = Struct {List.407, List.611}; + inc List.404; + let List.408 : List U8 = CallByName List.49 List.404 List.610; + let List.609 : U64 = CallByName Num.20 List.406 List.407; + let List.600 : {U64, U64} = Struct {List.609, List.407}; + let List.409 : List U8 = CallByName List.49 List.404 List.600; + let List.599 : {List U8, List U8} = Struct {List.408, List.409}; + ret List.599; + in + let List.614 : Int1 = CallByName Num.24 List.406 List.405; + if List.614 then + jump List.613 List.405; + else + jump List.613 List.406; + +procedure List.6 (#Attr.2): + let List.585 : U64 = lowlevel ListLen #Attr.2; + ret List.585; + +procedure List.6 (#Attr.2): + let List.587 : U64 = lowlevel ListLen #Attr.2; ret List.587; -procedure List.18 (List.142, List.143, List.144): - let List.548 : {List U8, U64} = CallByName List.93 List.142 List.143 List.144; - ret List.548; - -procedure List.18 (List.142, List.143, List.144): - let List.568 : List U8 = CallByName List.93 List.142 List.143 List.144; - ret List.568; - -procedure List.26 (List.159, List.160, List.161): - let List.618 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.93 List.159 List.160 List.161; - let List.621 : U8 = 1i64; - let List.622 : U8 = GetTagId List.618; - let List.623 : Int1 = lowlevel Eq List.621 List.622; - if List.623 then - let List.162 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.618; - ret List.162; - else - let List.163 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.618; - ret List.163; - -procedure List.4 (List.113, List.114): - let List.547 : U64 = 1i64; - let List.546 : List U8 = CallByName List.70 List.113 List.547; - let List.545 : List U8 = CallByName List.71 List.546 List.114; - ret List.545; - -procedure List.49 (List.376, List.377): - let List.610 : U64 = StructAtIndex 0 List.377; - let List.611 : U64 = 0i64; - let List.608 : Int1 = CallByName Bool.11 List.610 List.611; - if List.608 then - dec List.376; - let List.609 : List U8 = Array []; - ret List.609; - else - let List.605 : U64 = StructAtIndex 1 List.377; - let List.606 : U64 = StructAtIndex 0 List.377; - let List.604 : List U8 = CallByName List.72 List.376 List.605 List.606; - ret List.604; - -procedure List.52 (List.391, List.392): - let List.393 : U64 = CallByName List.6 List.391; - joinpoint List.616 List.394: - let List.614 : U64 = 0i64; - let List.613 : {U64, U64} = Struct {List.394, List.614}; - inc List.391; - let List.395 : List U8 = CallByName List.49 List.391 List.613; - let List.612 : U64 = CallByName Num.20 List.393 List.394; - let List.603 : {U64, U64} = Struct {List.612, List.394}; - let List.396 : List U8 = CallByName List.49 List.391 List.603; - let List.602 : {List U8, List U8} = Struct {List.395, List.396}; - ret List.602; - in - let List.617 : Int1 = CallByName Num.24 List.393 List.392; - if List.617 then - jump List.616 List.392; - else - jump List.616 List.393; - -procedure List.6 (#Attr.2): - let List.588 : U64 = lowlevel ListLen #Attr.2; - ret List.588; - -procedure List.6 (#Attr.2): - let List.590 : U64 = lowlevel ListLen #Attr.2; - ret List.590; - procedure List.66 (#Attr.2, #Attr.3): - let List.564 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.564; - -procedure List.66 (#Attr.2, #Attr.3): - let List.584 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.584; - -procedure List.68 (#Attr.2): - let List.601 : List U8 = lowlevel ListWithCapacity #Attr.2; - ret List.601; - -procedure List.70 (#Attr.2, #Attr.3): - let List.526 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.526; - -procedure List.71 (#Attr.2, #Attr.3): - let List.524 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.524; - -procedure List.72 (#Attr.2, #Attr.3, #Attr.4): - let List.607 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; - ret List.607; - -procedure List.8 (#Attr.2, #Attr.3): - let List.599 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; - ret List.599; - -procedure List.80 (#Derived_gen.11, #Derived_gen.12, #Derived_gen.13, #Derived_gen.14, #Derived_gen.15): - joinpoint List.627 List.439 List.440 List.441 List.442 List.443: - let List.629 : Int1 = CallByName Num.22 List.442 List.443; - if List.629 then - let List.638 : U8 = CallByName List.66 List.439 List.442; - let List.630 : [C {U64, Int1}, C {U64, Int1}] = CallByName TotallyNotJson.189 List.440 List.638; - let List.635 : U8 = 1i64; - let List.636 : U8 = GetTagId List.630; - let List.637 : Int1 = lowlevel Eq List.635 List.636; - if List.637 then - let List.444 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.630; - let List.633 : U64 = 1i64; - let List.632 : U64 = CallByName Num.19 List.442 List.633; - jump List.627 List.439 List.444 List.441 List.632 List.443; - else - dec List.439; - let List.445 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.630; - let List.634 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) List.445; - ret List.634; - else - dec List.439; - let List.628 : [C {U64, Int1}, C {U64, Int1}] = TagId(1) List.440; - ret List.628; - in - jump List.627 #Derived_gen.11 #Derived_gen.12 #Derived_gen.13 #Derived_gen.14 #Derived_gen.15; - -procedure List.80 (#Derived_gen.19, #Derived_gen.20, #Derived_gen.21, #Derived_gen.22, #Derived_gen.23): - joinpoint List.554 List.439 List.440 List.441 List.442 List.443: - let List.556 : Int1 = CallByName Num.22 List.442 List.443; - if List.556 then - let List.563 : Str = CallByName List.66 List.439 List.442; - inc List.563; - let List.557 : {List U8, U64} = CallByName List.145 List.440 List.563 List.441; - let List.560 : U64 = 1i64; - let List.559 : U64 = CallByName Num.19 List.442 List.560; - jump List.554 List.439 List.557 List.441 List.559 List.443; - else - dec List.439; - ret List.440; - in - jump List.554 #Derived_gen.19 #Derived_gen.20 #Derived_gen.21 #Derived_gen.22 #Derived_gen.23; - -procedure List.80 (#Derived_gen.24, #Derived_gen.25, #Derived_gen.26, #Derived_gen.27, #Derived_gen.28): - joinpoint List.574 List.439 List.440 List.441 List.442 List.443: - let List.576 : Int1 = CallByName Num.22 List.442 List.443; - if List.576 then - let List.583 : U8 = CallByName List.66 List.439 List.442; - let List.577 : List U8 = CallByName List.145 List.440 List.583 List.441; - let List.580 : U64 = 1i64; - let List.579 : U64 = CallByName Num.19 List.442 List.580; - jump List.574 List.439 List.577 List.441 List.579 List.443; - else - dec List.439; - ret List.440; - in - jump List.574 #Derived_gen.24 #Derived_gen.25 #Derived_gen.26 #Derived_gen.27 #Derived_gen.28; - -procedure List.93 (List.436, List.437, List.438): - let List.552 : U64 = 0i64; - let List.553 : U64 = CallByName List.6 List.436; - let List.551 : {List U8, U64} = CallByName List.80 List.436 List.437 List.438 List.552 List.553; - ret List.551; - -procedure List.93 (List.436, List.437, List.438): - let List.572 : U64 = 0i64; - let List.573 : U64 = CallByName List.6 List.436; - let List.571 : List U8 = CallByName List.80 List.436 List.437 List.438 List.572 List.573; + let List.571 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; ret List.571; -procedure List.93 (List.436, List.437, List.438): - let List.625 : U64 = 0i64; - let List.626 : U64 = CallByName List.6 List.436; - let List.624 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.80 List.436 List.437 List.438 List.625 List.626; - ret List.624; +procedure List.66 (#Attr.2, #Attr.3): + let List.583 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.583; + +procedure List.68 (#Attr.2): + let List.598 : List U8 = lowlevel ListWithCapacity #Attr.2; + ret List.598; + +procedure List.70 (#Attr.2, #Attr.3): + let List.539 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.539; + +procedure List.71 (#Attr.2, #Attr.3): + let List.537 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.537; + +procedure List.72 (#Attr.2, #Attr.3, #Attr.4): + let List.604 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; + ret List.604; + +procedure List.8 (#Attr.2, #Attr.3): + let List.596 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; + ret List.596; + +procedure List.80 (#Derived_gen.11, #Derived_gen.12, #Derived_gen.13, #Derived_gen.14, #Derived_gen.15): + joinpoint List.624 List.452 List.453 List.454 List.455 List.456: + let List.626 : Int1 = CallByName Num.22 List.455 List.456; + if List.626 then + let List.635 : U8 = CallByName List.66 List.452 List.455; + let List.627 : [C {U64, Int1}, C {U64, Int1}] = CallByName TotallyNotJson.189 List.453 List.635; + let List.632 : U8 = 1i64; + let List.633 : U8 = GetTagId List.627; + let List.634 : Int1 = lowlevel Eq List.632 List.633; + if List.634 then + let List.457 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.627; + let List.630 : U64 = 1i64; + let List.629 : U64 = CallByName Num.19 List.455 List.630; + jump List.624 List.452 List.457 List.454 List.629 List.456; + else + dec List.452; + let List.458 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.627; + let List.631 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) List.458; + ret List.631; + else + dec List.452; + let List.625 : [C {U64, Int1}, C {U64, Int1}] = TagId(1) List.453; + ret List.625; + in + jump List.624 #Derived_gen.11 #Derived_gen.12 #Derived_gen.13 #Derived_gen.14 #Derived_gen.15; + +procedure List.86 (#Derived_gen.19, #Derived_gen.20, #Derived_gen.21, #Derived_gen.22, #Derived_gen.23): + joinpoint List.564 List.148 List.149 List.150 List.151 List.152: + let List.566 : Int1 = CallByName Num.22 List.151 List.152; + if List.566 then + let List.570 : Str = CallByName List.66 List.148 List.151; + inc List.570; + let List.153 : {List U8, U64} = CallByName TotallyNotJson.267 List.149 List.570 List.150; + let List.569 : U64 = 1i64; + let List.568 : U64 = CallByName Num.51 List.151 List.569; + jump List.564 List.148 List.153 List.150 List.568 List.152; + else + dec List.148; + ret List.149; + in + jump List.564 #Derived_gen.19 #Derived_gen.20 #Derived_gen.21 #Derived_gen.22 #Derived_gen.23; + +procedure List.86 (#Derived_gen.30, #Derived_gen.31, #Derived_gen.32, #Derived_gen.33, #Derived_gen.34): + joinpoint List.576 List.148 List.149 List.150 List.151 List.152: + let List.578 : Int1 = CallByName Num.22 List.151 List.152; + if List.578 then + let List.582 : U8 = CallByName List.66 List.148 List.151; + let List.153 : List U8 = CallByName TotallyNotJson.215 List.149 List.582; + let List.581 : U64 = 1i64; + let List.580 : U64 = CallByName Num.51 List.151 List.581; + jump List.576 List.148 List.153 List.150 List.580 List.152; + else + dec List.148; + ret List.149; + in + jump List.576 #Derived_gen.30 #Derived_gen.31 #Derived_gen.32 #Derived_gen.33 #Derived_gen.34; + +procedure List.96 (List.449, List.450, List.451): + let List.622 : U64 = 0i64; + let List.623 : U64 = CallByName List.6 List.449; + let List.621 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.80 List.449 List.450 List.451 List.622 List.623; + ret List.621; procedure Num.127 (#Attr.2): let Num.299 : U8 = lowlevel NumIntCast #Attr.2; ret Num.299; procedure Num.19 (#Attr.2, #Attr.3): - let Num.308 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.308; + let Num.313 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.313; procedure Num.20 (#Attr.2, #Attr.3): - let Num.312 : U64 = lowlevel NumSub #Attr.2 #Attr.3; - ret Num.312; + let Num.311 : U64 = lowlevel NumSub #Attr.2 #Attr.3; + ret Num.311; procedure Num.21 (#Attr.2, #Attr.3): let Num.305 : U64 = lowlevel NumMul #Attr.2 #Attr.3; ret Num.305; procedure Num.22 (#Attr.2, #Attr.3): - let Num.311 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; - ret Num.311; + let Num.310 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + ret Num.310; procedure Num.24 (#Attr.2, #Attr.3): - let Num.313 : Int1 = lowlevel NumGt #Attr.2 #Attr.3; - ret Num.313; + let Num.312 : Int1 = lowlevel NumGt #Attr.2 #Attr.3; + ret Num.312; + +procedure Num.51 (#Attr.2, #Attr.3): + let Num.307 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; + ret Num.307; procedure Num.94 (#Attr.2, #Attr.3): let Num.304 : U64 = lowlevel NumDivCeilUnchecked #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/ir_int_add.txt b/crates/compiler/test_mono/generated/ir_int_add.txt index 2e4de96845..ee18efd6a5 100644 --- a/crates/compiler/test_mono/generated/ir_int_add.txt +++ b/crates/compiler/test_mono/generated/ir_int_add.txt @@ -1,6 +1,6 @@ procedure List.6 (#Attr.2): - let List.521 : U64 = lowlevel ListLen #Attr.2; - ret List.521; + let List.534 : U64 = lowlevel ListLen #Attr.2; + ret List.534; procedure Num.19 (#Attr.2, #Attr.3): let Num.294 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/issue_2583_specialize_errors_behind_unified_branches.txt b/crates/compiler/test_mono/generated/issue_2583_specialize_errors_behind_unified_branches.txt index 96c021a84b..2beda8055b 100644 --- a/crates/compiler/test_mono/generated/issue_2583_specialize_errors_behind_unified_branches.txt +++ b/crates/compiler/test_mono/generated/issue_2583_specialize_errors_behind_unified_branches.txt @@ -6,42 +6,42 @@ procedure Bool.2 (): let Bool.23 : Int1 = true; ret Bool.23; -procedure List.2 (List.97, List.98): - let List.535 : U64 = CallByName List.6 List.97; - let List.531 : Int1 = CallByName Num.22 List.98 List.535; - if List.531 then - let List.533 : I64 = CallByName List.66 List.97 List.98; - dec List.97; - let List.532 : [C {}, C I64] = TagId(1) List.533; - ret List.532; +procedure List.2 (List.100, List.101): + let List.548 : U64 = CallByName List.6 List.100; + let List.544 : Int1 = CallByName Num.22 List.101 List.548; + if List.544 then + let List.546 : I64 = CallByName List.66 List.100 List.101; + dec List.100; + let List.545 : [C {}, C I64] = TagId(1) List.546; + ret List.545; else - dec List.97; - let List.530 : {} = Struct {}; - let List.529 : [C {}, C I64] = TagId(0) List.530; - ret List.529; + dec List.100; + let List.543 : {} = Struct {}; + let List.542 : [C {}, C I64] = TagId(0) List.543; + ret List.542; procedure List.6 (#Attr.2): - let List.536 : U64 = lowlevel ListLen #Attr.2; - ret List.536; + let List.549 : U64 = lowlevel ListLen #Attr.2; + ret List.549; procedure List.66 (#Attr.2, #Attr.3): - let List.534 : I64 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.534; + let List.547 : I64 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.547; -procedure List.9 (List.293): - let List.528 : U64 = 0i64; - let List.521 : [C {}, C I64] = CallByName List.2 List.293 List.528; - let List.525 : U8 = 1i64; - let List.526 : U8 = GetTagId List.521; - let List.527 : Int1 = lowlevel Eq List.525 List.526; - if List.527 then - let List.294 : I64 = UnionAtIndex (Id 1) (Index 0) List.521; - let List.522 : [C Int1, C I64] = TagId(1) List.294; - ret List.522; +procedure List.9 (List.306): + let List.541 : U64 = 0i64; + let List.534 : [C {}, C I64] = CallByName List.2 List.306 List.541; + let List.538 : U8 = 1i64; + let List.539 : U8 = GetTagId List.534; + let List.540 : Int1 = lowlevel Eq List.538 List.539; + if List.540 then + let List.307 : I64 = UnionAtIndex (Id 1) (Index 0) List.534; + let List.535 : [C Int1, C I64] = TagId(1) List.307; + ret List.535; else - let List.524 : Int1 = true; - let List.523 : [C Int1, C I64] = TagId(0) List.524; - ret List.523; + let List.537 : Int1 = true; + let List.536 : [C Int1, C I64] = TagId(0) List.537; + ret List.536; procedure Num.22 (#Attr.2, #Attr.3): let Num.292 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/issue_4749.txt b/crates/compiler/test_mono/generated/issue_4749.txt index 61797ec653..292656f2af 100644 --- a/crates/compiler/test_mono/generated/issue_4749.txt +++ b/crates/compiler/test_mono/generated/issue_4749.txt @@ -64,136 +64,136 @@ procedure Decode.27 (Decode.107, Decode.108): let Decode.123 : [C [C List U8, C ], C Str] = TagId(0) Decode.124; ret Decode.123; -procedure List.1 (List.96): - let List.588 : U64 = CallByName List.6 List.96; - dec List.96; - let List.589 : U64 = 0i64; - let List.587 : Int1 = CallByName Bool.11 List.588 List.589; - ret List.587; +procedure List.1 (List.99): + let List.601 : U64 = CallByName List.6 List.99; + dec List.99; + let List.602 : U64 = 0i64; + let List.600 : Int1 = CallByName Bool.11 List.601 List.602; + ret List.600; -procedure List.2 (List.97, List.98): - let List.571 : U64 = CallByName List.6 List.97; - let List.568 : Int1 = CallByName Num.22 List.98 List.571; - if List.568 then - let List.570 : U8 = CallByName List.66 List.97 List.98; - dec List.97; - let List.569 : [C {}, C U8] = TagId(1) List.570; - ret List.569; +procedure List.2 (List.100, List.101): + let List.584 : U64 = CallByName List.6 List.100; + let List.581 : Int1 = CallByName Num.22 List.101 List.584; + if List.581 then + let List.583 : U8 = CallByName List.66 List.100 List.101; + dec List.100; + let List.582 : [C {}, C U8] = TagId(1) List.583; + ret List.582; else - dec List.97; - let List.567 : {} = Struct {}; - let List.566 : [C {}, C U8] = TagId(0) List.567; - ret List.566; - -procedure List.26 (List.159, List.160, List.161): - let List.590 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = CallByName List.93 List.159 List.160 List.161; - let List.593 : U8 = 1i64; - let List.594 : U8 = GetTagId List.590; - let List.595 : Int1 = lowlevel Eq List.593 List.594; - if List.595 then - let List.162 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = UnionAtIndex (Id 1) (Index 0) List.590; - ret List.162; - else - let List.163 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = UnionAtIndex (Id 0) (Index 0) List.590; - ret List.163; - -procedure List.29 (List.304, List.305): - let List.545 : U64 = CallByName List.6 List.304; - let List.306 : U64 = CallByName Num.77 List.545 List.305; - let List.544 : List U8 = CallByName List.43 List.304 List.306; - ret List.544; - -procedure List.31 (#Attr.2, #Attr.3): - let List.558 : List U8 = lowlevel ListDropAt #Attr.2 #Attr.3; - ret List.558; - -procedure List.38 (List.298): - let List.557 : U64 = 0i64; - let List.556 : List U8 = CallByName List.31 List.298 List.557; - ret List.556; - -procedure List.4 (List.113, List.114): - let List.555 : U64 = 1i64; - let List.554 : List U8 = CallByName List.70 List.113 List.555; - let List.553 : List U8 = CallByName List.71 List.554 List.114; - ret List.553; - -procedure List.43 (List.302, List.303): - let List.537 : U64 = CallByName List.6 List.302; - let List.536 : U64 = CallByName Num.77 List.537 List.303; - let List.527 : {U64, U64} = Struct {List.303, List.536}; - let List.526 : List U8 = CallByName List.49 List.302 List.527; - ret List.526; - -procedure List.49 (List.376, List.377): - let List.584 : U64 = StructAtIndex 0 List.377; - let List.585 : U64 = 0i64; - let List.582 : Int1 = CallByName Bool.11 List.584 List.585; - if List.582 then - dec List.376; - let List.583 : List U8 = Array []; - ret List.583; - else - let List.580 : U64 = StructAtIndex 1 List.377; - let List.581 : U64 = StructAtIndex 0 List.377; - let List.579 : List U8 = CallByName List.72 List.376 List.580 List.581; + dec List.100; + let List.580 : {} = Struct {}; + let List.579 : [C {}, C U8] = TagId(0) List.580; ret List.579; +procedure List.26 (List.172, List.173, List.174): + let List.603 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = CallByName List.96 List.172 List.173 List.174; + let List.606 : U8 = 1i64; + let List.607 : U8 = GetTagId List.603; + let List.608 : Int1 = lowlevel Eq List.606 List.607; + if List.608 then + let List.175 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = UnionAtIndex (Id 1) (Index 0) List.603; + ret List.175; + else + let List.176 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = UnionAtIndex (Id 0) (Index 0) List.603; + ret List.176; + +procedure List.29 (List.317, List.318): + let List.558 : U64 = CallByName List.6 List.317; + let List.319 : U64 = CallByName Num.77 List.558 List.318; + let List.557 : List U8 = CallByName List.43 List.317 List.319; + ret List.557; + +procedure List.31 (#Attr.2, #Attr.3): + let List.571 : List U8 = lowlevel ListDropAt #Attr.2 #Attr.3; + ret List.571; + +procedure List.38 (List.311): + let List.570 : U64 = 0i64; + let List.569 : List U8 = CallByName List.31 List.311 List.570; + ret List.569; + +procedure List.4 (List.116, List.117): + let List.568 : U64 = 1i64; + let List.567 : List U8 = CallByName List.70 List.116 List.568; + let List.566 : List U8 = CallByName List.71 List.567 List.117; + ret List.566; + +procedure List.43 (List.315, List.316): + let List.550 : U64 = CallByName List.6 List.315; + let List.549 : U64 = CallByName Num.77 List.550 List.316; + let List.540 : {U64, U64} = Struct {List.316, List.549}; + let List.539 : List U8 = CallByName List.49 List.315 List.540; + ret List.539; + +procedure List.49 (List.389, List.390): + let List.597 : U64 = StructAtIndex 0 List.390; + let List.598 : U64 = 0i64; + let List.595 : Int1 = CallByName Bool.11 List.597 List.598; + if List.595 then + dec List.389; + let List.596 : List U8 = Array []; + ret List.596; + else + let List.593 : U64 = StructAtIndex 1 List.390; + let List.594 : U64 = StructAtIndex 0 List.390; + let List.592 : List U8 = CallByName List.72 List.389 List.593 List.594; + ret List.592; + procedure List.6 (#Attr.2): - let List.611 : U64 = lowlevel ListLen #Attr.2; - ret List.611; + let List.624 : U64 = lowlevel ListLen #Attr.2; + ret List.624; procedure List.66 (#Attr.2, #Attr.3): - let List.564 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.564; + let List.577 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.577; procedure List.70 (#Attr.2, #Attr.3): - let List.552 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.552; + let List.565 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.565; procedure List.71 (#Attr.2, #Attr.3): - let List.550 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.550; + let List.563 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.563; procedure List.72 (#Attr.2, #Attr.3, #Attr.4): - let List.531 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; - ret List.531; + let List.544 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; + ret List.544; procedure List.8 (#Attr.2, #Attr.3): - let List.547 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; - ret List.547; + let List.560 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; + ret List.560; procedure List.80 (#Derived_gen.0, #Derived_gen.1, #Derived_gen.2, #Derived_gen.3, #Derived_gen.4): - joinpoint List.599 List.439 List.440 List.441 List.442 List.443: - let List.601 : Int1 = CallByName Num.22 List.442 List.443; - if List.601 then - let List.610 : U8 = CallByName List.66 List.439 List.442; - let List.602 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = CallByName TotallyNotJson.62 List.440 List.610; - let List.607 : U8 = 1i64; - let List.608 : U8 = GetTagId List.602; - let List.609 : Int1 = lowlevel Eq List.607 List.608; - if List.609 then - let List.444 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = UnionAtIndex (Id 1) (Index 0) List.602; - let List.605 : U64 = 1i64; - let List.604 : U64 = CallByName Num.19 List.442 List.605; - jump List.599 List.439 List.444 List.441 List.604 List.443; + joinpoint List.612 List.452 List.453 List.454 List.455 List.456: + let List.614 : Int1 = CallByName Num.22 List.455 List.456; + if List.614 then + let List.623 : U8 = CallByName List.66 List.452 List.455; + let List.615 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = CallByName TotallyNotJson.62 List.453 List.623; + let List.620 : U8 = 1i64; + let List.621 : U8 = GetTagId List.615; + let List.622 : Int1 = lowlevel Eq List.620 List.621; + if List.622 then + let List.457 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = UnionAtIndex (Id 1) (Index 0) List.615; + let List.618 : U64 = 1i64; + let List.617 : U64 = CallByName Num.19 List.455 List.618; + jump List.612 List.452 List.457 List.454 List.617 List.456; else - dec List.439; - let List.445 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = UnionAtIndex (Id 0) (Index 0) List.602; - let List.606 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = TagId(0) List.445; - ret List.606; + dec List.452; + let List.458 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = UnionAtIndex (Id 0) (Index 0) List.615; + let List.619 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = TagId(0) List.458; + ret List.619; else - dec List.439; - let List.600 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = TagId(1) List.440; - ret List.600; + dec List.452; + let List.613 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = TagId(1) List.453; + ret List.613; in - jump List.599 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4; + jump List.612 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4; -procedure List.93 (List.436, List.437, List.438): - let List.597 : U64 = 0i64; - let List.598 : U64 = CallByName List.6 List.436; - let List.596 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = CallByName List.80 List.436 List.437 List.438 List.597 List.598; - ret List.596; +procedure List.96 (List.449, List.450, List.451): + let List.610 : U64 = 0i64; + let List.611 : U64 = CallByName List.6 List.449; + let List.609 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = CallByName List.80 List.449 List.450 List.451 List.610 List.611; + ret List.609; procedure Num.19 (#Attr.2, #Attr.3): let Num.295 : U8 = lowlevel NumAdd #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/issue_4770.txt b/crates/compiler/test_mono/generated/issue_4770.txt index 7c010f6334..8cfe939fa3 100644 --- a/crates/compiler/test_mono/generated/issue_4770.txt +++ b/crates/compiler/test_mono/generated/issue_4770.txt @@ -6,80 +6,80 @@ procedure Bool.2 (): let Bool.24 : Int1 = true; ret Bool.24; -procedure List.194 (List.523, List.195, List.193): - let List.553 : Int1 = CallByName Test.1 List.195; - if List.553 then - let List.555 : {} = Struct {}; - let List.554 : [C {}, C {}] = TagId(1) List.555; - ret List.554; +procedure List.207 (List.536, List.208, List.206): + let List.566 : Int1 = CallByName Test.1 List.208; + if List.566 then + let List.568 : {} = Struct {}; + let List.567 : [C {}, C {}] = TagId(1) List.568; + ret List.567; else - let List.552 : {} = Struct {}; - let List.551 : [C {}, C {}] = TagId(0) List.552; - ret List.551; + let List.565 : {} = Struct {}; + let List.564 : [C {}, C {}] = TagId(0) List.565; + ret List.564; procedure List.23 (#Attr.2, #Attr.3, #Attr.4): - let List.556 : List {[C I64, C List *self], [C I64, C List *self]} = lowlevel ListMap2 { xs: `#Attr.#arg1`, ys: `#Attr.#arg2` } #Attr.2 #Attr.3 Test.15 #Attr.4; + let List.569 : List {[C I64, C List *self], [C I64, C List *self]} = lowlevel ListMap2 { xs: `#Attr.#arg1`, ys: `#Attr.#arg2` } #Attr.2 #Attr.3 Test.15 #Attr.4; decref #Attr.3; decref #Attr.2; - ret List.556; + ret List.569; -procedure List.56 (List.192, List.193): - let List.532 : {} = Struct {}; - let List.524 : [C {}, C {}] = CallByName List.93 List.192 List.532 List.193; - let List.529 : U8 = 1i64; - let List.530 : U8 = GetTagId List.524; - let List.531 : Int1 = lowlevel Eq List.529 List.530; - if List.531 then - let List.525 : Int1 = CallByName Bool.2; - ret List.525; +procedure List.56 (List.205, List.206): + let List.545 : {} = Struct {}; + let List.537 : [C {}, C {}] = CallByName List.96 List.205 List.545 List.206; + let List.542 : U8 = 1i64; + let List.543 : U8 = GetTagId List.537; + let List.544 : Int1 = lowlevel Eq List.542 List.543; + if List.544 then + let List.538 : Int1 = CallByName Bool.2; + ret List.538; else - let List.526 : Int1 = CallByName Bool.1; - ret List.526; + let List.539 : Int1 = CallByName Bool.1; + ret List.539; procedure List.6 (#Attr.2): - let List.522 : U64 = lowlevel ListLen #Attr.2; - ret List.522; + let List.535 : U64 = lowlevel ListLen #Attr.2; + ret List.535; procedure List.6 (#Attr.2): - let List.550 : U64 = lowlevel ListLen #Attr.2; - ret List.550; + let List.563 : U64 = lowlevel ListLen #Attr.2; + ret List.563; procedure List.66 (#Attr.2, #Attr.3): - let List.549 : {[C I64, C List *self], [C I64, C List *self]} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.549; + let List.562 : {[C I64, C List *self], [C I64, C List *self]} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.562; procedure List.80 (#Derived_gen.1, #Derived_gen.2, #Derived_gen.3, #Derived_gen.4, #Derived_gen.5): - joinpoint List.537 List.439 List.440 List.441 List.442 List.443: - let List.539 : Int1 = CallByName Num.22 List.442 List.443; - if List.539 then - let List.548 : {[C I64, C List *self], [C I64, C List *self]} = CallByName List.66 List.439 List.442; - inc List.548; - let List.540 : [C {}, C {}] = CallByName List.194 List.440 List.548 List.441; - let List.545 : U8 = 1i64; - let List.546 : U8 = GetTagId List.540; - let List.547 : Int1 = lowlevel Eq List.545 List.546; - if List.547 then - let List.444 : {} = UnionAtIndex (Id 1) (Index 0) List.540; - let List.543 : U64 = 1i64; - let List.542 : U64 = CallByName Num.19 List.442 List.543; - jump List.537 List.439 List.444 List.441 List.542 List.443; + joinpoint List.550 List.452 List.453 List.454 List.455 List.456: + let List.552 : Int1 = CallByName Num.22 List.455 List.456; + if List.552 then + let List.561 : {[C I64, C List *self], [C I64, C List *self]} = CallByName List.66 List.452 List.455; + inc List.561; + let List.553 : [C {}, C {}] = CallByName List.207 List.453 List.561 List.454; + let List.558 : U8 = 1i64; + let List.559 : U8 = GetTagId List.553; + let List.560 : Int1 = lowlevel Eq List.558 List.559; + if List.560 then + let List.457 : {} = UnionAtIndex (Id 1) (Index 0) List.553; + let List.556 : U64 = 1i64; + let List.555 : U64 = CallByName Num.19 List.455 List.556; + jump List.550 List.452 List.457 List.454 List.555 List.456; else - dec List.439; - let List.445 : {} = UnionAtIndex (Id 0) (Index 0) List.540; - let List.544 : [C {}, C {}] = TagId(0) List.445; - ret List.544; + dec List.452; + let List.458 : {} = UnionAtIndex (Id 0) (Index 0) List.553; + let List.557 : [C {}, C {}] = TagId(0) List.458; + ret List.557; else - dec List.439; - let List.538 : [C {}, C {}] = TagId(1) List.440; - ret List.538; + dec List.452; + let List.551 : [C {}, C {}] = TagId(1) List.453; + ret List.551; in - jump List.537 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4 #Derived_gen.5; + jump List.550 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4 #Derived_gen.5; -procedure List.93 (List.436, List.437, List.438): - let List.535 : U64 = 0i64; - let List.536 : U64 = CallByName List.6 List.436; - let List.534 : [C {}, C {}] = CallByName List.80 List.436 List.437 List.438 List.535 List.536; - ret List.534; +procedure List.96 (List.449, List.450, List.451): + let List.548 : U64 = 0i64; + let List.549 : U64 = CallByName List.6 List.449; + let List.547 : [C {}, C {}] = CallByName List.80 List.449 List.450 List.451 List.548 List.549; + ret List.547; procedure Num.19 (#Attr.2, #Attr.3): let Num.294 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/issue_4772_weakened_monomorphic_destructure.txt b/crates/compiler/test_mono/generated/issue_4772_weakened_monomorphic_destructure.txt index 368ce7bef1..567b0ff85b 100644 --- a/crates/compiler/test_mono/generated/issue_4772_weakened_monomorphic_destructure.txt +++ b/crates/compiler/test_mono/generated/issue_4772_weakened_monomorphic_destructure.txt @@ -38,136 +38,136 @@ procedure Decode.26 (Decode.105, Decode.106): let Decode.122 : {List U8, [C {}, C Str]} = CallByName Decode.25 Decode.105 Decode.123 Decode.106; ret Decode.122; -procedure List.1 (List.96): - let List.584 : U64 = CallByName List.6 List.96; - dec List.96; - let List.585 : U64 = 0i64; - let List.583 : Int1 = CallByName Bool.11 List.584 List.585; - ret List.583; +procedure List.1 (List.99): + let List.597 : U64 = CallByName List.6 List.99; + dec List.99; + let List.598 : U64 = 0i64; + let List.596 : Int1 = CallByName Bool.11 List.597 List.598; + ret List.596; -procedure List.2 (List.97, List.98): - let List.567 : U64 = CallByName List.6 List.97; - let List.564 : Int1 = CallByName Num.22 List.98 List.567; - if List.564 then - let List.566 : U8 = CallByName List.66 List.97 List.98; - dec List.97; - let List.565 : [C {}, C U8] = TagId(1) List.566; - ret List.565; +procedure List.2 (List.100, List.101): + let List.580 : U64 = CallByName List.6 List.100; + let List.577 : Int1 = CallByName Num.22 List.101 List.580; + if List.577 then + let List.579 : U8 = CallByName List.66 List.100 List.101; + dec List.100; + let List.578 : [C {}, C U8] = TagId(1) List.579; + ret List.578; else - dec List.97; - let List.563 : {} = Struct {}; - let List.562 : [C {}, C U8] = TagId(0) List.563; - ret List.562; - -procedure List.26 (List.159, List.160, List.161): - let List.586 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = CallByName List.93 List.159 List.160 List.161; - let List.589 : U8 = 1i64; - let List.590 : U8 = GetTagId List.586; - let List.591 : Int1 = lowlevel Eq List.589 List.590; - if List.591 then - let List.162 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = UnionAtIndex (Id 1) (Index 0) List.586; - ret List.162; - else - let List.163 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = UnionAtIndex (Id 0) (Index 0) List.586; - ret List.163; - -procedure List.29 (List.304, List.305): - let List.541 : U64 = CallByName List.6 List.304; - let List.306 : U64 = CallByName Num.77 List.541 List.305; - let List.540 : List U8 = CallByName List.43 List.304 List.306; - ret List.540; - -procedure List.31 (#Attr.2, #Attr.3): - let List.554 : List U8 = lowlevel ListDropAt #Attr.2 #Attr.3; - ret List.554; - -procedure List.38 (List.298): - let List.553 : U64 = 0i64; - let List.552 : List U8 = CallByName List.31 List.298 List.553; - ret List.552; - -procedure List.4 (List.113, List.114): - let List.551 : U64 = 1i64; - let List.550 : List U8 = CallByName List.70 List.113 List.551; - let List.549 : List U8 = CallByName List.71 List.550 List.114; - ret List.549; - -procedure List.43 (List.302, List.303): - let List.533 : U64 = CallByName List.6 List.302; - let List.532 : U64 = CallByName Num.77 List.533 List.303; - let List.523 : {U64, U64} = Struct {List.303, List.532}; - let List.522 : List U8 = CallByName List.49 List.302 List.523; - ret List.522; - -procedure List.49 (List.376, List.377): - let List.580 : U64 = StructAtIndex 0 List.377; - let List.581 : U64 = 0i64; - let List.578 : Int1 = CallByName Bool.11 List.580 List.581; - if List.578 then - dec List.376; - let List.579 : List U8 = Array []; - ret List.579; - else - let List.576 : U64 = StructAtIndex 1 List.377; - let List.577 : U64 = StructAtIndex 0 List.377; - let List.575 : List U8 = CallByName List.72 List.376 List.576 List.577; + dec List.100; + let List.576 : {} = Struct {}; + let List.575 : [C {}, C U8] = TagId(0) List.576; ret List.575; +procedure List.26 (List.172, List.173, List.174): + let List.599 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = CallByName List.96 List.172 List.173 List.174; + let List.602 : U8 = 1i64; + let List.603 : U8 = GetTagId List.599; + let List.604 : Int1 = lowlevel Eq List.602 List.603; + if List.604 then + let List.175 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = UnionAtIndex (Id 1) (Index 0) List.599; + ret List.175; + else + let List.176 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = UnionAtIndex (Id 0) (Index 0) List.599; + ret List.176; + +procedure List.29 (List.317, List.318): + let List.554 : U64 = CallByName List.6 List.317; + let List.319 : U64 = CallByName Num.77 List.554 List.318; + let List.553 : List U8 = CallByName List.43 List.317 List.319; + ret List.553; + +procedure List.31 (#Attr.2, #Attr.3): + let List.567 : List U8 = lowlevel ListDropAt #Attr.2 #Attr.3; + ret List.567; + +procedure List.38 (List.311): + let List.566 : U64 = 0i64; + let List.565 : List U8 = CallByName List.31 List.311 List.566; + ret List.565; + +procedure List.4 (List.116, List.117): + let List.564 : U64 = 1i64; + let List.563 : List U8 = CallByName List.70 List.116 List.564; + let List.562 : List U8 = CallByName List.71 List.563 List.117; + ret List.562; + +procedure List.43 (List.315, List.316): + let List.546 : U64 = CallByName List.6 List.315; + let List.545 : U64 = CallByName Num.77 List.546 List.316; + let List.536 : {U64, U64} = Struct {List.316, List.545}; + let List.535 : List U8 = CallByName List.49 List.315 List.536; + ret List.535; + +procedure List.49 (List.389, List.390): + let List.593 : U64 = StructAtIndex 0 List.390; + let List.594 : U64 = 0i64; + let List.591 : Int1 = CallByName Bool.11 List.593 List.594; + if List.591 then + dec List.389; + let List.592 : List U8 = Array []; + ret List.592; + else + let List.589 : U64 = StructAtIndex 1 List.390; + let List.590 : U64 = StructAtIndex 0 List.390; + let List.588 : List U8 = CallByName List.72 List.389 List.589 List.590; + ret List.588; + procedure List.6 (#Attr.2): - let List.607 : U64 = lowlevel ListLen #Attr.2; - ret List.607; + let List.620 : U64 = lowlevel ListLen #Attr.2; + ret List.620; procedure List.66 (#Attr.2, #Attr.3): - let List.560 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.560; + let List.573 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.573; procedure List.70 (#Attr.2, #Attr.3): - let List.548 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.548; + let List.561 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.561; procedure List.71 (#Attr.2, #Attr.3): - let List.546 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.546; + let List.559 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.559; procedure List.72 (#Attr.2, #Attr.3, #Attr.4): - let List.527 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; - ret List.527; + let List.540 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; + ret List.540; procedure List.8 (#Attr.2, #Attr.3): - let List.543 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; - ret List.543; + let List.556 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; + ret List.556; procedure List.80 (#Derived_gen.0, #Derived_gen.1, #Derived_gen.2, #Derived_gen.3, #Derived_gen.4): - joinpoint List.595 List.439 List.440 List.441 List.442 List.443: - let List.597 : Int1 = CallByName Num.22 List.442 List.443; - if List.597 then - let List.606 : U8 = CallByName List.66 List.439 List.442; - let List.598 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = CallByName TotallyNotJson.62 List.440 List.606; - let List.603 : U8 = 1i64; - let List.604 : U8 = GetTagId List.598; - let List.605 : Int1 = lowlevel Eq List.603 List.604; - if List.605 then - let List.444 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = UnionAtIndex (Id 1) (Index 0) List.598; - let List.601 : U64 = 1i64; - let List.600 : U64 = CallByName Num.19 List.442 List.601; - jump List.595 List.439 List.444 List.441 List.600 List.443; + joinpoint List.608 List.452 List.453 List.454 List.455 List.456: + let List.610 : Int1 = CallByName Num.22 List.455 List.456; + if List.610 then + let List.619 : U8 = CallByName List.66 List.452 List.455; + let List.611 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = CallByName TotallyNotJson.62 List.453 List.619; + let List.616 : U8 = 1i64; + let List.617 : U8 = GetTagId List.611; + let List.618 : Int1 = lowlevel Eq List.616 List.617; + if List.618 then + let List.457 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = UnionAtIndex (Id 1) (Index 0) List.611; + let List.614 : U64 = 1i64; + let List.613 : U64 = CallByName Num.19 List.455 List.614; + jump List.608 List.452 List.457 List.454 List.613 List.456; else - dec List.439; - let List.445 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = UnionAtIndex (Id 0) (Index 0) List.598; - let List.602 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = TagId(0) List.445; - ret List.602; + dec List.452; + let List.458 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = UnionAtIndex (Id 0) (Index 0) List.611; + let List.615 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = TagId(0) List.458; + ret List.615; else - dec List.439; - let List.596 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = TagId(1) List.440; - ret List.596; + dec List.452; + let List.609 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = TagId(1) List.453; + ret List.609; in - jump List.595 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4; + jump List.608 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4; -procedure List.93 (List.436, List.437, List.438): - let List.593 : U64 = 0i64; - let List.594 : U64 = CallByName List.6 List.436; - let List.592 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = CallByName List.80 List.436 List.437 List.438 List.593 List.594; - ret List.592; +procedure List.96 (List.449, List.450, List.451): + let List.606 : U64 = 0i64; + let List.607 : U64 = CallByName List.6 List.449; + let List.605 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = CallByName List.80 List.449 List.450 List.451 List.606 List.607; + ret List.605; procedure Num.19 (#Attr.2, #Attr.3): let Num.295 : U8 = lowlevel NumAdd #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/layout_cache_structure_with_multiple_recursive_structures.txt b/crates/compiler/test_mono/generated/layout_cache_structure_with_multiple_recursive_structures.txt index d94a1b57be..0c9ea68629 100644 --- a/crates/compiler/test_mono/generated/layout_cache_structure_with_multiple_recursive_structures.txt +++ b/crates/compiler/test_mono/generated/layout_cache_structure_with_multiple_recursive_structures.txt @@ -1,49 +1,41 @@ -procedure List.145 (List.146, List.147, List.144): - let List.540 : [, C {[C *self, ], *self}] = CallByName Test.7 List.146 List.147; - ret List.540; - -procedure List.18 (List.142, List.143, List.144): - let List.521 : [, C {[C *self, ], *self}] = CallByName List.93 List.142 List.143 List.144; - ret List.521; +procedure List.18 (List.145, List.146, List.147): + let List.535 : U64 = 0i64; + let List.536 : U64 = CallByName List.6 List.145; + let List.534 : [, C {[C *self, ], *self}] = CallByName List.86 List.145 List.146 List.147 List.535 List.536; + ret List.534; procedure List.6 (#Attr.2): - let List.538 : U64 = lowlevel ListLen #Attr.2; - ret List.538; + let List.545 : U64 = lowlevel ListLen #Attr.2; + ret List.545; procedure List.66 (#Attr.2, #Attr.3): - let List.537 : [C *self, ] = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.537; + let List.544 : [C *self, ] = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.544; -procedure List.80 (#Derived_gen.0, #Derived_gen.1, #Derived_gen.2, #Derived_gen.3, #Derived_gen.4): - joinpoint List.527 List.439 List.440 List.441 List.442 List.443: - let List.529 : Int1 = CallByName Num.22 List.442 List.443; - if List.529 then - let List.536 : [C *self, ] = CallByName List.66 List.439 List.442; - inc List.536; - let List.530 : [, C {[C *self, ], *self}] = CallByName List.145 List.440 List.536 List.441; - let List.533 : U64 = 1i64; - let List.532 : U64 = CallByName Num.19 List.442 List.533; - jump List.527 List.439 List.530 List.441 List.532 List.443; +procedure List.86 (#Derived_gen.0, #Derived_gen.1, #Derived_gen.2, #Derived_gen.3, #Derived_gen.4): + joinpoint List.537 List.148 List.149 List.150 List.151 List.152: + let List.539 : Int1 = CallByName Num.22 List.151 List.152; + if List.539 then + let List.543 : [C *self, ] = CallByName List.66 List.148 List.151; + inc List.543; + let List.153 : [, C {[C *self, ], *self}] = CallByName Test.7 List.149 List.543; + let List.542 : U64 = 1i64; + let List.541 : U64 = CallByName Num.51 List.151 List.542; + jump List.537 List.148 List.153 List.150 List.541 List.152; else - dec List.439; - ret List.440; + dec List.148; + ret List.149; in - jump List.527 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4; - -procedure List.93 (List.436, List.437, List.438): - let List.525 : U64 = 0i64; - let List.526 : U64 = CallByName List.6 List.436; - let List.524 : [, C {[C *self, ], *self}] = CallByName List.80 List.436 List.437 List.438 List.525 List.526; - ret List.524; - -procedure Num.19 (#Attr.2, #Attr.3): - let Num.292 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.292; + jump List.537 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4; procedure Num.22 (#Attr.2, #Attr.3): let Num.293 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; ret Num.293; +procedure Num.51 (#Attr.2, #Attr.3): + let Num.292 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; + ret Num.292; + procedure Test.7 (Test.11, Test.12): let Test.17 : {[C *self, ], [, C {[C *self, ], *self}]} = Struct {Test.12, Test.11}; let Test.16 : [, C {[C *self, ], *self}] = TagId(0) Test.17; diff --git a/crates/compiler/test_mono/generated/list_append.txt b/crates/compiler/test_mono/generated/list_append.txt index e13262740b..7bbcc56583 100644 --- a/crates/compiler/test_mono/generated/list_append.txt +++ b/crates/compiler/test_mono/generated/list_append.txt @@ -1,16 +1,16 @@ -procedure List.4 (List.113, List.114): - let List.524 : U64 = 1i64; - let List.522 : List I64 = CallByName List.70 List.113 List.524; - let List.521 : List I64 = CallByName List.71 List.522 List.114; - ret List.521; +procedure List.4 (List.116, List.117): + let List.537 : U64 = 1i64; + let List.535 : List I64 = CallByName List.70 List.116 List.537; + let List.534 : List I64 = CallByName List.71 List.535 List.117; + ret List.534; procedure List.70 (#Attr.2, #Attr.3): - let List.525 : List I64 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.525; + let List.538 : List I64 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.538; procedure List.71 (#Attr.2, #Attr.3): - let List.523 : List I64 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.523; + let List.536 : List I64 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.536; procedure Test.0 (): let Test.2 : List I64 = Array [1i64]; diff --git a/crates/compiler/test_mono/generated/list_append_closure.txt b/crates/compiler/test_mono/generated/list_append_closure.txt index e61910787a..c5b6b5bf4e 100644 --- a/crates/compiler/test_mono/generated/list_append_closure.txt +++ b/crates/compiler/test_mono/generated/list_append_closure.txt @@ -1,16 +1,16 @@ -procedure List.4 (List.113, List.114): - let List.524 : U64 = 1i64; - let List.522 : List I64 = CallByName List.70 List.113 List.524; - let List.521 : List I64 = CallByName List.71 List.522 List.114; - ret List.521; +procedure List.4 (List.116, List.117): + let List.537 : U64 = 1i64; + let List.535 : List I64 = CallByName List.70 List.116 List.537; + let List.534 : List I64 = CallByName List.71 List.535 List.117; + ret List.534; procedure List.70 (#Attr.2, #Attr.3): - let List.525 : List I64 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.525; + let List.538 : List I64 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.538; procedure List.71 (#Attr.2, #Attr.3): - let List.523 : List I64 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.523; + let List.536 : List I64 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.536; procedure Test.1 (Test.2): let Test.6 : I64 = 42i64; diff --git a/crates/compiler/test_mono/generated/list_cannot_update_inplace.txt b/crates/compiler/test_mono/generated/list_cannot_update_inplace.txt index feb8f2d3b7..d4be88def5 100644 --- a/crates/compiler/test_mono/generated/list_cannot_update_inplace.txt +++ b/crates/compiler/test_mono/generated/list_cannot_update_inplace.txt @@ -1,25 +1,25 @@ -procedure List.3 (List.105, List.106, List.107): - let List.524 : {List I64, I64} = CallByName List.64 List.105 List.106 List.107; - let List.523 : List I64 = StructAtIndex 0 List.524; - ret List.523; +procedure List.3 (List.108, List.109, List.110): + let List.537 : {List I64, I64} = CallByName List.64 List.108 List.109 List.110; + let List.536 : List I64 = StructAtIndex 0 List.537; + ret List.536; procedure List.6 (#Attr.2): - let List.522 : U64 = lowlevel ListLen #Attr.2; - ret List.522; + let List.535 : U64 = lowlevel ListLen #Attr.2; + ret List.535; -procedure List.64 (List.102, List.103, List.104): - let List.529 : U64 = CallByName List.6 List.102; - let List.526 : Int1 = CallByName Num.22 List.103 List.529; - if List.526 then - let List.527 : {List I64, I64} = CallByName List.67 List.102 List.103 List.104; - ret List.527; +procedure List.64 (List.105, List.106, List.107): + let List.542 : U64 = CallByName List.6 List.105; + let List.539 : Int1 = CallByName Num.22 List.106 List.542; + if List.539 then + let List.540 : {List I64, I64} = CallByName List.67 List.105 List.106 List.107; + ret List.540; else - let List.525 : {List I64, I64} = Struct {List.102, List.104}; - ret List.525; + let List.538 : {List I64, I64} = Struct {List.105, List.107}; + ret List.538; procedure List.67 (#Attr.2, #Attr.3, #Attr.4): - let List.528 : {List I64, I64} = lowlevel ListReplaceUnsafe #Attr.2 #Attr.3 #Attr.4; - ret List.528; + let List.541 : {List I64, I64} = lowlevel ListReplaceUnsafe #Attr.2 #Attr.3 #Attr.4; + ret List.541; procedure Num.19 (#Attr.2, #Attr.3): let Num.292 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/list_get.txt b/crates/compiler/test_mono/generated/list_get.txt index 02404934e9..0d58eda351 100644 --- a/crates/compiler/test_mono/generated/list_get.txt +++ b/crates/compiler/test_mono/generated/list_get.txt @@ -1,24 +1,24 @@ -procedure List.2 (List.97, List.98): - let List.527 : U64 = CallByName List.6 List.97; - let List.523 : Int1 = CallByName Num.22 List.98 List.527; - if List.523 then - let List.525 : I64 = CallByName List.66 List.97 List.98; - dec List.97; - let List.524 : [C {}, C I64] = TagId(1) List.525; - ret List.524; +procedure List.2 (List.100, List.101): + let List.540 : U64 = CallByName List.6 List.100; + let List.536 : Int1 = CallByName Num.22 List.101 List.540; + if List.536 then + let List.538 : I64 = CallByName List.66 List.100 List.101; + dec List.100; + let List.537 : [C {}, C I64] = TagId(1) List.538; + ret List.537; else - dec List.97; - let List.522 : {} = Struct {}; - let List.521 : [C {}, C I64] = TagId(0) List.522; - ret List.521; + dec List.100; + let List.535 : {} = Struct {}; + let List.534 : [C {}, C I64] = TagId(0) List.535; + ret List.534; procedure List.6 (#Attr.2): - let List.528 : U64 = lowlevel ListLen #Attr.2; - ret List.528; + let List.541 : U64 = lowlevel ListLen #Attr.2; + ret List.541; procedure List.66 (#Attr.2, #Attr.3): - let List.526 : I64 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.526; + let List.539 : I64 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.539; procedure Num.22 (#Attr.2, #Attr.3): let Num.292 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/list_len.txt b/crates/compiler/test_mono/generated/list_len.txt index 9691dc2b48..b9cb7f3800 100644 --- a/crates/compiler/test_mono/generated/list_len.txt +++ b/crates/compiler/test_mono/generated/list_len.txt @@ -1,10 +1,10 @@ procedure List.6 (#Attr.2): - let List.521 : U64 = lowlevel ListLen #Attr.2; - ret List.521; + let List.534 : U64 = lowlevel ListLen #Attr.2; + ret List.534; procedure List.6 (#Attr.2): - let List.522 : U64 = lowlevel ListLen #Attr.2; - ret List.522; + let List.535 : U64 = lowlevel ListLen #Attr.2; + ret List.535; procedure Num.19 (#Attr.2, #Attr.3): let Num.292 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/list_map_closure_borrows.txt b/crates/compiler/test_mono/generated/list_map_closure_borrows.txt index c5d65f94a7..094ea6af7f 100644 --- a/crates/compiler/test_mono/generated/list_map_closure_borrows.txt +++ b/crates/compiler/test_mono/generated/list_map_closure_borrows.txt @@ -1,30 +1,30 @@ -procedure List.2 (List.97, List.98): - let List.527 : U64 = CallByName List.6 List.97; - let List.523 : Int1 = CallByName Num.22 List.98 List.527; - if List.523 then - let List.525 : Str = CallByName List.66 List.97 List.98; - inc List.525; - dec List.97; - let List.524 : [C {}, C Str] = TagId(1) List.525; - ret List.524; +procedure List.2 (List.100, List.101): + let List.540 : U64 = CallByName List.6 List.100; + let List.536 : Int1 = CallByName Num.22 List.101 List.540; + if List.536 then + let List.538 : Str = CallByName List.66 List.100 List.101; + inc List.538; + dec List.100; + let List.537 : [C {}, C Str] = TagId(1) List.538; + ret List.537; else - dec List.97; - let List.522 : {} = Struct {}; - let List.521 : [C {}, C Str] = TagId(0) List.522; - ret List.521; + dec List.100; + let List.535 : {} = Struct {}; + let List.534 : [C {}, C Str] = TagId(0) List.535; + ret List.534; procedure List.5 (#Attr.2, #Attr.3): - let List.529 : List Str = lowlevel ListMap { xs: `#Attr.#arg1` } #Attr.2 Test.3 #Attr.3; + let List.542 : List Str = lowlevel ListMap { xs: `#Attr.#arg1` } #Attr.2 Test.3 #Attr.3; decref #Attr.2; - ret List.529; + ret List.542; procedure List.6 (#Attr.2): - let List.528 : U64 = lowlevel ListLen #Attr.2; - ret List.528; + let List.541 : U64 = lowlevel ListLen #Attr.2; + ret List.541; procedure List.66 (#Attr.2, #Attr.3): - let List.526 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.526; + let List.539 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.539; procedure Num.22 (#Attr.2, #Attr.3): let Num.292 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/list_map_closure_owns.txt b/crates/compiler/test_mono/generated/list_map_closure_owns.txt index a384497df2..413372f559 100644 --- a/crates/compiler/test_mono/generated/list_map_closure_owns.txt +++ b/crates/compiler/test_mono/generated/list_map_closure_owns.txt @@ -1,30 +1,30 @@ -procedure List.2 (List.97, List.98): - let List.527 : U64 = CallByName List.6 List.97; - let List.523 : Int1 = CallByName Num.22 List.98 List.527; - if List.523 then - let List.525 : Str = CallByName List.66 List.97 List.98; - inc List.525; - dec List.97; - let List.524 : [C {}, C Str] = TagId(1) List.525; - ret List.524; +procedure List.2 (List.100, List.101): + let List.540 : U64 = CallByName List.6 List.100; + let List.536 : Int1 = CallByName Num.22 List.101 List.540; + if List.536 then + let List.538 : Str = CallByName List.66 List.100 List.101; + inc List.538; + dec List.100; + let List.537 : [C {}, C Str] = TagId(1) List.538; + ret List.537; else - dec List.97; - let List.522 : {} = Struct {}; - let List.521 : [C {}, C Str] = TagId(0) List.522; - ret List.521; + dec List.100; + let List.535 : {} = Struct {}; + let List.534 : [C {}, C Str] = TagId(0) List.535; + ret List.534; procedure List.5 (#Attr.2, #Attr.3): - let List.529 : List Str = lowlevel ListMap { xs: `#Attr.#arg1` } #Attr.2 Test.3 #Attr.3; + let List.542 : List Str = lowlevel ListMap { xs: `#Attr.#arg1` } #Attr.2 Test.3 #Attr.3; decref #Attr.2; - ret List.529; + ret List.542; procedure List.6 (#Attr.2): - let List.528 : U64 = lowlevel ListLen #Attr.2; - ret List.528; + let List.541 : U64 = lowlevel ListLen #Attr.2; + ret List.541; procedure List.66 (#Attr.2, #Attr.3): - let List.526 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.526; + let List.539 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.539; procedure Num.22 (#Attr.2, #Attr.3): let Num.292 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/list_map_take_capturing_or_noncapturing.txt b/crates/compiler/test_mono/generated/list_map_take_capturing_or_noncapturing.txt index 6054fd9062..559ed77dac 100644 --- a/crates/compiler/test_mono/generated/list_map_take_capturing_or_noncapturing.txt +++ b/crates/compiler/test_mono/generated/list_map_take_capturing_or_noncapturing.txt @@ -1,23 +1,23 @@ procedure List.5 (#Attr.2, #Attr.3): - let List.522 : U8 = GetTagId #Attr.3; - joinpoint List.523 List.521: - ret List.521; + let List.535 : U8 = GetTagId #Attr.3; + joinpoint List.536 List.534: + ret List.534; in - switch List.522: + switch List.535: case 0: - let List.524 : List U8 = lowlevel ListMap { xs: `#Attr.#arg1` } #Attr.2 Test.4 #Attr.3; + let List.537 : List U8 = lowlevel ListMap { xs: `#Attr.#arg1` } #Attr.2 Test.4 #Attr.3; decref #Attr.2; - jump List.523 List.524; + jump List.536 List.537; case 1: - let List.525 : List U8 = lowlevel ListMap { xs: `#Attr.#arg1` } #Attr.2 Test.6 #Attr.3; + let List.538 : List U8 = lowlevel ListMap { xs: `#Attr.#arg1` } #Attr.2 Test.6 #Attr.3; decref #Attr.2; - jump List.523 List.525; + jump List.536 List.538; default: - let List.526 : List U8 = lowlevel ListMap { xs: `#Attr.#arg1` } #Attr.2 Test.8 #Attr.3; + let List.539 : List U8 = lowlevel ListMap { xs: `#Attr.#arg1` } #Attr.2 Test.8 #Attr.3; decref #Attr.2; - jump List.523 List.526; + jump List.536 List.539; procedure Num.19 (#Attr.2, #Attr.3): diff --git a/crates/compiler/test_mono/generated/list_pass_to_function.txt b/crates/compiler/test_mono/generated/list_pass_to_function.txt index e2b7c8a453..fc33d3be82 100644 --- a/crates/compiler/test_mono/generated/list_pass_to_function.txt +++ b/crates/compiler/test_mono/generated/list_pass_to_function.txt @@ -1,25 +1,25 @@ -procedure List.3 (List.105, List.106, List.107): - let List.522 : {List I64, I64} = CallByName List.64 List.105 List.106 List.107; - let List.521 : List I64 = StructAtIndex 0 List.522; - ret List.521; +procedure List.3 (List.108, List.109, List.110): + let List.535 : {List I64, I64} = CallByName List.64 List.108 List.109 List.110; + let List.534 : List I64 = StructAtIndex 0 List.535; + ret List.534; procedure List.6 (#Attr.2): - let List.528 : U64 = lowlevel ListLen #Attr.2; - ret List.528; + let List.541 : U64 = lowlevel ListLen #Attr.2; + ret List.541; -procedure List.64 (List.102, List.103, List.104): - let List.527 : U64 = CallByName List.6 List.102; - let List.524 : Int1 = CallByName Num.22 List.103 List.527; - if List.524 then - let List.525 : {List I64, I64} = CallByName List.67 List.102 List.103 List.104; - ret List.525; +procedure List.64 (List.105, List.106, List.107): + let List.540 : U64 = CallByName List.6 List.105; + let List.537 : Int1 = CallByName Num.22 List.106 List.540; + if List.537 then + let List.538 : {List I64, I64} = CallByName List.67 List.105 List.106 List.107; + ret List.538; else - let List.523 : {List I64, I64} = Struct {List.102, List.104}; - ret List.523; + let List.536 : {List I64, I64} = Struct {List.105, List.107}; + ret List.536; procedure List.67 (#Attr.2, #Attr.3, #Attr.4): - let List.526 : {List I64, I64} = lowlevel ListReplaceUnsafe #Attr.2 #Attr.3 #Attr.4; - ret List.526; + let List.539 : {List I64, I64} = lowlevel ListReplaceUnsafe #Attr.2 #Attr.3 #Attr.4; + ret List.539; procedure Num.22 (#Attr.2, #Attr.3): let Num.292 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/list_sort_asc.txt b/crates/compiler/test_mono/generated/list_sort_asc.txt index 92a0c599c1..2e3a7afe02 100644 --- a/crates/compiler/test_mono/generated/list_sort_asc.txt +++ b/crates/compiler/test_mono/generated/list_sort_asc.txt @@ -1,11 +1,11 @@ procedure List.28 (#Attr.2, #Attr.3): - let List.523 : List I64 = lowlevel ListSortWith { xs: `#Attr.#arg1` } #Attr.2 Num.46 #Attr.3; - ret List.523; + let List.536 : List I64 = lowlevel ListSortWith { xs: `#Attr.#arg1` } #Attr.2 Num.46 #Attr.3; + ret List.536; -procedure List.59 (List.288): - let List.522 : {} = Struct {}; - let List.521 : List I64 = CallByName List.28 List.288 List.522; - ret List.521; +procedure List.59 (List.301): + let List.535 : {} = Struct {}; + let List.534 : List I64 = CallByName List.28 List.301 List.535; + ret List.534; procedure Num.46 (#Attr.2, #Attr.3): let Num.292 : U8 = lowlevel NumCompare #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/quicksort_swap.txt b/crates/compiler/test_mono/generated/quicksort_swap.txt index b592bcc4e6..0a3e17d08c 100644 --- a/crates/compiler/test_mono/generated/quicksort_swap.txt +++ b/crates/compiler/test_mono/generated/quicksort_swap.txt @@ -1,43 +1,43 @@ -procedure List.2 (List.97, List.98): - let List.543 : U64 = CallByName List.6 List.97; - let List.540 : Int1 = CallByName Num.22 List.98 List.543; - if List.540 then - let List.542 : I64 = CallByName List.66 List.97 List.98; - dec List.97; - let List.541 : [C {}, C I64] = TagId(1) List.542; - ret List.541; +procedure List.2 (List.100, List.101): + let List.556 : U64 = CallByName List.6 List.100; + let List.553 : Int1 = CallByName Num.22 List.101 List.556; + if List.553 then + let List.555 : I64 = CallByName List.66 List.100 List.101; + dec List.100; + let List.554 : [C {}, C I64] = TagId(1) List.555; + ret List.554; else - dec List.97; - let List.539 : {} = Struct {}; - let List.538 : [C {}, C I64] = TagId(0) List.539; - ret List.538; + dec List.100; + let List.552 : {} = Struct {}; + let List.551 : [C {}, C I64] = TagId(0) List.552; + ret List.551; -procedure List.3 (List.105, List.106, List.107): - let List.530 : {List I64, I64} = CallByName List.64 List.105 List.106 List.107; - let List.529 : List I64 = StructAtIndex 0 List.530; - ret List.529; +procedure List.3 (List.108, List.109, List.110): + let List.543 : {List I64, I64} = CallByName List.64 List.108 List.109 List.110; + let List.542 : List I64 = StructAtIndex 0 List.543; + ret List.542; procedure List.6 (#Attr.2): - let List.528 : U64 = lowlevel ListLen #Attr.2; - ret List.528; + let List.541 : U64 = lowlevel ListLen #Attr.2; + ret List.541; -procedure List.64 (List.102, List.103, List.104): - let List.527 : U64 = CallByName List.6 List.102; - let List.524 : Int1 = CallByName Num.22 List.103 List.527; - if List.524 then - let List.525 : {List I64, I64} = CallByName List.67 List.102 List.103 List.104; - ret List.525; +procedure List.64 (List.105, List.106, List.107): + let List.540 : U64 = CallByName List.6 List.105; + let List.537 : Int1 = CallByName Num.22 List.106 List.540; + if List.537 then + let List.538 : {List I64, I64} = CallByName List.67 List.105 List.106 List.107; + ret List.538; else - let List.523 : {List I64, I64} = Struct {List.102, List.104}; - ret List.523; + let List.536 : {List I64, I64} = Struct {List.105, List.107}; + ret List.536; procedure List.66 (#Attr.2, #Attr.3): - let List.536 : I64 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.536; + let List.549 : I64 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.549; procedure List.67 (#Attr.2, #Attr.3, #Attr.4): - let List.526 : {List I64, I64} = lowlevel ListReplaceUnsafe #Attr.2 #Attr.3 #Attr.4; - ret List.526; + let List.539 : {List I64, I64} = lowlevel ListReplaceUnsafe #Attr.2 #Attr.3 #Attr.4; + ret List.539; procedure Num.22 (#Attr.2, #Attr.3): let Num.294 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/record_update.txt b/crates/compiler/test_mono/generated/record_update.txt index e5b9598325..82bbdcc0b5 100644 --- a/crates/compiler/test_mono/generated/record_update.txt +++ b/crates/compiler/test_mono/generated/record_update.txt @@ -1,25 +1,25 @@ -procedure List.3 (List.105, List.106, List.107): - let List.530 : {List U64, U64} = CallByName List.64 List.105 List.106 List.107; - let List.529 : List U64 = StructAtIndex 0 List.530; - ret List.529; +procedure List.3 (List.108, List.109, List.110): + let List.543 : {List U64, U64} = CallByName List.64 List.108 List.109 List.110; + let List.542 : List U64 = StructAtIndex 0 List.543; + ret List.542; procedure List.6 (#Attr.2): - let List.528 : U64 = lowlevel ListLen #Attr.2; - ret List.528; + let List.541 : U64 = lowlevel ListLen #Attr.2; + ret List.541; -procedure List.64 (List.102, List.103, List.104): - let List.527 : U64 = CallByName List.6 List.102; - let List.524 : Int1 = CallByName Num.22 List.103 List.527; - if List.524 then - let List.525 : {List U64, U64} = CallByName List.67 List.102 List.103 List.104; - ret List.525; +procedure List.64 (List.105, List.106, List.107): + let List.540 : U64 = CallByName List.6 List.105; + let List.537 : Int1 = CallByName Num.22 List.106 List.540; + if List.537 then + let List.538 : {List U64, U64} = CallByName List.67 List.105 List.106 List.107; + ret List.538; else - let List.523 : {List U64, U64} = Struct {List.102, List.104}; - ret List.523; + let List.536 : {List U64, U64} = Struct {List.105, List.107}; + ret List.536; procedure List.67 (#Attr.2, #Attr.3, #Attr.4): - let List.526 : {List U64, U64} = lowlevel ListReplaceUnsafe #Attr.2 #Attr.3 #Attr.4; - ret List.526; + let List.539 : {List U64, U64} = lowlevel ListReplaceUnsafe #Attr.2 #Attr.3 #Attr.4; + ret List.539; procedure Num.22 (#Attr.2, #Attr.3): let Num.292 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/recursive_function_and_union_with_inference_hole.txt b/crates/compiler/test_mono/generated/recursive_function_and_union_with_inference_hole.txt index 2e772fba51..4b6d833c35 100644 --- a/crates/compiler/test_mono/generated/recursive_function_and_union_with_inference_hole.txt +++ b/crates/compiler/test_mono/generated/recursive_function_and_union_with_inference_hole.txt @@ -1,7 +1,7 @@ procedure List.5 (#Attr.2, #Attr.3): - let List.521 : List [C List *self] = lowlevel ListMap { xs: `#Attr.#arg1` } #Attr.2 Test.2 #Attr.3; + let List.534 : List [C List *self] = lowlevel ListMap { xs: `#Attr.#arg1` } #Attr.2 Test.2 #Attr.3; decref #Attr.2; - ret List.521; + ret List.534; procedure Test.2 (Test.5): let Test.6 : List [C List *self] = UnionAtIndex (Id 0) (Index 0) Test.5; diff --git a/crates/compiler/test_mono/generated/rigids.txt b/crates/compiler/test_mono/generated/rigids.txt index 5ba8e329d0..880989e3a5 100644 --- a/crates/compiler/test_mono/generated/rigids.txt +++ b/crates/compiler/test_mono/generated/rigids.txt @@ -1,43 +1,43 @@ -procedure List.2 (List.97, List.98): - let List.543 : U64 = CallByName List.6 List.97; - let List.540 : Int1 = CallByName Num.22 List.98 List.543; - if List.540 then - let List.542 : I64 = CallByName List.66 List.97 List.98; - dec List.97; - let List.541 : [C {}, C I64] = TagId(1) List.542; - ret List.541; +procedure List.2 (List.100, List.101): + let List.556 : U64 = CallByName List.6 List.100; + let List.553 : Int1 = CallByName Num.22 List.101 List.556; + if List.553 then + let List.555 : I64 = CallByName List.66 List.100 List.101; + dec List.100; + let List.554 : [C {}, C I64] = TagId(1) List.555; + ret List.554; else - dec List.97; - let List.539 : {} = Struct {}; - let List.538 : [C {}, C I64] = TagId(0) List.539; - ret List.538; + dec List.100; + let List.552 : {} = Struct {}; + let List.551 : [C {}, C I64] = TagId(0) List.552; + ret List.551; -procedure List.3 (List.105, List.106, List.107): - let List.530 : {List I64, I64} = CallByName List.64 List.105 List.106 List.107; - let List.529 : List I64 = StructAtIndex 0 List.530; - ret List.529; +procedure List.3 (List.108, List.109, List.110): + let List.543 : {List I64, I64} = CallByName List.64 List.108 List.109 List.110; + let List.542 : List I64 = StructAtIndex 0 List.543; + ret List.542; procedure List.6 (#Attr.2): - let List.528 : U64 = lowlevel ListLen #Attr.2; - ret List.528; + let List.541 : U64 = lowlevel ListLen #Attr.2; + ret List.541; -procedure List.64 (List.102, List.103, List.104): - let List.527 : U64 = CallByName List.6 List.102; - let List.524 : Int1 = CallByName Num.22 List.103 List.527; - if List.524 then - let List.525 : {List I64, I64} = CallByName List.67 List.102 List.103 List.104; - ret List.525; +procedure List.64 (List.105, List.106, List.107): + let List.540 : U64 = CallByName List.6 List.105; + let List.537 : Int1 = CallByName Num.22 List.106 List.540; + if List.537 then + let List.538 : {List I64, I64} = CallByName List.67 List.105 List.106 List.107; + ret List.538; else - let List.523 : {List I64, I64} = Struct {List.102, List.104}; - ret List.523; + let List.536 : {List I64, I64} = Struct {List.105, List.107}; + ret List.536; procedure List.66 (#Attr.2, #Attr.3): - let List.536 : I64 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.536; + let List.549 : I64 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.549; procedure List.67 (#Attr.2, #Attr.3, #Attr.4): - let List.526 : {List I64, I64} = lowlevel ListReplaceUnsafe #Attr.2 #Attr.3 #Attr.4; - ret List.526; + let List.539 : {List I64, I64} = lowlevel ListReplaceUnsafe #Attr.2 #Attr.3 #Attr.4; + ret List.539; procedure Num.22 (#Attr.2, #Attr.3): let Num.294 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/unspecialized_lambda_set_unification_does_not_duplicate_identical_concrete_types.txt b/crates/compiler/test_mono/generated/unspecialized_lambda_set_unification_does_not_duplicate_identical_concrete_types.txt index ebeec28457..dd3800bbfb 100644 --- a/crates/compiler/test_mono/generated/unspecialized_lambda_set_unification_does_not_duplicate_identical_concrete_types.txt +++ b/crates/compiler/test_mono/generated/unspecialized_lambda_set_unification_does_not_duplicate_identical_concrete_types.txt @@ -33,207 +33,195 @@ procedure Encode.26 (Encode.105, Encode.106): let Encode.108 : List U8 = CallByName Encode.24 Encode.109 Encode.110 Encode.106; ret Encode.108; -procedure List.145 (List.146, List.147, List.144): - let List.566 : {List U8, U64} = CallByName TotallyNotJson.267 List.146 List.147 List.144; - ret List.566; +procedure List.18 (List.145, List.146, List.147): + let List.561 : U64 = 0i64; + let List.562 : U64 = CallByName List.6 List.145; + let List.560 : {List U8, U64} = CallByName List.86 List.145 List.146 List.147 List.561 List.562; + ret List.560; -procedure List.145 (List.146, List.147, List.144): - let List.586 : List U8 = CallByName TotallyNotJson.215 List.146 List.147; +procedure List.18 (List.145, List.146, List.147): + let List.573 : U64 = 0i64; + let List.574 : U64 = CallByName List.6 List.145; + let List.572 : List U8 = CallByName List.86 List.145 List.146 List.147 List.573 List.574; + ret List.572; + +procedure List.26 (List.172, List.173, List.174): + let List.614 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.96 List.172 List.173 List.174; + let List.617 : U8 = 1i64; + let List.618 : U8 = GetTagId List.614; + let List.619 : Int1 = lowlevel Eq List.617 List.618; + if List.619 then + let List.175 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.614; + ret List.175; + else + let List.176 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.614; + ret List.176; + +procedure List.4 (List.116, List.117): + let List.559 : U64 = 1i64; + let List.558 : List U8 = CallByName List.70 List.116 List.559; + let List.557 : List U8 = CallByName List.71 List.558 List.117; + ret List.557; + +procedure List.49 (List.389, List.390): + let List.606 : U64 = StructAtIndex 0 List.390; + let List.607 : U64 = 0i64; + let List.604 : Int1 = CallByName Bool.11 List.606 List.607; + if List.604 then + dec List.389; + let List.605 : List U8 = Array []; + ret List.605; + else + let List.601 : U64 = StructAtIndex 1 List.390; + let List.602 : U64 = StructAtIndex 0 List.390; + let List.600 : List U8 = CallByName List.72 List.389 List.601 List.602; + ret List.600; + +procedure List.52 (List.404, List.405): + let List.406 : U64 = CallByName List.6 List.404; + joinpoint List.612 List.407: + let List.610 : U64 = 0i64; + let List.609 : {U64, U64} = Struct {List.407, List.610}; + inc List.404; + let List.408 : List U8 = CallByName List.49 List.404 List.609; + let List.608 : U64 = CallByName Num.20 List.406 List.407; + let List.599 : {U64, U64} = Struct {List.608, List.407}; + let List.409 : List U8 = CallByName List.49 List.404 List.599; + let List.598 : {List U8, List U8} = Struct {List.408, List.409}; + ret List.598; + in + let List.613 : Int1 = CallByName Num.24 List.406 List.405; + if List.613 then + jump List.612 List.405; + else + jump List.612 List.406; + +procedure List.6 (#Attr.2): + let List.584 : U64 = lowlevel ListLen #Attr.2; + ret List.584; + +procedure List.6 (#Attr.2): + let List.586 : U64 = lowlevel ListLen #Attr.2; ret List.586; -procedure List.18 (List.142, List.143, List.144): - let List.547 : {List U8, U64} = CallByName List.93 List.142 List.143 List.144; - ret List.547; - -procedure List.18 (List.142, List.143, List.144): - let List.567 : List U8 = CallByName List.93 List.142 List.143 List.144; - ret List.567; - -procedure List.26 (List.159, List.160, List.161): - let List.617 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.93 List.159 List.160 List.161; - let List.620 : U8 = 1i64; - let List.621 : U8 = GetTagId List.617; - let List.622 : Int1 = lowlevel Eq List.620 List.621; - if List.622 then - let List.162 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.617; - ret List.162; - else - let List.163 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.617; - ret List.163; - -procedure List.4 (List.113, List.114): - let List.546 : U64 = 1i64; - let List.545 : List U8 = CallByName List.70 List.113 List.546; - let List.544 : List U8 = CallByName List.71 List.545 List.114; - ret List.544; - -procedure List.49 (List.376, List.377): - let List.609 : U64 = StructAtIndex 0 List.377; - let List.610 : U64 = 0i64; - let List.607 : Int1 = CallByName Bool.11 List.609 List.610; - if List.607 then - dec List.376; - let List.608 : List U8 = Array []; - ret List.608; - else - let List.604 : U64 = StructAtIndex 1 List.377; - let List.605 : U64 = StructAtIndex 0 List.377; - let List.603 : List U8 = CallByName List.72 List.376 List.604 List.605; - ret List.603; - -procedure List.52 (List.391, List.392): - let List.393 : U64 = CallByName List.6 List.391; - joinpoint List.615 List.394: - let List.613 : U64 = 0i64; - let List.612 : {U64, U64} = Struct {List.394, List.613}; - inc List.391; - let List.395 : List U8 = CallByName List.49 List.391 List.612; - let List.611 : U64 = CallByName Num.20 List.393 List.394; - let List.602 : {U64, U64} = Struct {List.611, List.394}; - let List.396 : List U8 = CallByName List.49 List.391 List.602; - let List.601 : {List U8, List U8} = Struct {List.395, List.396}; - ret List.601; - in - let List.616 : Int1 = CallByName Num.24 List.393 List.392; - if List.616 then - jump List.615 List.392; - else - jump List.615 List.393; - -procedure List.6 (#Attr.2): - let List.587 : U64 = lowlevel ListLen #Attr.2; - ret List.587; - -procedure List.6 (#Attr.2): - let List.589 : U64 = lowlevel ListLen #Attr.2; - ret List.589; - procedure List.66 (#Attr.2, #Attr.3): - let List.563 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.563; - -procedure List.66 (#Attr.2, #Attr.3): - let List.583 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.583; - -procedure List.68 (#Attr.2): - let List.600 : List U8 = lowlevel ListWithCapacity #Attr.2; - ret List.600; - -procedure List.70 (#Attr.2, #Attr.3): - let List.525 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.525; - -procedure List.71 (#Attr.2, #Attr.3): - let List.523 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.523; - -procedure List.72 (#Attr.2, #Attr.3, #Attr.4): - let List.606 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; - ret List.606; - -procedure List.8 (#Attr.2, #Attr.3): - let List.598 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; - ret List.598; - -procedure List.80 (#Derived_gen.19, #Derived_gen.20, #Derived_gen.21, #Derived_gen.22, #Derived_gen.23): - joinpoint List.553 List.439 List.440 List.441 List.442 List.443: - let List.555 : Int1 = CallByName Num.22 List.442 List.443; - if List.555 then - let List.562 : Str = CallByName List.66 List.439 List.442; - inc List.562; - let List.556 : {List U8, U64} = CallByName List.145 List.440 List.562 List.441; - let List.559 : U64 = 1i64; - let List.558 : U64 = CallByName Num.19 List.442 List.559; - jump List.553 List.439 List.556 List.441 List.558 List.443; - else - dec List.439; - ret List.440; - in - jump List.553 #Derived_gen.19 #Derived_gen.20 #Derived_gen.21 #Derived_gen.22 #Derived_gen.23; - -procedure List.80 (#Derived_gen.3, #Derived_gen.4, #Derived_gen.5, #Derived_gen.6, #Derived_gen.7): - joinpoint List.573 List.439 List.440 List.441 List.442 List.443: - let List.575 : Int1 = CallByName Num.22 List.442 List.443; - if List.575 then - let List.582 : U8 = CallByName List.66 List.439 List.442; - let List.576 : List U8 = CallByName List.145 List.440 List.582 List.441; - let List.579 : U64 = 1i64; - let List.578 : U64 = CallByName Num.19 List.442 List.579; - jump List.573 List.439 List.576 List.441 List.578 List.443; - else - dec List.439; - ret List.440; - in - jump List.573 #Derived_gen.3 #Derived_gen.4 #Derived_gen.5 #Derived_gen.6 #Derived_gen.7; - -procedure List.80 (#Derived_gen.8, #Derived_gen.9, #Derived_gen.10, #Derived_gen.11, #Derived_gen.12): - joinpoint List.626 List.439 List.440 List.441 List.442 List.443: - let List.628 : Int1 = CallByName Num.22 List.442 List.443; - if List.628 then - let List.637 : U8 = CallByName List.66 List.439 List.442; - let List.629 : [C {U64, Int1}, C {U64, Int1}] = CallByName TotallyNotJson.189 List.440 List.637; - let List.634 : U8 = 1i64; - let List.635 : U8 = GetTagId List.629; - let List.636 : Int1 = lowlevel Eq List.634 List.635; - if List.636 then - let List.444 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.629; - let List.632 : U64 = 1i64; - let List.631 : U64 = CallByName Num.19 List.442 List.632; - jump List.626 List.439 List.444 List.441 List.631 List.443; - else - dec List.439; - let List.445 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.629; - let List.633 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) List.445; - ret List.633; - else - dec List.439; - let List.627 : [C {U64, Int1}, C {U64, Int1}] = TagId(1) List.440; - ret List.627; - in - jump List.626 #Derived_gen.8 #Derived_gen.9 #Derived_gen.10 #Derived_gen.11 #Derived_gen.12; - -procedure List.93 (List.436, List.437, List.438): - let List.551 : U64 = 0i64; - let List.552 : U64 = CallByName List.6 List.436; - let List.550 : {List U8, U64} = CallByName List.80 List.436 List.437 List.438 List.551 List.552; - ret List.550; - -procedure List.93 (List.436, List.437, List.438): - let List.571 : U64 = 0i64; - let List.572 : U64 = CallByName List.6 List.436; - let List.570 : List U8 = CallByName List.80 List.436 List.437 List.438 List.571 List.572; + let List.570 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; ret List.570; -procedure List.93 (List.436, List.437, List.438): - let List.624 : U64 = 0i64; - let List.625 : U64 = CallByName List.6 List.436; - let List.623 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.80 List.436 List.437 List.438 List.624 List.625; - ret List.623; +procedure List.66 (#Attr.2, #Attr.3): + let List.582 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.582; + +procedure List.68 (#Attr.2): + let List.597 : List U8 = lowlevel ListWithCapacity #Attr.2; + ret List.597; + +procedure List.70 (#Attr.2, #Attr.3): + let List.538 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.538; + +procedure List.71 (#Attr.2, #Attr.3): + let List.536 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.536; + +procedure List.72 (#Attr.2, #Attr.3, #Attr.4): + let List.603 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; + ret List.603; + +procedure List.8 (#Attr.2, #Attr.3): + let List.595 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; + ret List.595; + +procedure List.80 (#Derived_gen.8, #Derived_gen.9, #Derived_gen.10, #Derived_gen.11, #Derived_gen.12): + joinpoint List.623 List.452 List.453 List.454 List.455 List.456: + let List.625 : Int1 = CallByName Num.22 List.455 List.456; + if List.625 then + let List.634 : U8 = CallByName List.66 List.452 List.455; + let List.626 : [C {U64, Int1}, C {U64, Int1}] = CallByName TotallyNotJson.189 List.453 List.634; + let List.631 : U8 = 1i64; + let List.632 : U8 = GetTagId List.626; + let List.633 : Int1 = lowlevel Eq List.631 List.632; + if List.633 then + let List.457 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.626; + let List.629 : U64 = 1i64; + let List.628 : U64 = CallByName Num.19 List.455 List.629; + jump List.623 List.452 List.457 List.454 List.628 List.456; + else + dec List.452; + let List.458 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.626; + let List.630 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) List.458; + ret List.630; + else + dec List.452; + let List.624 : [C {U64, Int1}, C {U64, Int1}] = TagId(1) List.453; + ret List.624; + in + jump List.623 #Derived_gen.8 #Derived_gen.9 #Derived_gen.10 #Derived_gen.11 #Derived_gen.12; + +procedure List.86 (#Derived_gen.13, #Derived_gen.14, #Derived_gen.15, #Derived_gen.16, #Derived_gen.17): + joinpoint List.575 List.148 List.149 List.150 List.151 List.152: + let List.577 : Int1 = CallByName Num.22 List.151 List.152; + if List.577 then + let List.581 : U8 = CallByName List.66 List.148 List.151; + let List.153 : List U8 = CallByName TotallyNotJson.215 List.149 List.581; + let List.580 : U64 = 1i64; + let List.579 : U64 = CallByName Num.51 List.151 List.580; + jump List.575 List.148 List.153 List.150 List.579 List.152; + else + dec List.148; + ret List.149; + in + jump List.575 #Derived_gen.13 #Derived_gen.14 #Derived_gen.15 #Derived_gen.16 #Derived_gen.17; + +procedure List.86 (#Derived_gen.3, #Derived_gen.4, #Derived_gen.5, #Derived_gen.6, #Derived_gen.7): + joinpoint List.563 List.148 List.149 List.150 List.151 List.152: + let List.565 : Int1 = CallByName Num.22 List.151 List.152; + if List.565 then + let List.569 : Str = CallByName List.66 List.148 List.151; + inc List.569; + let List.153 : {List U8, U64} = CallByName TotallyNotJson.267 List.149 List.569 List.150; + let List.568 : U64 = 1i64; + let List.567 : U64 = CallByName Num.51 List.151 List.568; + jump List.563 List.148 List.153 List.150 List.567 List.152; + else + dec List.148; + ret List.149; + in + jump List.563 #Derived_gen.3 #Derived_gen.4 #Derived_gen.5 #Derived_gen.6 #Derived_gen.7; + +procedure List.96 (List.449, List.450, List.451): + let List.621 : U64 = 0i64; + let List.622 : U64 = CallByName List.6 List.449; + let List.620 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.80 List.449 List.450 List.451 List.621 List.622; + ret List.620; procedure Num.127 (#Attr.2): let Num.299 : U8 = lowlevel NumIntCast #Attr.2; ret Num.299; procedure Num.19 (#Attr.2, #Attr.3): - let Num.308 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.308; + let Num.313 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.313; procedure Num.20 (#Attr.2, #Attr.3): - let Num.312 : U64 = lowlevel NumSub #Attr.2 #Attr.3; - ret Num.312; + let Num.311 : U64 = lowlevel NumSub #Attr.2 #Attr.3; + ret Num.311; procedure Num.21 (#Attr.2, #Attr.3): let Num.305 : U64 = lowlevel NumMul #Attr.2 #Attr.3; ret Num.305; procedure Num.22 (#Attr.2, #Attr.3): - let Num.311 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; - ret Num.311; + let Num.310 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + ret Num.310; procedure Num.24 (#Attr.2, #Attr.3): - let Num.313 : Int1 = lowlevel NumGt #Attr.2 #Attr.3; - ret Num.313; + let Num.312 : Int1 = lowlevel NumGt #Attr.2 #Attr.3; + ret Num.312; + +procedure Num.51 (#Attr.2, #Attr.3): + let Num.307 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; + ret Num.307; procedure Num.94 (#Attr.2, #Attr.3): let Num.304 : U64 = lowlevel NumDivCeilUnchecked #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/unspecialized_lambda_set_unification_keeps_all_concrete_types_without_unification_of_unifiable.txt b/crates/compiler/test_mono/generated/unspecialized_lambda_set_unification_keeps_all_concrete_types_without_unification_of_unifiable.txt index cf967c3b4d..36d2f4a150 100644 --- a/crates/compiler/test_mono/generated/unspecialized_lambda_set_unification_keeps_all_concrete_types_without_unification_of_unifiable.txt +++ b/crates/compiler/test_mono/generated/unspecialized_lambda_set_unification_keeps_all_concrete_types_without_unification_of_unifiable.txt @@ -81,106 +81,86 @@ procedure Encode.26 (Encode.105, Encode.106): let Encode.108 : List U8 = CallByName Encode.24 Encode.109 Encode.110 Encode.106; ret Encode.108; -procedure List.145 (List.146, List.147, List.144): - let List.566 : {List U8, U64} = CallByName TotallyNotJson.267 List.146 List.147 List.144; - ret List.566; +procedure List.18 (List.145, List.146, List.147): + let List.561 : U64 = 0i64; + let List.562 : U64 = CallByName List.6 List.145; + let List.560 : {List U8, U64} = CallByName List.86 List.145 List.146 List.147 List.561 List.562; + ret List.560; -procedure List.145 (List.146, List.147, List.144): - let List.614 : {List U8, U64} = CallByName TotallyNotJson.267 List.146 List.147 List.144; - ret List.614; +procedure List.18 (List.145, List.146, List.147): + let List.601 : U64 = 0i64; + let List.602 : U64 = CallByName List.6 List.145; + let List.600 : {List U8, U64} = CallByName List.86 List.145 List.146 List.147 List.601 List.602; + ret List.600; -procedure List.18 (List.142, List.143, List.144): - let List.547 : {List U8, U64} = CallByName List.93 List.142 List.143 List.144; - ret List.547; - -procedure List.18 (List.142, List.143, List.144): - let List.595 : {List U8, U64} = CallByName List.93 List.142 List.143 List.144; - ret List.595; - -procedure List.4 (List.113, List.114): - let List.594 : U64 = 1i64; - let List.593 : List U8 = CallByName List.70 List.113 List.594; - let List.592 : List U8 = CallByName List.71 List.593 List.114; - ret List.592; +procedure List.4 (List.116, List.117): + let List.599 : U64 = 1i64; + let List.598 : List U8 = CallByName List.70 List.116 List.599; + let List.597 : List U8 = CallByName List.71 List.598 List.117; + ret List.597; procedure List.6 (#Attr.2): - let List.567 : U64 = lowlevel ListLen #Attr.2; - ret List.567; + let List.572 : U64 = lowlevel ListLen #Attr.2; + ret List.572; procedure List.6 (#Attr.2): - let List.615 : U64 = lowlevel ListLen #Attr.2; - ret List.615; + let List.612 : U64 = lowlevel ListLen #Attr.2; + ret List.612; procedure List.66 (#Attr.2, #Attr.3): - let List.563 : [C {}, C {}] = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.563; + let List.570 : [C {}, C {}] = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.570; procedure List.66 (#Attr.2, #Attr.3): - let List.611 : [] = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.611; + let List.610 : [] = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.610; procedure List.70 (#Attr.2, #Attr.3): - let List.573 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.573; + let List.578 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.578; procedure List.71 (#Attr.2, #Attr.3): - let List.571 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.571; + let List.576 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.576; procedure List.8 (#Attr.2, #Attr.3): - let List.616 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; - ret List.616; + let List.613 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; + ret List.613; -procedure List.80 (#Derived_gen.18, #Derived_gen.19, #Derived_gen.20, #Derived_gen.21, #Derived_gen.22): - joinpoint List.601 List.439 List.440 List.441 List.442 List.443: - let List.603 : Int1 = CallByName Num.22 List.442 List.443; - if List.603 then - let List.610 : [] = CallByName List.66 List.439 List.442; - let List.604 : {List U8, U64} = CallByName List.145 List.440 List.610 List.441; - let List.607 : U64 = 1i64; - let List.606 : U64 = CallByName Num.19 List.442 List.607; - jump List.601 List.439 List.604 List.441 List.606 List.443; +procedure List.86 (#Derived_gen.18, #Derived_gen.19, #Derived_gen.20, #Derived_gen.21, #Derived_gen.22): + joinpoint List.563 List.148 List.149 List.150 List.151 List.152: + let List.565 : Int1 = CallByName Num.22 List.151 List.152; + if List.565 then + let List.569 : [C {}, C {}] = CallByName List.66 List.148 List.151; + let List.153 : {List U8, U64} = CallByName TotallyNotJson.267 List.149 List.569 List.150; + let List.568 : U64 = 1i64; + let List.567 : U64 = CallByName Num.51 List.151 List.568; + jump List.563 List.148 List.153 List.150 List.567 List.152; else - dec List.439; - ret List.440; + dec List.148; + ret List.149; in - jump List.601 #Derived_gen.18 #Derived_gen.19 #Derived_gen.20 #Derived_gen.21 #Derived_gen.22; + jump List.563 #Derived_gen.18 #Derived_gen.19 #Derived_gen.20 #Derived_gen.21 #Derived_gen.22; -procedure List.80 (#Derived_gen.38, #Derived_gen.39, #Derived_gen.40, #Derived_gen.41, #Derived_gen.42): - joinpoint List.553 List.439 List.440 List.441 List.442 List.443: - let List.555 : Int1 = CallByName Num.22 List.442 List.443; - if List.555 then - let List.562 : [C {}, C {}] = CallByName List.66 List.439 List.442; - let List.556 : {List U8, U64} = CallByName List.145 List.440 List.562 List.441; - let List.559 : U64 = 1i64; - let List.558 : U64 = CallByName Num.19 List.442 List.559; - jump List.553 List.439 List.556 List.441 List.558 List.443; +procedure List.86 (#Derived_gen.29, #Derived_gen.30, #Derived_gen.31, #Derived_gen.32, #Derived_gen.33): + joinpoint List.603 List.148 List.149 List.150 List.151 List.152: + let List.605 : Int1 = CallByName Num.22 List.151 List.152; + if List.605 then + let List.609 : [] = CallByName List.66 List.148 List.151; + let List.153 : {List U8, U64} = CallByName TotallyNotJson.267 List.149 List.609 List.150; + let List.608 : U64 = 1i64; + let List.607 : U64 = CallByName Num.51 List.151 List.608; + jump List.603 List.148 List.153 List.150 List.607 List.152; else - dec List.439; - ret List.440; + dec List.148; + ret List.149; in - jump List.553 #Derived_gen.38 #Derived_gen.39 #Derived_gen.40 #Derived_gen.41 #Derived_gen.42; - -procedure List.93 (List.436, List.437, List.438): - let List.551 : U64 = 0i64; - let List.552 : U64 = CallByName List.6 List.436; - let List.550 : {List U8, U64} = CallByName List.80 List.436 List.437 List.438 List.551 List.552; - ret List.550; - -procedure List.93 (List.436, List.437, List.438): - let List.599 : U64 = 0i64; - let List.600 : U64 = CallByName List.6 List.436; - let List.598 : {List U8, U64} = CallByName List.80 List.436 List.437 List.438 List.599 List.600; - ret List.598; + jump List.603 #Derived_gen.29 #Derived_gen.30 #Derived_gen.31 #Derived_gen.32 #Derived_gen.33; procedure Num.127 (#Attr.2): let Num.311 : U8 = lowlevel NumIntCast #Attr.2; ret Num.311; -procedure Num.19 (#Attr.2, #Attr.3): - let Num.314 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; - ret Num.314; - procedure Num.20 (#Attr.2, #Attr.3): let Num.312 : U64 = lowlevel NumSub #Attr.2 #Attr.3; ret Num.312; @@ -193,6 +173,10 @@ procedure Num.24 (#Attr.2, #Attr.3): let Num.313 : Int1 = lowlevel NumGt #Attr.2 #Attr.3; ret Num.313; +procedure Num.51 (#Attr.2, #Attr.3): + let Num.314 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; + ret Num.314; + procedure Str.12 (#Attr.2): let Str.290 : List U8 = lowlevel StrToUtf8 #Attr.2; ret Str.290; diff --git a/crates/compiler/test_mono/generated/weakening_avoids_overspecialization.txt b/crates/compiler/test_mono/generated/weakening_avoids_overspecialization.txt index 1396a444e3..213104322c 100644 --- a/crates/compiler/test_mono/generated/weakening_avoids_overspecialization.txt +++ b/crates/compiler/test_mono/generated/weakening_avoids_overspecialization.txt @@ -2,88 +2,88 @@ procedure Bool.11 (#Attr.2, #Attr.3): let Bool.24 : Int1 = lowlevel Eq #Attr.2 #Attr.3; ret Bool.24; -procedure List.26 (List.159, List.160, List.161): - let List.536 : [C U64, C U64] = CallByName List.93 List.159 List.160 List.161; - let List.539 : U8 = 1i64; - let List.540 : U8 = GetTagId List.536; - let List.541 : Int1 = lowlevel Eq List.539 List.540; - if List.541 then - let List.162 : U64 = UnionAtIndex (Id 1) (Index 0) List.536; - ret List.162; +procedure List.26 (List.172, List.173, List.174): + let List.549 : [C U64, C U64] = CallByName List.96 List.172 List.173 List.174; + let List.552 : U8 = 1i64; + let List.553 : U8 = GetTagId List.549; + let List.554 : Int1 = lowlevel Eq List.552 List.553; + if List.554 then + let List.175 : U64 = UnionAtIndex (Id 1) (Index 0) List.549; + ret List.175; else - let List.163 : U64 = UnionAtIndex (Id 0) (Index 0) List.536; - ret List.163; + let List.176 : U64 = UnionAtIndex (Id 0) (Index 0) List.549; + ret List.176; -procedure List.29 (List.304, List.305): - let List.535 : U64 = CallByName List.6 List.304; - let List.306 : U64 = CallByName Num.77 List.535 List.305; - let List.521 : List U8 = CallByName List.43 List.304 List.306; - ret List.521; - -procedure List.43 (List.302, List.303): - let List.533 : U64 = CallByName List.6 List.302; - let List.532 : U64 = CallByName Num.77 List.533 List.303; - let List.523 : {U64, U64} = Struct {List.303, List.532}; - let List.522 : List U8 = CallByName List.49 List.302 List.523; - ret List.522; - -procedure List.49 (List.376, List.377): - let List.530 : U64 = StructAtIndex 0 List.377; - let List.531 : U64 = 0i64; - let List.528 : Int1 = CallByName Bool.11 List.530 List.531; - if List.528 then - dec List.376; - let List.529 : List U8 = Array []; - ret List.529; - else - let List.525 : U64 = StructAtIndex 1 List.377; - let List.526 : U64 = StructAtIndex 0 List.377; - let List.524 : List U8 = CallByName List.72 List.376 List.525 List.526; - ret List.524; - -procedure List.6 (#Attr.2): - let List.534 : U64 = lowlevel ListLen #Attr.2; +procedure List.29 (List.317, List.318): + let List.548 : U64 = CallByName List.6 List.317; + let List.319 : U64 = CallByName Num.77 List.548 List.318; + let List.534 : List U8 = CallByName List.43 List.317 List.319; ret List.534; +procedure List.43 (List.315, List.316): + let List.546 : U64 = CallByName List.6 List.315; + let List.545 : U64 = CallByName Num.77 List.546 List.316; + let List.536 : {U64, U64} = Struct {List.316, List.545}; + let List.535 : List U8 = CallByName List.49 List.315 List.536; + ret List.535; + +procedure List.49 (List.389, List.390): + let List.543 : U64 = StructAtIndex 0 List.390; + let List.544 : U64 = 0i64; + let List.541 : Int1 = CallByName Bool.11 List.543 List.544; + if List.541 then + dec List.389; + let List.542 : List U8 = Array []; + ret List.542; + else + let List.538 : U64 = StructAtIndex 1 List.390; + let List.539 : U64 = StructAtIndex 0 List.390; + let List.537 : List U8 = CallByName List.72 List.389 List.538 List.539; + ret List.537; + +procedure List.6 (#Attr.2): + let List.547 : U64 = lowlevel ListLen #Attr.2; + ret List.547; + procedure List.66 (#Attr.2, #Attr.3): - let List.557 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.557; + let List.570 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.570; procedure List.72 (#Attr.2, #Attr.3, #Attr.4): - let List.527 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; - ret List.527; + let List.540 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; + ret List.540; procedure List.80 (#Derived_gen.0, #Derived_gen.1, #Derived_gen.2, #Derived_gen.3, #Derived_gen.4): - joinpoint List.545 List.439 List.440 List.441 List.442 List.443: - let List.547 : Int1 = CallByName Num.22 List.442 List.443; - if List.547 then - let List.556 : U8 = CallByName List.66 List.439 List.442; - let List.548 : [C U64, C U64] = CallByName Test.3 List.440 List.556; - let List.553 : U8 = 1i64; - let List.554 : U8 = GetTagId List.548; - let List.555 : Int1 = lowlevel Eq List.553 List.554; - if List.555 then - let List.444 : U64 = UnionAtIndex (Id 1) (Index 0) List.548; - let List.551 : U64 = 1i64; - let List.550 : U64 = CallByName Num.19 List.442 List.551; - jump List.545 List.439 List.444 List.441 List.550 List.443; + joinpoint List.558 List.452 List.453 List.454 List.455 List.456: + let List.560 : Int1 = CallByName Num.22 List.455 List.456; + if List.560 then + let List.569 : U8 = CallByName List.66 List.452 List.455; + let List.561 : [C U64, C U64] = CallByName Test.3 List.453 List.569; + let List.566 : U8 = 1i64; + let List.567 : U8 = GetTagId List.561; + let List.568 : Int1 = lowlevel Eq List.566 List.567; + if List.568 then + let List.457 : U64 = UnionAtIndex (Id 1) (Index 0) List.561; + let List.564 : U64 = 1i64; + let List.563 : U64 = CallByName Num.19 List.455 List.564; + jump List.558 List.452 List.457 List.454 List.563 List.456; else - dec List.439; - let List.445 : U64 = UnionAtIndex (Id 0) (Index 0) List.548; - let List.552 : [C U64, C U64] = TagId(0) List.445; - ret List.552; + dec List.452; + let List.458 : U64 = UnionAtIndex (Id 0) (Index 0) List.561; + let List.565 : [C U64, C U64] = TagId(0) List.458; + ret List.565; else - dec List.439; - let List.546 : [C U64, C U64] = TagId(1) List.440; - ret List.546; + dec List.452; + let List.559 : [C U64, C U64] = TagId(1) List.453; + ret List.559; in - jump List.545 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4; + jump List.558 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4; -procedure List.93 (List.436, List.437, List.438): - let List.543 : U64 = 0i64; - let List.544 : U64 = CallByName List.6 List.436; - let List.542 : [C U64, C U64] = CallByName List.80 List.436 List.437 List.438 List.543 List.544; - ret List.542; +procedure List.96 (List.449, List.450, List.451): + let List.556 : U64 = 0i64; + let List.557 : U64 = CallByName List.6 List.449; + let List.555 : [C U64, C U64] = CallByName List.80 List.449 List.450 List.451 List.556 List.557; + ret List.555; procedure Num.19 (#Attr.2, #Attr.3): let Num.294 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; From df21104457dc23c2fc4f297dc026f1f362d00eff Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Tue, 15 Aug 2023 02:38:16 -0400 Subject: [PATCH 123/176] Inline inc and dec This is for the dev backend's benefit --- crates/compiler/builtins/roc/List.roc | 38 +++++++++++---------------- crates/compiler/builtins/roc/Str.roc | 12 ++++----- 2 files changed, 21 insertions(+), 29 deletions(-) diff --git a/crates/compiler/builtins/roc/List.roc b/crates/compiler/builtins/roc/List.roc index b4e3031608..a99c42ec27 100644 --- a/crates/compiler/builtins/roc/List.roc +++ b/crates/compiler/builtins/roc/List.roc @@ -391,7 +391,7 @@ repeat = \value, count -> repeatHelp : a, Nat, List a -> List a repeatHelp = \value, count, accum -> if count > 0 then - repeatHelp value (dec count) (List.appendUnsafe accum value) + repeatHelp value (Num.subWrap count 1) (List.appendUnsafe accum value) else accum @@ -405,7 +405,7 @@ reverse = \list -> reverseHelp = \list, left, right -> if left < right then - reverseHelp (List.swap list left right) (inc left) (dec right) + reverseHelp (List.swap list left right) (Num.addWrap left 1) (Num.subWrap right 1) else list @@ -420,7 +420,7 @@ join = \lists -> totalLength = List.walk lists 0 (\state, list -> Num.addWrap state (List.len list)) - List.walk lists (List.withCapacity totalLength) (\state, list -> List.concat state list) + List.walk lists (List.withCapacity totalLength) \state, list -> List.concat state list contains : List a, a -> Bool where a implements Eq contains = \list, needle -> @@ -478,7 +478,7 @@ walkBackwardsHelp = \list, state, f, indexPlusOne -> if indexPlusOne == 0 then state else - index = dec indexPlusOne + index = Num.subWrap indexPlusOne 1 nextState = f state (getUnsafe list index) walkBackwardsHelp list nextState f index @@ -590,9 +590,9 @@ keepIfHelp : List a, (a -> Bool), Nat, Nat, Nat -> List a keepIfHelp = \list, predicate, kept, index, length -> if index < length then if predicate (List.getUnsafe list index) then - keepIfHelp (List.swap list kept index) predicate (inc kept) (inc index) length + keepIfHelp (List.swap list kept index) predicate (Num.addWrap kept 1) (Num.addWrap index 1) length else - keepIfHelp list predicate kept (inc index) length + keepIfHelp list predicate kept (Num.addWrap index 1) length else List.takeFirst list kept @@ -619,7 +619,7 @@ countIf : List a, (a -> Bool) -> Nat countIf = \list, predicate -> walkState = \state, elem -> if predicate elem then - inc state + Num.addWrap state 1 else state @@ -712,7 +712,7 @@ mapWithIndexHelp = \src, dest, func, index, length -> mappedElem = func elem index newDest = List.appendUnsafe dest mappedElem - mapWithIndexHelp src newDest func (inc index) length + mapWithIndexHelp src newDest func (Num.addWrap index 1) length else dest @@ -817,7 +817,7 @@ rangeLengthHelp = \accum, i, remaining, calcNext -> else when i is Ok val -> - rangeLengthHelp (List.appendUnsafe accum val) (calcNext val) (dec remaining) calcNext + rangeLengthHelp (List.appendUnsafe accum val) (calcNext val) (Num.subWrap remaining 1) calcNext Err _ -> # We went past the end of the numeric range and there is no next. @@ -1036,7 +1036,7 @@ findFirstIndex = \list, matcher -> if matcher elem then Break index else - Continue (inc index) + Continue (Num.addWrap index 1) when foundIndex is Break index -> Ok index @@ -1048,7 +1048,7 @@ findFirstIndex = \list, matcher -> findLastIndex : List elem, (elem -> Bool) -> Result Nat [NotFound] findLastIndex = \list, matches -> foundIndex = List.iterateBackwards list (List.len list) \prevIndex, elem -> - answer = dec prevIndex + answer = Num.subWrap prevIndex 1 if matches elem then Break answer @@ -1153,7 +1153,7 @@ splitFirst = \list, delimiter -> when List.findFirstIndex list (\elem -> elem == delimiter) is Ok index -> before = List.sublist list { start: 0, len: index } - after = List.sublist list { start: inc index, len: Num.subWrap (List.len list) index |> dec } + after = List.sublist list { start: Num.addWrap index 1, len: Num.subWrap (List.len list) index |> Num.subWrap 1 } Ok { before, after } @@ -1169,7 +1169,7 @@ splitLast = \list, delimiter -> when List.findLastIndex list (\elem -> elem == delimiter) is Ok index -> before = List.sublist list { start: 0, len: index } - after = List.sublist list { start: inc index, len: Num.subWrap (List.len list) index |> dec } + after = List.sublist list { start: Num.addWrap index 1, len: Num.subWrap (List.len list) index |> Num.subWrap 1 } Ok { before, after } @@ -1204,7 +1204,7 @@ walkTryHelp : List elem, state, (state, elem -> Result state err), Nat, Nat -> R walkTryHelp = \list, state, f, index, length -> if index < length then when f state (List.getUnsafe list index) is - Ok nextState -> walkTryHelp list nextState f (inc index) length + Ok nextState -> walkTryHelp list nextState f (Num.addWrap index 1) length Err b -> Err b else Ok state @@ -1219,7 +1219,7 @@ iterHelp : List elem, s, (s, elem -> [Continue s, Break b]), Nat, Nat -> [Contin iterHelp = \list, state, f, index, length -> if index < length then when f state (List.getUnsafe list index) is - Continue nextState -> iterHelp list nextState f (inc index) length + Continue nextState -> iterHelp list nextState f (Num.addWrap index 1) length Break b -> Break b else Continue state @@ -1234,16 +1234,10 @@ iterateBackwards = \list, init, func -> iterBackwardsHelp : List elem, s, (s, elem -> [Continue s, Break b]), Nat -> [Continue s, Break b] iterBackwardsHelp = \list, state, f, prevIndex -> if prevIndex > 0 then - index = dec prevIndex + index = Num.subWrap prevIndex 1 when f state (List.getUnsafe list index) is Continue nextState -> iterBackwardsHelp list nextState f index Break b -> Break b else Continue state - -inc : Int a -> Int a -inc = \num -> Num.addWrap num 1 - -dec : Int a -> Int a -dec = \num -> Num.subWrap num 1 diff --git a/crates/compiler/builtins/roc/Str.roc b/crates/compiler/builtins/roc/Str.roc index dfe600a523..f2a0da3f34 100644 --- a/crates/compiler/builtins/roc/Str.roc +++ b/crates/compiler/builtins/roc/Str.roc @@ -757,7 +757,7 @@ firstMatchHelp = \haystack, needle, index, lastPossible -> if matchesAt haystack index needle then Some index else - firstMatchHelp haystack needle (inc index) lastPossible + firstMatchHelp haystack needle (Num.addWrap index 1) lastPossible else None @@ -847,8 +847,8 @@ matchesAtHelp = \state -> doesRestMatch = matchesAtHelp { state & - haystackIndex: inc haystackIndex, - needleIndex: inc needleIndex, + haystackIndex: Num.addWrap haystackIndex 1, + needleIndex: Num.addWrap needleIndex 1, } doesThisMatch && doesRestMatch @@ -871,7 +871,7 @@ walkUtf8WithIndexHelp = \string, state, step, index, length -> byte = Str.getUnsafe string index newState = step state byte index - walkUtf8WithIndexHelp string newState step (inc index) length + walkUtf8WithIndexHelp string newState step (Num.addWrap index 1) length else state @@ -892,7 +892,7 @@ walkUtf8Help = \str, state, step, index, length -> byte = Str.getUnsafe str index newState = step state byte - walkUtf8Help str newState step (inc index) length + walkUtf8Help str newState step (Num.addWrap index 1) length else state @@ -995,5 +995,3 @@ strToNumHelp = \string -> ## ``` withPrefix : Str, Str -> Str withPrefix = \str, prefix -> Str.concat prefix str - -inc = \num -> Num.addWrap num 1 From 7768264868612a09e967d4d5eb102d0914a035b2 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Tue, 15 Aug 2023 02:39:50 -0400 Subject: [PATCH 124/176] Update mono tests again --- ...e_in_polymorphic_expression_issue_4717.txt | 134 +++-- .../generated/call_function_in_empty_list.txt | 4 +- .../call_function_in_empty_list_unbound.txt | 4 +- .../generated/capture_void_layout_task.txt | 56 +-- ...ose_correct_recursion_var_under_record.txt | 66 +-- .../test_mono/generated/closure_in_list.txt | 4 +- ...lambda_set_productive_nullable_wrapped.txt | 60 ++- crates/compiler/test_mono/generated/dict.txt | 93 ++-- .../generated/empty_list_of_function_type.txt | 32 +- .../compiler/test_mono/generated/encode.txt | 18 +- .../encode_derived_nested_record_string.txt | 469 +++++++++--------- ...encode_derived_record_one_field_string.txt | 440 ++++++++-------- ...ncode_derived_record_two_field_strings.txt | 440 ++++++++-------- .../generated/encode_derived_string.txt | 267 +++++----- .../encode_derived_tag_one_field_string.txt | 338 +++++++------ ...encode_derived_tag_two_payloads_string.txt | 336 +++++++------ .../test_mono/generated/ir_int_add.txt | 4 +- ...cialize_errors_behind_unified_branches.txt | 94 ++-- .../test_mono/generated/issue_4749.txt | 256 +++++----- .../test_mono/generated/issue_4770.txt | 114 ++--- ..._4772_weakened_monomorphic_destructure.txt | 296 ++++++----- ...ure_with_multiple_recursive_structures.txt | 58 +-- .../test_mono/generated/list_append.txt | 18 +- .../generated/list_append_closure.txt | 18 +- .../generated/list_cannot_update_inplace.txt | 32 +- .../compiler/test_mono/generated/list_get.txt | 32 +- .../compiler/test_mono/generated/list_len.txt | 8 +- .../generated/list_map_closure_borrows.txt | 46 +- .../generated/list_map_closure_owns.txt | 42 +- ...ist_map_take_capturing_or_noncapturing.txt | 20 +- .../generated/list_pass_to_function.txt | 32 +- .../test_mono/generated/list_sort_asc.txt | 12 +- .../polymorphic_expression_unification.txt | 4 +- .../test_mono/generated/quicksort_swap.txt | 60 +-- .../test_mono/generated/record_update.txt | 32 +- ...function_and_union_with_inference_hole.txt | 4 +- .../generated/recursively_build_effect.txt | 4 +- .../compiler/test_mono/generated/rigids.txt | 60 +-- ...not_duplicate_identical_concrete_types.txt | 304 ++++++------ ...types_without_unification_of_unifiable.txt | 135 +++-- .../weakening_avoids_overspecialization.txt | 134 +++-- 41 files changed, 2264 insertions(+), 2316 deletions(-) diff --git a/crates/compiler/test_mono/generated/anonymous_closure_in_polymorphic_expression_issue_4717.txt b/crates/compiler/test_mono/generated/anonymous_closure_in_polymorphic_expression_issue_4717.txt index 660969c3dd..36ef1bba00 100644 --- a/crates/compiler/test_mono/generated/anonymous_closure_in_polymorphic_expression_issue_4717.txt +++ b/crates/compiler/test_mono/generated/anonymous_closure_in_polymorphic_expression_issue_4717.txt @@ -2,92 +2,88 @@ procedure Bool.11 (#Attr.2, #Attr.3): let Bool.24 : Int1 = lowlevel Eq #Attr.2 #Attr.3; ret Bool.24; -procedure List.26 (List.161, List.162, List.163): - let List.541 : [C U64, C U64] = CallByName List.93 List.161 List.162 List.163; - let List.544 : U8 = 1i64; - let List.545 : U8 = GetTagId List.541; - let List.546 : Int1 = lowlevel Eq List.544 List.545; - if List.546 then - let List.164 : U64 = UnionAtIndex (Id 1) (Index 0) List.541; - ret List.164; +procedure List.26 (List.159, List.160, List.161): + let List.537 : [C U64, C U64] = CallByName List.93 List.159 List.160 List.161; + let List.540 : U8 = 1i64; + let List.541 : U8 = GetTagId List.537; + let List.542 : Int1 = lowlevel Eq List.540 List.541; + if List.542 then + let List.162 : U64 = UnionAtIndex (Id 1) (Index 0) List.537; + ret List.162; else - let List.165 : U64 = UnionAtIndex (Id 0) (Index 0) List.541; - ret List.165; + let List.163 : U64 = UnionAtIndex (Id 0) (Index 0) List.537; + ret List.163; -procedure List.29 (List.306, List.307): - let List.540 : U64 = CallByName List.6 List.306; - let List.308 : U64 = CallByName Num.77 List.540 List.307; - let List.526 : List U8 = CallByName List.43 List.306 List.308; - ret List.526; +procedure List.29 (List.304, List.305): + let List.536 : U64 = CallByName List.6 List.304; + let List.306 : U64 = CallByName Num.77 List.536 List.305; + let List.522 : List U8 = CallByName List.43 List.304 List.306; + ret List.522; -procedure List.43 (List.304, List.305): - let List.538 : U64 = CallByName List.6 List.304; - let List.537 : U64 = CallByName Num.77 List.538 List.305; - let List.528 : {U64, U64} = Struct {List.305, List.537}; - let List.527 : List U8 = CallByName List.49 List.304 List.528; - ret List.527; +procedure List.43 (List.302, List.303): + let List.534 : U64 = CallByName List.6 List.302; + let List.533 : U64 = CallByName Num.77 List.534 List.303; + let List.524 : {U64, U64} = Struct {List.303, List.533}; + let List.523 : List U8 = CallByName List.49 List.302 List.524; + ret List.523; -procedure List.49 (List.379, List.380): - let List.535 : U64 = StructAtIndex 0 List.380; - let List.536 : U64 = 0i64; - let List.533 : Int1 = CallByName Bool.11 List.535 List.536; - if List.533 then - dec List.379; - let List.534 : List U8 = Array []; - ret List.534; +procedure List.49 (List.377, List.378): + let List.531 : U64 = StructAtIndex 0 List.378; + let List.532 : U64 = 0i64; + let List.529 : Int1 = CallByName Bool.11 List.531 List.532; + if List.529 then + dec List.377; + let List.530 : List U8 = Array []; + ret List.530; else - let List.530 : U64 = StructAtIndex 1 List.380; - let List.531 : U64 = StructAtIndex 0 List.380; - let List.529 : List U8 = CallByName List.72 List.379 List.530 List.531; - ret List.529; + let List.526 : U64 = StructAtIndex 1 List.378; + let List.527 : U64 = StructAtIndex 0 List.378; + let List.525 : List U8 = CallByName List.72 List.377 List.526 List.527; + ret List.525; procedure List.6 (#Attr.2): - let List.539 : U64 = lowlevel ListLen #Attr.2; - ret List.539; + let List.535 : U64 = lowlevel ListLen #Attr.2; + ret List.535; procedure List.66 (#Attr.2, #Attr.3): - let List.563 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.563; + let List.558 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.558; procedure List.72 (#Attr.2, #Attr.3, #Attr.4): - let List.532 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; - ret List.532; + let List.528 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; + ret List.528; procedure List.80 (#Derived_gen.0, #Derived_gen.1, #Derived_gen.2, #Derived_gen.3, #Derived_gen.4): - joinpoint List.550 List.442 List.443 List.444 List.445 List.446: - let List.552 : Int1 = CallByName Num.22 List.445 List.446; - if List.552 then - let List.562 : U8 = CallByName List.66 List.442 List.445; - let List.553 : [C U64, C U64] = CallByName Test.4 List.443 List.562; - let List.559 : U8 = 1i64; - let List.560 : U8 = GetTagId List.553; - let List.561 : Int1 = lowlevel Eq List.559 List.560; - if List.561 then - let List.447 : U64 = UnionAtIndex (Id 1) (Index 0) List.553; - let List.555 : U64 = CallByName List.96 List.445; - jump List.550 List.442 List.447 List.444 List.555 List.446; + joinpoint List.546 List.440 List.441 List.442 List.443 List.444: + let List.548 : Int1 = CallByName Num.22 List.443 List.444; + if List.548 then + let List.557 : U8 = CallByName List.66 List.440 List.443; + let List.549 : [C U64, C U64] = CallByName Test.4 List.441 List.557; + let List.554 : U8 = 1i64; + let List.555 : U8 = GetTagId List.549; + let List.556 : Int1 = lowlevel Eq List.554 List.555; + if List.556 then + let List.445 : U64 = UnionAtIndex (Id 1) (Index 0) List.549; + let List.552 : U64 = 1i64; + let List.551 : U64 = CallByName Num.51 List.443 List.552; + jump List.546 List.440 List.445 List.442 List.551 List.444; else - dec List.442; - let List.448 : U64 = UnionAtIndex (Id 0) (Index 0) List.553; - let List.558 : [C U64, C U64] = TagId(0) List.448; - ret List.558; + dec List.440; + let List.446 : U64 = UnionAtIndex (Id 0) (Index 0) List.549; + let List.553 : [C U64, C U64] = TagId(0) List.446; + ret List.553; else - dec List.442; - let List.551 : [C U64, C U64] = TagId(1) List.443; - ret List.551; + dec List.440; + let List.547 : [C U64, C U64] = TagId(1) List.441; + ret List.547; in - jump List.550 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4; + jump List.546 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4; -procedure List.93 (List.439, List.440, List.441): - let List.548 : U64 = 0i64; - let List.549 : U64 = CallByName List.6 List.439; - let List.547 : [C U64, C U64] = CallByName List.80 List.439 List.440 List.441 List.548 List.549; - ret List.547; - -procedure List.96 (List.463): - let List.557 : U64 = 1i64; - let List.556 : U64 = CallByName Num.51 List.463 List.557; - ret List.556; +procedure List.93 (List.437, List.438, List.439): + let List.544 : U64 = 0i64; + let List.545 : U64 = CallByName List.6 List.437; + let List.543 : [C U64, C U64] = CallByName List.80 List.437 List.438 List.439 List.544 List.545; + ret List.543; procedure Num.22 (#Attr.2, #Attr.3): let Num.295 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/call_function_in_empty_list.txt b/crates/compiler/test_mono/generated/call_function_in_empty_list.txt index ccc0b31927..3225490553 100644 --- a/crates/compiler/test_mono/generated/call_function_in_empty_list.txt +++ b/crates/compiler/test_mono/generated/call_function_in_empty_list.txt @@ -1,7 +1,7 @@ procedure List.5 (#Attr.2, #Attr.3): - let List.526 : List {} = lowlevel ListMap { xs: `#Attr.#arg1` } #Attr.2 Test.2 #Attr.3; + let List.522 : List {} = lowlevel ListMap { xs: `#Attr.#arg1` } #Attr.2 Test.2 #Attr.3; decref #Attr.2; - ret List.526; + ret List.522; procedure Test.2 (Test.3): let Test.7 : {} = Struct {}; diff --git a/crates/compiler/test_mono/generated/call_function_in_empty_list_unbound.txt b/crates/compiler/test_mono/generated/call_function_in_empty_list_unbound.txt index 9333feee95..55e6993cd5 100644 --- a/crates/compiler/test_mono/generated/call_function_in_empty_list_unbound.txt +++ b/crates/compiler/test_mono/generated/call_function_in_empty_list_unbound.txt @@ -1,7 +1,7 @@ procedure List.5 (#Attr.2, #Attr.3): - let List.526 : List [] = lowlevel ListMap { xs: `#Attr.#arg1` } #Attr.2 Test.2 #Attr.3; + let List.522 : List [] = lowlevel ListMap { xs: `#Attr.#arg1` } #Attr.2 Test.2 #Attr.3; decref #Attr.2; - ret List.526; + ret List.522; procedure Test.2 (Test.3): let Test.7 : {} = Struct {}; diff --git a/crates/compiler/test_mono/generated/capture_void_layout_task.txt b/crates/compiler/test_mono/generated/capture_void_layout_task.txt index 824018fe4f..3d8605ff8a 100644 --- a/crates/compiler/test_mono/generated/capture_void_layout_task.txt +++ b/crates/compiler/test_mono/generated/capture_void_layout_task.txt @@ -1,43 +1,39 @@ -procedure List.147 (List.148, List.149, List.146): - let List.546 : [C {}, C *self {{}, []}] = CallByName Test.29 List.148 List.149 List.146; - ret List.546; +procedure List.145 (List.146, List.147, List.144): + let List.541 : [C {}, C *self {{}, []}] = CallByName Test.29 List.146 List.147 List.144; + ret List.541; -procedure List.18 (List.144, List.145, List.146): - let List.526 : [C {}, C *self {{}, []}] = CallByName List.93 List.144 List.145 List.146; - ret List.526; +procedure List.18 (List.142, List.143, List.144): + let List.522 : [C {}, C *self {{}, []}] = CallByName List.93 List.142 List.143 List.144; + ret List.522; procedure List.6 (#Attr.2): - let List.544 : U64 = lowlevel ListLen #Attr.2; - ret List.544; + let List.539 : U64 = lowlevel ListLen #Attr.2; + ret List.539; procedure List.66 (#Attr.2, #Attr.3): - let List.543 : [] = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.543; + let List.538 : [] = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.538; procedure List.80 (#Derived_gen.13, #Derived_gen.14, #Derived_gen.15, #Derived_gen.16, #Derived_gen.17): - joinpoint List.532 List.442 List.443 List.444 List.445 List.446: - let List.534 : Int1 = CallByName Num.22 List.445 List.446; - if List.534 then - let List.542 : [] = CallByName List.66 List.442 List.445; - let List.535 : [C {}, C *self {{}, []}] = CallByName List.147 List.443 List.542 List.444; - let List.537 : U64 = CallByName List.96 List.445; - jump List.532 List.442 List.535 List.444 List.537 List.446; + joinpoint List.528 List.440 List.441 List.442 List.443 List.444: + let List.530 : Int1 = CallByName Num.22 List.443 List.444; + if List.530 then + let List.537 : [] = CallByName List.66 List.440 List.443; + let List.531 : [C {}, C *self {{}, []}] = CallByName List.145 List.441 List.537 List.442; + let List.534 : U64 = 1i64; + let List.533 : U64 = CallByName Num.51 List.443 List.534; + jump List.528 List.440 List.531 List.442 List.533 List.444; else - dec List.442; - ret List.443; + dec List.440; + ret List.441; in - jump List.532 #Derived_gen.13 #Derived_gen.14 #Derived_gen.15 #Derived_gen.16 #Derived_gen.17; + jump List.528 #Derived_gen.13 #Derived_gen.14 #Derived_gen.15 #Derived_gen.16 #Derived_gen.17; -procedure List.93 (List.439, List.440, List.441): - let List.530 : U64 = 0i64; - let List.531 : U64 = CallByName List.6 List.439; - let List.529 : [C {}, C *self {{}, []}] = CallByName List.80 List.439 List.440 List.441 List.530 List.531; - ret List.529; - -procedure List.96 (List.463): - let List.539 : U64 = 1i64; - let List.538 : U64 = CallByName Num.51 List.463 List.539; - ret List.538; +procedure List.93 (List.437, List.438, List.439): + let List.526 : U64 = 0i64; + let List.527 : U64 = CallByName List.6 List.437; + let List.525 : [C {}, C *self {{}, []}] = CallByName List.80 List.437 List.438 List.439 List.526 List.527; + ret List.525; procedure Num.22 (#Attr.2, #Attr.3): let Num.293 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/choose_correct_recursion_var_under_record.txt b/crates/compiler/test_mono/generated/choose_correct_recursion_var_under_record.txt index f2172509f2..75b8e68c19 100644 --- a/crates/compiler/test_mono/generated/choose_correct_recursion_var_under_record.txt +++ b/crates/compiler/test_mono/generated/choose_correct_recursion_var_under_record.txt @@ -2,49 +2,49 @@ procedure Bool.1 (): let Bool.24 : Int1 = false; ret Bool.24; -procedure List.2 (List.99, List.100): - let List.540 : U64 = CallByName List.6 List.99; - let List.536 : Int1 = CallByName Num.22 List.100 List.540; - if List.536 then - let List.538 : Str = CallByName List.66 List.99 List.100; - inc List.538; - dec List.99; - let List.537 : [C {}, C Str] = TagId(1) List.538; - ret List.537; +procedure List.2 (List.97, List.98): + let List.536 : U64 = CallByName List.6 List.97; + let List.532 : Int1 = CallByName Num.22 List.98 List.536; + if List.532 then + let List.534 : Str = CallByName List.66 List.97 List.98; + inc List.534; + dec List.97; + let List.533 : [C {}, C Str] = TagId(1) List.534; + ret List.533; else - dec List.99; - let List.535 : {} = Struct {}; - let List.534 : [C {}, C Str] = TagId(0) List.535; - ret List.534; + dec List.97; + let List.531 : {} = Struct {}; + let List.530 : [C {}, C Str] = TagId(0) List.531; + ret List.530; procedure List.5 (#Attr.2, #Attr.3): - let List.542 : List Str = lowlevel ListMap { xs: `#Attr.#arg1` } #Attr.2 Test.10 #Attr.3; + let List.538 : List Str = lowlevel ListMap { xs: `#Attr.#arg1` } #Attr.2 Test.10 #Attr.3; decref #Attr.2; - ret List.542; + ret List.538; procedure List.6 (#Attr.2): - let List.541 : U64 = lowlevel ListLen #Attr.2; - ret List.541; + let List.537 : U64 = lowlevel ListLen #Attr.2; + ret List.537; procedure List.66 (#Attr.2, #Attr.3): - let List.539 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.539; + let List.535 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.535; -procedure List.9 (List.295): - let List.533 : U64 = 0i64; - let List.526 : [C {}, C Str] = CallByName List.2 List.295 List.533; - let List.530 : U8 = 1i64; - let List.531 : U8 = GetTagId List.526; - let List.532 : Int1 = lowlevel Eq List.530 List.531; - if List.532 then - let List.296 : Str = UnionAtIndex (Id 1) (Index 0) List.526; - let List.527 : [C {}, C Str] = TagId(1) List.296; - ret List.527; +procedure List.9 (List.293): + let List.529 : U64 = 0i64; + let List.522 : [C {}, C Str] = CallByName List.2 List.293 List.529; + let List.526 : U8 = 1i64; + let List.527 : U8 = GetTagId List.522; + let List.528 : Int1 = lowlevel Eq List.526 List.527; + if List.528 then + let List.294 : Str = UnionAtIndex (Id 1) (Index 0) List.522; + let List.523 : [C {}, C Str] = TagId(1) List.294; + ret List.523; else - dec List.526; - let List.529 : {} = Struct {}; - let List.528 : [C {}, C Str] = TagId(0) List.529; - ret List.528; + dec List.522; + let List.525 : {} = Struct {}; + let List.524 : [C {}, C Str] = TagId(0) List.525; + ret List.524; procedure Num.22 (#Attr.2, #Attr.3): let Num.292 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/closure_in_list.txt b/crates/compiler/test_mono/generated/closure_in_list.txt index be6512aa8e..339aa13435 100644 --- a/crates/compiler/test_mono/generated/closure_in_list.txt +++ b/crates/compiler/test_mono/generated/closure_in_list.txt @@ -1,6 +1,6 @@ procedure List.6 (#Attr.2): - let List.526 : U64 = lowlevel ListLen #Attr.2; - ret List.526; + let List.522 : U64 = lowlevel ListLen #Attr.2; + ret List.522; procedure Test.1 (Test.5): let Test.2 : I64 = 41i64; diff --git a/crates/compiler/test_mono/generated/compose_recursive_lambda_set_productive_nullable_wrapped.txt b/crates/compiler/test_mono/generated/compose_recursive_lambda_set_productive_nullable_wrapped.txt index e900422447..4362ba3a8a 100644 --- a/crates/compiler/test_mono/generated/compose_recursive_lambda_set_productive_nullable_wrapped.txt +++ b/crates/compiler/test_mono/generated/compose_recursive_lambda_set_productive_nullable_wrapped.txt @@ -2,46 +2,42 @@ procedure Bool.2 (): let Bool.23 : Int1 = true; ret Bool.23; -procedure List.147 (List.148, List.149, List.146): - let List.546 : [, C *self Int1, C *self Int1] = CallByName Test.6 List.148 List.149 List.146; - ret List.546; +procedure List.145 (List.146, List.147, List.144): + let List.541 : [, C *self Int1, C *self Int1] = CallByName Test.6 List.146 List.147 List.144; + ret List.541; -procedure List.18 (List.144, List.145, List.146): - let List.526 : [, C *self Int1, C *self Int1] = CallByName List.93 List.144 List.145 List.146; - ret List.526; +procedure List.18 (List.142, List.143, List.144): + let List.522 : [, C *self Int1, C *self Int1] = CallByName List.93 List.142 List.143 List.144; + ret List.522; procedure List.6 (#Attr.2): - let List.544 : U64 = lowlevel ListLen #Attr.2; - ret List.544; + let List.539 : U64 = lowlevel ListLen #Attr.2; + ret List.539; procedure List.66 (#Attr.2, #Attr.3): - let List.543 : Int1 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.543; + let List.538 : Int1 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.538; procedure List.80 (#Derived_gen.3, #Derived_gen.4, #Derived_gen.5, #Derived_gen.6, #Derived_gen.7): - joinpoint List.532 List.442 List.443 List.444 List.445 List.446: - let List.534 : Int1 = CallByName Num.22 List.445 List.446; - if List.534 then - let List.542 : Int1 = CallByName List.66 List.442 List.445; - let List.535 : [, C *self Int1, C *self Int1] = CallByName List.147 List.443 List.542 List.444; - let List.537 : U64 = CallByName List.96 List.445; - jump List.532 List.442 List.535 List.444 List.537 List.446; + joinpoint List.528 List.440 List.441 List.442 List.443 List.444: + let List.530 : Int1 = CallByName Num.22 List.443 List.444; + if List.530 then + let List.537 : Int1 = CallByName List.66 List.440 List.443; + let List.531 : [, C *self Int1, C *self Int1] = CallByName List.145 List.441 List.537 List.442; + let List.534 : U64 = 1i64; + let List.533 : U64 = CallByName Num.51 List.443 List.534; + jump List.528 List.440 List.531 List.442 List.533 List.444; else - dec List.442; - ret List.443; + dec List.440; + ret List.441; in - jump List.532 #Derived_gen.3 #Derived_gen.4 #Derived_gen.5 #Derived_gen.6 #Derived_gen.7; + jump List.528 #Derived_gen.3 #Derived_gen.4 #Derived_gen.5 #Derived_gen.6 #Derived_gen.7; -procedure List.93 (List.439, List.440, List.441): - let List.530 : U64 = 0i64; - let List.531 : U64 = CallByName List.6 List.439; - let List.529 : [, C *self Int1, C *self Int1] = CallByName List.80 List.439 List.440 List.441 List.530 List.531; - ret List.529; - -procedure List.96 (List.463): - let List.539 : U64 = 1i64; - let List.538 : U64 = CallByName Num.51 List.463 List.539; - ret List.538; +procedure List.93 (List.437, List.438, List.439): + let List.526 : U64 = 0i64; + let List.527 : U64 = CallByName List.6 List.437; + let List.525 : [, C *self Int1, C *self Int1] = CallByName List.80 List.437 List.438 List.439 List.526 List.527; + ret List.525; procedure Num.22 (#Attr.2, #Attr.3): let Num.293 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; @@ -52,8 +48,8 @@ procedure Num.51 (#Attr.2, #Attr.3): ret Num.292; procedure Str.3 (#Attr.2, #Attr.3): - let Str.293 : Str = lowlevel StrConcat #Attr.2 #Attr.3; - ret Str.293; + let Str.291 : Str = lowlevel StrConcat #Attr.2 #Attr.3; + ret Str.291; procedure Test.1 (Test.5): ret Test.5; diff --git a/crates/compiler/test_mono/generated/dict.txt b/crates/compiler/test_mono/generated/dict.txt index 2a0278ef10..0382e0709c 100644 --- a/crates/compiler/test_mono/generated/dict.txt +++ b/crates/compiler/test_mono/generated/dict.txt @@ -24,70 +24,67 @@ procedure Dict.4 (Dict.562): dec #Derived_gen.6; ret Dict.100; -procedure List.11 (List.123, List.124): - let List.527 : List I8 = CallByName List.68 List.124; - let List.526 : List I8 = CallByName List.83 List.123 List.124 List.527; - ret List.526; +procedure List.11 (List.121, List.122): + let List.523 : List I8 = CallByName List.68 List.122; + let List.522 : List I8 = CallByName List.83 List.121 List.122 List.523; + ret List.522; -procedure List.11 (List.123, List.124): - let List.540 : List U64 = CallByName List.68 List.124; - let List.539 : List U64 = CallByName List.83 List.123 List.124 List.540; - ret List.539; - -procedure List.68 (#Attr.2): - let List.538 : List I8 = lowlevel ListWithCapacity #Attr.2; - ret List.538; - -procedure List.68 (#Attr.2): - let List.549 : List U64 = lowlevel ListWithCapacity #Attr.2; - ret List.549; - -procedure List.71 (#Attr.2, #Attr.3): - let List.534 : List I8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; +procedure List.11 (List.121, List.122): + let List.535 : List U64 = CallByName List.68 List.122; + let List.534 : List U64 = CallByName List.83 List.121 List.122 List.535; ret List.534; +procedure List.68 (#Attr.2): + let List.533 : List I8 = lowlevel ListWithCapacity #Attr.2; + ret List.533; + +procedure List.68 (#Attr.2): + let List.545 : List U64 = lowlevel ListWithCapacity #Attr.2; + ret List.545; + procedure List.71 (#Attr.2, #Attr.3): - let List.547 : List U64 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.547; + let List.530 : List I8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.530; + +procedure List.71 (#Attr.2, #Attr.3): + let List.542 : List U64 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.542; procedure List.83 (#Derived_gen.0, #Derived_gen.1, #Derived_gen.2): - joinpoint List.528 List.125 List.126 List.127: - let List.537 : U64 = 0i64; - let List.530 : Int1 = CallByName Num.24 List.126 List.537; - if List.530 then - let List.532 : U64 = CallByName List.97 List.126; - let List.533 : List I8 = CallByName List.71 List.127 List.125; - jump List.528 List.125 List.532 List.533; + joinpoint List.524 List.123 List.124 List.125: + let List.532 : U64 = 0i64; + let List.526 : Int1 = CallByName Num.24 List.124 List.532; + if List.526 then + let List.531 : U64 = 1i64; + let List.528 : U64 = CallByName Num.75 List.124 List.531; + let List.529 : List I8 = CallByName List.71 List.125 List.123; + jump List.524 List.123 List.528 List.529; else - ret List.127; + ret List.125; in - jump List.528 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2; + jump List.524 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2; procedure List.83 (#Derived_gen.3, #Derived_gen.4, #Derived_gen.5): - joinpoint List.541 List.125 List.126 List.127: - let List.548 : U64 = 0i64; - let List.543 : Int1 = CallByName Num.24 List.126 List.548; - if List.543 then - let List.545 : U64 = CallByName List.97 List.126; - let List.546 : List U64 = CallByName List.71 List.127 List.125; - jump List.541 List.125 List.545 List.546; + joinpoint List.536 List.123 List.124 List.125: + let List.544 : U64 = 0i64; + let List.538 : Int1 = CallByName Num.24 List.124 List.544; + if List.538 then + let List.543 : U64 = 1i64; + let List.540 : U64 = CallByName Num.75 List.124 List.543; + let List.541 : List U64 = CallByName List.71 List.125 List.123; + jump List.536 List.123 List.540 List.541; else - ret List.127; + ret List.125; in - jump List.541 #Derived_gen.3 #Derived_gen.4 #Derived_gen.5; - -procedure List.97 (List.464): - let List.536 : U64 = 1i64; - let List.535 : U64 = CallByName Num.75 List.464 List.536; - ret List.535; + jump List.536 #Derived_gen.3 #Derived_gen.4 #Derived_gen.5; procedure Num.24 (#Attr.2, #Attr.3): - let Num.294 : Int1 = lowlevel NumGt #Attr.2 #Attr.3; - ret Num.294; + let Num.295 : Int1 = lowlevel NumGt #Attr.2 #Attr.3; + ret Num.295; procedure Num.75 (#Attr.2, #Attr.3): - let Num.292 : U64 = lowlevel NumSubWrap #Attr.2 #Attr.3; - ret Num.292; + let Num.293 : U64 = lowlevel NumSubWrap #Attr.2 #Attr.3; + ret Num.293; procedure Test.0 (): let Test.3 : {} = Struct {}; diff --git a/crates/compiler/test_mono/generated/empty_list_of_function_type.txt b/crates/compiler/test_mono/generated/empty_list_of_function_type.txt index 5ad7a34fc4..b41e1ea706 100644 --- a/crates/compiler/test_mono/generated/empty_list_of_function_type.txt +++ b/crates/compiler/test_mono/generated/empty_list_of_function_type.txt @@ -2,27 +2,27 @@ procedure Bool.1 (): let Bool.23 : Int1 = false; ret Bool.23; -procedure List.2 (List.99, List.100): - let List.532 : U64 = CallByName List.6 List.99; - let List.528 : Int1 = CallByName Num.22 List.100 List.532; - if List.528 then - let List.530 : {} = CallByName List.66 List.99 List.100; - dec List.99; - let List.529 : [C {}, C {}] = TagId(1) List.530; - ret List.529; +procedure List.2 (List.97, List.98): + let List.528 : U64 = CallByName List.6 List.97; + let List.524 : Int1 = CallByName Num.22 List.98 List.528; + if List.524 then + let List.526 : {} = CallByName List.66 List.97 List.98; + dec List.97; + let List.525 : [C {}, C {}] = TagId(1) List.526; + ret List.525; else - dec List.99; - let List.527 : {} = Struct {}; - let List.526 : [C {}, C {}] = TagId(0) List.527; - ret List.526; + dec List.97; + let List.523 : {} = Struct {}; + let List.522 : [C {}, C {}] = TagId(0) List.523; + ret List.522; procedure List.6 (#Attr.2): - let List.533 : U64 = lowlevel ListLen #Attr.2; - ret List.533; + let List.529 : U64 = lowlevel ListLen #Attr.2; + ret List.529; procedure List.66 (#Attr.2, #Attr.3): - let List.531 : {} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.531; + let List.527 : {} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.527; procedure Num.22 (#Attr.2, #Attr.3): let Num.292 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/encode.txt b/crates/compiler/test_mono/generated/encode.txt index e9a8057897..e743aecba5 100644 --- a/crates/compiler/test_mono/generated/encode.txt +++ b/crates/compiler/test_mono/generated/encode.txt @@ -1,16 +1,16 @@ -procedure List.4 (List.115, List.116): - let List.529 : U64 = 1i64; - let List.527 : List U8 = CallByName List.70 List.115 List.529; - let List.526 : List U8 = CallByName List.71 List.527 List.116; - ret List.526; +procedure List.4 (List.113, List.114): + let List.525 : U64 = 1i64; + let List.523 : List U8 = CallByName List.70 List.113 List.525; + let List.522 : List U8 = CallByName List.71 List.523 List.114; + ret List.522; procedure List.70 (#Attr.2, #Attr.3): - let List.530 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.530; + let List.526 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.526; procedure List.71 (#Attr.2, #Attr.3): - let List.528 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.528; + let List.524 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.524; procedure Test.23 (Test.24, Test.35, Test.22): let Test.37 : List U8 = CallByName List.4 Test.24 Test.22; diff --git a/crates/compiler/test_mono/generated/encode_derived_nested_record_string.txt b/crates/compiler/test_mono/generated/encode_derived_nested_record_string.txt index b5e95a69b3..5ae3e46cae 100644 --- a/crates/compiler/test_mono/generated/encode_derived_nested_record_string.txt +++ b/crates/compiler/test_mono/generated/encode_derived_nested_record_string.txt @@ -78,260 +78,259 @@ procedure Encode.26 (Encode.105, Encode.106): ret Encode.108; procedure List.13 (#Attr.2, #Attr.3): - let List.695 : List Str = lowlevel ListPrepend #Attr.2 #Attr.3; - ret List.695; + let List.690 : List Str = lowlevel ListPrepend #Attr.2 #Attr.3; + ret List.690; -procedure List.147 (List.148, List.149, List.146): - let List.575 : {List U8, U64} = CallByName TotallyNotJson.237 List.148 List.149 List.146; - ret List.575; +procedure List.145 (List.146, List.147, List.144): + let List.570 : {List U8, U64} = CallByName TotallyNotJson.237 List.146 List.147 List.144; + ret List.570; -procedure List.147 (List.148, List.149, List.146): - let List.644 : {List U8, U64} = CallByName TotallyNotJson.237 List.148 List.149 List.146; - ret List.644; +procedure List.145 (List.146, List.147, List.144): + let List.638 : {List U8, U64} = CallByName TotallyNotJson.237 List.146 List.147 List.144; + ret List.638; -procedure List.147 (List.148, List.149, List.146): - let List.663 : List U8 = CallByName TotallyNotJson.215 List.148 List.149; - ret List.663; +procedure List.145 (List.146, List.147, List.144): + let List.658 : List U8 = CallByName TotallyNotJson.215 List.146 List.147; + ret List.658; -procedure List.18 (List.144, List.145, List.146): - let List.555 : {List U8, U64} = CallByName List.93 List.144 List.145 List.146; - ret List.555; +procedure List.18 (List.142, List.143, List.144): + let List.551 : {List U8, U64} = CallByName List.93 List.142 List.143 List.144; + ret List.551; -procedure List.18 (List.144, List.145, List.146): - let List.624 : {List U8, U64} = CallByName List.93 List.144 List.145 List.146; - ret List.624; +procedure List.18 (List.142, List.143, List.144): + let List.619 : {List U8, U64} = CallByName List.93 List.142 List.143 List.144; + ret List.619; -procedure List.18 (List.144, List.145, List.146): - let List.645 : List U8 = CallByName List.93 List.144 List.145 List.146; - ret List.645; +procedure List.18 (List.142, List.143, List.144): + let List.639 : List U8 = CallByName List.93 List.142 List.143 List.144; + ret List.639; -procedure List.26 (List.161, List.162, List.163): - let List.712 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.93 List.161 List.162 List.163; - let List.715 : U8 = 1i64; - let List.716 : U8 = GetTagId List.712; - let List.717 : Int1 = lowlevel Eq List.715 List.716; - if List.717 then - let List.164 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.712; - ret List.164; +procedure List.26 (List.159, List.160, List.161): + let List.707 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.93 List.159 List.160 List.161; + let List.710 : U8 = 1i64; + let List.711 : U8 = GetTagId List.707; + let List.712 : Int1 = lowlevel Eq List.710 List.711; + if List.712 then + let List.162 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.707; + ret List.162; else - let List.165 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.712; - ret List.165; + let List.163 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.707; + ret List.163; procedure List.31 (#Attr.2, #Attr.3): - let List.677 : List Str = lowlevel ListDropAt #Attr.2 #Attr.3; - ret List.677; + let List.672 : List Str = lowlevel ListDropAt #Attr.2 #Attr.3; + ret List.672; -procedure List.38 (List.300): - let List.685 : U64 = 0i64; - let List.684 : List Str = CallByName List.31 List.300 List.685; - ret List.684; +procedure List.38 (List.298): + let List.680 : U64 = 0i64; + let List.679 : List Str = CallByName List.31 List.298 List.680; + ret List.679; -procedure List.4 (List.115, List.116): - let List.620 : U64 = 1i64; - let List.619 : List Str = CallByName List.70 List.115 List.620; - let List.618 : List Str = CallByName List.71 List.619 List.116; - ret List.618; +procedure List.4 (List.113, List.114): + let List.615 : U64 = 1i64; + let List.614 : List Str = CallByName List.70 List.113 List.615; + let List.613 : List Str = CallByName List.71 List.614 List.114; + ret List.613; -procedure List.4 (List.115, List.116): - let List.623 : U64 = 1i64; - let List.622 : List U8 = CallByName List.70 List.115 List.623; - let List.621 : List U8 = CallByName List.71 List.622 List.116; - ret List.621; +procedure List.4 (List.113, List.114): + let List.618 : U64 = 1i64; + let List.617 : List U8 = CallByName List.70 List.113 List.618; + let List.616 : List U8 = CallByName List.71 List.617 List.114; + ret List.616; -procedure List.49 (List.379, List.380): - let List.704 : U64 = StructAtIndex 0 List.380; - let List.705 : U64 = 0i64; - let List.702 : Int1 = CallByName Bool.11 List.704 List.705; - if List.702 then - dec List.379; - let List.703 : List U8 = Array []; - ret List.703; - else - let List.699 : U64 = StructAtIndex 1 List.380; - let List.700 : U64 = StructAtIndex 0 List.380; - let List.698 : List U8 = CallByName List.72 List.379 List.699 List.700; +procedure List.49 (List.377, List.378): + let List.699 : U64 = StructAtIndex 0 List.378; + let List.700 : U64 = 0i64; + let List.697 : Int1 = CallByName Bool.11 List.699 List.700; + if List.697 then + dec List.377; + let List.698 : List U8 = Array []; ret List.698; - -procedure List.52 (List.394, List.395): - let List.396 : U64 = CallByName List.6 List.394; - joinpoint List.710 List.397: - let List.708 : U64 = 0i64; - let List.707 : {U64, U64} = Struct {List.397, List.708}; - inc List.394; - let List.398 : List U8 = CallByName List.49 List.394 List.707; - let List.706 : U64 = CallByName Num.75 List.396 List.397; - let List.697 : {U64, U64} = Struct {List.706, List.397}; - let List.399 : List U8 = CallByName List.49 List.394 List.697; - let List.696 : {List U8, List U8} = Struct {List.398, List.399}; - ret List.696; - in - let List.711 : Int1 = CallByName Num.24 List.396 List.395; - if List.711 then - jump List.710 List.395; else - jump List.710 List.396; + let List.694 : U64 = StructAtIndex 1 List.378; + let List.695 : U64 = StructAtIndex 0 List.378; + let List.693 : List U8 = CallByName List.72 List.377 List.694 List.695; + ret List.693; + +procedure List.52 (List.392, List.393): + let List.394 : U64 = CallByName List.6 List.392; + joinpoint List.705 List.395: + let List.703 : U64 = 0i64; + let List.702 : {U64, U64} = Struct {List.395, List.703}; + inc List.392; + let List.396 : List U8 = CallByName List.49 List.392 List.702; + let List.701 : U64 = CallByName Num.75 List.394 List.395; + let List.692 : {U64, U64} = Struct {List.701, List.395}; + let List.397 : List U8 = CallByName List.49 List.392 List.692; + let List.691 : {List U8, List U8} = Struct {List.396, List.397}; + ret List.691; + in + let List.706 : Int1 = CallByName Num.24 List.394 List.393; + if List.706 then + jump List.705 List.393; + else + jump List.705 List.394; procedure List.6 (#Attr.2): - let List.594 : U64 = lowlevel ListLen #Attr.2; - ret List.594; + let List.589 : U64 = lowlevel ListLen #Attr.2; + ret List.589; procedure List.6 (#Attr.2): - let List.691 : U64 = lowlevel ListLen #Attr.2; - ret List.691; + let List.686 : U64 = lowlevel ListLen #Attr.2; + ret List.686; procedure List.6 (#Attr.2): - let List.692 : U64 = lowlevel ListLen #Attr.2; - ret List.692; - -procedure List.6 (#Attr.2): - let List.694 : U64 = lowlevel ListLen #Attr.2; - ret List.694; - -procedure List.66 (#Attr.2, #Attr.3): - let List.572 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.572; - -procedure List.66 (#Attr.2, #Attr.3): - let List.641 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.641; - -procedure List.66 (#Attr.2, #Attr.3): - let List.660 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.660; - -procedure List.68 (#Attr.2): - let List.687 : List Str = lowlevel ListWithCapacity #Attr.2; + let List.687 : U64 = lowlevel ListLen #Attr.2; ret List.687; -procedure List.68 (#Attr.2): - let List.689 : List U8 = lowlevel ListWithCapacity #Attr.2; +procedure List.6 (#Attr.2): + let List.689 : U64 = lowlevel ListLen #Attr.2; ret List.689; -procedure List.70 (#Attr.2, #Attr.3): - let List.600 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.600; +procedure List.66 (#Attr.2, #Attr.3): + let List.567 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.567; + +procedure List.66 (#Attr.2, #Attr.3): + let List.635 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.635; + +procedure List.66 (#Attr.2, #Attr.3): + let List.655 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.655; + +procedure List.68 (#Attr.2): + let List.682 : List Str = lowlevel ListWithCapacity #Attr.2; + ret List.682; + +procedure List.68 (#Attr.2): + let List.684 : List U8 = lowlevel ListWithCapacity #Attr.2; + ret List.684; procedure List.70 (#Attr.2, #Attr.3): - let List.617 : List Str = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.617; + let List.595 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.595; + +procedure List.70 (#Attr.2, #Attr.3): + let List.612 : List Str = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.612; procedure List.71 (#Attr.2, #Attr.3): - let List.598 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.598; + let List.593 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.593; procedure List.71 (#Attr.2, #Attr.3): - let List.615 : List Str = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.615; + let List.610 : List Str = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.610; procedure List.72 (#Attr.2, #Attr.3, #Attr.4): - let List.701 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; - ret List.701; + let List.696 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; + ret List.696; procedure List.8 (#Attr.2, #Attr.3): - let List.666 : List Str = lowlevel ListConcat #Attr.2 #Attr.3; - ret List.666; + let List.661 : List Str = lowlevel ListConcat #Attr.2 #Attr.3; + ret List.661; procedure List.8 (#Attr.2, #Attr.3): - let List.674 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; - ret List.674; + let List.669 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; + ret List.669; -procedure List.80 (#Derived_gen.23, #Derived_gen.24, #Derived_gen.25, #Derived_gen.26, #Derived_gen.27): - joinpoint List.630 List.442 List.443 List.444 List.445 List.446: - let List.632 : Int1 = CallByName Num.22 List.445 List.446; - if List.632 then - let List.640 : {Str, Str} = CallByName List.66 List.442 List.445; - inc List.640; - let List.633 : {List U8, U64} = CallByName List.147 List.443 List.640 List.444; - let List.635 : U64 = CallByName List.96 List.445; - jump List.630 List.442 List.633 List.444 List.635 List.446; +procedure List.80 (#Derived_gen.26, #Derived_gen.27, #Derived_gen.28, #Derived_gen.29, #Derived_gen.30): + joinpoint List.645 List.440 List.441 List.442 List.443 List.444: + let List.647 : Int1 = CallByName Num.22 List.443 List.444; + if List.647 then + let List.654 : U8 = CallByName List.66 List.440 List.443; + let List.648 : List U8 = CallByName List.145 List.441 List.654 List.442; + let List.651 : U64 = 1i64; + let List.650 : U64 = CallByName Num.51 List.443 List.651; + jump List.645 List.440 List.648 List.442 List.650 List.444; else - dec List.442; - ret List.443; + dec List.440; + ret List.441; in - jump List.630 #Derived_gen.23 #Derived_gen.24 #Derived_gen.25 #Derived_gen.26 #Derived_gen.27; + jump List.645 #Derived_gen.26 #Derived_gen.27 #Derived_gen.28 #Derived_gen.29 #Derived_gen.30; -procedure List.80 (#Derived_gen.36, #Derived_gen.37, #Derived_gen.38, #Derived_gen.39, #Derived_gen.40): - joinpoint List.651 List.442 List.443 List.444 List.445 List.446: - let List.653 : Int1 = CallByName Num.22 List.445 List.446; - if List.653 then - let List.659 : U8 = CallByName List.66 List.442 List.445; - let List.654 : List U8 = CallByName List.147 List.443 List.659 List.444; - let List.656 : U64 = CallByName List.96 List.445; - jump List.651 List.442 List.654 List.444 List.656 List.446; - else - dec List.442; - ret List.443; - in - jump List.651 #Derived_gen.36 #Derived_gen.37 #Derived_gen.38 #Derived_gen.39 #Derived_gen.40; - -procedure List.80 (#Derived_gen.47, #Derived_gen.48, #Derived_gen.49, #Derived_gen.50, #Derived_gen.51): - joinpoint List.721 List.442 List.443 List.444 List.445 List.446: - let List.723 : Int1 = CallByName Num.22 List.445 List.446; - if List.723 then - let List.731 : U8 = CallByName List.66 List.442 List.445; - let List.724 : [C {U64, Int1}, C {U64, Int1}] = CallByName TotallyNotJson.189 List.443 List.731; - let List.728 : U8 = 1i64; - let List.729 : U8 = GetTagId List.724; - let List.730 : Int1 = lowlevel Eq List.728 List.729; - if List.730 then - let List.447 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.724; - let List.726 : U64 = CallByName List.96 List.445; - jump List.721 List.442 List.447 List.444 List.726 List.446; +procedure List.80 (#Derived_gen.35, #Derived_gen.36, #Derived_gen.37, #Derived_gen.38, #Derived_gen.39): + joinpoint List.716 List.440 List.441 List.442 List.443 List.444: + let List.718 : Int1 = CallByName Num.22 List.443 List.444; + if List.718 then + let List.727 : U8 = CallByName List.66 List.440 List.443; + let List.719 : [C {U64, Int1}, C {U64, Int1}] = CallByName TotallyNotJson.189 List.441 List.727; + let List.724 : U8 = 1i64; + let List.725 : U8 = GetTagId List.719; + let List.726 : Int1 = lowlevel Eq List.724 List.725; + if List.726 then + let List.445 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.719; + let List.722 : U64 = 1i64; + let List.721 : U64 = CallByName Num.51 List.443 List.722; + jump List.716 List.440 List.445 List.442 List.721 List.444; else - dec List.442; - let List.448 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.724; - let List.727 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) List.448; - ret List.727; + dec List.440; + let List.446 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.719; + let List.723 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) List.446; + ret List.723; else - dec List.442; - let List.722 : [C {U64, Int1}, C {U64, Int1}] = TagId(1) List.443; - ret List.722; + dec List.440; + let List.717 : [C {U64, Int1}, C {U64, Int1}] = TagId(1) List.441; + ret List.717; in - jump List.721 #Derived_gen.47 #Derived_gen.48 #Derived_gen.49 #Derived_gen.50 #Derived_gen.51; + jump List.716 #Derived_gen.35 #Derived_gen.36 #Derived_gen.37 #Derived_gen.38 #Derived_gen.39; + +procedure List.80 (#Derived_gen.41, #Derived_gen.42, #Derived_gen.43, #Derived_gen.44, #Derived_gen.45): + joinpoint List.625 List.440 List.441 List.442 List.443 List.444: + let List.627 : Int1 = CallByName Num.22 List.443 List.444; + if List.627 then + let List.634 : {Str, Str} = CallByName List.66 List.440 List.443; + inc List.634; + let List.628 : {List U8, U64} = CallByName List.145 List.441 List.634 List.442; + let List.631 : U64 = 1i64; + let List.630 : U64 = CallByName Num.51 List.443 List.631; + jump List.625 List.440 List.628 List.442 List.630 List.444; + else + dec List.440; + ret List.441; + in + jump List.625 #Derived_gen.41 #Derived_gen.42 #Derived_gen.43 #Derived_gen.44 #Derived_gen.45; procedure List.80 (#Derived_gen.52, #Derived_gen.53, #Derived_gen.54, #Derived_gen.55, #Derived_gen.56): - joinpoint List.561 List.442 List.443 List.444 List.445 List.446: - let List.563 : Int1 = CallByName Num.22 List.445 List.446; - if List.563 then - let List.571 : {Str, Str} = CallByName List.66 List.442 List.445; - inc List.571; - let List.564 : {List U8, U64} = CallByName List.147 List.443 List.571 List.444; - let List.566 : U64 = CallByName List.96 List.445; - jump List.561 List.442 List.564 List.444 List.566 List.446; + joinpoint List.557 List.440 List.441 List.442 List.443 List.444: + let List.559 : Int1 = CallByName Num.22 List.443 List.444; + if List.559 then + let List.566 : {Str, Str} = CallByName List.66 List.440 List.443; + inc List.566; + let List.560 : {List U8, U64} = CallByName List.145 List.441 List.566 List.442; + let List.563 : U64 = 1i64; + let List.562 : U64 = CallByName Num.51 List.443 List.563; + jump List.557 List.440 List.560 List.442 List.562 List.444; else - dec List.442; - ret List.443; + dec List.440; + ret List.441; in - jump List.561 #Derived_gen.52 #Derived_gen.53 #Derived_gen.54 #Derived_gen.55 #Derived_gen.56; + jump List.557 #Derived_gen.52 #Derived_gen.53 #Derived_gen.54 #Derived_gen.55 #Derived_gen.56; -procedure List.93 (List.439, List.440, List.441): - let List.559 : U64 = 0i64; - let List.560 : U64 = CallByName List.6 List.439; - let List.558 : {List U8, U64} = CallByName List.80 List.439 List.440 List.441 List.559 List.560; - ret List.558; +procedure List.93 (List.437, List.438, List.439): + let List.555 : U64 = 0i64; + let List.556 : U64 = CallByName List.6 List.437; + let List.554 : {List U8, U64} = CallByName List.80 List.437 List.438 List.439 List.555 List.556; + ret List.554; -procedure List.93 (List.439, List.440, List.441): - let List.628 : U64 = 0i64; - let List.629 : U64 = CallByName List.6 List.439; - let List.627 : {List U8, U64} = CallByName List.80 List.439 List.440 List.441 List.628 List.629; - ret List.627; +procedure List.93 (List.437, List.438, List.439): + let List.623 : U64 = 0i64; + let List.624 : U64 = CallByName List.6 List.437; + let List.622 : {List U8, U64} = CallByName List.80 List.437 List.438 List.439 List.623 List.624; + ret List.622; -procedure List.93 (List.439, List.440, List.441): - let List.649 : U64 = 0i64; - let List.650 : U64 = CallByName List.6 List.439; - let List.648 : List U8 = CallByName List.80 List.439 List.440 List.441 List.649 List.650; - ret List.648; +procedure List.93 (List.437, List.438, List.439): + let List.643 : U64 = 0i64; + let List.644 : U64 = CallByName List.6 List.437; + let List.642 : List U8 = CallByName List.80 List.437 List.438 List.439 List.643 List.644; + ret List.642; -procedure List.93 (List.439, List.440, List.441): - let List.719 : U64 = 0i64; - let List.720 : U64 = CallByName List.6 List.439; - let List.718 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.80 List.439 List.440 List.441 List.719 List.720; - ret List.718; - -procedure List.96 (List.463): - let List.637 : U64 = 1i64; - let List.636 : U64 = CallByName Num.51 List.463 List.637; - ret List.636; +procedure List.93 (List.437, List.438, List.439): + let List.714 : U64 = 0i64; + let List.715 : U64 = CallByName List.6 List.437; + let List.713 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.80 List.437 List.438 List.439 List.714 List.715; + ret List.713; procedure Num.127 (#Attr.2): let Num.307 : U8 = lowlevel NumIntCast #Attr.2; @@ -350,58 +349,58 @@ procedure Num.21 (#Attr.2, #Attr.3): ret Num.313; procedure Num.22 (#Attr.2, #Attr.3): - let Num.317 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; - ret Num.317; - -procedure Num.24 (#Attr.2, #Attr.3): - let Num.319 : Int1 = lowlevel NumGt #Attr.2 #Attr.3; + let Num.319 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; ret Num.319; +procedure Num.24 (#Attr.2, #Attr.3): + let Num.321 : Int1 = lowlevel NumGt #Attr.2 #Attr.3; + ret Num.321; + procedure Num.51 (#Attr.2, #Attr.3): - let Num.314 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; - ret Num.314; + let Num.316 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; + ret Num.316; procedure Num.75 (#Attr.2, #Attr.3): - let Num.318 : U64 = lowlevel NumSubWrap #Attr.2 #Attr.3; - ret Num.318; + let Num.320 : U64 = lowlevel NumSubWrap #Attr.2 #Attr.3; + ret Num.320; procedure Num.94 (#Attr.2, #Attr.3): let Num.312 : U64 = lowlevel NumDivCeilUnchecked #Attr.2 #Attr.3; ret Num.312; procedure Str.12 (#Attr.2): - let Str.309 : List U8 = lowlevel StrToUtf8 #Attr.2; - ret Str.309; + let Str.307 : List U8 = lowlevel StrToUtf8 #Attr.2; + ret Str.307; procedure Str.4 (#Attr.2, #Attr.3): - let Str.312 : Str = lowlevel StrJoinWith #Attr.2 #Attr.3; - ret Str.312; + let Str.310 : Str = lowlevel StrJoinWith #Attr.2 #Attr.3; + ret Str.310; procedure Str.48 (#Attr.2, #Attr.3, #Attr.4): - let Str.300 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8Range #Attr.2 #Attr.3 #Attr.4; - ret Str.300; + let Str.298 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8Range #Attr.2 #Attr.3 #Attr.4; + ret Str.298; procedure Str.55 (#Attr.2): - let Str.315 : List Str = lowlevel StrGraphemes #Attr.2; - ret Str.315; + let Str.313 : List Str = lowlevel StrGraphemes #Attr.2; + ret Str.313; -procedure Str.9 (Str.80): - let Str.298 : U64 = 0i64; - let Str.299 : U64 = CallByName List.6 Str.80; - let Str.81 : {U64, Str, Int1, U8} = CallByName Str.48 Str.80 Str.298 Str.299; - let Str.295 : Int1 = StructAtIndex 2 Str.81; - if Str.295 then - let Str.297 : Str = StructAtIndex 1 Str.81; - let Str.296 : [C {U64, U8}, C Str] = TagId(1) Str.297; - ret Str.296; +procedure Str.9 (Str.79): + let Str.296 : U64 = 0i64; + let Str.297 : U64 = CallByName List.6 Str.79; + let Str.80 : {U64, Str, Int1, U8} = CallByName Str.48 Str.79 Str.296 Str.297; + let Str.293 : Int1 = StructAtIndex 2 Str.80; + if Str.293 then + let Str.295 : Str = StructAtIndex 1 Str.80; + let Str.294 : [C {U64, U8}, C Str] = TagId(1) Str.295; + ret Str.294; else - let Str.293 : U8 = StructAtIndex 3 Str.81; - let Str.294 : U64 = StructAtIndex 0 Str.81; - let #Derived_gen.57 : Str = StructAtIndex 1 Str.81; + let Str.291 : U8 = StructAtIndex 3 Str.80; + let Str.292 : U64 = StructAtIndex 0 Str.80; + let #Derived_gen.57 : Str = StructAtIndex 1 Str.80; dec #Derived_gen.57; - let Str.292 : {U64, U8} = Struct {Str.294, Str.293}; - let Str.291 : [C {U64, U8}, C Str] = TagId(0) Str.292; - ret Str.291; + let Str.290 : {U64, U8} = Struct {Str.292, Str.291}; + let Str.289 : [C {U64, U8}, C Str] = TagId(0) Str.290; + ret Str.289; procedure TotallyNotJson.100 (TotallyNotJson.850): let TotallyNotJson.1830 : Str = "a"; @@ -1455,7 +1454,7 @@ procedure TotallyNotJson.97 (TotallyNotJson.837): dec TotallyNotJson.1562; ret TotallyNotJson.1560; -procedure TotallyNotJson.98 (#Derived_gen.35): +procedure TotallyNotJson.98 (#Derived_gen.40): joinpoint TotallyNotJson.1568 TotallyNotJson.1169: let TotallyNotJson.842 : List Str = StructAtIndex 0 TotallyNotJson.1169; let TotallyNotJson.841 : List Str = StructAtIndex 1 TotallyNotJson.1169; @@ -1491,7 +1490,7 @@ procedure TotallyNotJson.98 (#Derived_gen.35): let TotallyNotJson.1569 : {List Str, List Str} = Struct {TotallyNotJson.842, TotallyNotJson.841}; ret TotallyNotJson.1569; in - jump TotallyNotJson.1568 #Derived_gen.35; + jump TotallyNotJson.1568 #Derived_gen.40; procedure Test.0 (): let Test.12 : Str = "bar"; diff --git a/crates/compiler/test_mono/generated/encode_derived_record_one_field_string.txt b/crates/compiler/test_mono/generated/encode_derived_record_one_field_string.txt index 77ae7816a6..034a1b92d2 100644 --- a/crates/compiler/test_mono/generated/encode_derived_record_one_field_string.txt +++ b/crates/compiler/test_mono/generated/encode_derived_record_one_field_string.txt @@ -51,223 +51,221 @@ procedure Encode.26 (Encode.105, Encode.106): ret Encode.108; procedure List.13 (#Attr.2, #Attr.3): - let List.626 : List Str = lowlevel ListPrepend #Attr.2 #Attr.3; - ret List.626; - -procedure List.147 (List.148, List.149, List.146): - let List.575 : {List U8, U64} = CallByName TotallyNotJson.237 List.148 List.149 List.146; - ret List.575; - -procedure List.147 (List.148, List.149, List.146): - let List.594 : List U8 = CallByName TotallyNotJson.215 List.148 List.149; - ret List.594; - -procedure List.18 (List.144, List.145, List.146): - let List.555 : {List U8, U64} = CallByName List.93 List.144 List.145 List.146; - ret List.555; - -procedure List.18 (List.144, List.145, List.146): - let List.576 : List U8 = CallByName List.93 List.144 List.145 List.146; - ret List.576; - -procedure List.26 (List.161, List.162, List.163): - let List.643 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.93 List.161 List.162 List.163; - let List.646 : U8 = 1i64; - let List.647 : U8 = GetTagId List.643; - let List.648 : Int1 = lowlevel Eq List.646 List.647; - if List.648 then - let List.164 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.643; - ret List.164; - else - let List.165 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.643; - ret List.165; - -procedure List.31 (#Attr.2, #Attr.3): - let List.608 : List Str = lowlevel ListDropAt #Attr.2 #Attr.3; - ret List.608; - -procedure List.38 (List.300): - let List.616 : U64 = 0i64; - let List.615 : List Str = CallByName List.31 List.300 List.616; - ret List.615; - -procedure List.4 (List.115, List.116): - let List.551 : U64 = 1i64; - let List.550 : List Str = CallByName List.70 List.115 List.551; - let List.549 : List Str = CallByName List.71 List.550 List.116; - ret List.549; - -procedure List.4 (List.115, List.116): - let List.554 : U64 = 1i64; - let List.553 : List U8 = CallByName List.70 List.115 List.554; - let List.552 : List U8 = CallByName List.71 List.553 List.116; - ret List.552; - -procedure List.49 (List.379, List.380): - let List.635 : U64 = StructAtIndex 0 List.380; - let List.636 : U64 = 0i64; - let List.633 : Int1 = CallByName Bool.11 List.635 List.636; - if List.633 then - dec List.379; - let List.634 : List U8 = Array []; - ret List.634; - else - let List.630 : U64 = StructAtIndex 1 List.380; - let List.631 : U64 = StructAtIndex 0 List.380; - let List.629 : List U8 = CallByName List.72 List.379 List.630 List.631; - ret List.629; - -procedure List.52 (List.394, List.395): - let List.396 : U64 = CallByName List.6 List.394; - joinpoint List.641 List.397: - let List.639 : U64 = 0i64; - let List.638 : {U64, U64} = Struct {List.397, List.639}; - inc List.394; - let List.398 : List U8 = CallByName List.49 List.394 List.638; - let List.637 : U64 = CallByName Num.75 List.396 List.397; - let List.628 : {U64, U64} = Struct {List.637, List.397}; - let List.399 : List U8 = CallByName List.49 List.394 List.628; - let List.627 : {List U8, List U8} = Struct {List.398, List.399}; - ret List.627; - in - let List.642 : Int1 = CallByName Num.24 List.396 List.395; - if List.642 then - jump List.641 List.395; - else - jump List.641 List.396; - -procedure List.6 (#Attr.2): - let List.622 : U64 = lowlevel ListLen #Attr.2; + let List.622 : List Str = lowlevel ListPrepend #Attr.2 #Attr.3; ret List.622; -procedure List.6 (#Attr.2): - let List.623 : U64 = lowlevel ListLen #Attr.2; - ret List.623; +procedure List.145 (List.146, List.147, List.144): + let List.570 : {List U8, U64} = CallByName TotallyNotJson.237 List.146 List.147 List.144; + ret List.570; -procedure List.6 (#Attr.2): - let List.625 : U64 = lowlevel ListLen #Attr.2; - ret List.625; +procedure List.145 (List.146, List.147, List.144): + let List.590 : List U8 = CallByName TotallyNotJson.215 List.146 List.147; + ret List.590; -procedure List.66 (#Attr.2, #Attr.3): - let List.572 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.572; +procedure List.18 (List.142, List.143, List.144): + let List.551 : {List U8, U64} = CallByName List.93 List.142 List.143 List.144; + ret List.551; -procedure List.66 (#Attr.2, #Attr.3): - let List.591 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.591; +procedure List.18 (List.142, List.143, List.144): + let List.571 : List U8 = CallByName List.93 List.142 List.143 List.144; + ret List.571; -procedure List.68 (#Attr.2): - let List.618 : List Str = lowlevel ListWithCapacity #Attr.2; - ret List.618; +procedure List.26 (List.159, List.160, List.161): + let List.639 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.93 List.159 List.160 List.161; + let List.642 : U8 = 1i64; + let List.643 : U8 = GetTagId List.639; + let List.644 : Int1 = lowlevel Eq List.642 List.643; + if List.644 then + let List.162 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.639; + ret List.162; + else + let List.163 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.639; + ret List.163; -procedure List.68 (#Attr.2): - let List.620 : List U8 = lowlevel ListWithCapacity #Attr.2; - ret List.620; +procedure List.31 (#Attr.2, #Attr.3): + let List.604 : List Str = lowlevel ListDropAt #Attr.2 #Attr.3; + ret List.604; -procedure List.70 (#Attr.2, #Attr.3): - let List.531 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.531; +procedure List.38 (List.298): + let List.612 : U64 = 0i64; + let List.611 : List Str = CallByName List.31 List.298 List.612; + ret List.611; -procedure List.70 (#Attr.2, #Attr.3): - let List.548 : List Str = lowlevel ListReserve #Attr.2 #Attr.3; +procedure List.4 (List.113, List.114): + let List.547 : U64 = 1i64; + let List.546 : List Str = CallByName List.70 List.113 List.547; + let List.545 : List Str = CallByName List.71 List.546 List.114; + ret List.545; + +procedure List.4 (List.113, List.114): + let List.550 : U64 = 1i64; + let List.549 : List U8 = CallByName List.70 List.113 List.550; + let List.548 : List U8 = CallByName List.71 List.549 List.114; ret List.548; -procedure List.71 (#Attr.2, #Attr.3): - let List.529 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.529; +procedure List.49 (List.377, List.378): + let List.631 : U64 = StructAtIndex 0 List.378; + let List.632 : U64 = 0i64; + let List.629 : Int1 = CallByName Bool.11 List.631 List.632; + if List.629 then + dec List.377; + let List.630 : List U8 = Array []; + ret List.630; + else + let List.626 : U64 = StructAtIndex 1 List.378; + let List.627 : U64 = StructAtIndex 0 List.378; + let List.625 : List U8 = CallByName List.72 List.377 List.626 List.627; + ret List.625; + +procedure List.52 (List.392, List.393): + let List.394 : U64 = CallByName List.6 List.392; + joinpoint List.637 List.395: + let List.635 : U64 = 0i64; + let List.634 : {U64, U64} = Struct {List.395, List.635}; + inc List.392; + let List.396 : List U8 = CallByName List.49 List.392 List.634; + let List.633 : U64 = CallByName Num.75 List.394 List.395; + let List.624 : {U64, U64} = Struct {List.633, List.395}; + let List.397 : List U8 = CallByName List.49 List.392 List.624; + let List.623 : {List U8, List U8} = Struct {List.396, List.397}; + ret List.623; + in + let List.638 : Int1 = CallByName Num.24 List.394 List.393; + if List.638 then + jump List.637 List.393; + else + jump List.637 List.394; + +procedure List.6 (#Attr.2): + let List.618 : U64 = lowlevel ListLen #Attr.2; + ret List.618; + +procedure List.6 (#Attr.2): + let List.619 : U64 = lowlevel ListLen #Attr.2; + ret List.619; + +procedure List.6 (#Attr.2): + let List.621 : U64 = lowlevel ListLen #Attr.2; + ret List.621; + +procedure List.66 (#Attr.2, #Attr.3): + let List.567 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.567; + +procedure List.66 (#Attr.2, #Attr.3): + let List.587 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.587; + +procedure List.68 (#Attr.2): + let List.614 : List Str = lowlevel ListWithCapacity #Attr.2; + ret List.614; + +procedure List.68 (#Attr.2): + let List.616 : List U8 = lowlevel ListWithCapacity #Attr.2; + ret List.616; + +procedure List.70 (#Attr.2, #Attr.3): + let List.527 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.527; + +procedure List.70 (#Attr.2, #Attr.3): + let List.544 : List Str = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.544; procedure List.71 (#Attr.2, #Attr.3): - let List.546 : List Str = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.546; + let List.525 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.525; + +procedure List.71 (#Attr.2, #Attr.3): + let List.542 : List Str = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.542; procedure List.72 (#Attr.2, #Attr.3, #Attr.4): - let List.632 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; - ret List.632; + let List.628 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; + ret List.628; procedure List.8 (#Attr.2, #Attr.3): - let List.597 : List Str = lowlevel ListConcat #Attr.2 #Attr.3; - ret List.597; + let List.593 : List Str = lowlevel ListConcat #Attr.2 #Attr.3; + ret List.593; procedure List.8 (#Attr.2, #Attr.3): - let List.605 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; - ret List.605; + let List.601 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; + ret List.601; procedure List.80 (#Derived_gen.10, #Derived_gen.11, #Derived_gen.12, #Derived_gen.13, #Derived_gen.14): - joinpoint List.652 List.442 List.443 List.444 List.445 List.446: - let List.654 : Int1 = CallByName Num.22 List.445 List.446; - if List.654 then - let List.662 : U8 = CallByName List.66 List.442 List.445; - let List.655 : [C {U64, Int1}, C {U64, Int1}] = CallByName TotallyNotJson.189 List.443 List.662; - let List.659 : U8 = 1i64; - let List.660 : U8 = GetTagId List.655; - let List.661 : Int1 = lowlevel Eq List.659 List.660; - if List.661 then - let List.447 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.655; - let List.657 : U64 = CallByName List.96 List.445; - jump List.652 List.442 List.447 List.444 List.657 List.446; + joinpoint List.648 List.440 List.441 List.442 List.443 List.444: + let List.650 : Int1 = CallByName Num.22 List.443 List.444; + if List.650 then + let List.659 : U8 = CallByName List.66 List.440 List.443; + let List.651 : [C {U64, Int1}, C {U64, Int1}] = CallByName TotallyNotJson.189 List.441 List.659; + let List.656 : U8 = 1i64; + let List.657 : U8 = GetTagId List.651; + let List.658 : Int1 = lowlevel Eq List.656 List.657; + if List.658 then + let List.445 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.651; + let List.654 : U64 = 1i64; + let List.653 : U64 = CallByName Num.51 List.443 List.654; + jump List.648 List.440 List.445 List.442 List.653 List.444; else - dec List.442; - let List.448 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.655; - let List.658 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) List.448; - ret List.658; + dec List.440; + let List.446 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.651; + let List.655 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) List.446; + ret List.655; else - dec List.442; - let List.653 : [C {U64, Int1}, C {U64, Int1}] = TagId(1) List.443; - ret List.653; + dec List.440; + let List.649 : [C {U64, Int1}, C {U64, Int1}] = TagId(1) List.441; + ret List.649; in - jump List.652 #Derived_gen.10 #Derived_gen.11 #Derived_gen.12 #Derived_gen.13 #Derived_gen.14; + jump List.648 #Derived_gen.10 #Derived_gen.11 #Derived_gen.12 #Derived_gen.13 #Derived_gen.14; -procedure List.80 (#Derived_gen.25, #Derived_gen.26, #Derived_gen.27, #Derived_gen.28, #Derived_gen.29): - joinpoint List.582 List.442 List.443 List.444 List.445 List.446: - let List.584 : Int1 = CallByName Num.22 List.445 List.446; - if List.584 then - let List.590 : U8 = CallByName List.66 List.442 List.445; - let List.585 : List U8 = CallByName List.147 List.443 List.590 List.444; - let List.587 : U64 = CallByName List.96 List.445; - jump List.582 List.442 List.585 List.444 List.587 List.446; +procedure List.80 (#Derived_gen.18, #Derived_gen.19, #Derived_gen.20, #Derived_gen.21, #Derived_gen.22): + joinpoint List.577 List.440 List.441 List.442 List.443 List.444: + let List.579 : Int1 = CallByName Num.22 List.443 List.444; + if List.579 then + let List.586 : U8 = CallByName List.66 List.440 List.443; + let List.580 : List U8 = CallByName List.145 List.441 List.586 List.442; + let List.583 : U64 = 1i64; + let List.582 : U64 = CallByName Num.51 List.443 List.583; + jump List.577 List.440 List.580 List.442 List.582 List.444; else - dec List.442; - ret List.443; + dec List.440; + ret List.441; in - jump List.582 #Derived_gen.25 #Derived_gen.26 #Derived_gen.27 #Derived_gen.28 #Derived_gen.29; + jump List.577 #Derived_gen.18 #Derived_gen.19 #Derived_gen.20 #Derived_gen.21 #Derived_gen.22; procedure List.80 (#Derived_gen.31, #Derived_gen.32, #Derived_gen.33, #Derived_gen.34, #Derived_gen.35): - joinpoint List.561 List.442 List.443 List.444 List.445 List.446: - let List.563 : Int1 = CallByName Num.22 List.445 List.446; - if List.563 then - let List.571 : {Str, Str} = CallByName List.66 List.442 List.445; - inc List.571; - let List.564 : {List U8, U64} = CallByName List.147 List.443 List.571 List.444; - let List.566 : U64 = CallByName List.96 List.445; - jump List.561 List.442 List.564 List.444 List.566 List.446; + joinpoint List.557 List.440 List.441 List.442 List.443 List.444: + let List.559 : Int1 = CallByName Num.22 List.443 List.444; + if List.559 then + let List.566 : {Str, Str} = CallByName List.66 List.440 List.443; + inc List.566; + let List.560 : {List U8, U64} = CallByName List.145 List.441 List.566 List.442; + let List.563 : U64 = 1i64; + let List.562 : U64 = CallByName Num.51 List.443 List.563; + jump List.557 List.440 List.560 List.442 List.562 List.444; else - dec List.442; - ret List.443; + dec List.440; + ret List.441; in - jump List.561 #Derived_gen.31 #Derived_gen.32 #Derived_gen.33 #Derived_gen.34 #Derived_gen.35; + jump List.557 #Derived_gen.31 #Derived_gen.32 #Derived_gen.33 #Derived_gen.34 #Derived_gen.35; -procedure List.93 (List.439, List.440, List.441): - let List.559 : U64 = 0i64; - let List.560 : U64 = CallByName List.6 List.439; - let List.558 : {List U8, U64} = CallByName List.80 List.439 List.440 List.441 List.559 List.560; - ret List.558; +procedure List.93 (List.437, List.438, List.439): + let List.555 : U64 = 0i64; + let List.556 : U64 = CallByName List.6 List.437; + let List.554 : {List U8, U64} = CallByName List.80 List.437 List.438 List.439 List.555 List.556; + ret List.554; -procedure List.93 (List.439, List.440, List.441): - let List.580 : U64 = 0i64; - let List.581 : U64 = CallByName List.6 List.439; - let List.579 : List U8 = CallByName List.80 List.439 List.440 List.441 List.580 List.581; - ret List.579; +procedure List.93 (List.437, List.438, List.439): + let List.575 : U64 = 0i64; + let List.576 : U64 = CallByName List.6 List.437; + let List.574 : List U8 = CallByName List.80 List.437 List.438 List.439 List.575 List.576; + ret List.574; -procedure List.93 (List.439, List.440, List.441): - let List.650 : U64 = 0i64; - let List.651 : U64 = CallByName List.6 List.439; - let List.649 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.80 List.439 List.440 List.441 List.650 List.651; - ret List.649; - -procedure List.96 (List.463): - let List.568 : U64 = 1i64; - let List.567 : U64 = CallByName Num.51 List.463 List.568; - ret List.567; +procedure List.93 (List.437, List.438, List.439): + let List.646 : U64 = 0i64; + let List.647 : U64 = CallByName List.6 List.437; + let List.645 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.80 List.437 List.438 List.439 List.646 List.647; + ret List.645; procedure Num.127 (#Attr.2): let Num.297 : U8 = lowlevel NumIntCast #Attr.2; @@ -286,58 +284,58 @@ procedure Num.21 (#Attr.2, #Attr.3): ret Num.303; procedure Num.22 (#Attr.2, #Attr.3): - let Num.307 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; - ret Num.307; - -procedure Num.24 (#Attr.2, #Attr.3): - let Num.309 : Int1 = lowlevel NumGt #Attr.2 #Attr.3; + let Num.309 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; ret Num.309; +procedure Num.24 (#Attr.2, #Attr.3): + let Num.311 : Int1 = lowlevel NumGt #Attr.2 #Attr.3; + ret Num.311; + procedure Num.51 (#Attr.2, #Attr.3): - let Num.304 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; - ret Num.304; + let Num.306 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; + ret Num.306; procedure Num.75 (#Attr.2, #Attr.3): - let Num.308 : U64 = lowlevel NumSubWrap #Attr.2 #Attr.3; - ret Num.308; + let Num.310 : U64 = lowlevel NumSubWrap #Attr.2 #Attr.3; + ret Num.310; procedure Num.94 (#Attr.2, #Attr.3): let Num.302 : U64 = lowlevel NumDivCeilUnchecked #Attr.2 #Attr.3; ret Num.302; procedure Str.12 (#Attr.2): - let Str.302 : List U8 = lowlevel StrToUtf8 #Attr.2; - ret Str.302; - -procedure Str.4 (#Attr.2, #Attr.3): - let Str.305 : Str = lowlevel StrJoinWith #Attr.2 #Attr.3; - ret Str.305; - -procedure Str.48 (#Attr.2, #Attr.3, #Attr.4): - let Str.300 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8Range #Attr.2 #Attr.3 #Attr.4; + let Str.300 : List U8 = lowlevel StrToUtf8 #Attr.2; ret Str.300; -procedure Str.55 (#Attr.2): - let Str.308 : List Str = lowlevel StrGraphemes #Attr.2; - ret Str.308; +procedure Str.4 (#Attr.2, #Attr.3): + let Str.303 : Str = lowlevel StrJoinWith #Attr.2 #Attr.3; + ret Str.303; -procedure Str.9 (Str.80): - let Str.298 : U64 = 0i64; - let Str.299 : U64 = CallByName List.6 Str.80; - let Str.81 : {U64, Str, Int1, U8} = CallByName Str.48 Str.80 Str.298 Str.299; - let Str.295 : Int1 = StructAtIndex 2 Str.81; - if Str.295 then - let Str.297 : Str = StructAtIndex 1 Str.81; - let Str.296 : [C {U64, U8}, C Str] = TagId(1) Str.297; - ret Str.296; +procedure Str.48 (#Attr.2, #Attr.3, #Attr.4): + let Str.298 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8Range #Attr.2 #Attr.3 #Attr.4; + ret Str.298; + +procedure Str.55 (#Attr.2): + let Str.306 : List Str = lowlevel StrGraphemes #Attr.2; + ret Str.306; + +procedure Str.9 (Str.79): + let Str.296 : U64 = 0i64; + let Str.297 : U64 = CallByName List.6 Str.79; + let Str.80 : {U64, Str, Int1, U8} = CallByName Str.48 Str.79 Str.296 Str.297; + let Str.293 : Int1 = StructAtIndex 2 Str.80; + if Str.293 then + let Str.295 : Str = StructAtIndex 1 Str.80; + let Str.294 : [C {U64, U8}, C Str] = TagId(1) Str.295; + ret Str.294; else - let Str.293 : U8 = StructAtIndex 3 Str.81; - let Str.294 : U64 = StructAtIndex 0 Str.81; - let #Derived_gen.36 : Str = StructAtIndex 1 Str.81; + let Str.291 : U8 = StructAtIndex 3 Str.80; + let Str.292 : U64 = StructAtIndex 0 Str.80; + let #Derived_gen.36 : Str = StructAtIndex 1 Str.80; dec #Derived_gen.36; - let Str.292 : {U64, U8} = Struct {Str.294, Str.293}; - let Str.291 : [C {U64, U8}, C Str] = TagId(0) Str.292; - ret Str.291; + let Str.290 : {U64, U8} = Struct {Str.292, Str.291}; + let Str.289 : [C {U64, U8}, C Str] = TagId(0) Str.290; + ret Str.289; procedure TotallyNotJson.100 (TotallyNotJson.850): let TotallyNotJson.1479 : Str = "a"; @@ -1287,7 +1285,7 @@ procedure TotallyNotJson.95 (TotallyNotJson.829): dec TotallyNotJson.1489; ret TotallyNotJson.1488; -procedure TotallyNotJson.96 (#Derived_gen.21): +procedure TotallyNotJson.96 (#Derived_gen.26): joinpoint TotallyNotJson.1496 TotallyNotJson.1168: let TotallyNotJson.834 : List Str = StructAtIndex 0 TotallyNotJson.1168; let TotallyNotJson.833 : List Str = StructAtIndex 1 TotallyNotJson.1168; @@ -1323,7 +1321,7 @@ procedure TotallyNotJson.96 (#Derived_gen.21): let TotallyNotJson.1497 : {List Str, List Str} = Struct {TotallyNotJson.834, TotallyNotJson.833}; ret TotallyNotJson.1497; in - jump TotallyNotJson.1496 #Derived_gen.21; + jump TotallyNotJson.1496 #Derived_gen.26; procedure TotallyNotJson.97 (TotallyNotJson.837): let TotallyNotJson.838 : List Str = CallByName Str.55 TotallyNotJson.837; diff --git a/crates/compiler/test_mono/generated/encode_derived_record_two_field_strings.txt b/crates/compiler/test_mono/generated/encode_derived_record_two_field_strings.txt index 21ddc6551b..afb6f01362 100644 --- a/crates/compiler/test_mono/generated/encode_derived_record_two_field_strings.txt +++ b/crates/compiler/test_mono/generated/encode_derived_record_two_field_strings.txt @@ -58,223 +58,221 @@ procedure Encode.26 (Encode.105, Encode.106): ret Encode.108; procedure List.13 (#Attr.2, #Attr.3): - let List.626 : List Str = lowlevel ListPrepend #Attr.2 #Attr.3; - ret List.626; - -procedure List.147 (List.148, List.149, List.146): - let List.575 : {List U8, U64} = CallByName TotallyNotJson.237 List.148 List.149 List.146; - ret List.575; - -procedure List.147 (List.148, List.149, List.146): - let List.594 : List U8 = CallByName TotallyNotJson.215 List.148 List.149; - ret List.594; - -procedure List.18 (List.144, List.145, List.146): - let List.555 : {List U8, U64} = CallByName List.93 List.144 List.145 List.146; - ret List.555; - -procedure List.18 (List.144, List.145, List.146): - let List.576 : List U8 = CallByName List.93 List.144 List.145 List.146; - ret List.576; - -procedure List.26 (List.161, List.162, List.163): - let List.643 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.93 List.161 List.162 List.163; - let List.646 : U8 = 1i64; - let List.647 : U8 = GetTagId List.643; - let List.648 : Int1 = lowlevel Eq List.646 List.647; - if List.648 then - let List.164 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.643; - ret List.164; - else - let List.165 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.643; - ret List.165; - -procedure List.31 (#Attr.2, #Attr.3): - let List.608 : List Str = lowlevel ListDropAt #Attr.2 #Attr.3; - ret List.608; - -procedure List.38 (List.300): - let List.616 : U64 = 0i64; - let List.615 : List Str = CallByName List.31 List.300 List.616; - ret List.615; - -procedure List.4 (List.115, List.116): - let List.551 : U64 = 1i64; - let List.550 : List Str = CallByName List.70 List.115 List.551; - let List.549 : List Str = CallByName List.71 List.550 List.116; - ret List.549; - -procedure List.4 (List.115, List.116): - let List.554 : U64 = 1i64; - let List.553 : List U8 = CallByName List.70 List.115 List.554; - let List.552 : List U8 = CallByName List.71 List.553 List.116; - ret List.552; - -procedure List.49 (List.379, List.380): - let List.635 : U64 = StructAtIndex 0 List.380; - let List.636 : U64 = 0i64; - let List.633 : Int1 = CallByName Bool.11 List.635 List.636; - if List.633 then - dec List.379; - let List.634 : List U8 = Array []; - ret List.634; - else - let List.630 : U64 = StructAtIndex 1 List.380; - let List.631 : U64 = StructAtIndex 0 List.380; - let List.629 : List U8 = CallByName List.72 List.379 List.630 List.631; - ret List.629; - -procedure List.52 (List.394, List.395): - let List.396 : U64 = CallByName List.6 List.394; - joinpoint List.641 List.397: - let List.639 : U64 = 0i64; - let List.638 : {U64, U64} = Struct {List.397, List.639}; - inc List.394; - let List.398 : List U8 = CallByName List.49 List.394 List.638; - let List.637 : U64 = CallByName Num.75 List.396 List.397; - let List.628 : {U64, U64} = Struct {List.637, List.397}; - let List.399 : List U8 = CallByName List.49 List.394 List.628; - let List.627 : {List U8, List U8} = Struct {List.398, List.399}; - ret List.627; - in - let List.642 : Int1 = CallByName Num.24 List.396 List.395; - if List.642 then - jump List.641 List.395; - else - jump List.641 List.396; - -procedure List.6 (#Attr.2): - let List.622 : U64 = lowlevel ListLen #Attr.2; + let List.622 : List Str = lowlevel ListPrepend #Attr.2 #Attr.3; ret List.622; -procedure List.6 (#Attr.2): - let List.623 : U64 = lowlevel ListLen #Attr.2; - ret List.623; +procedure List.145 (List.146, List.147, List.144): + let List.570 : {List U8, U64} = CallByName TotallyNotJson.237 List.146 List.147 List.144; + ret List.570; -procedure List.6 (#Attr.2): - let List.625 : U64 = lowlevel ListLen #Attr.2; - ret List.625; +procedure List.145 (List.146, List.147, List.144): + let List.590 : List U8 = CallByName TotallyNotJson.215 List.146 List.147; + ret List.590; -procedure List.66 (#Attr.2, #Attr.3): - let List.572 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.572; +procedure List.18 (List.142, List.143, List.144): + let List.551 : {List U8, U64} = CallByName List.93 List.142 List.143 List.144; + ret List.551; -procedure List.66 (#Attr.2, #Attr.3): - let List.591 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.591; +procedure List.18 (List.142, List.143, List.144): + let List.571 : List U8 = CallByName List.93 List.142 List.143 List.144; + ret List.571; -procedure List.68 (#Attr.2): - let List.618 : List Str = lowlevel ListWithCapacity #Attr.2; - ret List.618; +procedure List.26 (List.159, List.160, List.161): + let List.639 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.93 List.159 List.160 List.161; + let List.642 : U8 = 1i64; + let List.643 : U8 = GetTagId List.639; + let List.644 : Int1 = lowlevel Eq List.642 List.643; + if List.644 then + let List.162 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.639; + ret List.162; + else + let List.163 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.639; + ret List.163; -procedure List.68 (#Attr.2): - let List.620 : List U8 = lowlevel ListWithCapacity #Attr.2; - ret List.620; +procedure List.31 (#Attr.2, #Attr.3): + let List.604 : List Str = lowlevel ListDropAt #Attr.2 #Attr.3; + ret List.604; -procedure List.70 (#Attr.2, #Attr.3): - let List.531 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.531; +procedure List.38 (List.298): + let List.612 : U64 = 0i64; + let List.611 : List Str = CallByName List.31 List.298 List.612; + ret List.611; -procedure List.70 (#Attr.2, #Attr.3): - let List.548 : List Str = lowlevel ListReserve #Attr.2 #Attr.3; +procedure List.4 (List.113, List.114): + let List.547 : U64 = 1i64; + let List.546 : List Str = CallByName List.70 List.113 List.547; + let List.545 : List Str = CallByName List.71 List.546 List.114; + ret List.545; + +procedure List.4 (List.113, List.114): + let List.550 : U64 = 1i64; + let List.549 : List U8 = CallByName List.70 List.113 List.550; + let List.548 : List U8 = CallByName List.71 List.549 List.114; ret List.548; -procedure List.71 (#Attr.2, #Attr.3): - let List.529 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.529; +procedure List.49 (List.377, List.378): + let List.631 : U64 = StructAtIndex 0 List.378; + let List.632 : U64 = 0i64; + let List.629 : Int1 = CallByName Bool.11 List.631 List.632; + if List.629 then + dec List.377; + let List.630 : List U8 = Array []; + ret List.630; + else + let List.626 : U64 = StructAtIndex 1 List.378; + let List.627 : U64 = StructAtIndex 0 List.378; + let List.625 : List U8 = CallByName List.72 List.377 List.626 List.627; + ret List.625; + +procedure List.52 (List.392, List.393): + let List.394 : U64 = CallByName List.6 List.392; + joinpoint List.637 List.395: + let List.635 : U64 = 0i64; + let List.634 : {U64, U64} = Struct {List.395, List.635}; + inc List.392; + let List.396 : List U8 = CallByName List.49 List.392 List.634; + let List.633 : U64 = CallByName Num.75 List.394 List.395; + let List.624 : {U64, U64} = Struct {List.633, List.395}; + let List.397 : List U8 = CallByName List.49 List.392 List.624; + let List.623 : {List U8, List U8} = Struct {List.396, List.397}; + ret List.623; + in + let List.638 : Int1 = CallByName Num.24 List.394 List.393; + if List.638 then + jump List.637 List.393; + else + jump List.637 List.394; + +procedure List.6 (#Attr.2): + let List.618 : U64 = lowlevel ListLen #Attr.2; + ret List.618; + +procedure List.6 (#Attr.2): + let List.619 : U64 = lowlevel ListLen #Attr.2; + ret List.619; + +procedure List.6 (#Attr.2): + let List.621 : U64 = lowlevel ListLen #Attr.2; + ret List.621; + +procedure List.66 (#Attr.2, #Attr.3): + let List.567 : {Str, Str} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.567; + +procedure List.66 (#Attr.2, #Attr.3): + let List.587 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.587; + +procedure List.68 (#Attr.2): + let List.614 : List Str = lowlevel ListWithCapacity #Attr.2; + ret List.614; + +procedure List.68 (#Attr.2): + let List.616 : List U8 = lowlevel ListWithCapacity #Attr.2; + ret List.616; + +procedure List.70 (#Attr.2, #Attr.3): + let List.527 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.527; + +procedure List.70 (#Attr.2, #Attr.3): + let List.544 : List Str = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.544; procedure List.71 (#Attr.2, #Attr.3): - let List.546 : List Str = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.546; + let List.525 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.525; + +procedure List.71 (#Attr.2, #Attr.3): + let List.542 : List Str = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.542; procedure List.72 (#Attr.2, #Attr.3, #Attr.4): - let List.632 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; - ret List.632; + let List.628 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; + ret List.628; procedure List.8 (#Attr.2, #Attr.3): - let List.597 : List Str = lowlevel ListConcat #Attr.2 #Attr.3; - ret List.597; + let List.593 : List Str = lowlevel ListConcat #Attr.2 #Attr.3; + ret List.593; procedure List.8 (#Attr.2, #Attr.3): - let List.605 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; - ret List.605; + let List.601 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; + ret List.601; procedure List.80 (#Derived_gen.14, #Derived_gen.15, #Derived_gen.16, #Derived_gen.17, #Derived_gen.18): - joinpoint List.652 List.442 List.443 List.444 List.445 List.446: - let List.654 : Int1 = CallByName Num.22 List.445 List.446; - if List.654 then - let List.662 : U8 = CallByName List.66 List.442 List.445; - let List.655 : [C {U64, Int1}, C {U64, Int1}] = CallByName TotallyNotJson.189 List.443 List.662; - let List.659 : U8 = 1i64; - let List.660 : U8 = GetTagId List.655; - let List.661 : Int1 = lowlevel Eq List.659 List.660; - if List.661 then - let List.447 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.655; - let List.657 : U64 = CallByName List.96 List.445; - jump List.652 List.442 List.447 List.444 List.657 List.446; + joinpoint List.648 List.440 List.441 List.442 List.443 List.444: + let List.650 : Int1 = CallByName Num.22 List.443 List.444; + if List.650 then + let List.659 : U8 = CallByName List.66 List.440 List.443; + let List.651 : [C {U64, Int1}, C {U64, Int1}] = CallByName TotallyNotJson.189 List.441 List.659; + let List.656 : U8 = 1i64; + let List.657 : U8 = GetTagId List.651; + let List.658 : Int1 = lowlevel Eq List.656 List.657; + if List.658 then + let List.445 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.651; + let List.654 : U64 = 1i64; + let List.653 : U64 = CallByName Num.51 List.443 List.654; + jump List.648 List.440 List.445 List.442 List.653 List.444; else - dec List.442; - let List.448 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.655; - let List.658 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) List.448; - ret List.658; + dec List.440; + let List.446 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.651; + let List.655 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) List.446; + ret List.655; else - dec List.442; - let List.653 : [C {U64, Int1}, C {U64, Int1}] = TagId(1) List.443; - ret List.653; + dec List.440; + let List.649 : [C {U64, Int1}, C {U64, Int1}] = TagId(1) List.441; + ret List.649; in - jump List.652 #Derived_gen.14 #Derived_gen.15 #Derived_gen.16 #Derived_gen.17 #Derived_gen.18; + jump List.648 #Derived_gen.14 #Derived_gen.15 #Derived_gen.16 #Derived_gen.17 #Derived_gen.18; -procedure List.80 (#Derived_gen.29, #Derived_gen.30, #Derived_gen.31, #Derived_gen.32, #Derived_gen.33): - joinpoint List.582 List.442 List.443 List.444 List.445 List.446: - let List.584 : Int1 = CallByName Num.22 List.445 List.446; - if List.584 then - let List.590 : U8 = CallByName List.66 List.442 List.445; - let List.585 : List U8 = CallByName List.147 List.443 List.590 List.444; - let List.587 : U64 = CallByName List.96 List.445; - jump List.582 List.442 List.585 List.444 List.587 List.446; +procedure List.80 (#Derived_gen.22, #Derived_gen.23, #Derived_gen.24, #Derived_gen.25, #Derived_gen.26): + joinpoint List.577 List.440 List.441 List.442 List.443 List.444: + let List.579 : Int1 = CallByName Num.22 List.443 List.444; + if List.579 then + let List.586 : U8 = CallByName List.66 List.440 List.443; + let List.580 : List U8 = CallByName List.145 List.441 List.586 List.442; + let List.583 : U64 = 1i64; + let List.582 : U64 = CallByName Num.51 List.443 List.583; + jump List.577 List.440 List.580 List.442 List.582 List.444; else - dec List.442; - ret List.443; + dec List.440; + ret List.441; in - jump List.582 #Derived_gen.29 #Derived_gen.30 #Derived_gen.31 #Derived_gen.32 #Derived_gen.33; + jump List.577 #Derived_gen.22 #Derived_gen.23 #Derived_gen.24 #Derived_gen.25 #Derived_gen.26; procedure List.80 (#Derived_gen.35, #Derived_gen.36, #Derived_gen.37, #Derived_gen.38, #Derived_gen.39): - joinpoint List.561 List.442 List.443 List.444 List.445 List.446: - let List.563 : Int1 = CallByName Num.22 List.445 List.446; - if List.563 then - let List.571 : {Str, Str} = CallByName List.66 List.442 List.445; - inc List.571; - let List.564 : {List U8, U64} = CallByName List.147 List.443 List.571 List.444; - let List.566 : U64 = CallByName List.96 List.445; - jump List.561 List.442 List.564 List.444 List.566 List.446; + joinpoint List.557 List.440 List.441 List.442 List.443 List.444: + let List.559 : Int1 = CallByName Num.22 List.443 List.444; + if List.559 then + let List.566 : {Str, Str} = CallByName List.66 List.440 List.443; + inc List.566; + let List.560 : {List U8, U64} = CallByName List.145 List.441 List.566 List.442; + let List.563 : U64 = 1i64; + let List.562 : U64 = CallByName Num.51 List.443 List.563; + jump List.557 List.440 List.560 List.442 List.562 List.444; else - dec List.442; - ret List.443; + dec List.440; + ret List.441; in - jump List.561 #Derived_gen.35 #Derived_gen.36 #Derived_gen.37 #Derived_gen.38 #Derived_gen.39; + jump List.557 #Derived_gen.35 #Derived_gen.36 #Derived_gen.37 #Derived_gen.38 #Derived_gen.39; -procedure List.93 (List.439, List.440, List.441): - let List.559 : U64 = 0i64; - let List.560 : U64 = CallByName List.6 List.439; - let List.558 : {List U8, U64} = CallByName List.80 List.439 List.440 List.441 List.559 List.560; - ret List.558; +procedure List.93 (List.437, List.438, List.439): + let List.555 : U64 = 0i64; + let List.556 : U64 = CallByName List.6 List.437; + let List.554 : {List U8, U64} = CallByName List.80 List.437 List.438 List.439 List.555 List.556; + ret List.554; -procedure List.93 (List.439, List.440, List.441): - let List.580 : U64 = 0i64; - let List.581 : U64 = CallByName List.6 List.439; - let List.579 : List U8 = CallByName List.80 List.439 List.440 List.441 List.580 List.581; - ret List.579; +procedure List.93 (List.437, List.438, List.439): + let List.575 : U64 = 0i64; + let List.576 : U64 = CallByName List.6 List.437; + let List.574 : List U8 = CallByName List.80 List.437 List.438 List.439 List.575 List.576; + ret List.574; -procedure List.93 (List.439, List.440, List.441): - let List.650 : U64 = 0i64; - let List.651 : U64 = CallByName List.6 List.439; - let List.649 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.80 List.439 List.440 List.441 List.650 List.651; - ret List.649; - -procedure List.96 (List.463): - let List.568 : U64 = 1i64; - let List.567 : U64 = CallByName Num.51 List.463 List.568; - ret List.567; +procedure List.93 (List.437, List.438, List.439): + let List.646 : U64 = 0i64; + let List.647 : U64 = CallByName List.6 List.437; + let List.645 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.80 List.437 List.438 List.439 List.646 List.647; + ret List.645; procedure Num.127 (#Attr.2): let Num.297 : U8 = lowlevel NumIntCast #Attr.2; @@ -293,58 +291,58 @@ procedure Num.21 (#Attr.2, #Attr.3): ret Num.303; procedure Num.22 (#Attr.2, #Attr.3): - let Num.307 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; - ret Num.307; - -procedure Num.24 (#Attr.2, #Attr.3): - let Num.309 : Int1 = lowlevel NumGt #Attr.2 #Attr.3; + let Num.309 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; ret Num.309; +procedure Num.24 (#Attr.2, #Attr.3): + let Num.311 : Int1 = lowlevel NumGt #Attr.2 #Attr.3; + ret Num.311; + procedure Num.51 (#Attr.2, #Attr.3): - let Num.304 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; - ret Num.304; + let Num.306 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; + ret Num.306; procedure Num.75 (#Attr.2, #Attr.3): - let Num.308 : U64 = lowlevel NumSubWrap #Attr.2 #Attr.3; - ret Num.308; + let Num.310 : U64 = lowlevel NumSubWrap #Attr.2 #Attr.3; + ret Num.310; procedure Num.94 (#Attr.2, #Attr.3): let Num.302 : U64 = lowlevel NumDivCeilUnchecked #Attr.2 #Attr.3; ret Num.302; procedure Str.12 (#Attr.2): - let Str.302 : List U8 = lowlevel StrToUtf8 #Attr.2; - ret Str.302; - -procedure Str.4 (#Attr.2, #Attr.3): - let Str.305 : Str = lowlevel StrJoinWith #Attr.2 #Attr.3; - ret Str.305; - -procedure Str.48 (#Attr.2, #Attr.3, #Attr.4): - let Str.300 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8Range #Attr.2 #Attr.3 #Attr.4; + let Str.300 : List U8 = lowlevel StrToUtf8 #Attr.2; ret Str.300; -procedure Str.55 (#Attr.2): - let Str.308 : List Str = lowlevel StrGraphemes #Attr.2; - ret Str.308; +procedure Str.4 (#Attr.2, #Attr.3): + let Str.303 : Str = lowlevel StrJoinWith #Attr.2 #Attr.3; + ret Str.303; -procedure Str.9 (Str.80): - let Str.298 : U64 = 0i64; - let Str.299 : U64 = CallByName List.6 Str.80; - let Str.81 : {U64, Str, Int1, U8} = CallByName Str.48 Str.80 Str.298 Str.299; - let Str.295 : Int1 = StructAtIndex 2 Str.81; - if Str.295 then - let Str.297 : Str = StructAtIndex 1 Str.81; - let Str.296 : [C {U64, U8}, C Str] = TagId(1) Str.297; - ret Str.296; +procedure Str.48 (#Attr.2, #Attr.3, #Attr.4): + let Str.298 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8Range #Attr.2 #Attr.3 #Attr.4; + ret Str.298; + +procedure Str.55 (#Attr.2): + let Str.306 : List Str = lowlevel StrGraphemes #Attr.2; + ret Str.306; + +procedure Str.9 (Str.79): + let Str.296 : U64 = 0i64; + let Str.297 : U64 = CallByName List.6 Str.79; + let Str.80 : {U64, Str, Int1, U8} = CallByName Str.48 Str.79 Str.296 Str.297; + let Str.293 : Int1 = StructAtIndex 2 Str.80; + if Str.293 then + let Str.295 : Str = StructAtIndex 1 Str.80; + let Str.294 : [C {U64, U8}, C Str] = TagId(1) Str.295; + ret Str.294; else - let Str.293 : U8 = StructAtIndex 3 Str.81; - let Str.294 : U64 = StructAtIndex 0 Str.81; - let #Derived_gen.40 : Str = StructAtIndex 1 Str.81; + let Str.291 : U8 = StructAtIndex 3 Str.80; + let Str.292 : U64 = StructAtIndex 0 Str.80; + let #Derived_gen.40 : Str = StructAtIndex 1 Str.80; dec #Derived_gen.40; - let Str.292 : {U64, U8} = Struct {Str.294, Str.293}; - let Str.291 : [C {U64, U8}, C Str] = TagId(0) Str.292; - ret Str.291; + let Str.290 : {U64, U8} = Struct {Str.292, Str.291}; + let Str.289 : [C {U64, U8}, C Str] = TagId(0) Str.290; + ret Str.289; procedure TotallyNotJson.100 (TotallyNotJson.850): let TotallyNotJson.1479 : Str = "a"; @@ -1294,7 +1292,7 @@ procedure TotallyNotJson.95 (TotallyNotJson.829): dec TotallyNotJson.1489; ret TotallyNotJson.1488; -procedure TotallyNotJson.96 (#Derived_gen.25): +procedure TotallyNotJson.96 (#Derived_gen.30): joinpoint TotallyNotJson.1496 TotallyNotJson.1168: let TotallyNotJson.834 : List Str = StructAtIndex 0 TotallyNotJson.1168; let TotallyNotJson.833 : List Str = StructAtIndex 1 TotallyNotJson.1168; @@ -1330,7 +1328,7 @@ procedure TotallyNotJson.96 (#Derived_gen.25): let TotallyNotJson.1497 : {List Str, List Str} = Struct {TotallyNotJson.834, TotallyNotJson.833}; ret TotallyNotJson.1497; in - jump TotallyNotJson.1496 #Derived_gen.25; + jump TotallyNotJson.1496 #Derived_gen.30; procedure TotallyNotJson.97 (TotallyNotJson.837): let TotallyNotJson.838 : List Str = CallByName Str.55 TotallyNotJson.837; diff --git a/crates/compiler/test_mono/generated/encode_derived_string.txt b/crates/compiler/test_mono/generated/encode_derived_string.txt index 90db775eb5..ad11e78a5a 100644 --- a/crates/compiler/test_mono/generated/encode_derived_string.txt +++ b/crates/compiler/test_mono/generated/encode_derived_string.txt @@ -15,134 +15,131 @@ procedure Encode.26 (Encode.105, Encode.106): let Encode.108 : List U8 = CallByName Encode.24 Encode.109 Encode.110 Encode.106; ret Encode.108; -procedure List.147 (List.148, List.149, List.146): - let List.558 : List U8 = CallByName TotallyNotJson.215 List.148 List.149; - ret List.558; +procedure List.145 (List.146, List.147, List.144): + let List.553 : List U8 = CallByName TotallyNotJson.215 List.146 List.147; + ret List.553; -procedure List.18 (List.144, List.145, List.146): - let List.539 : List U8 = CallByName List.93 List.144 List.145 List.146; - ret List.539; +procedure List.18 (List.142, List.143, List.144): + let List.535 : List U8 = CallByName List.93 List.142 List.143 List.144; + ret List.535; -procedure List.26 (List.161, List.162, List.163): - let List.575 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.93 List.161 List.162 List.163; - let List.578 : U8 = 1i64; - let List.579 : U8 = GetTagId List.575; - let List.580 : Int1 = lowlevel Eq List.578 List.579; - if List.580 then - let List.164 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.575; - ret List.164; +procedure List.26 (List.159, List.160, List.161): + let List.570 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.93 List.159 List.160 List.161; + let List.573 : U8 = 1i64; + let List.574 : U8 = GetTagId List.570; + let List.575 : Int1 = lowlevel Eq List.573 List.574; + if List.575 then + let List.162 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.570; + ret List.162; else - let List.165 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.575; - ret List.165; + let List.163 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.570; + ret List.163; -procedure List.49 (List.379, List.380): - let List.567 : U64 = StructAtIndex 0 List.380; - let List.568 : U64 = 0i64; - let List.565 : Int1 = CallByName Bool.11 List.567 List.568; - if List.565 then - dec List.379; - let List.566 : List U8 = Array []; - ret List.566; - else - let List.562 : U64 = StructAtIndex 1 List.380; - let List.563 : U64 = StructAtIndex 0 List.380; - let List.561 : List U8 = CallByName List.72 List.379 List.562 List.563; +procedure List.49 (List.377, List.378): + let List.562 : U64 = StructAtIndex 0 List.378; + let List.563 : U64 = 0i64; + let List.560 : Int1 = CallByName Bool.11 List.562 List.563; + if List.560 then + dec List.377; + let List.561 : List U8 = Array []; ret List.561; - -procedure List.52 (List.394, List.395): - let List.396 : U64 = CallByName List.6 List.394; - joinpoint List.573 List.397: - let List.571 : U64 = 0i64; - let List.570 : {U64, U64} = Struct {List.397, List.571}; - inc List.394; - let List.398 : List U8 = CallByName List.49 List.394 List.570; - let List.569 : U64 = CallByName Num.75 List.396 List.397; - let List.560 : {U64, U64} = Struct {List.569, List.397}; - let List.399 : List U8 = CallByName List.49 List.394 List.560; - let List.559 : {List U8, List U8} = Struct {List.398, List.399}; - ret List.559; - in - let List.574 : Int1 = CallByName Num.24 List.396 List.395; - if List.574 then - jump List.573 List.395; else - jump List.573 List.396; + let List.557 : U64 = StructAtIndex 1 List.378; + let List.558 : U64 = StructAtIndex 0 List.378; + let List.556 : List U8 = CallByName List.72 List.377 List.557 List.558; + ret List.556; + +procedure List.52 (List.392, List.393): + let List.394 : U64 = CallByName List.6 List.392; + joinpoint List.568 List.395: + let List.566 : U64 = 0i64; + let List.565 : {U64, U64} = Struct {List.395, List.566}; + inc List.392; + let List.396 : List U8 = CallByName List.49 List.392 List.565; + let List.564 : U64 = CallByName Num.75 List.394 List.395; + let List.555 : {U64, U64} = Struct {List.564, List.395}; + let List.397 : List U8 = CallByName List.49 List.392 List.555; + let List.554 : {List U8, List U8} = Struct {List.396, List.397}; + ret List.554; + in + let List.569 : Int1 = CallByName Num.24 List.394 List.393; + if List.569 then + jump List.568 List.393; + else + jump List.568 List.394; procedure List.6 (#Attr.2): - let List.538 : U64 = lowlevel ListLen #Attr.2; - ret List.538; - -procedure List.66 (#Attr.2, #Attr.3): - let List.556 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.556; - -procedure List.68 (#Attr.2): - let List.536 : List U8 = lowlevel ListWithCapacity #Attr.2; - ret List.536; - -procedure List.72 (#Attr.2, #Attr.3, #Attr.4): - let List.564 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; - ret List.564; - -procedure List.8 (#Attr.2, #Attr.3): - let List.534 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; + let List.534 : U64 = lowlevel ListLen #Attr.2; ret List.534; +procedure List.66 (#Attr.2, #Attr.3): + let List.551 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.551; + +procedure List.68 (#Attr.2): + let List.532 : List U8 = lowlevel ListWithCapacity #Attr.2; + ret List.532; + +procedure List.72 (#Attr.2, #Attr.3, #Attr.4): + let List.559 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; + ret List.559; + +procedure List.8 (#Attr.2, #Attr.3): + let List.530 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; + ret List.530; + procedure List.80 (#Derived_gen.0, #Derived_gen.1, #Derived_gen.2, #Derived_gen.3, #Derived_gen.4): - joinpoint List.545 List.442 List.443 List.444 List.445 List.446: - let List.547 : Int1 = CallByName Num.22 List.445 List.446; - if List.547 then - let List.555 : U8 = CallByName List.66 List.442 List.445; - let List.548 : List U8 = CallByName List.147 List.443 List.555 List.444; - let List.550 : U64 = CallByName List.96 List.445; - jump List.545 List.442 List.548 List.444 List.550 List.446; + joinpoint List.541 List.440 List.441 List.442 List.443 List.444: + let List.543 : Int1 = CallByName Num.22 List.443 List.444; + if List.543 then + let List.550 : U8 = CallByName List.66 List.440 List.443; + let List.544 : List U8 = CallByName List.145 List.441 List.550 List.442; + let List.547 : U64 = 1i64; + let List.546 : U64 = CallByName Num.51 List.443 List.547; + jump List.541 List.440 List.544 List.442 List.546 List.444; else - dec List.442; - ret List.443; + dec List.440; + ret List.441; in - jump List.545 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4; + jump List.541 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4; procedure List.80 (#Derived_gen.8, #Derived_gen.9, #Derived_gen.10, #Derived_gen.11, #Derived_gen.12): - joinpoint List.584 List.442 List.443 List.444 List.445 List.446: - let List.586 : Int1 = CallByName Num.22 List.445 List.446; - if List.586 then - let List.594 : U8 = CallByName List.66 List.442 List.445; - let List.587 : [C {U64, Int1}, C {U64, Int1}] = CallByName TotallyNotJson.189 List.443 List.594; - let List.591 : U8 = 1i64; - let List.592 : U8 = GetTagId List.587; - let List.593 : Int1 = lowlevel Eq List.591 List.592; - if List.593 then - let List.447 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.587; - let List.589 : U64 = CallByName List.96 List.445; - jump List.584 List.442 List.447 List.444 List.589 List.446; + joinpoint List.579 List.440 List.441 List.442 List.443 List.444: + let List.581 : Int1 = CallByName Num.22 List.443 List.444; + if List.581 then + let List.590 : U8 = CallByName List.66 List.440 List.443; + let List.582 : [C {U64, Int1}, C {U64, Int1}] = CallByName TotallyNotJson.189 List.441 List.590; + let List.587 : U8 = 1i64; + let List.588 : U8 = GetTagId List.582; + let List.589 : Int1 = lowlevel Eq List.587 List.588; + if List.589 then + let List.445 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.582; + let List.585 : U64 = 1i64; + let List.584 : U64 = CallByName Num.51 List.443 List.585; + jump List.579 List.440 List.445 List.442 List.584 List.444; else - dec List.442; - let List.448 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.587; - let List.590 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) List.448; - ret List.590; + dec List.440; + let List.446 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.582; + let List.586 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) List.446; + ret List.586; else - dec List.442; - let List.585 : [C {U64, Int1}, C {U64, Int1}] = TagId(1) List.443; - ret List.585; + dec List.440; + let List.580 : [C {U64, Int1}, C {U64, Int1}] = TagId(1) List.441; + ret List.580; in - jump List.584 #Derived_gen.8 #Derived_gen.9 #Derived_gen.10 #Derived_gen.11 #Derived_gen.12; + jump List.579 #Derived_gen.8 #Derived_gen.9 #Derived_gen.10 #Derived_gen.11 #Derived_gen.12; -procedure List.93 (List.439, List.440, List.441): - let List.543 : U64 = 0i64; - let List.544 : U64 = CallByName List.6 List.439; - let List.542 : List U8 = CallByName List.80 List.439 List.440 List.441 List.543 List.544; - ret List.542; +procedure List.93 (List.437, List.438, List.439): + let List.539 : U64 = 0i64; + let List.540 : U64 = CallByName List.6 List.437; + let List.538 : List U8 = CallByName List.80 List.437 List.438 List.439 List.539 List.540; + ret List.538; -procedure List.93 (List.439, List.440, List.441): - let List.582 : U64 = 0i64; - let List.583 : U64 = CallByName List.6 List.439; - let List.581 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.80 List.439 List.440 List.441 List.582 List.583; - ret List.581; - -procedure List.96 (List.463): - let List.552 : U64 = 1i64; - let List.551 : U64 = CallByName Num.51 List.463 List.552; - ret List.551; +procedure List.93 (List.437, List.438, List.439): + let List.577 : U64 = 0i64; + let List.578 : U64 = CallByName List.6 List.437; + let List.576 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.80 List.437 List.438 List.439 List.577 List.578; + ret List.576; procedure Num.19 (#Attr.2, #Attr.3): let Num.293 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; @@ -153,50 +150,50 @@ procedure Num.21 (#Attr.2, #Attr.3): ret Num.295; procedure Num.22 (#Attr.2, #Attr.3): - let Num.298 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; - ret Num.298; + let Num.299 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; + ret Num.299; procedure Num.24 (#Attr.2, #Attr.3): - let Num.300 : Int1 = lowlevel NumGt #Attr.2 #Attr.3; - ret Num.300; + let Num.301 : Int1 = lowlevel NumGt #Attr.2 #Attr.3; + ret Num.301; procedure Num.51 (#Attr.2, #Attr.3): - let Num.296 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; - ret Num.296; + let Num.297 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; + ret Num.297; procedure Num.75 (#Attr.2, #Attr.3): - let Num.299 : U64 = lowlevel NumSubWrap #Attr.2 #Attr.3; - ret Num.299; + let Num.300 : U64 = lowlevel NumSubWrap #Attr.2 #Attr.3; + ret Num.300; procedure Num.94 (#Attr.2, #Attr.3): let Num.294 : U64 = lowlevel NumDivCeilUnchecked #Attr.2 #Attr.3; ret Num.294; procedure Str.12 (#Attr.2): - let Str.301 : List U8 = lowlevel StrToUtf8 #Attr.2; - ret Str.301; + let Str.299 : List U8 = lowlevel StrToUtf8 #Attr.2; + ret Str.299; procedure Str.48 (#Attr.2, #Attr.3, #Attr.4): - let Str.300 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8Range #Attr.2 #Attr.3 #Attr.4; - ret Str.300; + let Str.298 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8Range #Attr.2 #Attr.3 #Attr.4; + ret Str.298; -procedure Str.9 (Str.80): - let Str.298 : U64 = 0i64; - let Str.299 : U64 = CallByName List.6 Str.80; - let Str.81 : {U64, Str, Int1, U8} = CallByName Str.48 Str.80 Str.298 Str.299; - let Str.295 : Int1 = StructAtIndex 2 Str.81; - if Str.295 then - let Str.297 : Str = StructAtIndex 1 Str.81; - let Str.296 : [C {U64, U8}, C Str] = TagId(1) Str.297; - ret Str.296; +procedure Str.9 (Str.79): + let Str.296 : U64 = 0i64; + let Str.297 : U64 = CallByName List.6 Str.79; + let Str.80 : {U64, Str, Int1, U8} = CallByName Str.48 Str.79 Str.296 Str.297; + let Str.293 : Int1 = StructAtIndex 2 Str.80; + if Str.293 then + let Str.295 : Str = StructAtIndex 1 Str.80; + let Str.294 : [C {U64, U8}, C Str] = TagId(1) Str.295; + ret Str.294; else - let Str.293 : U8 = StructAtIndex 3 Str.81; - let Str.294 : U64 = StructAtIndex 0 Str.81; - let #Derived_gen.13 : Str = StructAtIndex 1 Str.81; + let Str.291 : U8 = StructAtIndex 3 Str.80; + let Str.292 : U64 = StructAtIndex 0 Str.80; + let #Derived_gen.13 : Str = StructAtIndex 1 Str.80; dec #Derived_gen.13; - let Str.292 : {U64, U8} = Struct {Str.294, Str.293}; - let Str.291 : [C {U64, U8}, C Str] = TagId(0) Str.292; - ret Str.291; + let Str.290 : {U64, U8} = Struct {Str.292, Str.291}; + let Str.289 : [C {U64, U8}, C Str] = TagId(0) Str.290; + ret Str.289; procedure TotallyNotJson.182 (TotallyNotJson.183, TotallyNotJson.1175, TotallyNotJson.181): let TotallyNotJson.1178 : List U8 = CallByName TotallyNotJson.26 TotallyNotJson.181; diff --git a/crates/compiler/test_mono/generated/encode_derived_tag_one_field_string.txt b/crates/compiler/test_mono/generated/encode_derived_tag_one_field_string.txt index 947daf976f..62f8d58cd4 100644 --- a/crates/compiler/test_mono/generated/encode_derived_tag_one_field_string.txt +++ b/crates/compiler/test_mono/generated/encode_derived_tag_one_field_string.txt @@ -44,185 +44,183 @@ procedure Encode.26 (Encode.105, Encode.106): let Encode.108 : List U8 = CallByName Encode.24 Encode.109 Encode.110 Encode.106; ret Encode.108; -procedure List.147 (List.148, List.149, List.146): - let List.573 : {List U8, U64} = CallByName TotallyNotJson.267 List.148 List.149 List.146; - ret List.573; +procedure List.145 (List.146, List.147, List.144): + let List.568 : {List U8, U64} = CallByName TotallyNotJson.267 List.146 List.147 List.144; + ret List.568; -procedure List.147 (List.148, List.149, List.146): - let List.592 : List U8 = CallByName TotallyNotJson.215 List.148 List.149; - ret List.592; +procedure List.145 (List.146, List.147, List.144): + let List.588 : List U8 = CallByName TotallyNotJson.215 List.146 List.147; + ret List.588; -procedure List.18 (List.144, List.145, List.146): - let List.553 : {List U8, U64} = CallByName List.93 List.144 List.145 List.146; - ret List.553; +procedure List.18 (List.142, List.143, List.144): + let List.549 : {List U8, U64} = CallByName List.93 List.142 List.143 List.144; + ret List.549; -procedure List.18 (List.144, List.145, List.146): - let List.574 : List U8 = CallByName List.93 List.144 List.145 List.146; - ret List.574; +procedure List.18 (List.142, List.143, List.144): + let List.569 : List U8 = CallByName List.93 List.142 List.143 List.144; + ret List.569; -procedure List.26 (List.161, List.162, List.163): - let List.623 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.93 List.161 List.162 List.163; - let List.626 : U8 = 1i64; - let List.627 : U8 = GetTagId List.623; - let List.628 : Int1 = lowlevel Eq List.626 List.627; - if List.628 then - let List.164 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.623; - ret List.164; +procedure List.26 (List.159, List.160, List.161): + let List.619 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.93 List.159 List.160 List.161; + let List.622 : U8 = 1i64; + let List.623 : U8 = GetTagId List.619; + let List.624 : Int1 = lowlevel Eq List.622 List.623; + if List.624 then + let List.162 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.619; + ret List.162; else - let List.165 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.623; - ret List.165; + let List.163 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.619; + ret List.163; -procedure List.4 (List.115, List.116): - let List.552 : U64 = 1i64; - let List.551 : List U8 = CallByName List.70 List.115 List.552; - let List.550 : List U8 = CallByName List.71 List.551 List.116; - ret List.550; +procedure List.4 (List.113, List.114): + let List.548 : U64 = 1i64; + let List.547 : List U8 = CallByName List.70 List.113 List.548; + let List.546 : List U8 = CallByName List.71 List.547 List.114; + ret List.546; -procedure List.49 (List.379, List.380): - let List.615 : U64 = StructAtIndex 0 List.380; - let List.616 : U64 = 0i64; - let List.613 : Int1 = CallByName Bool.11 List.615 List.616; - if List.613 then - dec List.379; - let List.614 : List U8 = Array []; - ret List.614; +procedure List.49 (List.377, List.378): + let List.611 : U64 = StructAtIndex 0 List.378; + let List.612 : U64 = 0i64; + let List.609 : Int1 = CallByName Bool.11 List.611 List.612; + if List.609 then + dec List.377; + let List.610 : List U8 = Array []; + ret List.610; else - let List.610 : U64 = StructAtIndex 1 List.380; - let List.611 : U64 = StructAtIndex 0 List.380; - let List.609 : List U8 = CallByName List.72 List.379 List.610 List.611; - ret List.609; + let List.606 : U64 = StructAtIndex 1 List.378; + let List.607 : U64 = StructAtIndex 0 List.378; + let List.605 : List U8 = CallByName List.72 List.377 List.606 List.607; + ret List.605; -procedure List.52 (List.394, List.395): - let List.396 : U64 = CallByName List.6 List.394; - joinpoint List.621 List.397: - let List.619 : U64 = 0i64; - let List.618 : {U64, U64} = Struct {List.397, List.619}; - inc List.394; - let List.398 : List U8 = CallByName List.49 List.394 List.618; - let List.617 : U64 = CallByName Num.75 List.396 List.397; - let List.608 : {U64, U64} = Struct {List.617, List.397}; - let List.399 : List U8 = CallByName List.49 List.394 List.608; - let List.607 : {List U8, List U8} = Struct {List.398, List.399}; - ret List.607; +procedure List.52 (List.392, List.393): + let List.394 : U64 = CallByName List.6 List.392; + joinpoint List.617 List.395: + let List.615 : U64 = 0i64; + let List.614 : {U64, U64} = Struct {List.395, List.615}; + inc List.392; + let List.396 : List U8 = CallByName List.49 List.392 List.614; + let List.613 : U64 = CallByName Num.75 List.394 List.395; + let List.604 : {U64, U64} = Struct {List.613, List.395}; + let List.397 : List U8 = CallByName List.49 List.392 List.604; + let List.603 : {List U8, List U8} = Struct {List.396, List.397}; + ret List.603; in - let List.622 : Int1 = CallByName Num.24 List.396 List.395; - if List.622 then - jump List.621 List.395; + let List.618 : Int1 = CallByName Num.24 List.394 List.393; + if List.618 then + jump List.617 List.393; else - jump List.621 List.396; + jump List.617 List.394; procedure List.6 (#Attr.2): - let List.593 : U64 = lowlevel ListLen #Attr.2; - ret List.593; - -procedure List.6 (#Attr.2): - let List.595 : U64 = lowlevel ListLen #Attr.2; - ret List.595; - -procedure List.66 (#Attr.2, #Attr.3): - let List.570 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.570; - -procedure List.66 (#Attr.2, #Attr.3): - let List.589 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + let List.589 : U64 = lowlevel ListLen #Attr.2; ret List.589; +procedure List.6 (#Attr.2): + let List.591 : U64 = lowlevel ListLen #Attr.2; + ret List.591; + +procedure List.66 (#Attr.2, #Attr.3): + let List.565 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.565; + +procedure List.66 (#Attr.2, #Attr.3): + let List.585 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.585; + procedure List.68 (#Attr.2): - let List.606 : List U8 = lowlevel ListWithCapacity #Attr.2; - ret List.606; + let List.602 : List U8 = lowlevel ListWithCapacity #Attr.2; + ret List.602; procedure List.70 (#Attr.2, #Attr.3): - let List.531 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.531; + let List.527 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.527; procedure List.71 (#Attr.2, #Attr.3): - let List.529 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.529; + let List.525 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.525; procedure List.72 (#Attr.2, #Attr.3, #Attr.4): - let List.612 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; - ret List.612; + let List.608 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; + ret List.608; procedure List.8 (#Attr.2, #Attr.3): - let List.604 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; - ret List.604; + let List.600 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; + ret List.600; -procedure List.80 (#Derived_gen.13, #Derived_gen.14, #Derived_gen.15, #Derived_gen.16, #Derived_gen.17): - joinpoint List.580 List.442 List.443 List.444 List.445 List.446: - let List.582 : Int1 = CallByName Num.22 List.445 List.446; - if List.582 then - let List.588 : U8 = CallByName List.66 List.442 List.445; - let List.583 : List U8 = CallByName List.147 List.443 List.588 List.444; - let List.585 : U64 = CallByName List.96 List.445; - jump List.580 List.442 List.583 List.444 List.585 List.446; +procedure List.80 (#Derived_gen.16, #Derived_gen.17, #Derived_gen.18, #Derived_gen.19, #Derived_gen.20): + joinpoint List.575 List.440 List.441 List.442 List.443 List.444: + let List.577 : Int1 = CallByName Num.22 List.443 List.444; + if List.577 then + let List.584 : U8 = CallByName List.66 List.440 List.443; + let List.578 : List U8 = CallByName List.145 List.441 List.584 List.442; + let List.581 : U64 = 1i64; + let List.580 : U64 = CallByName Num.51 List.443 List.581; + jump List.575 List.440 List.578 List.442 List.580 List.444; else - dec List.442; - ret List.443; + dec List.440; + ret List.441; in - jump List.580 #Derived_gen.13 #Derived_gen.14 #Derived_gen.15 #Derived_gen.16 #Derived_gen.17; + jump List.575 #Derived_gen.16 #Derived_gen.17 #Derived_gen.18 #Derived_gen.19 #Derived_gen.20; procedure List.80 (#Derived_gen.21, #Derived_gen.22, #Derived_gen.23, #Derived_gen.24, #Derived_gen.25): - joinpoint List.559 List.442 List.443 List.444 List.445 List.446: - let List.561 : Int1 = CallByName Num.22 List.445 List.446; - if List.561 then - let List.569 : Str = CallByName List.66 List.442 List.445; - inc List.569; - let List.562 : {List U8, U64} = CallByName List.147 List.443 List.569 List.444; - let List.564 : U64 = CallByName List.96 List.445; - jump List.559 List.442 List.562 List.444 List.564 List.446; + joinpoint List.628 List.440 List.441 List.442 List.443 List.444: + let List.630 : Int1 = CallByName Num.22 List.443 List.444; + if List.630 then + let List.639 : U8 = CallByName List.66 List.440 List.443; + let List.631 : [C {U64, Int1}, C {U64, Int1}] = CallByName TotallyNotJson.189 List.441 List.639; + let List.636 : U8 = 1i64; + let List.637 : U8 = GetTagId List.631; + let List.638 : Int1 = lowlevel Eq List.636 List.637; + if List.638 then + let List.445 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.631; + let List.634 : U64 = 1i64; + let List.633 : U64 = CallByName Num.51 List.443 List.634; + jump List.628 List.440 List.445 List.442 List.633 List.444; + else + dec List.440; + let List.446 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.631; + let List.635 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) List.446; + ret List.635; else - dec List.442; - ret List.443; + dec List.440; + let List.629 : [C {U64, Int1}, C {U64, Int1}] = TagId(1) List.441; + ret List.629; in - jump List.559 #Derived_gen.21 #Derived_gen.22 #Derived_gen.23 #Derived_gen.24 #Derived_gen.25; + jump List.628 #Derived_gen.21 #Derived_gen.22 #Derived_gen.23 #Derived_gen.24 #Derived_gen.25; procedure List.80 (#Derived_gen.29, #Derived_gen.30, #Derived_gen.31, #Derived_gen.32, #Derived_gen.33): - joinpoint List.632 List.442 List.443 List.444 List.445 List.446: - let List.634 : Int1 = CallByName Num.22 List.445 List.446; - if List.634 then - let List.642 : U8 = CallByName List.66 List.442 List.445; - let List.635 : [C {U64, Int1}, C {U64, Int1}] = CallByName TotallyNotJson.189 List.443 List.642; - let List.639 : U8 = 1i64; - let List.640 : U8 = GetTagId List.635; - let List.641 : Int1 = lowlevel Eq List.639 List.640; - if List.641 then - let List.447 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.635; - let List.637 : U64 = CallByName List.96 List.445; - jump List.632 List.442 List.447 List.444 List.637 List.446; - else - dec List.442; - let List.448 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.635; - let List.638 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) List.448; - ret List.638; + joinpoint List.555 List.440 List.441 List.442 List.443 List.444: + let List.557 : Int1 = CallByName Num.22 List.443 List.444; + if List.557 then + let List.564 : Str = CallByName List.66 List.440 List.443; + inc List.564; + let List.558 : {List U8, U64} = CallByName List.145 List.441 List.564 List.442; + let List.561 : U64 = 1i64; + let List.560 : U64 = CallByName Num.51 List.443 List.561; + jump List.555 List.440 List.558 List.442 List.560 List.444; else - dec List.442; - let List.633 : [C {U64, Int1}, C {U64, Int1}] = TagId(1) List.443; - ret List.633; + dec List.440; + ret List.441; in - jump List.632 #Derived_gen.29 #Derived_gen.30 #Derived_gen.31 #Derived_gen.32 #Derived_gen.33; + jump List.555 #Derived_gen.29 #Derived_gen.30 #Derived_gen.31 #Derived_gen.32 #Derived_gen.33; -procedure List.93 (List.439, List.440, List.441): - let List.557 : U64 = 0i64; - let List.558 : U64 = CallByName List.6 List.439; - let List.556 : {List U8, U64} = CallByName List.80 List.439 List.440 List.441 List.557 List.558; - ret List.556; +procedure List.93 (List.437, List.438, List.439): + let List.553 : U64 = 0i64; + let List.554 : U64 = CallByName List.6 List.437; + let List.552 : {List U8, U64} = CallByName List.80 List.437 List.438 List.439 List.553 List.554; + ret List.552; -procedure List.93 (List.439, List.440, List.441): - let List.578 : U64 = 0i64; - let List.579 : U64 = CallByName List.6 List.439; - let List.577 : List U8 = CallByName List.80 List.439 List.440 List.441 List.578 List.579; - ret List.577; +procedure List.93 (List.437, List.438, List.439): + let List.573 : U64 = 0i64; + let List.574 : U64 = CallByName List.6 List.437; + let List.572 : List U8 = CallByName List.80 List.437 List.438 List.439 List.573 List.574; + ret List.572; -procedure List.93 (List.439, List.440, List.441): - let List.630 : U64 = 0i64; - let List.631 : U64 = CallByName List.6 List.439; - let List.629 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.80 List.439 List.440 List.441 List.630 List.631; - ret List.629; - -procedure List.96 (List.463): - let List.566 : U64 = 1i64; - let List.565 : U64 = CallByName Num.51 List.463 List.566; - ret List.565; +procedure List.93 (List.437, List.438, List.439): + let List.626 : U64 = 0i64; + let List.627 : U64 = CallByName List.6 List.437; + let List.625 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.80 List.437 List.438 List.439 List.626 List.627; + ret List.625; procedure Num.127 (#Attr.2): let Num.299 : U8 = lowlevel NumIntCast #Attr.2; @@ -241,50 +239,50 @@ procedure Num.21 (#Attr.2, #Attr.3): ret Num.305; procedure Num.22 (#Attr.2, #Attr.3): - let Num.309 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; - ret Num.309; - -procedure Num.24 (#Attr.2, #Attr.3): - let Num.311 : Int1 = lowlevel NumGt #Attr.2 #Attr.3; + let Num.311 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; ret Num.311; +procedure Num.24 (#Attr.2, #Attr.3): + let Num.313 : Int1 = lowlevel NumGt #Attr.2 #Attr.3; + ret Num.313; + procedure Num.51 (#Attr.2, #Attr.3): - let Num.306 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; - ret Num.306; + let Num.308 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; + ret Num.308; procedure Num.75 (#Attr.2, #Attr.3): - let Num.310 : U64 = lowlevel NumSubWrap #Attr.2 #Attr.3; - ret Num.310; + let Num.312 : U64 = lowlevel NumSubWrap #Attr.2 #Attr.3; + ret Num.312; procedure Num.94 (#Attr.2, #Attr.3): let Num.304 : U64 = lowlevel NumDivCeilUnchecked #Attr.2 #Attr.3; ret Num.304; procedure Str.12 (#Attr.2): - let Str.302 : List U8 = lowlevel StrToUtf8 #Attr.2; - ret Str.302; - -procedure Str.48 (#Attr.2, #Attr.3, #Attr.4): - let Str.300 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8Range #Attr.2 #Attr.3 #Attr.4; + let Str.300 : List U8 = lowlevel StrToUtf8 #Attr.2; ret Str.300; -procedure Str.9 (Str.80): - let Str.298 : U64 = 0i64; - let Str.299 : U64 = CallByName List.6 Str.80; - let Str.81 : {U64, Str, Int1, U8} = CallByName Str.48 Str.80 Str.298 Str.299; - let Str.295 : Int1 = StructAtIndex 2 Str.81; - if Str.295 then - let Str.297 : Str = StructAtIndex 1 Str.81; - let Str.296 : [C {U64, U8}, C Str] = TagId(1) Str.297; - ret Str.296; +procedure Str.48 (#Attr.2, #Attr.3, #Attr.4): + let Str.298 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8Range #Attr.2 #Attr.3 #Attr.4; + ret Str.298; + +procedure Str.9 (Str.79): + let Str.296 : U64 = 0i64; + let Str.297 : U64 = CallByName List.6 Str.79; + let Str.80 : {U64, Str, Int1, U8} = CallByName Str.48 Str.79 Str.296 Str.297; + let Str.293 : Int1 = StructAtIndex 2 Str.80; + if Str.293 then + let Str.295 : Str = StructAtIndex 1 Str.80; + let Str.294 : [C {U64, U8}, C Str] = TagId(1) Str.295; + ret Str.294; else - let Str.293 : U8 = StructAtIndex 3 Str.81; - let Str.294 : U64 = StructAtIndex 0 Str.81; - let #Derived_gen.34 : Str = StructAtIndex 1 Str.81; + let Str.291 : U8 = StructAtIndex 3 Str.80; + let Str.292 : U64 = StructAtIndex 0 Str.80; + let #Derived_gen.34 : Str = StructAtIndex 1 Str.80; dec #Derived_gen.34; - let Str.292 : {U64, U8} = Struct {Str.294, Str.293}; - let Str.291 : [C {U64, U8}, C Str] = TagId(0) Str.292; - ret Str.291; + let Str.290 : {U64, U8} = Struct {Str.292, Str.291}; + let Str.289 : [C {U64, U8}, C Str] = TagId(0) Str.290; + ret Str.289; procedure TotallyNotJson.182 (TotallyNotJson.183, TotallyNotJson.1216, TotallyNotJson.181): let TotallyNotJson.1219 : List U8 = CallByName TotallyNotJson.26 TotallyNotJson.181; diff --git a/crates/compiler/test_mono/generated/encode_derived_tag_two_payloads_string.txt b/crates/compiler/test_mono/generated/encode_derived_tag_two_payloads_string.txt index 28405e9664..bca8a4af90 100644 --- a/crates/compiler/test_mono/generated/encode_derived_tag_two_payloads_string.txt +++ b/crates/compiler/test_mono/generated/encode_derived_tag_two_payloads_string.txt @@ -47,185 +47,183 @@ procedure Encode.26 (Encode.105, Encode.106): let Encode.108 : List U8 = CallByName Encode.24 Encode.109 Encode.110 Encode.106; ret Encode.108; -procedure List.147 (List.148, List.149, List.146): - let List.573 : {List U8, U64} = CallByName TotallyNotJson.267 List.148 List.149 List.146; - ret List.573; +procedure List.145 (List.146, List.147, List.144): + let List.568 : {List U8, U64} = CallByName TotallyNotJson.267 List.146 List.147 List.144; + ret List.568; -procedure List.147 (List.148, List.149, List.146): - let List.592 : List U8 = CallByName TotallyNotJson.215 List.148 List.149; - ret List.592; +procedure List.145 (List.146, List.147, List.144): + let List.588 : List U8 = CallByName TotallyNotJson.215 List.146 List.147; + ret List.588; -procedure List.18 (List.144, List.145, List.146): - let List.553 : {List U8, U64} = CallByName List.93 List.144 List.145 List.146; - ret List.553; +procedure List.18 (List.142, List.143, List.144): + let List.549 : {List U8, U64} = CallByName List.93 List.142 List.143 List.144; + ret List.549; -procedure List.18 (List.144, List.145, List.146): - let List.574 : List U8 = CallByName List.93 List.144 List.145 List.146; - ret List.574; +procedure List.18 (List.142, List.143, List.144): + let List.569 : List U8 = CallByName List.93 List.142 List.143 List.144; + ret List.569; -procedure List.26 (List.161, List.162, List.163): - let List.623 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.93 List.161 List.162 List.163; - let List.626 : U8 = 1i64; - let List.627 : U8 = GetTagId List.623; - let List.628 : Int1 = lowlevel Eq List.626 List.627; - if List.628 then - let List.164 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.623; - ret List.164; +procedure List.26 (List.159, List.160, List.161): + let List.619 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.93 List.159 List.160 List.161; + let List.622 : U8 = 1i64; + let List.623 : U8 = GetTagId List.619; + let List.624 : Int1 = lowlevel Eq List.622 List.623; + if List.624 then + let List.162 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.619; + ret List.162; else - let List.165 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.623; - ret List.165; + let List.163 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.619; + ret List.163; -procedure List.4 (List.115, List.116): - let List.552 : U64 = 1i64; - let List.551 : List U8 = CallByName List.70 List.115 List.552; - let List.550 : List U8 = CallByName List.71 List.551 List.116; - ret List.550; +procedure List.4 (List.113, List.114): + let List.548 : U64 = 1i64; + let List.547 : List U8 = CallByName List.70 List.113 List.548; + let List.546 : List U8 = CallByName List.71 List.547 List.114; + ret List.546; -procedure List.49 (List.379, List.380): - let List.615 : U64 = StructAtIndex 0 List.380; - let List.616 : U64 = 0i64; - let List.613 : Int1 = CallByName Bool.11 List.615 List.616; - if List.613 then - dec List.379; - let List.614 : List U8 = Array []; - ret List.614; +procedure List.49 (List.377, List.378): + let List.611 : U64 = StructAtIndex 0 List.378; + let List.612 : U64 = 0i64; + let List.609 : Int1 = CallByName Bool.11 List.611 List.612; + if List.609 then + dec List.377; + let List.610 : List U8 = Array []; + ret List.610; else - let List.610 : U64 = StructAtIndex 1 List.380; - let List.611 : U64 = StructAtIndex 0 List.380; - let List.609 : List U8 = CallByName List.72 List.379 List.610 List.611; - ret List.609; + let List.606 : U64 = StructAtIndex 1 List.378; + let List.607 : U64 = StructAtIndex 0 List.378; + let List.605 : List U8 = CallByName List.72 List.377 List.606 List.607; + ret List.605; -procedure List.52 (List.394, List.395): - let List.396 : U64 = CallByName List.6 List.394; - joinpoint List.621 List.397: - let List.619 : U64 = 0i64; - let List.618 : {U64, U64} = Struct {List.397, List.619}; - inc List.394; - let List.398 : List U8 = CallByName List.49 List.394 List.618; - let List.617 : U64 = CallByName Num.75 List.396 List.397; - let List.608 : {U64, U64} = Struct {List.617, List.397}; - let List.399 : List U8 = CallByName List.49 List.394 List.608; - let List.607 : {List U8, List U8} = Struct {List.398, List.399}; - ret List.607; +procedure List.52 (List.392, List.393): + let List.394 : U64 = CallByName List.6 List.392; + joinpoint List.617 List.395: + let List.615 : U64 = 0i64; + let List.614 : {U64, U64} = Struct {List.395, List.615}; + inc List.392; + let List.396 : List U8 = CallByName List.49 List.392 List.614; + let List.613 : U64 = CallByName Num.75 List.394 List.395; + let List.604 : {U64, U64} = Struct {List.613, List.395}; + let List.397 : List U8 = CallByName List.49 List.392 List.604; + let List.603 : {List U8, List U8} = Struct {List.396, List.397}; + ret List.603; in - let List.622 : Int1 = CallByName Num.24 List.396 List.395; - if List.622 then - jump List.621 List.395; + let List.618 : Int1 = CallByName Num.24 List.394 List.393; + if List.618 then + jump List.617 List.393; else - jump List.621 List.396; + jump List.617 List.394; procedure List.6 (#Attr.2): - let List.593 : U64 = lowlevel ListLen #Attr.2; - ret List.593; - -procedure List.6 (#Attr.2): - let List.595 : U64 = lowlevel ListLen #Attr.2; - ret List.595; - -procedure List.66 (#Attr.2, #Attr.3): - let List.570 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.570; - -procedure List.66 (#Attr.2, #Attr.3): - let List.589 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + let List.589 : U64 = lowlevel ListLen #Attr.2; ret List.589; +procedure List.6 (#Attr.2): + let List.591 : U64 = lowlevel ListLen #Attr.2; + ret List.591; + +procedure List.66 (#Attr.2, #Attr.3): + let List.565 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.565; + +procedure List.66 (#Attr.2, #Attr.3): + let List.585 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.585; + procedure List.68 (#Attr.2): - let List.606 : List U8 = lowlevel ListWithCapacity #Attr.2; - ret List.606; + let List.602 : List U8 = lowlevel ListWithCapacity #Attr.2; + ret List.602; procedure List.70 (#Attr.2, #Attr.3): - let List.531 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.531; + let List.527 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.527; procedure List.71 (#Attr.2, #Attr.3): - let List.529 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.529; + let List.525 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.525; procedure List.72 (#Attr.2, #Attr.3, #Attr.4): - let List.612 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; - ret List.612; + let List.608 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; + ret List.608; procedure List.8 (#Attr.2, #Attr.3): - let List.604 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; - ret List.604; + let List.600 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; + ret List.600; -procedure List.80 (#Derived_gen.11, #Derived_gen.12, #Derived_gen.13, #Derived_gen.14, #Derived_gen.15): - joinpoint List.632 List.442 List.443 List.444 List.445 List.446: - let List.634 : Int1 = CallByName Num.22 List.445 List.446; - if List.634 then - let List.642 : U8 = CallByName List.66 List.442 List.445; - let List.635 : [C {U64, Int1}, C {U64, Int1}] = CallByName TotallyNotJson.189 List.443 List.642; - let List.639 : U8 = 1i64; - let List.640 : U8 = GetTagId List.635; - let List.641 : Int1 = lowlevel Eq List.639 List.640; - if List.641 then - let List.447 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.635; - let List.637 : U64 = CallByName List.96 List.445; - jump List.632 List.442 List.447 List.444 List.637 List.446; +procedure List.80 (#Derived_gen.14, #Derived_gen.15, #Derived_gen.16, #Derived_gen.17, #Derived_gen.18): + joinpoint List.628 List.440 List.441 List.442 List.443 List.444: + let List.630 : Int1 = CallByName Num.22 List.443 List.444; + if List.630 then + let List.639 : U8 = CallByName List.66 List.440 List.443; + let List.631 : [C {U64, Int1}, C {U64, Int1}] = CallByName TotallyNotJson.189 List.441 List.639; + let List.636 : U8 = 1i64; + let List.637 : U8 = GetTagId List.631; + let List.638 : Int1 = lowlevel Eq List.636 List.637; + if List.638 then + let List.445 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.631; + let List.634 : U64 = 1i64; + let List.633 : U64 = CallByName Num.51 List.443 List.634; + jump List.628 List.440 List.445 List.442 List.633 List.444; else - dec List.442; - let List.448 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.635; - let List.638 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) List.448; - ret List.638; + dec List.440; + let List.446 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.631; + let List.635 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) List.446; + ret List.635; else - dec List.442; - let List.633 : [C {U64, Int1}, C {U64, Int1}] = TagId(1) List.443; - ret List.633; + dec List.440; + let List.629 : [C {U64, Int1}, C {U64, Int1}] = TagId(1) List.441; + ret List.629; in - jump List.632 #Derived_gen.11 #Derived_gen.12 #Derived_gen.13 #Derived_gen.14 #Derived_gen.15; + jump List.628 #Derived_gen.14 #Derived_gen.15 #Derived_gen.16 #Derived_gen.17 #Derived_gen.18; procedure List.80 (#Derived_gen.19, #Derived_gen.20, #Derived_gen.21, #Derived_gen.22, #Derived_gen.23): - joinpoint List.559 List.442 List.443 List.444 List.445 List.446: - let List.561 : Int1 = CallByName Num.22 List.445 List.446; - if List.561 then - let List.569 : Str = CallByName List.66 List.442 List.445; - inc List.569; - let List.562 : {List U8, U64} = CallByName List.147 List.443 List.569 List.444; - let List.564 : U64 = CallByName List.96 List.445; - jump List.559 List.442 List.562 List.444 List.564 List.446; + joinpoint List.555 List.440 List.441 List.442 List.443 List.444: + let List.557 : Int1 = CallByName Num.22 List.443 List.444; + if List.557 then + let List.564 : Str = CallByName List.66 List.440 List.443; + inc List.564; + let List.558 : {List U8, U64} = CallByName List.145 List.441 List.564 List.442; + let List.561 : U64 = 1i64; + let List.560 : U64 = CallByName Num.51 List.443 List.561; + jump List.555 List.440 List.558 List.442 List.560 List.444; else - dec List.442; - ret List.443; + dec List.440; + ret List.441; in - jump List.559 #Derived_gen.19 #Derived_gen.20 #Derived_gen.21 #Derived_gen.22 #Derived_gen.23; + jump List.555 #Derived_gen.19 #Derived_gen.20 #Derived_gen.21 #Derived_gen.22 #Derived_gen.23; procedure List.80 (#Derived_gen.30, #Derived_gen.31, #Derived_gen.32, #Derived_gen.33, #Derived_gen.34): - joinpoint List.580 List.442 List.443 List.444 List.445 List.446: - let List.582 : Int1 = CallByName Num.22 List.445 List.446; - if List.582 then - let List.588 : U8 = CallByName List.66 List.442 List.445; - let List.583 : List U8 = CallByName List.147 List.443 List.588 List.444; - let List.585 : U64 = CallByName List.96 List.445; - jump List.580 List.442 List.583 List.444 List.585 List.446; + joinpoint List.575 List.440 List.441 List.442 List.443 List.444: + let List.577 : Int1 = CallByName Num.22 List.443 List.444; + if List.577 then + let List.584 : U8 = CallByName List.66 List.440 List.443; + let List.578 : List U8 = CallByName List.145 List.441 List.584 List.442; + let List.581 : U64 = 1i64; + let List.580 : U64 = CallByName Num.51 List.443 List.581; + jump List.575 List.440 List.578 List.442 List.580 List.444; else - dec List.442; - ret List.443; + dec List.440; + ret List.441; in - jump List.580 #Derived_gen.30 #Derived_gen.31 #Derived_gen.32 #Derived_gen.33 #Derived_gen.34; + jump List.575 #Derived_gen.30 #Derived_gen.31 #Derived_gen.32 #Derived_gen.33 #Derived_gen.34; -procedure List.93 (List.439, List.440, List.441): - let List.557 : U64 = 0i64; - let List.558 : U64 = CallByName List.6 List.439; - let List.556 : {List U8, U64} = CallByName List.80 List.439 List.440 List.441 List.557 List.558; - ret List.556; +procedure List.93 (List.437, List.438, List.439): + let List.553 : U64 = 0i64; + let List.554 : U64 = CallByName List.6 List.437; + let List.552 : {List U8, U64} = CallByName List.80 List.437 List.438 List.439 List.553 List.554; + ret List.552; -procedure List.93 (List.439, List.440, List.441): - let List.578 : U64 = 0i64; - let List.579 : U64 = CallByName List.6 List.439; - let List.577 : List U8 = CallByName List.80 List.439 List.440 List.441 List.578 List.579; - ret List.577; +procedure List.93 (List.437, List.438, List.439): + let List.573 : U64 = 0i64; + let List.574 : U64 = CallByName List.6 List.437; + let List.572 : List U8 = CallByName List.80 List.437 List.438 List.439 List.573 List.574; + ret List.572; -procedure List.93 (List.439, List.440, List.441): - let List.630 : U64 = 0i64; - let List.631 : U64 = CallByName List.6 List.439; - let List.629 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.80 List.439 List.440 List.441 List.630 List.631; - ret List.629; - -procedure List.96 (List.463): - let List.566 : U64 = 1i64; - let List.565 : U64 = CallByName Num.51 List.463 List.566; - ret List.565; +procedure List.93 (List.437, List.438, List.439): + let List.626 : U64 = 0i64; + let List.627 : U64 = CallByName List.6 List.437; + let List.625 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.80 List.437 List.438 List.439 List.626 List.627; + ret List.625; procedure Num.127 (#Attr.2): let Num.299 : U8 = lowlevel NumIntCast #Attr.2; @@ -244,50 +242,50 @@ procedure Num.21 (#Attr.2, #Attr.3): ret Num.305; procedure Num.22 (#Attr.2, #Attr.3): - let Num.309 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; - ret Num.309; - -procedure Num.24 (#Attr.2, #Attr.3): - let Num.311 : Int1 = lowlevel NumGt #Attr.2 #Attr.3; + let Num.311 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; ret Num.311; +procedure Num.24 (#Attr.2, #Attr.3): + let Num.313 : Int1 = lowlevel NumGt #Attr.2 #Attr.3; + ret Num.313; + procedure Num.51 (#Attr.2, #Attr.3): - let Num.306 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; - ret Num.306; + let Num.308 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; + ret Num.308; procedure Num.75 (#Attr.2, #Attr.3): - let Num.310 : U64 = lowlevel NumSubWrap #Attr.2 #Attr.3; - ret Num.310; + let Num.312 : U64 = lowlevel NumSubWrap #Attr.2 #Attr.3; + ret Num.312; procedure Num.94 (#Attr.2, #Attr.3): let Num.304 : U64 = lowlevel NumDivCeilUnchecked #Attr.2 #Attr.3; ret Num.304; procedure Str.12 (#Attr.2): - let Str.302 : List U8 = lowlevel StrToUtf8 #Attr.2; - ret Str.302; - -procedure Str.48 (#Attr.2, #Attr.3, #Attr.4): - let Str.300 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8Range #Attr.2 #Attr.3 #Attr.4; + let Str.300 : List U8 = lowlevel StrToUtf8 #Attr.2; ret Str.300; -procedure Str.9 (Str.80): - let Str.298 : U64 = 0i64; - let Str.299 : U64 = CallByName List.6 Str.80; - let Str.81 : {U64, Str, Int1, U8} = CallByName Str.48 Str.80 Str.298 Str.299; - let Str.295 : Int1 = StructAtIndex 2 Str.81; - if Str.295 then - let Str.297 : Str = StructAtIndex 1 Str.81; - let Str.296 : [C {U64, U8}, C Str] = TagId(1) Str.297; - ret Str.296; +procedure Str.48 (#Attr.2, #Attr.3, #Attr.4): + let Str.298 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8Range #Attr.2 #Attr.3 #Attr.4; + ret Str.298; + +procedure Str.9 (Str.79): + let Str.296 : U64 = 0i64; + let Str.297 : U64 = CallByName List.6 Str.79; + let Str.80 : {U64, Str, Int1, U8} = CallByName Str.48 Str.79 Str.296 Str.297; + let Str.293 : Int1 = StructAtIndex 2 Str.80; + if Str.293 then + let Str.295 : Str = StructAtIndex 1 Str.80; + let Str.294 : [C {U64, U8}, C Str] = TagId(1) Str.295; + ret Str.294; else - let Str.293 : U8 = StructAtIndex 3 Str.81; - let Str.294 : U64 = StructAtIndex 0 Str.81; - let #Derived_gen.35 : Str = StructAtIndex 1 Str.81; + let Str.291 : U8 = StructAtIndex 3 Str.80; + let Str.292 : U64 = StructAtIndex 0 Str.80; + let #Derived_gen.35 : Str = StructAtIndex 1 Str.80; dec #Derived_gen.35; - let Str.292 : {U64, U8} = Struct {Str.294, Str.293}; - let Str.291 : [C {U64, U8}, C Str] = TagId(0) Str.292; - ret Str.291; + let Str.290 : {U64, U8} = Struct {Str.292, Str.291}; + let Str.289 : [C {U64, U8}, C Str] = TagId(0) Str.290; + ret Str.289; procedure TotallyNotJson.182 (TotallyNotJson.183, TotallyNotJson.1216, TotallyNotJson.181): let TotallyNotJson.1219 : List U8 = CallByName TotallyNotJson.26 TotallyNotJson.181; diff --git a/crates/compiler/test_mono/generated/ir_int_add.txt b/crates/compiler/test_mono/generated/ir_int_add.txt index 468ef440b5..4fce0b055a 100644 --- a/crates/compiler/test_mono/generated/ir_int_add.txt +++ b/crates/compiler/test_mono/generated/ir_int_add.txt @@ -1,6 +1,6 @@ procedure List.6 (#Attr.2): - let List.526 : U64 = lowlevel ListLen #Attr.2; - ret List.526; + let List.522 : U64 = lowlevel ListLen #Attr.2; + ret List.522; procedure Num.19 (#Attr.2, #Attr.3): let Num.294 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/issue_2583_specialize_errors_behind_unified_branches.txt b/crates/compiler/test_mono/generated/issue_2583_specialize_errors_behind_unified_branches.txt index 0674ea784d..1e6379681d 100644 --- a/crates/compiler/test_mono/generated/issue_2583_specialize_errors_behind_unified_branches.txt +++ b/crates/compiler/test_mono/generated/issue_2583_specialize_errors_behind_unified_branches.txt @@ -6,69 +6,69 @@ procedure Bool.2 (): let Bool.23 : Int1 = true; ret Bool.23; -procedure List.2 (List.99, List.100): - let List.540 : U64 = CallByName List.6 List.99; - let List.536 : Int1 = CallByName Num.22 List.100 List.540; - if List.536 then - let List.538 : I64 = CallByName List.66 List.99 List.100; - dec List.99; - let List.537 : [C {}, C I64] = TagId(1) List.538; - ret List.537; +procedure List.2 (List.97, List.98): + let List.536 : U64 = CallByName List.6 List.97; + let List.532 : Int1 = CallByName Num.22 List.98 List.536; + if List.532 then + let List.534 : I64 = CallByName List.66 List.97 List.98; + dec List.97; + let List.533 : [C {}, C I64] = TagId(1) List.534; + ret List.533; else - dec List.99; - let List.535 : {} = Struct {}; - let List.534 : [C {}, C I64] = TagId(0) List.535; - ret List.534; + dec List.97; + let List.531 : {} = Struct {}; + let List.530 : [C {}, C I64] = TagId(0) List.531; + ret List.530; procedure List.6 (#Attr.2): - let List.541 : U64 = lowlevel ListLen #Attr.2; - ret List.541; + let List.537 : U64 = lowlevel ListLen #Attr.2; + ret List.537; procedure List.66 (#Attr.2, #Attr.3): - let List.539 : I64 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.539; + let List.535 : I64 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.535; -procedure List.9 (List.295): - let List.533 : U64 = 0i64; - let List.526 : [C {}, C I64] = CallByName List.2 List.295 List.533; - let List.530 : U8 = 1i64; - let List.531 : U8 = GetTagId List.526; - let List.532 : Int1 = lowlevel Eq List.530 List.531; - if List.532 then - let List.296 : I64 = UnionAtIndex (Id 1) (Index 0) List.526; - let List.527 : [C Int1, C I64] = TagId(1) List.296; - ret List.527; +procedure List.9 (List.293): + let List.529 : U64 = 0i64; + let List.522 : [C {}, C I64] = CallByName List.2 List.293 List.529; + let List.526 : U8 = 1i64; + let List.527 : U8 = GetTagId List.522; + let List.528 : Int1 = lowlevel Eq List.526 List.527; + if List.528 then + let List.294 : I64 = UnionAtIndex (Id 1) (Index 0) List.522; + let List.523 : [C Int1, C I64] = TagId(1) List.294; + ret List.523; else - let List.529 : Int1 = true; - let List.528 : [C Int1, C I64] = TagId(0) List.529; - ret List.528; + let List.525 : Int1 = true; + let List.524 : [C Int1, C I64] = TagId(0) List.525; + ret List.524; procedure Num.22 (#Attr.2, #Attr.3): let Num.292 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; ret Num.292; -procedure Str.27 (Str.100): - let Str.291 : [C Int1, C I64] = CallByName Str.72 Str.100; - ret Str.291; +procedure Str.27 (Str.99): + let Str.289 : [C Int1, C I64] = CallByName Str.72 Str.99; + ret Str.289; procedure Str.47 (#Attr.2): - let Str.299 : {I64, U8} = lowlevel StrToNum #Attr.2; - ret Str.299; + let Str.297 : {I64, U8} = lowlevel StrToNum #Attr.2; + ret Str.297; -procedure Str.72 (Str.236): - let Str.237 : {I64, U8} = CallByName Str.47 Str.236; - dec Str.236; - let Str.297 : U8 = StructAtIndex 1 Str.237; - let Str.298 : U8 = 0i64; - let Str.294 : Int1 = CallByName Bool.11 Str.297 Str.298; - if Str.294 then - let Str.296 : I64 = StructAtIndex 0 Str.237; - let Str.295 : [C Int1, C I64] = TagId(1) Str.296; - ret Str.295; +procedure Str.72 (Str.235): + let Str.236 : {I64, U8} = CallByName Str.47 Str.235; + dec Str.235; + let Str.295 : U8 = StructAtIndex 1 Str.236; + let Str.296 : U8 = 0i64; + let Str.292 : Int1 = CallByName Bool.11 Str.295 Str.296; + if Str.292 then + let Str.294 : I64 = StructAtIndex 0 Str.236; + let Str.293 : [C Int1, C I64] = TagId(1) Str.294; + ret Str.293; else - let Str.293 : Int1 = false; - let Str.292 : [C Int1, C I64] = TagId(0) Str.293; - ret Str.292; + let Str.291 : Int1 = false; + let Str.290 : [C Int1, C I64] = TagId(0) Str.291; + ret Str.290; procedure Test.0 (): let Test.3 : Int1 = CallByName Bool.2; diff --git a/crates/compiler/test_mono/generated/issue_4749.txt b/crates/compiler/test_mono/generated/issue_4749.txt index 2d513bf108..5399a3a0cc 100644 --- a/crates/compiler/test_mono/generated/issue_4749.txt +++ b/crates/compiler/test_mono/generated/issue_4749.txt @@ -64,140 +64,136 @@ procedure Decode.27 (Decode.107, Decode.108): let Decode.123 : [C [C List U8, C ], C Str] = TagId(0) Decode.124; ret Decode.123; -procedure List.1 (List.98): - let List.593 : U64 = CallByName List.6 List.98; - dec List.98; - let List.594 : U64 = 0i64; - let List.592 : Int1 = CallByName Bool.11 List.593 List.594; - ret List.592; +procedure List.1 (List.96): + let List.589 : U64 = CallByName List.6 List.96; + dec List.96; + let List.590 : U64 = 0i64; + let List.588 : Int1 = CallByName Bool.11 List.589 List.590; + ret List.588; -procedure List.2 (List.99, List.100): - let List.576 : U64 = CallByName List.6 List.99; - let List.573 : Int1 = CallByName Num.22 List.100 List.576; - if List.573 then - let List.575 : U8 = CallByName List.66 List.99 List.100; - dec List.99; - let List.574 : [C {}, C U8] = TagId(1) List.575; - ret List.574; +procedure List.2 (List.97, List.98): + let List.572 : U64 = CallByName List.6 List.97; + let List.569 : Int1 = CallByName Num.22 List.98 List.572; + if List.569 then + let List.571 : U8 = CallByName List.66 List.97 List.98; + dec List.97; + let List.570 : [C {}, C U8] = TagId(1) List.571; + ret List.570; else - dec List.99; - let List.572 : {} = Struct {}; - let List.571 : [C {}, C U8] = TagId(0) List.572; - ret List.571; + dec List.97; + let List.568 : {} = Struct {}; + let List.567 : [C {}, C U8] = TagId(0) List.568; + ret List.567; -procedure List.26 (List.161, List.162, List.163): - let List.595 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = CallByName List.93 List.161 List.162 List.163; - let List.598 : U8 = 1i64; - let List.599 : U8 = GetTagId List.595; - let List.600 : Int1 = lowlevel Eq List.598 List.599; - if List.600 then - let List.164 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = UnionAtIndex (Id 1) (Index 0) List.595; - ret List.164; +procedure List.26 (List.159, List.160, List.161): + let List.591 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = CallByName List.93 List.159 List.160 List.161; + let List.594 : U8 = 1i64; + let List.595 : U8 = GetTagId List.591; + let List.596 : Int1 = lowlevel Eq List.594 List.595; + if List.596 then + let List.162 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = UnionAtIndex (Id 1) (Index 0) List.591; + ret List.162; else - let List.165 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = UnionAtIndex (Id 0) (Index 0) List.595; - ret List.165; + let List.163 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = UnionAtIndex (Id 0) (Index 0) List.591; + ret List.163; -procedure List.29 (List.306, List.307): - let List.550 : U64 = CallByName List.6 List.306; - let List.308 : U64 = CallByName Num.77 List.550 List.307; - let List.549 : List U8 = CallByName List.43 List.306 List.308; - ret List.549; +procedure List.29 (List.304, List.305): + let List.546 : U64 = CallByName List.6 List.304; + let List.306 : U64 = CallByName Num.77 List.546 List.305; + let List.545 : List U8 = CallByName List.43 List.304 List.306; + ret List.545; procedure List.31 (#Attr.2, #Attr.3): - let List.563 : List U8 = lowlevel ListDropAt #Attr.2 #Attr.3; - ret List.563; + let List.559 : List U8 = lowlevel ListDropAt #Attr.2 #Attr.3; + ret List.559; -procedure List.38 (List.300): - let List.562 : U64 = 0i64; - let List.561 : List U8 = CallByName List.31 List.300 List.562; - ret List.561; - -procedure List.4 (List.115, List.116): - let List.560 : U64 = 1i64; - let List.559 : List U8 = CallByName List.70 List.115 List.560; - let List.558 : List U8 = CallByName List.71 List.559 List.116; - ret List.558; - -procedure List.43 (List.304, List.305): - let List.542 : U64 = CallByName List.6 List.304; - let List.541 : U64 = CallByName Num.77 List.542 List.305; - let List.532 : {U64, U64} = Struct {List.305, List.541}; - let List.531 : List U8 = CallByName List.49 List.304 List.532; - ret List.531; - -procedure List.49 (List.379, List.380): - let List.589 : U64 = StructAtIndex 0 List.380; - let List.590 : U64 = 0i64; - let List.587 : Int1 = CallByName Bool.11 List.589 List.590; - if List.587 then - dec List.379; - let List.588 : List U8 = Array []; - ret List.588; - else - let List.585 : U64 = StructAtIndex 1 List.380; - let List.586 : U64 = StructAtIndex 0 List.380; - let List.584 : List U8 = CallByName List.72 List.379 List.585 List.586; - ret List.584; - -procedure List.6 (#Attr.2): - let List.617 : U64 = lowlevel ListLen #Attr.2; - ret List.617; - -procedure List.66 (#Attr.2, #Attr.3): - let List.569 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.569; - -procedure List.70 (#Attr.2, #Attr.3): - let List.557 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; +procedure List.38 (List.298): + let List.558 : U64 = 0i64; + let List.557 : List U8 = CallByName List.31 List.298 List.558; ret List.557; +procedure List.4 (List.113, List.114): + let List.556 : U64 = 1i64; + let List.555 : List U8 = CallByName List.70 List.113 List.556; + let List.554 : List U8 = CallByName List.71 List.555 List.114; + ret List.554; + +procedure List.43 (List.302, List.303): + let List.538 : U64 = CallByName List.6 List.302; + let List.537 : U64 = CallByName Num.77 List.538 List.303; + let List.528 : {U64, U64} = Struct {List.303, List.537}; + let List.527 : List U8 = CallByName List.49 List.302 List.528; + ret List.527; + +procedure List.49 (List.377, List.378): + let List.585 : U64 = StructAtIndex 0 List.378; + let List.586 : U64 = 0i64; + let List.583 : Int1 = CallByName Bool.11 List.585 List.586; + if List.583 then + dec List.377; + let List.584 : List U8 = Array []; + ret List.584; + else + let List.581 : U64 = StructAtIndex 1 List.378; + let List.582 : U64 = StructAtIndex 0 List.378; + let List.580 : List U8 = CallByName List.72 List.377 List.581 List.582; + ret List.580; + +procedure List.6 (#Attr.2): + let List.612 : U64 = lowlevel ListLen #Attr.2; + ret List.612; + +procedure List.66 (#Attr.2, #Attr.3): + let List.565 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.565; + +procedure List.70 (#Attr.2, #Attr.3): + let List.553 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.553; + procedure List.71 (#Attr.2, #Attr.3): - let List.555 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.555; + let List.551 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.551; procedure List.72 (#Attr.2, #Attr.3, #Attr.4): - let List.536 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; - ret List.536; + let List.532 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; + ret List.532; procedure List.8 (#Attr.2, #Attr.3): - let List.552 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; - ret List.552; + let List.548 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; + ret List.548; procedure List.80 (#Derived_gen.0, #Derived_gen.1, #Derived_gen.2, #Derived_gen.3, #Derived_gen.4): - joinpoint List.604 List.442 List.443 List.444 List.445 List.446: - let List.606 : Int1 = CallByName Num.22 List.445 List.446; - if List.606 then - let List.616 : U8 = CallByName List.66 List.442 List.445; - let List.607 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = CallByName TotallyNotJson.62 List.443 List.616; - let List.613 : U8 = 1i64; - let List.614 : U8 = GetTagId List.607; - let List.615 : Int1 = lowlevel Eq List.613 List.614; - if List.615 then - let List.447 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = UnionAtIndex (Id 1) (Index 0) List.607; - let List.609 : U64 = CallByName List.96 List.445; - jump List.604 List.442 List.447 List.444 List.609 List.446; + joinpoint List.600 List.440 List.441 List.442 List.443 List.444: + let List.602 : Int1 = CallByName Num.22 List.443 List.444; + if List.602 then + let List.611 : U8 = CallByName List.66 List.440 List.443; + let List.603 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = CallByName TotallyNotJson.62 List.441 List.611; + let List.608 : U8 = 1i64; + let List.609 : U8 = GetTagId List.603; + let List.610 : Int1 = lowlevel Eq List.608 List.609; + if List.610 then + let List.445 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = UnionAtIndex (Id 1) (Index 0) List.603; + let List.606 : U64 = 1i64; + let List.605 : U64 = CallByName Num.51 List.443 List.606; + jump List.600 List.440 List.445 List.442 List.605 List.444; else - dec List.442; - let List.448 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = UnionAtIndex (Id 0) (Index 0) List.607; - let List.612 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = TagId(0) List.448; - ret List.612; + dec List.440; + let List.446 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = UnionAtIndex (Id 0) (Index 0) List.603; + let List.607 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = TagId(0) List.446; + ret List.607; else - dec List.442; - let List.605 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = TagId(1) List.443; - ret List.605; + dec List.440; + let List.601 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = TagId(1) List.441; + ret List.601; in - jump List.604 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4; + jump List.600 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4; -procedure List.93 (List.439, List.440, List.441): - let List.602 : U64 = 0i64; - let List.603 : U64 = CallByName List.6 List.439; - let List.601 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = CallByName List.80 List.439 List.440 List.441 List.602 List.603; - ret List.601; - -procedure List.96 (List.463): - let List.611 : U64 = 1i64; - let List.610 : U64 = CallByName Num.51 List.463 List.611; - ret List.610; +procedure List.93 (List.437, List.438, List.439): + let List.598 : U64 = 0i64; + let List.599 : U64 = CallByName List.6 List.437; + let List.597 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = CallByName List.80 List.437 List.438 List.439 List.598 List.599; + ret List.597; procedure Num.19 (#Attr.2, #Attr.3): let Num.295 : U8 = lowlevel NumAdd #Attr.2 #Attr.3; @@ -240,26 +236,26 @@ procedure Num.77 (#Attr.2, #Attr.3): ret Num.325; procedure Str.48 (#Attr.2, #Attr.3, #Attr.4): - let Str.300 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8Range #Attr.2 #Attr.3 #Attr.4; - ret Str.300; + let Str.298 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8Range #Attr.2 #Attr.3 #Attr.4; + ret Str.298; -procedure Str.9 (Str.80): - let Str.298 : U64 = 0i64; - let Str.299 : U64 = CallByName List.6 Str.80; - let Str.81 : {U64, Str, Int1, U8} = CallByName Str.48 Str.80 Str.298 Str.299; - let Str.295 : Int1 = StructAtIndex 2 Str.81; - if Str.295 then - let Str.297 : Str = StructAtIndex 1 Str.81; - let Str.296 : [C {U64, U8}, C Str] = TagId(1) Str.297; - ret Str.296; +procedure Str.9 (Str.79): + let Str.296 : U64 = 0i64; + let Str.297 : U64 = CallByName List.6 Str.79; + let Str.80 : {U64, Str, Int1, U8} = CallByName Str.48 Str.79 Str.296 Str.297; + let Str.293 : Int1 = StructAtIndex 2 Str.80; + if Str.293 then + let Str.295 : Str = StructAtIndex 1 Str.80; + let Str.294 : [C {U64, U8}, C Str] = TagId(1) Str.295; + ret Str.294; else - let Str.293 : U8 = StructAtIndex 3 Str.81; - let Str.294 : U64 = StructAtIndex 0 Str.81; - let #Derived_gen.6 : Str = StructAtIndex 1 Str.81; + let Str.291 : U8 = StructAtIndex 3 Str.80; + let Str.292 : U64 = StructAtIndex 0 Str.80; + let #Derived_gen.6 : Str = StructAtIndex 1 Str.80; dec #Derived_gen.6; - let Str.292 : {U64, U8} = Struct {Str.294, Str.293}; - let Str.291 : [C {U64, U8}, C Str] = TagId(0) Str.292; - ret Str.291; + let Str.290 : {U64, U8} = Struct {Str.292, Str.291}; + let Str.289 : [C {U64, U8}, C Str] = TagId(0) Str.290; + ret Str.289; procedure Test.3 (): let Test.0 : List U8 = Array [82i64, 111i64, 99i64]; diff --git a/crates/compiler/test_mono/generated/issue_4770.txt b/crates/compiler/test_mono/generated/issue_4770.txt index 8b0d25dace..2bf66aad68 100644 --- a/crates/compiler/test_mono/generated/issue_4770.txt +++ b/crates/compiler/test_mono/generated/issue_4770.txt @@ -6,84 +6,80 @@ procedure Bool.2 (): let Bool.24 : Int1 = true; ret Bool.24; -procedure List.196 (List.528, List.197, List.195): - let List.559 : Int1 = CallByName Test.1 List.197; - if List.559 then - let List.561 : {} = Struct {}; - let List.560 : [C {}, C {}] = TagId(1) List.561; - ret List.560; +procedure List.194 (List.524, List.195, List.193): + let List.554 : Int1 = CallByName Test.1 List.195; + if List.554 then + let List.556 : {} = Struct {}; + let List.555 : [C {}, C {}] = TagId(1) List.556; + ret List.555; else - let List.558 : {} = Struct {}; - let List.557 : [C {}, C {}] = TagId(0) List.558; - ret List.557; + let List.553 : {} = Struct {}; + let List.552 : [C {}, C {}] = TagId(0) List.553; + ret List.552; procedure List.23 (#Attr.2, #Attr.3, #Attr.4): - let List.562 : List {[C I64, C List *self], [C I64, C List *self]} = lowlevel ListMap2 { xs: `#Attr.#arg1`, ys: `#Attr.#arg2` } #Attr.2 #Attr.3 Test.15 #Attr.4; + let List.557 : List {[C I64, C List *self], [C I64, C List *self]} = lowlevel ListMap2 { xs: `#Attr.#arg1`, ys: `#Attr.#arg2` } #Attr.2 #Attr.3 Test.15 #Attr.4; decref #Attr.3; decref #Attr.2; - ret List.562; + ret List.557; -procedure List.56 (List.194, List.195): - let List.537 : {} = Struct {}; - let List.529 : [C {}, C {}] = CallByName List.93 List.194 List.537 List.195; - let List.534 : U8 = 1i64; - let List.535 : U8 = GetTagId List.529; - let List.536 : Int1 = lowlevel Eq List.534 List.535; - if List.536 then - let List.530 : Int1 = CallByName Bool.2; - ret List.530; +procedure List.56 (List.192, List.193): + let List.533 : {} = Struct {}; + let List.525 : [C {}, C {}] = CallByName List.93 List.192 List.533 List.193; + let List.530 : U8 = 1i64; + let List.531 : U8 = GetTagId List.525; + let List.532 : Int1 = lowlevel Eq List.530 List.531; + if List.532 then + let List.526 : Int1 = CallByName Bool.2; + ret List.526; else - let List.531 : Int1 = CallByName Bool.1; - ret List.531; + let List.527 : Int1 = CallByName Bool.1; + ret List.527; procedure List.6 (#Attr.2): - let List.527 : U64 = lowlevel ListLen #Attr.2; - ret List.527; + let List.523 : U64 = lowlevel ListLen #Attr.2; + ret List.523; procedure List.6 (#Attr.2): - let List.556 : U64 = lowlevel ListLen #Attr.2; - ret List.556; + let List.551 : U64 = lowlevel ListLen #Attr.2; + ret List.551; procedure List.66 (#Attr.2, #Attr.3): - let List.555 : {[C I64, C List *self], [C I64, C List *self]} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.555; + let List.550 : {[C I64, C List *self], [C I64, C List *self]} = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.550; procedure List.80 (#Derived_gen.1, #Derived_gen.2, #Derived_gen.3, #Derived_gen.4, #Derived_gen.5): - joinpoint List.542 List.442 List.443 List.444 List.445 List.446: - let List.544 : Int1 = CallByName Num.22 List.445 List.446; - if List.544 then - let List.554 : {[C I64, C List *self], [C I64, C List *self]} = CallByName List.66 List.442 List.445; - inc List.554; - let List.545 : [C {}, C {}] = CallByName List.196 List.443 List.554 List.444; - let List.551 : U8 = 1i64; - let List.552 : U8 = GetTagId List.545; - let List.553 : Int1 = lowlevel Eq List.551 List.552; - if List.553 then - let List.447 : {} = UnionAtIndex (Id 1) (Index 0) List.545; - let List.547 : U64 = CallByName List.96 List.445; - jump List.542 List.442 List.447 List.444 List.547 List.446; + joinpoint List.538 List.440 List.441 List.442 List.443 List.444: + let List.540 : Int1 = CallByName Num.22 List.443 List.444; + if List.540 then + let List.549 : {[C I64, C List *self], [C I64, C List *self]} = CallByName List.66 List.440 List.443; + inc List.549; + let List.541 : [C {}, C {}] = CallByName List.194 List.441 List.549 List.442; + let List.546 : U8 = 1i64; + let List.547 : U8 = GetTagId List.541; + let List.548 : Int1 = lowlevel Eq List.546 List.547; + if List.548 then + let List.445 : {} = UnionAtIndex (Id 1) (Index 0) List.541; + let List.544 : U64 = 1i64; + let List.543 : U64 = CallByName Num.51 List.443 List.544; + jump List.538 List.440 List.445 List.442 List.543 List.444; else - dec List.442; - let List.448 : {} = UnionAtIndex (Id 0) (Index 0) List.545; - let List.550 : [C {}, C {}] = TagId(0) List.448; - ret List.550; + dec List.440; + let List.446 : {} = UnionAtIndex (Id 0) (Index 0) List.541; + let List.545 : [C {}, C {}] = TagId(0) List.446; + ret List.545; else - dec List.442; - let List.543 : [C {}, C {}] = TagId(1) List.443; - ret List.543; + dec List.440; + let List.539 : [C {}, C {}] = TagId(1) List.441; + ret List.539; in - jump List.542 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4 #Derived_gen.5; + jump List.538 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4 #Derived_gen.5; -procedure List.93 (List.439, List.440, List.441): - let List.540 : U64 = 0i64; - let List.541 : U64 = CallByName List.6 List.439; - let List.539 : [C {}, C {}] = CallByName List.80 List.439 List.440 List.441 List.540 List.541; - ret List.539; - -procedure List.96 (List.463): - let List.549 : U64 = 1i64; - let List.548 : U64 = CallByName Num.51 List.463 List.549; - ret List.548; +procedure List.93 (List.437, List.438, List.439): + let List.536 : U64 = 0i64; + let List.537 : U64 = CallByName List.6 List.437; + let List.535 : [C {}, C {}] = CallByName List.80 List.437 List.438 List.439 List.536 List.537; + ret List.535; procedure Num.22 (#Attr.2, #Attr.3): let Num.292 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/issue_4772_weakened_monomorphic_destructure.txt b/crates/compiler/test_mono/generated/issue_4772_weakened_monomorphic_destructure.txt index 366e1528bf..ad45dfce6d 100644 --- a/crates/compiler/test_mono/generated/issue_4772_weakened_monomorphic_destructure.txt +++ b/crates/compiler/test_mono/generated/issue_4772_weakened_monomorphic_destructure.txt @@ -38,140 +38,136 @@ procedure Decode.26 (Decode.105, Decode.106): let Decode.122 : {List U8, [C {}, C Str]} = CallByName Decode.25 Decode.105 Decode.123 Decode.106; ret Decode.122; -procedure List.1 (List.98): - let List.589 : U64 = CallByName List.6 List.98; - dec List.98; - let List.590 : U64 = 0i64; - let List.588 : Int1 = CallByName Bool.11 List.589 List.590; - ret List.588; +procedure List.1 (List.96): + let List.585 : U64 = CallByName List.6 List.96; + dec List.96; + let List.586 : U64 = 0i64; + let List.584 : Int1 = CallByName Bool.11 List.585 List.586; + ret List.584; -procedure List.2 (List.99, List.100): - let List.572 : U64 = CallByName List.6 List.99; - let List.569 : Int1 = CallByName Num.22 List.100 List.572; - if List.569 then - let List.571 : U8 = CallByName List.66 List.99 List.100; - dec List.99; - let List.570 : [C {}, C U8] = TagId(1) List.571; - ret List.570; +procedure List.2 (List.97, List.98): + let List.568 : U64 = CallByName List.6 List.97; + let List.565 : Int1 = CallByName Num.22 List.98 List.568; + if List.565 then + let List.567 : U8 = CallByName List.66 List.97 List.98; + dec List.97; + let List.566 : [C {}, C U8] = TagId(1) List.567; + ret List.566; else - dec List.99; - let List.568 : {} = Struct {}; - let List.567 : [C {}, C U8] = TagId(0) List.568; - ret List.567; + dec List.97; + let List.564 : {} = Struct {}; + let List.563 : [C {}, C U8] = TagId(0) List.564; + ret List.563; -procedure List.26 (List.161, List.162, List.163): - let List.591 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = CallByName List.93 List.161 List.162 List.163; - let List.594 : U8 = 1i64; - let List.595 : U8 = GetTagId List.591; - let List.596 : Int1 = lowlevel Eq List.594 List.595; - if List.596 then - let List.164 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = UnionAtIndex (Id 1) (Index 0) List.591; - ret List.164; +procedure List.26 (List.159, List.160, List.161): + let List.587 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = CallByName List.93 List.159 List.160 List.161; + let List.590 : U8 = 1i64; + let List.591 : U8 = GetTagId List.587; + let List.592 : Int1 = lowlevel Eq List.590 List.591; + if List.592 then + let List.162 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = UnionAtIndex (Id 1) (Index 0) List.587; + ret List.162; else - let List.165 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = UnionAtIndex (Id 0) (Index 0) List.591; - ret List.165; + let List.163 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = UnionAtIndex (Id 0) (Index 0) List.587; + ret List.163; -procedure List.29 (List.306, List.307): - let List.546 : U64 = CallByName List.6 List.306; - let List.308 : U64 = CallByName Num.77 List.546 List.307; - let List.545 : List U8 = CallByName List.43 List.306 List.308; - ret List.545; +procedure List.29 (List.304, List.305): + let List.542 : U64 = CallByName List.6 List.304; + let List.306 : U64 = CallByName Num.77 List.542 List.305; + let List.541 : List U8 = CallByName List.43 List.304 List.306; + ret List.541; procedure List.31 (#Attr.2, #Attr.3): - let List.559 : List U8 = lowlevel ListDropAt #Attr.2 #Attr.3; - ret List.559; + let List.555 : List U8 = lowlevel ListDropAt #Attr.2 #Attr.3; + ret List.555; -procedure List.38 (List.300): - let List.558 : U64 = 0i64; - let List.557 : List U8 = CallByName List.31 List.300 List.558; - ret List.557; - -procedure List.4 (List.115, List.116): - let List.556 : U64 = 1i64; - let List.555 : List U8 = CallByName List.70 List.115 List.556; - let List.554 : List U8 = CallByName List.71 List.555 List.116; - ret List.554; - -procedure List.43 (List.304, List.305): - let List.538 : U64 = CallByName List.6 List.304; - let List.537 : U64 = CallByName Num.77 List.538 List.305; - let List.528 : {U64, U64} = Struct {List.305, List.537}; - let List.527 : List U8 = CallByName List.49 List.304 List.528; - ret List.527; - -procedure List.49 (List.379, List.380): - let List.585 : U64 = StructAtIndex 0 List.380; - let List.586 : U64 = 0i64; - let List.583 : Int1 = CallByName Bool.11 List.585 List.586; - if List.583 then - dec List.379; - let List.584 : List U8 = Array []; - ret List.584; - else - let List.581 : U64 = StructAtIndex 1 List.380; - let List.582 : U64 = StructAtIndex 0 List.380; - let List.580 : List U8 = CallByName List.72 List.379 List.581 List.582; - ret List.580; - -procedure List.6 (#Attr.2): - let List.613 : U64 = lowlevel ListLen #Attr.2; - ret List.613; - -procedure List.66 (#Attr.2, #Attr.3): - let List.565 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.565; - -procedure List.70 (#Attr.2, #Attr.3): - let List.553 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; +procedure List.38 (List.298): + let List.554 : U64 = 0i64; + let List.553 : List U8 = CallByName List.31 List.298 List.554; ret List.553; +procedure List.4 (List.113, List.114): + let List.552 : U64 = 1i64; + let List.551 : List U8 = CallByName List.70 List.113 List.552; + let List.550 : List U8 = CallByName List.71 List.551 List.114; + ret List.550; + +procedure List.43 (List.302, List.303): + let List.534 : U64 = CallByName List.6 List.302; + let List.533 : U64 = CallByName Num.77 List.534 List.303; + let List.524 : {U64, U64} = Struct {List.303, List.533}; + let List.523 : List U8 = CallByName List.49 List.302 List.524; + ret List.523; + +procedure List.49 (List.377, List.378): + let List.581 : U64 = StructAtIndex 0 List.378; + let List.582 : U64 = 0i64; + let List.579 : Int1 = CallByName Bool.11 List.581 List.582; + if List.579 then + dec List.377; + let List.580 : List U8 = Array []; + ret List.580; + else + let List.577 : U64 = StructAtIndex 1 List.378; + let List.578 : U64 = StructAtIndex 0 List.378; + let List.576 : List U8 = CallByName List.72 List.377 List.577 List.578; + ret List.576; + +procedure List.6 (#Attr.2): + let List.608 : U64 = lowlevel ListLen #Attr.2; + ret List.608; + +procedure List.66 (#Attr.2, #Attr.3): + let List.561 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.561; + +procedure List.70 (#Attr.2, #Attr.3): + let List.549 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.549; + procedure List.71 (#Attr.2, #Attr.3): - let List.551 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.551; + let List.547 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.547; procedure List.72 (#Attr.2, #Attr.3, #Attr.4): - let List.532 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; - ret List.532; + let List.528 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; + ret List.528; procedure List.8 (#Attr.2, #Attr.3): - let List.548 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; - ret List.548; + let List.544 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; + ret List.544; procedure List.80 (#Derived_gen.0, #Derived_gen.1, #Derived_gen.2, #Derived_gen.3, #Derived_gen.4): - joinpoint List.600 List.442 List.443 List.444 List.445 List.446: - let List.602 : Int1 = CallByName Num.22 List.445 List.446; - if List.602 then - let List.612 : U8 = CallByName List.66 List.442 List.445; - let List.603 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = CallByName TotallyNotJson.62 List.443 List.612; - let List.609 : U8 = 1i64; - let List.610 : U8 = GetTagId List.603; - let List.611 : Int1 = lowlevel Eq List.609 List.610; - if List.611 then - let List.447 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = UnionAtIndex (Id 1) (Index 0) List.603; - let List.605 : U64 = CallByName List.96 List.445; - jump List.600 List.442 List.447 List.444 List.605 List.446; + joinpoint List.596 List.440 List.441 List.442 List.443 List.444: + let List.598 : Int1 = CallByName Num.22 List.443 List.444; + if List.598 then + let List.607 : U8 = CallByName List.66 List.440 List.443; + let List.599 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = CallByName TotallyNotJson.62 List.441 List.607; + let List.604 : U8 = 1i64; + let List.605 : U8 = GetTagId List.599; + let List.606 : Int1 = lowlevel Eq List.604 List.605; + if List.606 then + let List.445 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = UnionAtIndex (Id 1) (Index 0) List.599; + let List.602 : U64 = 1i64; + let List.601 : U64 = CallByName Num.51 List.443 List.602; + jump List.596 List.440 List.445 List.442 List.601 List.444; else - dec List.442; - let List.448 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = UnionAtIndex (Id 0) (Index 0) List.603; - let List.608 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = TagId(0) List.448; - ret List.608; + dec List.440; + let List.446 : [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64] = UnionAtIndex (Id 0) (Index 0) List.599; + let List.603 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = TagId(0) List.446; + ret List.603; else - dec List.442; - let List.601 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = TagId(1) List.443; - ret List.601; + dec List.440; + let List.597 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = TagId(1) List.441; + ret List.597; in - jump List.600 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4; + jump List.596 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4; -procedure List.93 (List.439, List.440, List.441): - let List.598 : U64 = 0i64; - let List.599 : U64 = CallByName List.6 List.439; - let List.597 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = CallByName List.80 List.439 List.440 List.441 List.598 List.599; - ret List.597; - -procedure List.96 (List.463): - let List.607 : U64 = 1i64; - let List.606 : U64 = CallByName Num.51 List.463 List.607; - ret List.606; +procedure List.93 (List.437, List.438, List.439): + let List.594 : U64 = 0i64; + let List.595 : U64 = CallByName List.6 List.437; + let List.593 : [C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64], C [C U64, C U64, C U64, C , C , C U64, C U64, C U64, C U64]] = CallByName List.80 List.437 List.438 List.439 List.594 List.595; + ret List.593; procedure Num.19 (#Attr.2, #Attr.3): let Num.295 : U8 = lowlevel NumAdd #Attr.2 #Attr.3; @@ -214,53 +210,53 @@ procedure Num.77 (#Attr.2, #Attr.3): ret Num.325; procedure Str.12 (#Attr.2): - let Str.300 : List U8 = lowlevel StrToUtf8 #Attr.2; - ret Str.300; + let Str.298 : List U8 = lowlevel StrToUtf8 #Attr.2; + ret Str.298; -procedure Str.27 (Str.100): - let Str.291 : [C {}, C I64] = CallByName Str.72 Str.100; - ret Str.291; +procedure Str.27 (Str.99): + let Str.289 : [C {}, C I64] = CallByName Str.72 Str.99; + ret Str.289; procedure Str.47 (#Attr.2): - let Str.299 : {I64, U8} = lowlevel StrToNum #Attr.2; - ret Str.299; + let Str.297 : {I64, U8} = lowlevel StrToNum #Attr.2; + ret Str.297; procedure Str.48 (#Attr.2, #Attr.3, #Attr.4): - let Str.310 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8Range #Attr.2 #Attr.3 #Attr.4; - ret Str.310; + let Str.308 : {U64, Str, Int1, U8} = lowlevel StrFromUtf8Range #Attr.2 #Attr.3 #Attr.4; + ret Str.308; -procedure Str.72 (Str.236): - let Str.237 : {I64, U8} = CallByName Str.47 Str.236; - dec Str.236; - let Str.297 : U8 = StructAtIndex 1 Str.237; - let Str.298 : U8 = 0i64; - let Str.294 : Int1 = CallByName Bool.11 Str.297 Str.298; - if Str.294 then - let Str.296 : I64 = StructAtIndex 0 Str.237; - let Str.295 : [C {}, C I64] = TagId(1) Str.296; - ret Str.295; +procedure Str.72 (Str.235): + let Str.236 : {I64, U8} = CallByName Str.47 Str.235; + dec Str.235; + let Str.295 : U8 = StructAtIndex 1 Str.236; + let Str.296 : U8 = 0i64; + let Str.292 : Int1 = CallByName Bool.11 Str.295 Str.296; + if Str.292 then + let Str.294 : I64 = StructAtIndex 0 Str.236; + let Str.293 : [C {}, C I64] = TagId(1) Str.294; + ret Str.293; else - let Str.293 : {} = Struct {}; - let Str.292 : [C {}, C I64] = TagId(0) Str.293; - ret Str.292; + let Str.291 : {} = Struct {}; + let Str.290 : [C {}, C I64] = TagId(0) Str.291; + ret Str.290; -procedure Str.9 (Str.80): - let Str.308 : U64 = 0i64; - let Str.309 : U64 = CallByName List.6 Str.80; - let Str.81 : {U64, Str, Int1, U8} = CallByName Str.48 Str.80 Str.308 Str.309; - let Str.305 : Int1 = StructAtIndex 2 Str.81; - if Str.305 then - let Str.307 : Str = StructAtIndex 1 Str.81; - let Str.306 : [C {U64, U8}, C Str] = TagId(1) Str.307; - ret Str.306; +procedure Str.9 (Str.79): + let Str.306 : U64 = 0i64; + let Str.307 : U64 = CallByName List.6 Str.79; + let Str.80 : {U64, Str, Int1, U8} = CallByName Str.48 Str.79 Str.306 Str.307; + let Str.303 : Int1 = StructAtIndex 2 Str.80; + if Str.303 then + let Str.305 : Str = StructAtIndex 1 Str.80; + let Str.304 : [C {U64, U8}, C Str] = TagId(1) Str.305; + ret Str.304; else - let Str.303 : U8 = StructAtIndex 3 Str.81; - let Str.304 : U64 = StructAtIndex 0 Str.81; - let #Derived_gen.7 : Str = StructAtIndex 1 Str.81; + let Str.301 : U8 = StructAtIndex 3 Str.80; + let Str.302 : U64 = StructAtIndex 0 Str.80; + let #Derived_gen.7 : Str = StructAtIndex 1 Str.80; dec #Derived_gen.7; - let Str.302 : {U64, U8} = Struct {Str.304, Str.303}; - let Str.301 : [C {U64, U8}, C Str] = TagId(0) Str.302; - ret Str.301; + let Str.300 : {U64, U8} = Struct {Str.302, Str.301}; + let Str.299 : [C {U64, U8}, C Str] = TagId(0) Str.300; + ret Str.299; procedure Test.0 (): let Test.37 : Str = "-1234"; diff --git a/crates/compiler/test_mono/generated/layout_cache_structure_with_multiple_recursive_structures.txt b/crates/compiler/test_mono/generated/layout_cache_structure_with_multiple_recursive_structures.txt index 3d9194e4d5..22014b9826 100644 --- a/crates/compiler/test_mono/generated/layout_cache_structure_with_multiple_recursive_structures.txt +++ b/crates/compiler/test_mono/generated/layout_cache_structure_with_multiple_recursive_structures.txt @@ -1,44 +1,40 @@ -procedure List.147 (List.148, List.149, List.146): - let List.546 : [, C {[C *self, ], *self}] = CallByName Test.7 List.148 List.149; - ret List.546; +procedure List.145 (List.146, List.147, List.144): + let List.541 : [, C {[C *self, ], *self}] = CallByName Test.7 List.146 List.147; + ret List.541; -procedure List.18 (List.144, List.145, List.146): - let List.526 : [, C {[C *self, ], *self}] = CallByName List.93 List.144 List.145 List.146; - ret List.526; +procedure List.18 (List.142, List.143, List.144): + let List.522 : [, C {[C *self, ], *self}] = CallByName List.93 List.142 List.143 List.144; + ret List.522; procedure List.6 (#Attr.2): - let List.544 : U64 = lowlevel ListLen #Attr.2; - ret List.544; + let List.539 : U64 = lowlevel ListLen #Attr.2; + ret List.539; procedure List.66 (#Attr.2, #Attr.3): - let List.543 : [C *self, ] = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.543; + let List.538 : [C *self, ] = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.538; procedure List.80 (#Derived_gen.0, #Derived_gen.1, #Derived_gen.2, #Derived_gen.3, #Derived_gen.4): - joinpoint List.532 List.442 List.443 List.444 List.445 List.446: - let List.534 : Int1 = CallByName Num.22 List.445 List.446; - if List.534 then - let List.542 : [C *self, ] = CallByName List.66 List.442 List.445; - inc List.542; - let List.535 : [, C {[C *self, ], *self}] = CallByName List.147 List.443 List.542 List.444; - let List.537 : U64 = CallByName List.96 List.445; - jump List.532 List.442 List.535 List.444 List.537 List.446; + joinpoint List.528 List.440 List.441 List.442 List.443 List.444: + let List.530 : Int1 = CallByName Num.22 List.443 List.444; + if List.530 then + let List.537 : [C *self, ] = CallByName List.66 List.440 List.443; + inc List.537; + let List.531 : [, C {[C *self, ], *self}] = CallByName List.145 List.441 List.537 List.442; + let List.534 : U64 = 1i64; + let List.533 : U64 = CallByName Num.51 List.443 List.534; + jump List.528 List.440 List.531 List.442 List.533 List.444; else - dec List.442; - ret List.443; + dec List.440; + ret List.441; in - jump List.532 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4; + jump List.528 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4; -procedure List.93 (List.439, List.440, List.441): - let List.530 : U64 = 0i64; - let List.531 : U64 = CallByName List.6 List.439; - let List.529 : [, C {[C *self, ], *self}] = CallByName List.80 List.439 List.440 List.441 List.530 List.531; - ret List.529; - -procedure List.96 (List.463): - let List.539 : U64 = 1i64; - let List.538 : U64 = CallByName Num.51 List.463 List.539; - ret List.538; +procedure List.93 (List.437, List.438, List.439): + let List.526 : U64 = 0i64; + let List.527 : U64 = CallByName List.6 List.437; + let List.525 : [, C {[C *self, ], *self}] = CallByName List.80 List.437 List.438 List.439 List.526 List.527; + ret List.525; procedure Num.22 (#Attr.2, #Attr.3): let Num.293 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/list_append.txt b/crates/compiler/test_mono/generated/list_append.txt index e710310e16..dcad898019 100644 --- a/crates/compiler/test_mono/generated/list_append.txt +++ b/crates/compiler/test_mono/generated/list_append.txt @@ -1,16 +1,16 @@ -procedure List.4 (List.115, List.116): - let List.529 : U64 = 1i64; - let List.527 : List I64 = CallByName List.70 List.115 List.529; - let List.526 : List I64 = CallByName List.71 List.527 List.116; - ret List.526; +procedure List.4 (List.113, List.114): + let List.525 : U64 = 1i64; + let List.523 : List I64 = CallByName List.70 List.113 List.525; + let List.522 : List I64 = CallByName List.71 List.523 List.114; + ret List.522; procedure List.70 (#Attr.2, #Attr.3): - let List.530 : List I64 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.530; + let List.526 : List I64 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.526; procedure List.71 (#Attr.2, #Attr.3): - let List.528 : List I64 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.528; + let List.524 : List I64 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.524; procedure Test.0 (): let Test.2 : List I64 = Array [1i64]; diff --git a/crates/compiler/test_mono/generated/list_append_closure.txt b/crates/compiler/test_mono/generated/list_append_closure.txt index 2c6b4360d5..c014ac6e02 100644 --- a/crates/compiler/test_mono/generated/list_append_closure.txt +++ b/crates/compiler/test_mono/generated/list_append_closure.txt @@ -1,16 +1,16 @@ -procedure List.4 (List.115, List.116): - let List.529 : U64 = 1i64; - let List.527 : List I64 = CallByName List.70 List.115 List.529; - let List.526 : List I64 = CallByName List.71 List.527 List.116; - ret List.526; +procedure List.4 (List.113, List.114): + let List.525 : U64 = 1i64; + let List.523 : List I64 = CallByName List.70 List.113 List.525; + let List.522 : List I64 = CallByName List.71 List.523 List.114; + ret List.522; procedure List.70 (#Attr.2, #Attr.3): - let List.530 : List I64 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.530; + let List.526 : List I64 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.526; procedure List.71 (#Attr.2, #Attr.3): - let List.528 : List I64 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.528; + let List.524 : List I64 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.524; procedure Test.1 (Test.2): let Test.6 : I64 = 42i64; diff --git a/crates/compiler/test_mono/generated/list_cannot_update_inplace.txt b/crates/compiler/test_mono/generated/list_cannot_update_inplace.txt index 59d57db5eb..da2130a4de 100644 --- a/crates/compiler/test_mono/generated/list_cannot_update_inplace.txt +++ b/crates/compiler/test_mono/generated/list_cannot_update_inplace.txt @@ -1,25 +1,25 @@ -procedure List.3 (List.107, List.108, List.109): - let List.529 : {List I64, I64} = CallByName List.64 List.107 List.108 List.109; - let List.528 : List I64 = StructAtIndex 0 List.529; - ret List.528; +procedure List.3 (List.105, List.106, List.107): + let List.525 : {List I64, I64} = CallByName List.64 List.105 List.106 List.107; + let List.524 : List I64 = StructAtIndex 0 List.525; + ret List.524; procedure List.6 (#Attr.2): - let List.527 : U64 = lowlevel ListLen #Attr.2; - ret List.527; + let List.523 : U64 = lowlevel ListLen #Attr.2; + ret List.523; -procedure List.64 (List.104, List.105, List.106): - let List.534 : U64 = CallByName List.6 List.104; - let List.531 : Int1 = CallByName Num.22 List.105 List.534; - if List.531 then - let List.532 : {List I64, I64} = CallByName List.67 List.104 List.105 List.106; - ret List.532; +procedure List.64 (List.102, List.103, List.104): + let List.530 : U64 = CallByName List.6 List.102; + let List.527 : Int1 = CallByName Num.22 List.103 List.530; + if List.527 then + let List.528 : {List I64, I64} = CallByName List.67 List.102 List.103 List.104; + ret List.528; else - let List.530 : {List I64, I64} = Struct {List.104, List.106}; - ret List.530; + let List.526 : {List I64, I64} = Struct {List.102, List.104}; + ret List.526; procedure List.67 (#Attr.2, #Attr.3, #Attr.4): - let List.533 : {List I64, I64} = lowlevel ListReplaceUnsafe #Attr.2 #Attr.3 #Attr.4; - ret List.533; + let List.529 : {List I64, I64} = lowlevel ListReplaceUnsafe #Attr.2 #Attr.3 #Attr.4; + ret List.529; procedure Num.19 (#Attr.2, #Attr.3): let Num.292 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/list_get.txt b/crates/compiler/test_mono/generated/list_get.txt index 0098beac1b..02d12606a4 100644 --- a/crates/compiler/test_mono/generated/list_get.txt +++ b/crates/compiler/test_mono/generated/list_get.txt @@ -1,24 +1,24 @@ -procedure List.2 (List.99, List.100): - let List.532 : U64 = CallByName List.6 List.99; - let List.528 : Int1 = CallByName Num.22 List.100 List.532; - if List.528 then - let List.530 : I64 = CallByName List.66 List.99 List.100; - dec List.99; - let List.529 : [C {}, C I64] = TagId(1) List.530; - ret List.529; +procedure List.2 (List.97, List.98): + let List.528 : U64 = CallByName List.6 List.97; + let List.524 : Int1 = CallByName Num.22 List.98 List.528; + if List.524 then + let List.526 : I64 = CallByName List.66 List.97 List.98; + dec List.97; + let List.525 : [C {}, C I64] = TagId(1) List.526; + ret List.525; else - dec List.99; - let List.527 : {} = Struct {}; - let List.526 : [C {}, C I64] = TagId(0) List.527; - ret List.526; + dec List.97; + let List.523 : {} = Struct {}; + let List.522 : [C {}, C I64] = TagId(0) List.523; + ret List.522; procedure List.6 (#Attr.2): - let List.533 : U64 = lowlevel ListLen #Attr.2; - ret List.533; + let List.529 : U64 = lowlevel ListLen #Attr.2; + ret List.529; procedure List.66 (#Attr.2, #Attr.3): - let List.531 : I64 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.531; + let List.527 : I64 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.527; procedure Num.22 (#Attr.2, #Attr.3): let Num.292 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/list_len.txt b/crates/compiler/test_mono/generated/list_len.txt index 308a475770..80c69a53e4 100644 --- a/crates/compiler/test_mono/generated/list_len.txt +++ b/crates/compiler/test_mono/generated/list_len.txt @@ -1,10 +1,10 @@ procedure List.6 (#Attr.2): - let List.526 : U64 = lowlevel ListLen #Attr.2; - ret List.526; + let List.522 : U64 = lowlevel ListLen #Attr.2; + ret List.522; procedure List.6 (#Attr.2): - let List.527 : U64 = lowlevel ListLen #Attr.2; - ret List.527; + let List.523 : U64 = lowlevel ListLen #Attr.2; + ret List.523; procedure Num.19 (#Attr.2, #Attr.3): let Num.292 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/list_map_closure_borrows.txt b/crates/compiler/test_mono/generated/list_map_closure_borrows.txt index 6a074e2669..9a4b59ac35 100644 --- a/crates/compiler/test_mono/generated/list_map_closure_borrows.txt +++ b/crates/compiler/test_mono/generated/list_map_closure_borrows.txt @@ -1,42 +1,42 @@ -procedure List.2 (List.99, List.100): - let List.532 : U64 = CallByName List.6 List.99; - let List.528 : Int1 = CallByName Num.22 List.100 List.532; - if List.528 then - let List.530 : Str = CallByName List.66 List.99 List.100; - inc List.530; - dec List.99; - let List.529 : [C {}, C Str] = TagId(1) List.530; - ret List.529; +procedure List.2 (List.97, List.98): + let List.528 : U64 = CallByName List.6 List.97; + let List.524 : Int1 = CallByName Num.22 List.98 List.528; + if List.524 then + let List.526 : Str = CallByName List.66 List.97 List.98; + inc List.526; + dec List.97; + let List.525 : [C {}, C Str] = TagId(1) List.526; + ret List.525; else - dec List.99; - let List.527 : {} = Struct {}; - let List.526 : [C {}, C Str] = TagId(0) List.527; - ret List.526; + dec List.97; + let List.523 : {} = Struct {}; + let List.522 : [C {}, C Str] = TagId(0) List.523; + ret List.522; procedure List.5 (#Attr.2, #Attr.3): - let List.534 : List Str = lowlevel ListMap { xs: `#Attr.#arg1` } #Attr.2 Test.3 #Attr.3; + let List.530 : List Str = lowlevel ListMap { xs: `#Attr.#arg1` } #Attr.2 Test.3 #Attr.3; decref #Attr.2; - ret List.534; + ret List.530; procedure List.6 (#Attr.2): - let List.533 : U64 = lowlevel ListLen #Attr.2; - ret List.533; + let List.529 : U64 = lowlevel ListLen #Attr.2; + ret List.529; procedure List.66 (#Attr.2, #Attr.3): - let List.531 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.531; + let List.527 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.527; procedure Num.22 (#Attr.2, #Attr.3): let Num.292 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; ret Num.292; procedure Str.16 (#Attr.2, #Attr.3): - let Str.291 : Str = lowlevel StrRepeat #Attr.2 #Attr.3; - ret Str.291; + let Str.289 : Str = lowlevel StrRepeat #Attr.2 #Attr.3; + ret Str.289; procedure Str.3 (#Attr.2, #Attr.3): - let Str.292 : Str = lowlevel StrConcat #Attr.2 #Attr.3; - ret Str.292; + let Str.290 : Str = lowlevel StrConcat #Attr.2 #Attr.3; + ret Str.290; procedure Test.1 (): let Test.21 : Str = "lllllllllllllllllllllooooooooooong"; diff --git a/crates/compiler/test_mono/generated/list_map_closure_owns.txt b/crates/compiler/test_mono/generated/list_map_closure_owns.txt index 956a6c7e76..3ed1e5d2d4 100644 --- a/crates/compiler/test_mono/generated/list_map_closure_owns.txt +++ b/crates/compiler/test_mono/generated/list_map_closure_owns.txt @@ -1,38 +1,38 @@ -procedure List.2 (List.99, List.100): - let List.532 : U64 = CallByName List.6 List.99; - let List.528 : Int1 = CallByName Num.22 List.100 List.532; - if List.528 then - let List.530 : Str = CallByName List.66 List.99 List.100; - inc List.530; - dec List.99; - let List.529 : [C {}, C Str] = TagId(1) List.530; - ret List.529; +procedure List.2 (List.97, List.98): + let List.528 : U64 = CallByName List.6 List.97; + let List.524 : Int1 = CallByName Num.22 List.98 List.528; + if List.524 then + let List.526 : Str = CallByName List.66 List.97 List.98; + inc List.526; + dec List.97; + let List.525 : [C {}, C Str] = TagId(1) List.526; + ret List.525; else - dec List.99; - let List.527 : {} = Struct {}; - let List.526 : [C {}, C Str] = TagId(0) List.527; - ret List.526; + dec List.97; + let List.523 : {} = Struct {}; + let List.522 : [C {}, C Str] = TagId(0) List.523; + ret List.522; procedure List.5 (#Attr.2, #Attr.3): - let List.534 : List Str = lowlevel ListMap { xs: `#Attr.#arg1` } #Attr.2 Test.3 #Attr.3; + let List.530 : List Str = lowlevel ListMap { xs: `#Attr.#arg1` } #Attr.2 Test.3 #Attr.3; decref #Attr.2; - ret List.534; + ret List.530; procedure List.6 (#Attr.2): - let List.533 : U64 = lowlevel ListLen #Attr.2; - ret List.533; + let List.529 : U64 = lowlevel ListLen #Attr.2; + ret List.529; procedure List.66 (#Attr.2, #Attr.3): - let List.531 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.531; + let List.527 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.527; procedure Num.22 (#Attr.2, #Attr.3): let Num.292 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; ret Num.292; procedure Str.3 (#Attr.2, #Attr.3): - let Str.292 : Str = lowlevel StrConcat #Attr.2 #Attr.3; - ret Str.292; + let Str.290 : Str = lowlevel StrConcat #Attr.2 #Attr.3; + ret Str.290; procedure Test.1 (): let Test.21 : Str = "lllllllllllllllllllllooooooooooong"; diff --git a/crates/compiler/test_mono/generated/list_map_take_capturing_or_noncapturing.txt b/crates/compiler/test_mono/generated/list_map_take_capturing_or_noncapturing.txt index 513956b5b0..d4843cdf1f 100644 --- a/crates/compiler/test_mono/generated/list_map_take_capturing_or_noncapturing.txt +++ b/crates/compiler/test_mono/generated/list_map_take_capturing_or_noncapturing.txt @@ -1,23 +1,23 @@ procedure List.5 (#Attr.2, #Attr.3): - let List.527 : U8 = GetTagId #Attr.3; - joinpoint List.528 List.526: - ret List.526; + let List.523 : U8 = GetTagId #Attr.3; + joinpoint List.524 List.522: + ret List.522; in - switch List.527: + switch List.523: case 0: - let List.529 : List U8 = lowlevel ListMap { xs: `#Attr.#arg1` } #Attr.2 Test.4 #Attr.3; + let List.525 : List U8 = lowlevel ListMap { xs: `#Attr.#arg1` } #Attr.2 Test.4 #Attr.3; decref #Attr.2; - jump List.528 List.529; + jump List.524 List.525; case 1: - let List.530 : List U8 = lowlevel ListMap { xs: `#Attr.#arg1` } #Attr.2 Test.6 #Attr.3; + let List.526 : List U8 = lowlevel ListMap { xs: `#Attr.#arg1` } #Attr.2 Test.6 #Attr.3; decref #Attr.2; - jump List.528 List.530; + jump List.524 List.526; default: - let List.531 : List U8 = lowlevel ListMap { xs: `#Attr.#arg1` } #Attr.2 Test.8 #Attr.3; + let List.527 : List U8 = lowlevel ListMap { xs: `#Attr.#arg1` } #Attr.2 Test.8 #Attr.3; decref #Attr.2; - jump List.528 List.531; + jump List.524 List.527; procedure Num.19 (#Attr.2, #Attr.3): diff --git a/crates/compiler/test_mono/generated/list_pass_to_function.txt b/crates/compiler/test_mono/generated/list_pass_to_function.txt index 07b42d5d6c..9901ef0c27 100644 --- a/crates/compiler/test_mono/generated/list_pass_to_function.txt +++ b/crates/compiler/test_mono/generated/list_pass_to_function.txt @@ -1,25 +1,25 @@ -procedure List.3 (List.107, List.108, List.109): - let List.527 : {List I64, I64} = CallByName List.64 List.107 List.108 List.109; - let List.526 : List I64 = StructAtIndex 0 List.527; - ret List.526; +procedure List.3 (List.105, List.106, List.107): + let List.523 : {List I64, I64} = CallByName List.64 List.105 List.106 List.107; + let List.522 : List I64 = StructAtIndex 0 List.523; + ret List.522; procedure List.6 (#Attr.2): - let List.533 : U64 = lowlevel ListLen #Attr.2; - ret List.533; + let List.529 : U64 = lowlevel ListLen #Attr.2; + ret List.529; -procedure List.64 (List.104, List.105, List.106): - let List.532 : U64 = CallByName List.6 List.104; - let List.529 : Int1 = CallByName Num.22 List.105 List.532; - if List.529 then - let List.530 : {List I64, I64} = CallByName List.67 List.104 List.105 List.106; - ret List.530; +procedure List.64 (List.102, List.103, List.104): + let List.528 : U64 = CallByName List.6 List.102; + let List.525 : Int1 = CallByName Num.22 List.103 List.528; + if List.525 then + let List.526 : {List I64, I64} = CallByName List.67 List.102 List.103 List.104; + ret List.526; else - let List.528 : {List I64, I64} = Struct {List.104, List.106}; - ret List.528; + let List.524 : {List I64, I64} = Struct {List.102, List.104}; + ret List.524; procedure List.67 (#Attr.2, #Attr.3, #Attr.4): - let List.531 : {List I64, I64} = lowlevel ListReplaceUnsafe #Attr.2 #Attr.3 #Attr.4; - ret List.531; + let List.527 : {List I64, I64} = lowlevel ListReplaceUnsafe #Attr.2 #Attr.3 #Attr.4; + ret List.527; procedure Num.22 (#Attr.2, #Attr.3): let Num.292 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/list_sort_asc.txt b/crates/compiler/test_mono/generated/list_sort_asc.txt index 974d7f357f..bae1137991 100644 --- a/crates/compiler/test_mono/generated/list_sort_asc.txt +++ b/crates/compiler/test_mono/generated/list_sort_asc.txt @@ -1,11 +1,11 @@ procedure List.28 (#Attr.2, #Attr.3): - let List.528 : List I64 = lowlevel ListSortWith { xs: `#Attr.#arg1` } #Attr.2 Num.46 #Attr.3; - ret List.528; + let List.524 : List I64 = lowlevel ListSortWith { xs: `#Attr.#arg1` } #Attr.2 Num.46 #Attr.3; + ret List.524; -procedure List.59 (List.290): - let List.527 : {} = Struct {}; - let List.526 : List I64 = CallByName List.28 List.290 List.527; - ret List.526; +procedure List.59 (List.288): + let List.523 : {} = Struct {}; + let List.522 : List I64 = CallByName List.28 List.288 List.523; + ret List.522; procedure Num.46 (#Attr.2, #Attr.3): let Num.292 : U8 = lowlevel NumCompare #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/polymorphic_expression_unification.txt b/crates/compiler/test_mono/generated/polymorphic_expression_unification.txt index ce2daa3f29..6e6d11abec 100644 --- a/crates/compiler/test_mono/generated/polymorphic_expression_unification.txt +++ b/crates/compiler/test_mono/generated/polymorphic_expression_unification.txt @@ -3,8 +3,8 @@ procedure Bool.11 (#Attr.2, #Attr.3): ret Bool.23; procedure Str.3 (#Attr.2, #Attr.3): - let Str.292 : Str = lowlevel StrConcat #Attr.2 #Attr.3; - ret Str.292; + let Str.290 : Str = lowlevel StrConcat #Attr.2 #Attr.3; + ret Str.290; procedure Test.2 (Test.7): let Test.24 : Str = ".trace(\""; diff --git a/crates/compiler/test_mono/generated/quicksort_swap.txt b/crates/compiler/test_mono/generated/quicksort_swap.txt index 3c7f411048..913ffec932 100644 --- a/crates/compiler/test_mono/generated/quicksort_swap.txt +++ b/crates/compiler/test_mono/generated/quicksort_swap.txt @@ -1,43 +1,43 @@ -procedure List.2 (List.99, List.100): - let List.548 : U64 = CallByName List.6 List.99; - let List.545 : Int1 = CallByName Num.22 List.100 List.548; - if List.545 then - let List.547 : I64 = CallByName List.66 List.99 List.100; - dec List.99; - let List.546 : [C {}, C I64] = TagId(1) List.547; - ret List.546; +procedure List.2 (List.97, List.98): + let List.544 : U64 = CallByName List.6 List.97; + let List.541 : Int1 = CallByName Num.22 List.98 List.544; + if List.541 then + let List.543 : I64 = CallByName List.66 List.97 List.98; + dec List.97; + let List.542 : [C {}, C I64] = TagId(1) List.543; + ret List.542; else - dec List.99; - let List.544 : {} = Struct {}; - let List.543 : [C {}, C I64] = TagId(0) List.544; - ret List.543; + dec List.97; + let List.540 : {} = Struct {}; + let List.539 : [C {}, C I64] = TagId(0) List.540; + ret List.539; -procedure List.3 (List.107, List.108, List.109): - let List.535 : {List I64, I64} = CallByName List.64 List.107 List.108 List.109; - let List.534 : List I64 = StructAtIndex 0 List.535; - ret List.534; +procedure List.3 (List.105, List.106, List.107): + let List.531 : {List I64, I64} = CallByName List.64 List.105 List.106 List.107; + let List.530 : List I64 = StructAtIndex 0 List.531; + ret List.530; procedure List.6 (#Attr.2): - let List.533 : U64 = lowlevel ListLen #Attr.2; - ret List.533; + let List.529 : U64 = lowlevel ListLen #Attr.2; + ret List.529; -procedure List.64 (List.104, List.105, List.106): - let List.532 : U64 = CallByName List.6 List.104; - let List.529 : Int1 = CallByName Num.22 List.105 List.532; - if List.529 then - let List.530 : {List I64, I64} = CallByName List.67 List.104 List.105 List.106; - ret List.530; +procedure List.64 (List.102, List.103, List.104): + let List.528 : U64 = CallByName List.6 List.102; + let List.525 : Int1 = CallByName Num.22 List.103 List.528; + if List.525 then + let List.526 : {List I64, I64} = CallByName List.67 List.102 List.103 List.104; + ret List.526; else - let List.528 : {List I64, I64} = Struct {List.104, List.106}; - ret List.528; + let List.524 : {List I64, I64} = Struct {List.102, List.104}; + ret List.524; procedure List.66 (#Attr.2, #Attr.3): - let List.541 : I64 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.541; + let List.537 : I64 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.537; procedure List.67 (#Attr.2, #Attr.3, #Attr.4): - let List.531 : {List I64, I64} = lowlevel ListReplaceUnsafe #Attr.2 #Attr.3 #Attr.4; - ret List.531; + let List.527 : {List I64, I64} = lowlevel ListReplaceUnsafe #Attr.2 #Attr.3 #Attr.4; + ret List.527; procedure Num.22 (#Attr.2, #Attr.3): let Num.294 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/record_update.txt b/crates/compiler/test_mono/generated/record_update.txt index 863b63e41c..9c11263201 100644 --- a/crates/compiler/test_mono/generated/record_update.txt +++ b/crates/compiler/test_mono/generated/record_update.txt @@ -1,25 +1,25 @@ -procedure List.3 (List.107, List.108, List.109): - let List.535 : {List U64, U64} = CallByName List.64 List.107 List.108 List.109; - let List.534 : List U64 = StructAtIndex 0 List.535; - ret List.534; +procedure List.3 (List.105, List.106, List.107): + let List.531 : {List U64, U64} = CallByName List.64 List.105 List.106 List.107; + let List.530 : List U64 = StructAtIndex 0 List.531; + ret List.530; procedure List.6 (#Attr.2): - let List.533 : U64 = lowlevel ListLen #Attr.2; - ret List.533; + let List.529 : U64 = lowlevel ListLen #Attr.2; + ret List.529; -procedure List.64 (List.104, List.105, List.106): - let List.532 : U64 = CallByName List.6 List.104; - let List.529 : Int1 = CallByName Num.22 List.105 List.532; - if List.529 then - let List.530 : {List U64, U64} = CallByName List.67 List.104 List.105 List.106; - ret List.530; +procedure List.64 (List.102, List.103, List.104): + let List.528 : U64 = CallByName List.6 List.102; + let List.525 : Int1 = CallByName Num.22 List.103 List.528; + if List.525 then + let List.526 : {List U64, U64} = CallByName List.67 List.102 List.103 List.104; + ret List.526; else - let List.528 : {List U64, U64} = Struct {List.104, List.106}; - ret List.528; + let List.524 : {List U64, U64} = Struct {List.102, List.104}; + ret List.524; procedure List.67 (#Attr.2, #Attr.3, #Attr.4): - let List.531 : {List U64, U64} = lowlevel ListReplaceUnsafe #Attr.2 #Attr.3 #Attr.4; - ret List.531; + let List.527 : {List U64, U64} = lowlevel ListReplaceUnsafe #Attr.2 #Attr.3 #Attr.4; + ret List.527; procedure Num.22 (#Attr.2, #Attr.3): let Num.292 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/recursive_function_and_union_with_inference_hole.txt b/crates/compiler/test_mono/generated/recursive_function_and_union_with_inference_hole.txt index 22d1fc88c4..447cd94eb8 100644 --- a/crates/compiler/test_mono/generated/recursive_function_and_union_with_inference_hole.txt +++ b/crates/compiler/test_mono/generated/recursive_function_and_union_with_inference_hole.txt @@ -1,7 +1,7 @@ procedure List.5 (#Attr.2, #Attr.3): - let List.526 : List [C List *self] = lowlevel ListMap { xs: `#Attr.#arg1` } #Attr.2 Test.2 #Attr.3; + let List.522 : List [C List *self] = lowlevel ListMap { xs: `#Attr.#arg1` } #Attr.2 Test.2 #Attr.3; decref #Attr.2; - ret List.526; + ret List.522; procedure Test.2 (Test.5): let Test.6 : List [C List *self] = UnionAtIndex (Id 0) (Index 0) Test.5; diff --git a/crates/compiler/test_mono/generated/recursively_build_effect.txt b/crates/compiler/test_mono/generated/recursively_build_effect.txt index ad5154b2d9..cac652954a 100644 --- a/crates/compiler/test_mono/generated/recursively_build_effect.txt +++ b/crates/compiler/test_mono/generated/recursively_build_effect.txt @@ -3,8 +3,8 @@ procedure Num.20 (#Attr.2, #Attr.3): ret Num.292; procedure Str.3 (#Attr.2, #Attr.3): - let Str.293 : Str = lowlevel StrConcat #Attr.2 #Attr.3; - ret Str.293; + let Str.291 : Str = lowlevel StrConcat #Attr.2 #Attr.3; + ret Str.291; procedure Test.11 (Test.29, #Attr.12): let Test.10 : {} = UnionAtIndex (Id 0) (Index 0) #Attr.12; diff --git a/crates/compiler/test_mono/generated/rigids.txt b/crates/compiler/test_mono/generated/rigids.txt index 4a5367feb3..0ac2663e17 100644 --- a/crates/compiler/test_mono/generated/rigids.txt +++ b/crates/compiler/test_mono/generated/rigids.txt @@ -1,43 +1,43 @@ -procedure List.2 (List.99, List.100): - let List.548 : U64 = CallByName List.6 List.99; - let List.545 : Int1 = CallByName Num.22 List.100 List.548; - if List.545 then - let List.547 : I64 = CallByName List.66 List.99 List.100; - dec List.99; - let List.546 : [C {}, C I64] = TagId(1) List.547; - ret List.546; +procedure List.2 (List.97, List.98): + let List.544 : U64 = CallByName List.6 List.97; + let List.541 : Int1 = CallByName Num.22 List.98 List.544; + if List.541 then + let List.543 : I64 = CallByName List.66 List.97 List.98; + dec List.97; + let List.542 : [C {}, C I64] = TagId(1) List.543; + ret List.542; else - dec List.99; - let List.544 : {} = Struct {}; - let List.543 : [C {}, C I64] = TagId(0) List.544; - ret List.543; + dec List.97; + let List.540 : {} = Struct {}; + let List.539 : [C {}, C I64] = TagId(0) List.540; + ret List.539; -procedure List.3 (List.107, List.108, List.109): - let List.535 : {List I64, I64} = CallByName List.64 List.107 List.108 List.109; - let List.534 : List I64 = StructAtIndex 0 List.535; - ret List.534; +procedure List.3 (List.105, List.106, List.107): + let List.531 : {List I64, I64} = CallByName List.64 List.105 List.106 List.107; + let List.530 : List I64 = StructAtIndex 0 List.531; + ret List.530; procedure List.6 (#Attr.2): - let List.533 : U64 = lowlevel ListLen #Attr.2; - ret List.533; + let List.529 : U64 = lowlevel ListLen #Attr.2; + ret List.529; -procedure List.64 (List.104, List.105, List.106): - let List.532 : U64 = CallByName List.6 List.104; - let List.529 : Int1 = CallByName Num.22 List.105 List.532; - if List.529 then - let List.530 : {List I64, I64} = CallByName List.67 List.104 List.105 List.106; - ret List.530; +procedure List.64 (List.102, List.103, List.104): + let List.528 : U64 = CallByName List.6 List.102; + let List.525 : Int1 = CallByName Num.22 List.103 List.528; + if List.525 then + let List.526 : {List I64, I64} = CallByName List.67 List.102 List.103 List.104; + ret List.526; else - let List.528 : {List I64, I64} = Struct {List.104, List.106}; - ret List.528; + let List.524 : {List I64, I64} = Struct {List.102, List.104}; + ret List.524; procedure List.66 (#Attr.2, #Attr.3): - let List.541 : I64 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.541; + let List.537 : I64 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.537; procedure List.67 (#Attr.2, #Attr.3, #Attr.4): - let List.531 : {List I64, I64} = lowlevel ListReplaceUnsafe #Attr.2 #Attr.3 #Attr.4; - ret List.531; + let List.527 : {List I64, I64} = lowlevel ListReplaceUnsafe #Attr.2 #Attr.3 #Attr.4; + ret List.527; procedure Num.22 (#Attr.2, #Attr.3): let Num.294 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; diff --git a/crates/compiler/test_mono/generated/unspecialized_lambda_set_unification_does_not_duplicate_identical_concrete_types.txt b/crates/compiler/test_mono/generated/unspecialized_lambda_set_unification_does_not_duplicate_identical_concrete_types.txt index c39e2964ad..a04ee78e15 100644 --- a/crates/compiler/test_mono/generated/unspecialized_lambda_set_unification_does_not_duplicate_identical_concrete_types.txt +++ b/crates/compiler/test_mono/generated/unspecialized_lambda_set_unification_does_not_duplicate_identical_concrete_types.txt @@ -33,185 +33,183 @@ procedure Encode.26 (Encode.105, Encode.106): let Encode.108 : List U8 = CallByName Encode.24 Encode.109 Encode.110 Encode.106; ret Encode.108; -procedure List.147 (List.148, List.149, List.146): - let List.572 : {List U8, U64} = CallByName TotallyNotJson.267 List.148 List.149 List.146; - ret List.572; +procedure List.145 (List.146, List.147, List.144): + let List.567 : {List U8, U64} = CallByName TotallyNotJson.267 List.146 List.147 List.144; + ret List.567; -procedure List.147 (List.148, List.149, List.146): - let List.591 : List U8 = CallByName TotallyNotJson.215 List.148 List.149; - ret List.591; +procedure List.145 (List.146, List.147, List.144): + let List.587 : List U8 = CallByName TotallyNotJson.215 List.146 List.147; + ret List.587; -procedure List.18 (List.144, List.145, List.146): - let List.552 : {List U8, U64} = CallByName List.93 List.144 List.145 List.146; - ret List.552; +procedure List.18 (List.142, List.143, List.144): + let List.548 : {List U8, U64} = CallByName List.93 List.142 List.143 List.144; + ret List.548; -procedure List.18 (List.144, List.145, List.146): - let List.573 : List U8 = CallByName List.93 List.144 List.145 List.146; - ret List.573; +procedure List.18 (List.142, List.143, List.144): + let List.568 : List U8 = CallByName List.93 List.142 List.143 List.144; + ret List.568; -procedure List.26 (List.161, List.162, List.163): - let List.622 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.93 List.161 List.162 List.163; - let List.625 : U8 = 1i64; - let List.626 : U8 = GetTagId List.622; - let List.627 : Int1 = lowlevel Eq List.625 List.626; - if List.627 then - let List.164 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.622; - ret List.164; +procedure List.26 (List.159, List.160, List.161): + let List.618 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.93 List.159 List.160 List.161; + let List.621 : U8 = 1i64; + let List.622 : U8 = GetTagId List.618; + let List.623 : Int1 = lowlevel Eq List.621 List.622; + if List.623 then + let List.162 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.618; + ret List.162; else - let List.165 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.622; - ret List.165; + let List.163 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.618; + ret List.163; -procedure List.4 (List.115, List.116): - let List.551 : U64 = 1i64; - let List.550 : List U8 = CallByName List.70 List.115 List.551; - let List.549 : List U8 = CallByName List.71 List.550 List.116; - ret List.549; +procedure List.4 (List.113, List.114): + let List.547 : U64 = 1i64; + let List.546 : List U8 = CallByName List.70 List.113 List.547; + let List.545 : List U8 = CallByName List.71 List.546 List.114; + ret List.545; -procedure List.49 (List.379, List.380): - let List.614 : U64 = StructAtIndex 0 List.380; - let List.615 : U64 = 0i64; - let List.612 : Int1 = CallByName Bool.11 List.614 List.615; - if List.612 then - dec List.379; - let List.613 : List U8 = Array []; - ret List.613; +procedure List.49 (List.377, List.378): + let List.610 : U64 = StructAtIndex 0 List.378; + let List.611 : U64 = 0i64; + let List.608 : Int1 = CallByName Bool.11 List.610 List.611; + if List.608 then + dec List.377; + let List.609 : List U8 = Array []; + ret List.609; else - let List.609 : U64 = StructAtIndex 1 List.380; - let List.610 : U64 = StructAtIndex 0 List.380; - let List.608 : List U8 = CallByName List.72 List.379 List.609 List.610; - ret List.608; + let List.605 : U64 = StructAtIndex 1 List.378; + let List.606 : U64 = StructAtIndex 0 List.378; + let List.604 : List U8 = CallByName List.72 List.377 List.605 List.606; + ret List.604; -procedure List.52 (List.394, List.395): - let List.396 : U64 = CallByName List.6 List.394; - joinpoint List.620 List.397: - let List.618 : U64 = 0i64; - let List.617 : {U64, U64} = Struct {List.397, List.618}; - inc List.394; - let List.398 : List U8 = CallByName List.49 List.394 List.617; - let List.616 : U64 = CallByName Num.75 List.396 List.397; - let List.607 : {U64, U64} = Struct {List.616, List.397}; - let List.399 : List U8 = CallByName List.49 List.394 List.607; - let List.606 : {List U8, List U8} = Struct {List.398, List.399}; - ret List.606; +procedure List.52 (List.392, List.393): + let List.394 : U64 = CallByName List.6 List.392; + joinpoint List.616 List.395: + let List.614 : U64 = 0i64; + let List.613 : {U64, U64} = Struct {List.395, List.614}; + inc List.392; + let List.396 : List U8 = CallByName List.49 List.392 List.613; + let List.612 : U64 = CallByName Num.75 List.394 List.395; + let List.603 : {U64, U64} = Struct {List.612, List.395}; + let List.397 : List U8 = CallByName List.49 List.392 List.603; + let List.602 : {List U8, List U8} = Struct {List.396, List.397}; + ret List.602; in - let List.621 : Int1 = CallByName Num.24 List.396 List.395; - if List.621 then - jump List.620 List.395; + let List.617 : Int1 = CallByName Num.24 List.394 List.393; + if List.617 then + jump List.616 List.393; else - jump List.620 List.396; + jump List.616 List.394; procedure List.6 (#Attr.2): - let List.592 : U64 = lowlevel ListLen #Attr.2; - ret List.592; - -procedure List.6 (#Attr.2): - let List.594 : U64 = lowlevel ListLen #Attr.2; - ret List.594; - -procedure List.66 (#Attr.2, #Attr.3): - let List.569 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.569; - -procedure List.66 (#Attr.2, #Attr.3): - let List.588 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + let List.588 : U64 = lowlevel ListLen #Attr.2; ret List.588; +procedure List.6 (#Attr.2): + let List.590 : U64 = lowlevel ListLen #Attr.2; + ret List.590; + +procedure List.66 (#Attr.2, #Attr.3): + let List.564 : Str = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.564; + +procedure List.66 (#Attr.2, #Attr.3): + let List.584 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.584; + procedure List.68 (#Attr.2): - let List.605 : List U8 = lowlevel ListWithCapacity #Attr.2; - ret List.605; + let List.601 : List U8 = lowlevel ListWithCapacity #Attr.2; + ret List.601; procedure List.70 (#Attr.2, #Attr.3): - let List.530 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.530; + let List.526 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.526; procedure List.71 (#Attr.2, #Attr.3): - let List.528 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.528; + let List.524 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.524; procedure List.72 (#Attr.2, #Attr.3, #Attr.4): - let List.611 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; - ret List.611; + let List.607 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; + ret List.607; procedure List.8 (#Attr.2, #Attr.3): - let List.603 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; - ret List.603; + let List.599 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; + ret List.599; -procedure List.80 (#Derived_gen.14, #Derived_gen.15, #Derived_gen.16, #Derived_gen.17, #Derived_gen.18): - joinpoint List.631 List.442 List.443 List.444 List.445 List.446: - let List.633 : Int1 = CallByName Num.22 List.445 List.446; - if List.633 then - let List.641 : U8 = CallByName List.66 List.442 List.445; - let List.634 : [C {U64, Int1}, C {U64, Int1}] = CallByName TotallyNotJson.189 List.443 List.641; - let List.638 : U8 = 1i64; - let List.639 : U8 = GetTagId List.634; - let List.640 : Int1 = lowlevel Eq List.638 List.639; - if List.640 then - let List.447 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.634; - let List.636 : U64 = CallByName List.96 List.445; - jump List.631 List.442 List.447 List.444 List.636 List.446; - else - dec List.442; - let List.448 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.634; - let List.637 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) List.448; - ret List.637; +procedure List.80 (#Derived_gen.11, #Derived_gen.12, #Derived_gen.13, #Derived_gen.14, #Derived_gen.15): + joinpoint List.574 List.440 List.441 List.442 List.443 List.444: + let List.576 : Int1 = CallByName Num.22 List.443 List.444; + if List.576 then + let List.583 : U8 = CallByName List.66 List.440 List.443; + let List.577 : List U8 = CallByName List.145 List.441 List.583 List.442; + let List.580 : U64 = 1i64; + let List.579 : U64 = CallByName Num.51 List.443 List.580; + jump List.574 List.440 List.577 List.442 List.579 List.444; else - dec List.442; - let List.632 : [C {U64, Int1}, C {U64, Int1}] = TagId(1) List.443; - ret List.632; + dec List.440; + ret List.441; in - jump List.631 #Derived_gen.14 #Derived_gen.15 #Derived_gen.16 #Derived_gen.17 #Derived_gen.18; + jump List.574 #Derived_gen.11 #Derived_gen.12 #Derived_gen.13 #Derived_gen.14 #Derived_gen.15; procedure List.80 (#Derived_gen.19, #Derived_gen.20, #Derived_gen.21, #Derived_gen.22, #Derived_gen.23): - joinpoint List.558 List.442 List.443 List.444 List.445 List.446: - let List.560 : Int1 = CallByName Num.22 List.445 List.446; - if List.560 then - let List.568 : Str = CallByName List.66 List.442 List.445; - inc List.568; - let List.561 : {List U8, U64} = CallByName List.147 List.443 List.568 List.444; - let List.563 : U64 = CallByName List.96 List.445; - jump List.558 List.442 List.561 List.444 List.563 List.446; + joinpoint List.554 List.440 List.441 List.442 List.443 List.444: + let List.556 : Int1 = CallByName Num.22 List.443 List.444; + if List.556 then + let List.563 : Str = CallByName List.66 List.440 List.443; + inc List.563; + let List.557 : {List U8, U64} = CallByName List.145 List.441 List.563 List.442; + let List.560 : U64 = 1i64; + let List.559 : U64 = CallByName Num.51 List.443 List.560; + jump List.554 List.440 List.557 List.442 List.559 List.444; else - dec List.442; - ret List.443; + dec List.440; + ret List.441; in - jump List.558 #Derived_gen.19 #Derived_gen.20 #Derived_gen.21 #Derived_gen.22 #Derived_gen.23; + jump List.554 #Derived_gen.19 #Derived_gen.20 #Derived_gen.21 #Derived_gen.22 #Derived_gen.23; -procedure List.80 (#Derived_gen.9, #Derived_gen.10, #Derived_gen.11, #Derived_gen.12, #Derived_gen.13): - joinpoint List.579 List.442 List.443 List.444 List.445 List.446: - let List.581 : Int1 = CallByName Num.22 List.445 List.446; - if List.581 then - let List.587 : U8 = CallByName List.66 List.442 List.445; - let List.582 : List U8 = CallByName List.147 List.443 List.587 List.444; - let List.584 : U64 = CallByName List.96 List.445; - jump List.579 List.442 List.582 List.444 List.584 List.446; +procedure List.80 (#Derived_gen.3, #Derived_gen.4, #Derived_gen.5, #Derived_gen.6, #Derived_gen.7): + joinpoint List.627 List.440 List.441 List.442 List.443 List.444: + let List.629 : Int1 = CallByName Num.22 List.443 List.444; + if List.629 then + let List.638 : U8 = CallByName List.66 List.440 List.443; + let List.630 : [C {U64, Int1}, C {U64, Int1}] = CallByName TotallyNotJson.189 List.441 List.638; + let List.635 : U8 = 1i64; + let List.636 : U8 = GetTagId List.630; + let List.637 : Int1 = lowlevel Eq List.635 List.636; + if List.637 then + let List.445 : {U64, Int1} = UnionAtIndex (Id 1) (Index 0) List.630; + let List.633 : U64 = 1i64; + let List.632 : U64 = CallByName Num.51 List.443 List.633; + jump List.627 List.440 List.445 List.442 List.632 List.444; + else + dec List.440; + let List.446 : {U64, Int1} = UnionAtIndex (Id 0) (Index 0) List.630; + let List.634 : [C {U64, Int1}, C {U64, Int1}] = TagId(0) List.446; + ret List.634; else - dec List.442; - ret List.443; + dec List.440; + let List.628 : [C {U64, Int1}, C {U64, Int1}] = TagId(1) List.441; + ret List.628; in - jump List.579 #Derived_gen.9 #Derived_gen.10 #Derived_gen.11 #Derived_gen.12 #Derived_gen.13; + jump List.627 #Derived_gen.3 #Derived_gen.4 #Derived_gen.5 #Derived_gen.6 #Derived_gen.7; -procedure List.93 (List.439, List.440, List.441): - let List.556 : U64 = 0i64; - let List.557 : U64 = CallByName List.6 List.439; - let List.555 : {List U8, U64} = CallByName List.80 List.439 List.440 List.441 List.556 List.557; - ret List.555; +procedure List.93 (List.437, List.438, List.439): + let List.552 : U64 = 0i64; + let List.553 : U64 = CallByName List.6 List.437; + let List.551 : {List U8, U64} = CallByName List.80 List.437 List.438 List.439 List.552 List.553; + ret List.551; -procedure List.93 (List.439, List.440, List.441): - let List.577 : U64 = 0i64; - let List.578 : U64 = CallByName List.6 List.439; - let List.576 : List U8 = CallByName List.80 List.439 List.440 List.441 List.577 List.578; - ret List.576; +procedure List.93 (List.437, List.438, List.439): + let List.572 : U64 = 0i64; + let List.573 : U64 = CallByName List.6 List.437; + let List.571 : List U8 = CallByName List.80 List.437 List.438 List.439 List.572 List.573; + ret List.571; -procedure List.93 (List.439, List.440, List.441): - let List.629 : U64 = 0i64; - let List.630 : U64 = CallByName List.6 List.439; - let List.628 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.80 List.439 List.440 List.441 List.629 List.630; - ret List.628; - -procedure List.96 (List.463): - let List.565 : U64 = 1i64; - let List.564 : U64 = CallByName Num.51 List.463 List.565; - ret List.564; +procedure List.93 (List.437, List.438, List.439): + let List.625 : U64 = 0i64; + let List.626 : U64 = CallByName List.6 List.437; + let List.624 : [C {U64, Int1}, C {U64, Int1}] = CallByName List.80 List.437 List.438 List.439 List.625 List.626; + ret List.624; procedure Num.127 (#Attr.2): let Num.299 : U8 = lowlevel NumIntCast #Attr.2; @@ -230,28 +228,28 @@ procedure Num.21 (#Attr.2, #Attr.3): ret Num.305; procedure Num.22 (#Attr.2, #Attr.3): - let Num.309 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; - ret Num.309; - -procedure Num.24 (#Attr.2, #Attr.3): - let Num.311 : Int1 = lowlevel NumGt #Attr.2 #Attr.3; + let Num.311 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; ret Num.311; +procedure Num.24 (#Attr.2, #Attr.3): + let Num.313 : Int1 = lowlevel NumGt #Attr.2 #Attr.3; + ret Num.313; + procedure Num.51 (#Attr.2, #Attr.3): - let Num.306 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; - ret Num.306; + let Num.308 : U64 = lowlevel NumAddWrap #Attr.2 #Attr.3; + ret Num.308; procedure Num.75 (#Attr.2, #Attr.3): - let Num.310 : U64 = lowlevel NumSubWrap #Attr.2 #Attr.3; - ret Num.310; + let Num.312 : U64 = lowlevel NumSubWrap #Attr.2 #Attr.3; + ret Num.312; procedure Num.94 (#Attr.2, #Attr.3): let Num.304 : U64 = lowlevel NumDivCeilUnchecked #Attr.2 #Attr.3; ret Num.304; procedure Str.12 (#Attr.2): - let Str.292 : List U8 = lowlevel StrToUtf8 #Attr.2; - ret Str.292; + let Str.290 : List U8 = lowlevel StrToUtf8 #Attr.2; + ret Str.290; procedure Test.2 (Test.10): let Test.15 : {Str, Str} = CallByName Encode.23 Test.10; diff --git a/crates/compiler/test_mono/generated/unspecialized_lambda_set_unification_keeps_all_concrete_types_without_unification_of_unifiable.txt b/crates/compiler/test_mono/generated/unspecialized_lambda_set_unification_keeps_all_concrete_types_without_unification_of_unifiable.txt index 9eaaa78431..276bbd459f 100644 --- a/crates/compiler/test_mono/generated/unspecialized_lambda_set_unification_keeps_all_concrete_types_without_unification_of_unifiable.txt +++ b/crates/compiler/test_mono/generated/unspecialized_lambda_set_unification_keeps_all_concrete_types_without_unification_of_unifiable.txt @@ -81,100 +81,97 @@ procedure Encode.26 (Encode.105, Encode.106): let Encode.108 : List U8 = CallByName Encode.24 Encode.109 Encode.110 Encode.106; ret Encode.108; -procedure List.147 (List.148, List.149, List.146): - let List.572 : {List U8, U64} = CallByName TotallyNotJson.267 List.148 List.149 List.146; - ret List.572; +procedure List.145 (List.146, List.147, List.144): + let List.567 : {List U8, U64} = CallByName TotallyNotJson.267 List.146 List.147 List.144; + ret List.567; -procedure List.147 (List.148, List.149, List.146): - let List.621 : {List U8, U64} = CallByName TotallyNotJson.267 List.148 List.149 List.146; - ret List.621; +procedure List.145 (List.146, List.147, List.144): + let List.615 : {List U8, U64} = CallByName TotallyNotJson.267 List.146 List.147 List.144; + ret List.615; -procedure List.18 (List.144, List.145, List.146): - let List.552 : {List U8, U64} = CallByName List.93 List.144 List.145 List.146; - ret List.552; +procedure List.18 (List.142, List.143, List.144): + let List.548 : {List U8, U64} = CallByName List.93 List.142 List.143 List.144; + ret List.548; -procedure List.18 (List.144, List.145, List.146): - let List.601 : {List U8, U64} = CallByName List.93 List.144 List.145 List.146; - ret List.601; +procedure List.18 (List.142, List.143, List.144): + let List.596 : {List U8, U64} = CallByName List.93 List.142 List.143 List.144; + ret List.596; -procedure List.4 (List.115, List.116): - let List.600 : U64 = 1i64; - let List.599 : List U8 = CallByName List.70 List.115 List.600; - let List.598 : List U8 = CallByName List.71 List.599 List.116; - ret List.598; +procedure List.4 (List.113, List.114): + let List.595 : U64 = 1i64; + let List.594 : List U8 = CallByName List.70 List.113 List.595; + let List.593 : List U8 = CallByName List.71 List.594 List.114; + ret List.593; procedure List.6 (#Attr.2): - let List.573 : U64 = lowlevel ListLen #Attr.2; - ret List.573; + let List.568 : U64 = lowlevel ListLen #Attr.2; + ret List.568; procedure List.6 (#Attr.2): - let List.622 : U64 = lowlevel ListLen #Attr.2; - ret List.622; + let List.616 : U64 = lowlevel ListLen #Attr.2; + ret List.616; procedure List.66 (#Attr.2, #Attr.3): - let List.569 : [C {}, C {}] = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.569; + let List.564 : [C {}, C {}] = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.564; procedure List.66 (#Attr.2, #Attr.3): - let List.618 : [] = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.618; + let List.612 : [] = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.612; procedure List.70 (#Attr.2, #Attr.3): - let List.579 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; - ret List.579; + let List.574 : List U8 = lowlevel ListReserve #Attr.2 #Attr.3; + ret List.574; procedure List.71 (#Attr.2, #Attr.3): - let List.577 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; - ret List.577; + let List.572 : List U8 = lowlevel ListAppendUnsafe #Attr.2 #Attr.3; + ret List.572; procedure List.8 (#Attr.2, #Attr.3): - let List.623 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; - ret List.623; + let List.617 : List U8 = lowlevel ListConcat #Attr.2 #Attr.3; + ret List.617; -procedure List.80 (#Derived_gen.33, #Derived_gen.34, #Derived_gen.35, #Derived_gen.36, #Derived_gen.37): - joinpoint List.558 List.442 List.443 List.444 List.445 List.446: - let List.560 : Int1 = CallByName Num.22 List.445 List.446; - if List.560 then - let List.568 : [C {}, C {}] = CallByName List.66 List.442 List.445; - let List.561 : {List U8, U64} = CallByName List.147 List.443 List.568 List.444; - let List.563 : U64 = CallByName List.96 List.445; - jump List.558 List.442 List.561 List.444 List.563 List.446; +procedure List.80 (#Derived_gen.18, #Derived_gen.19, #Derived_gen.20, #Derived_gen.21, #Derived_gen.22): + joinpoint List.602 List.440 List.441 List.442 List.443 List.444: + let List.604 : Int1 = CallByName Num.22 List.443 List.444; + if List.604 then + let List.611 : [] = CallByName List.66 List.440 List.443; + let List.605 : {List U8, U64} = CallByName List.145 List.441 List.611 List.442; + let List.608 : U64 = 1i64; + let List.607 : U64 = CallByName Num.51 List.443 List.608; + jump List.602 List.440 List.605 List.442 List.607 List.444; else - dec List.442; - ret List.443; + dec List.440; + ret List.441; in - jump List.558 #Derived_gen.33 #Derived_gen.34 #Derived_gen.35 #Derived_gen.36 #Derived_gen.37; + jump List.602 #Derived_gen.18 #Derived_gen.19 #Derived_gen.20 #Derived_gen.21 #Derived_gen.22; procedure List.80 (#Derived_gen.38, #Derived_gen.39, #Derived_gen.40, #Derived_gen.41, #Derived_gen.42): - joinpoint List.607 List.442 List.443 List.444 List.445 List.446: - let List.609 : Int1 = CallByName Num.22 List.445 List.446; - if List.609 then - let List.617 : [] = CallByName List.66 List.442 List.445; - let List.610 : {List U8, U64} = CallByName List.147 List.443 List.617 List.444; - let List.612 : U64 = CallByName List.96 List.445; - jump List.607 List.442 List.610 List.444 List.612 List.446; + joinpoint List.554 List.440 List.441 List.442 List.443 List.444: + let List.556 : Int1 = CallByName Num.22 List.443 List.444; + if List.556 then + let List.563 : [C {}, C {}] = CallByName List.66 List.440 List.443; + let List.557 : {List U8, U64} = CallByName List.145 List.441 List.563 List.442; + let List.560 : U64 = 1i64; + let List.559 : U64 = CallByName Num.51 List.443 List.560; + jump List.554 List.440 List.557 List.442 List.559 List.444; else - dec List.442; - ret List.443; + dec List.440; + ret List.441; in - jump List.607 #Derived_gen.38 #Derived_gen.39 #Derived_gen.40 #Derived_gen.41 #Derived_gen.42; + jump List.554 #Derived_gen.38 #Derived_gen.39 #Derived_gen.40 #Derived_gen.41 #Derived_gen.42; -procedure List.93 (List.439, List.440, List.441): - let List.556 : U64 = 0i64; - let List.557 : U64 = CallByName List.6 List.439; - let List.555 : {List U8, U64} = CallByName List.80 List.439 List.440 List.441 List.556 List.557; - ret List.555; +procedure List.93 (List.437, List.438, List.439): + let List.552 : U64 = 0i64; + let List.553 : U64 = CallByName List.6 List.437; + let List.551 : {List U8, U64} = CallByName List.80 List.437 List.438 List.439 List.552 List.553; + ret List.551; -procedure List.93 (List.439, List.440, List.441): - let List.605 : U64 = 0i64; - let List.606 : U64 = CallByName List.6 List.439; - let List.604 : {List U8, U64} = CallByName List.80 List.439 List.440 List.441 List.605 List.606; - ret List.604; - -procedure List.96 (List.463): - let List.614 : U64 = 1i64; - let List.613 : U64 = CallByName Num.51 List.463 List.614; - ret List.613; +procedure List.93 (List.437, List.438, List.439): + let List.600 : U64 = 0i64; + let List.601 : U64 = CallByName List.6 List.437; + let List.599 : {List U8, U64} = CallByName List.80 List.437 List.438 List.439 List.600 List.601; + ret List.599; procedure Num.127 (#Attr.2): let Num.311 : U8 = lowlevel NumIntCast #Attr.2; @@ -197,8 +194,8 @@ procedure Num.51 (#Attr.2, #Attr.3): ret Num.314; procedure Str.12 (#Attr.2): - let Str.292 : List U8 = lowlevel StrToUtf8 #Attr.2; - ret Str.292; + let Str.290 : List U8 = lowlevel StrToUtf8 #Attr.2; + ret Str.290; procedure Test.2 (Test.11): let Test.18 : {{}, {}} = CallByName Encode.23 Test.11; diff --git a/crates/compiler/test_mono/generated/weakening_avoids_overspecialization.txt b/crates/compiler/test_mono/generated/weakening_avoids_overspecialization.txt index ac41c56890..02d6e69fc3 100644 --- a/crates/compiler/test_mono/generated/weakening_avoids_overspecialization.txt +++ b/crates/compiler/test_mono/generated/weakening_avoids_overspecialization.txt @@ -2,92 +2,88 @@ procedure Bool.11 (#Attr.2, #Attr.3): let Bool.24 : Int1 = lowlevel Eq #Attr.2 #Attr.3; ret Bool.24; -procedure List.26 (List.161, List.162, List.163): - let List.541 : [C U64, C U64] = CallByName List.93 List.161 List.162 List.163; - let List.544 : U8 = 1i64; - let List.545 : U8 = GetTagId List.541; - let List.546 : Int1 = lowlevel Eq List.544 List.545; - if List.546 then - let List.164 : U64 = UnionAtIndex (Id 1) (Index 0) List.541; - ret List.164; +procedure List.26 (List.159, List.160, List.161): + let List.537 : [C U64, C U64] = CallByName List.93 List.159 List.160 List.161; + let List.540 : U8 = 1i64; + let List.541 : U8 = GetTagId List.537; + let List.542 : Int1 = lowlevel Eq List.540 List.541; + if List.542 then + let List.162 : U64 = UnionAtIndex (Id 1) (Index 0) List.537; + ret List.162; else - let List.165 : U64 = UnionAtIndex (Id 0) (Index 0) List.541; - ret List.165; + let List.163 : U64 = UnionAtIndex (Id 0) (Index 0) List.537; + ret List.163; -procedure List.29 (List.306, List.307): - let List.540 : U64 = CallByName List.6 List.306; - let List.308 : U64 = CallByName Num.77 List.540 List.307; - let List.526 : List U8 = CallByName List.43 List.306 List.308; - ret List.526; +procedure List.29 (List.304, List.305): + let List.536 : U64 = CallByName List.6 List.304; + let List.306 : U64 = CallByName Num.77 List.536 List.305; + let List.522 : List U8 = CallByName List.43 List.304 List.306; + ret List.522; -procedure List.43 (List.304, List.305): - let List.538 : U64 = CallByName List.6 List.304; - let List.537 : U64 = CallByName Num.77 List.538 List.305; - let List.528 : {U64, U64} = Struct {List.305, List.537}; - let List.527 : List U8 = CallByName List.49 List.304 List.528; - ret List.527; +procedure List.43 (List.302, List.303): + let List.534 : U64 = CallByName List.6 List.302; + let List.533 : U64 = CallByName Num.77 List.534 List.303; + let List.524 : {U64, U64} = Struct {List.303, List.533}; + let List.523 : List U8 = CallByName List.49 List.302 List.524; + ret List.523; -procedure List.49 (List.379, List.380): - let List.535 : U64 = StructAtIndex 0 List.380; - let List.536 : U64 = 0i64; - let List.533 : Int1 = CallByName Bool.11 List.535 List.536; - if List.533 then - dec List.379; - let List.534 : List U8 = Array []; - ret List.534; +procedure List.49 (List.377, List.378): + let List.531 : U64 = StructAtIndex 0 List.378; + let List.532 : U64 = 0i64; + let List.529 : Int1 = CallByName Bool.11 List.531 List.532; + if List.529 then + dec List.377; + let List.530 : List U8 = Array []; + ret List.530; else - let List.530 : U64 = StructAtIndex 1 List.380; - let List.531 : U64 = StructAtIndex 0 List.380; - let List.529 : List U8 = CallByName List.72 List.379 List.530 List.531; - ret List.529; + let List.526 : U64 = StructAtIndex 1 List.378; + let List.527 : U64 = StructAtIndex 0 List.378; + let List.525 : List U8 = CallByName List.72 List.377 List.526 List.527; + ret List.525; procedure List.6 (#Attr.2): - let List.539 : U64 = lowlevel ListLen #Attr.2; - ret List.539; + let List.535 : U64 = lowlevel ListLen #Attr.2; + ret List.535; procedure List.66 (#Attr.2, #Attr.3): - let List.563 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; - ret List.563; + let List.558 : U8 = lowlevel ListGetUnsafe #Attr.2 #Attr.3; + ret List.558; procedure List.72 (#Attr.2, #Attr.3, #Attr.4): - let List.532 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; - ret List.532; + let List.528 : List U8 = lowlevel ListSublist #Attr.2 #Attr.3 #Attr.4; + ret List.528; procedure List.80 (#Derived_gen.0, #Derived_gen.1, #Derived_gen.2, #Derived_gen.3, #Derived_gen.4): - joinpoint List.550 List.442 List.443 List.444 List.445 List.446: - let List.552 : Int1 = CallByName Num.22 List.445 List.446; - if List.552 then - let List.562 : U8 = CallByName List.66 List.442 List.445; - let List.553 : [C U64, C U64] = CallByName Test.3 List.443 List.562; - let List.559 : U8 = 1i64; - let List.560 : U8 = GetTagId List.553; - let List.561 : Int1 = lowlevel Eq List.559 List.560; - if List.561 then - let List.447 : U64 = UnionAtIndex (Id 1) (Index 0) List.553; - let List.555 : U64 = CallByName List.96 List.445; - jump List.550 List.442 List.447 List.444 List.555 List.446; + joinpoint List.546 List.440 List.441 List.442 List.443 List.444: + let List.548 : Int1 = CallByName Num.22 List.443 List.444; + if List.548 then + let List.557 : U8 = CallByName List.66 List.440 List.443; + let List.549 : [C U64, C U64] = CallByName Test.3 List.441 List.557; + let List.554 : U8 = 1i64; + let List.555 : U8 = GetTagId List.549; + let List.556 : Int1 = lowlevel Eq List.554 List.555; + if List.556 then + let List.445 : U64 = UnionAtIndex (Id 1) (Index 0) List.549; + let List.552 : U64 = 1i64; + let List.551 : U64 = CallByName Num.51 List.443 List.552; + jump List.546 List.440 List.445 List.442 List.551 List.444; else - dec List.442; - let List.448 : U64 = UnionAtIndex (Id 0) (Index 0) List.553; - let List.558 : [C U64, C U64] = TagId(0) List.448; - ret List.558; + dec List.440; + let List.446 : U64 = UnionAtIndex (Id 0) (Index 0) List.549; + let List.553 : [C U64, C U64] = TagId(0) List.446; + ret List.553; else - dec List.442; - let List.551 : [C U64, C U64] = TagId(1) List.443; - ret List.551; + dec List.440; + let List.547 : [C U64, C U64] = TagId(1) List.441; + ret List.547; in - jump List.550 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4; + jump List.546 #Derived_gen.0 #Derived_gen.1 #Derived_gen.2 #Derived_gen.3 #Derived_gen.4; -procedure List.93 (List.439, List.440, List.441): - let List.548 : U64 = 0i64; - let List.549 : U64 = CallByName List.6 List.439; - let List.547 : [C U64, C U64] = CallByName List.80 List.439 List.440 List.441 List.548 List.549; - ret List.547; - -procedure List.96 (List.463): - let List.557 : U64 = 1i64; - let List.556 : U64 = CallByName Num.51 List.463 List.557; - ret List.556; +procedure List.93 (List.437, List.438, List.439): + let List.544 : U64 = 0i64; + let List.545 : U64 = CallByName List.6 List.437; + let List.543 : [C U64, C U64] = CallByName List.80 List.437 List.438 List.439 List.544 List.545; + ret List.543; procedure Num.22 (#Attr.2, #Attr.3): let Num.295 : Int1 = lowlevel NumLt #Attr.2 #Attr.3; From 1731bbbb9f9798d7d64b29a647062b3ccf7f1d86 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Sun, 13 Aug 2023 15:15:53 -0400 Subject: [PATCH 125/176] Improve some FAQ wording --- FAQ.md | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/FAQ.md b/FAQ.md index 3d8187c6ee..461e674004 100644 --- a/FAQ.md +++ b/FAQ.md @@ -259,16 +259,14 @@ Str.concat "Hello, " "World!" ``` It's unsurprising to most beginners that these work the same way; it's common for a beginner who has recently learned -how `|>` works to expect that `|> Str.concat "!"` would concatenate `!` onto the end of a string. +how `|>` works to assume that `|> Str.concat "!"` would concatenate `!` onto the end of a string. This is not how it works in curried languages, however. In curried languages with a `|>` operator, the first expression still returns `"Hello, World!"` but the second one returns `"World!Hello, "` instead. This can be an unpleasant surprise for beginners, but even experienced users commonly find that this behavior is less useful than having both of these expressions evaluate to the same thing. -In Roc, both expressions evaluate to the same thing in Roc because Roc's `|>` operator uses the expression before the `|>` as the _first_ argument, whereas in curried languages, `|>` uses it as the _last_ argument. - -(For example, this is how `|>` works in both [F#](https://docs.microsoft.com/en-us/dotnet/fsharp/language-reference/symbol-and-operator-reference/#function-symbols-and-operators) and in [Elm](https://package.elm-lang.org/packages/elm/core/1.0.5/Basics#|%3E), both of which are curried languages. In contrast, Roc's `|>` design uses the same argument ordering as [Elixir](https://hexdocs.pm/elixir/1.14.0/Kernel.html#%7C%3E/2) and [Gleam](https://gleam.run/book/tour/functions.html#pipe-operator), none of which are curried languages.) +In Roc, both expressions evaluate to the same thing because Roc's `|>` operator uses the expression before the `|>` as the _first_ argument, whereas in curried languages, `|>` uses it as the _last_ argument. For example, this is how `|>` works in both [F#](https://docs.microsoft.com/en-us/dotnet/fsharp/language-reference/symbol-and-operator-reference/#function-symbols-and-operators) and in [Elm](https://package.elm-lang.org/packages/elm/core/1.0.5/Basics#|%3E), both of which are curried languages. In contrast, Roc's `|>` design uses the same argument ordering as [Elixir](https://hexdocs.pm/elixir/1.14.0/Kernel.html#%7C%3E/2) and [Gleam](https://gleam.run/book/tour/functions.html#pipe-operator), none of which are curried languages. This comes up in other situations besides string concatenation. For example, consider subtraction and division: @@ -289,7 +287,7 @@ divides it by a number, and `|> Num.sub 1` takes the number 1 and subtracts a nu from it. This is once again both more surprising to beginners and less useful to experienced users. -This style has a second benefit when it comes to higher-order functions. Consider these two examples: +The way `|>` works in Roc has a second benefit when it comes to higher-order functions. Consider these two examples: ```elixir answer = List.map numbers \num -> @@ -332,6 +330,13 @@ answer = numbers ``` +The Roc version of this is nicer in that it doesn't require parentheses around the function argument. A curried language +could theoretically adopt Roc's style of `|>` (where it pipes in the first argument instead of the last argument), but +to get this second benefit, the language would also need to have `List.map` take the function as its second argument +instead of the first. However, this would work against currying's one upside; it would no longer work to write +`(List.map negate)` if the `List.map` arguments were flipped, the way they are in Roc. So currying and `|>` are unavoidably +in tension. + As a historical note, these stylistic benefits (of `|> Num.sub 1` working as expected, and being able to write `List.map numbers \num ->`) were not among the original reasons Roc did not have currying. These benefits were discovered after the decision had already been made that Roc would not be a curried language, and they served to reinforce after the fact that the decision was the right one for Roc given the language's goals. ### Currying and learning curve @@ -340,14 +345,14 @@ Currying leads to function signatures that look surprising to beginners. For exa [`Bool.and`](https://www.roc-lang.org/builtins/Bool#and) function has the type `Bool, Bool -> Bool`. If Roc were a curried language, this function would instead have the type `Bool -> Bool -> Bool`. Since no mainstream programming languages today are curried, anyone who knows a mainstream language and is learning their first curried language will -require additional explaination about why function types look this way. +require additional explanation about why function types look this way. This explanation is nontrivial. It requires explaining partial application, how curried functions facilitate partial application, how function signatures accurately reflect that they're curried, and going through examples for all of these. All of it builds up to the punchline that "technically, all functions in this language have a single argument," which some percentage of learners find interesting, and some percentage still find confusing even after all that explanation. -It's common for beginners to report that currying only "clikced" for them after spending significant time writing code +It's common for beginners to report that currying only "clicked" for them after spending significant time writing code in a curried language. This is not the end of the world, especially because it's easy enough to think "I still don't totally get this even after that explanation, but I can remember that function arguments are separated by `->` in this language and maybe I'll understand the rest later." Clearly currying doesn't preclude a language from being easy to learn, @@ -377,17 +382,16 @@ reverseSort : List elem -> List elem reverseSort = \list -> List.reverse (List.sort list) ``` -It's very common for programmers to build a mental model of what `compose List.reverse List.sort` does by -mentally translating it into `\list -> List.reverse (List.sort list)`. This makes it take longer to read -and to understand despite being technically more concise. Worse, in more complex examples (this is among -the tamest of pointfree function composition examples), the chances increase of making a mistake in the mental -translation step, leading to a misundesrtanding of what the function is doing—which can cause bugs. +It's common for programmers to build a mental model of what `compose List.reverse List.sort` does by mentally +translating it into `\list -> List.reverse (List.sort list)`. This extra mental translation step makes it take +longer to read and to understand despite being technically more concise. In more complex examples (this +is among the tamest of pointfree function composition examples), the chances increase of making a mistake in +the mental translation step, leading to a misundesrtanding of what the function is doing—which can cause bugs. -In these ways, pointfree function composition makes code take longer to read and to understand, while increasing the -odds of misunderstanding what the code is doing. Some languages place such a high value on conciseness that they would -consider the conciceness upside to outweigh these downsides, but Roc is not one of those languages. It's considered -stylistically better in Roc to write the second version above. Given this, since currying facilitates pointfree function -composition, making Roc a curried language would have the downside of facilitating an antipattern in the language. +Some languages place such a high value on conciseness that they would consider the conciceness upside to outweigh +these downsides, but Roc is not one of those languages. It's considered stylistically better in Roc to write the +second version above. Given this, since currying facilitates pointfree function composition, making Roc a curried +language would have the downside of facilitating an antipattern in the language. Stacking up all these downsides of currying against the one upside of making certain function calls more concise, it seems clear that Roc should not be a curried language. From 2c22786dc2eaba671f0e0221e405ab67b3152c3a Mon Sep 17 00:00:00 2001 From: Folkert Date: Wed, 16 Aug 2023 11:32:11 +0200 Subject: [PATCH 126/176] remove hardcoded type name --- crates/glue/src/RustGlue.roc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/glue/src/RustGlue.roc b/crates/glue/src/RustGlue.roc index d94c205fc2..dbbd468a1e 100644 --- a/crates/glue/src/RustGlue.roc +++ b/crates/glue/src/RustGlue.roc @@ -1171,7 +1171,7 @@ generateRecursiveTagUnion = \buf, types, id, tagUnionName, tags, discriminantSiz } } - fn unmasked_pointer(&self) -> *mut union_Op { + fn unmasked_pointer(&self) -> *mut union_\(escapedName) { debug_assert!(!self.0.is_null()); let mask = match std::mem::size_of::() { @@ -1180,10 +1180,10 @@ generateRecursiveTagUnion = \buf, types, id, tagUnionName, tags, discriminantSiz _ => unreachable!(), }; - ((self.0 as usize) & mask) as *mut union_Op + ((self.0 as usize) & mask) as *mut union_\(escapedName) } - unsafe fn ptr_read_union(&self) -> core::mem::ManuallyDrop { + unsafe fn ptr_read_union(&self) -> core::mem::ManuallyDrop { let ptr = self.unmasked_pointer(); core::mem::ManuallyDrop::new(unsafe { std::ptr::read(ptr) }) From 064613850986ad3de0c810e437b942bbf157b5b4 Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Wed, 16 Aug 2023 19:17:47 +0200 Subject: [PATCH 127/176] added comments, tests --- crates/cli/tests/cli_run.rs | 27 +++++++++++++++++++++++++-- examples/Community.roc | 3 +++ examples/GuiFormatter.roc | 2 ++ examples/LogFormatter.roc | 2 ++ examples/inspect-gui.roc | 4 ++++ examples/inspect-logging.roc | 6 +++++- 6 files changed, 41 insertions(+), 3 deletions(-) diff --git a/crates/cli/tests/cli_run.rs b/crates/cli/tests/cli_run.rs index f39dce01bb..ee26dca463 100644 --- a/crates/cli/tests/cli_run.rs +++ b/crates/cli/tests/cli_run.rs @@ -309,7 +309,7 @@ mod cli_run { if !actual.ends_with(expected_ending) { panic!( - "expected output to end with:\n{}\nbut instead got:\n{}\n stderr was:\n{}", + "> expected output to end with:\n{}\n> but instead got:\n{}\n> stderr was:\n{}", expected_ending, actual, out.stderr ); } @@ -387,7 +387,7 @@ mod cli_run { let mut custom_flags: Vec<&str> = Vec::new(); match executable_filename { - "form" | "hello-gui" | "breakout" | "libhello" => { + "form" | "hello-gui" | "breakout" | "libhello" | "inspect-gui" => { // Since these require things the build system often doesn't have // (e.g. GUIs open a window, Ruby needs ruby installed, WASM needs a browser) // we do `roc build` on them but don't run them. @@ -938,6 +938,29 @@ mod cli_run { test_roc_expect("examples/parser/package", "ParserHttp.roc") } + #[test] + fn inspect_logging() { + test_roc_app_slim( + "examples", + "inspect-logging.roc", + "inspect-logging", + r#"{people: [{firstName: "John", lastName: "Smith", age: 27, hasBeard: true, favoriteColor: Blue}, {firstName: "Debby", lastName: "Johnson", age: 47, hasBeard: false, favoriteColor: Green}, {firstName: "Jane", lastName: "Doe", age: 33, hasBeard: false, favoriteColor: (RGB (255, 255, 0))}], friends: [{2}, {2}, {0, 1}]} +"#, + UseValgrind::Yes, + ) + } + + #[test] + fn inspect_gui() { + test_roc_app_slim( + "examples", + "inspect-gui.roc", + "inspect-gui", + "", + UseValgrind::No, + ) + } + // TODO not sure if this cfg should still be here: #[cfg(not(debug_assertions))] // this is for testing the benchmarks, to perform proper benchmarks see crates/cli/benches/README.md mod test_benchmarks { diff --git a/examples/Community.roc b/examples/Community.roc index 5316c0fd52..7be09c317a 100644 --- a/examples/Community.roc +++ b/examples/Community.roc @@ -9,6 +9,8 @@ interface Community ] imports [] +## Datatype representing a community for demonstration purposes in inspect-gui.roc and inspect-logging.roc + Community := { people : List Person, friends : List (Set Nat), @@ -88,6 +90,7 @@ walkFriendNames = \@Community { people, friends }, s0, nextFn -> (nextFn s1 personName friendNames, id + 1) out +# The functions below will be auto-generated in the future inspectCommunity : Community -> Inspector f where f implements InspectFormatter inspectCommunity = \@Community { people, friends } -> f0 <- Inspect.custom diff --git a/examples/GuiFormatter.roc b/examples/GuiFormatter.roc index f48956363b..615edb15c8 100644 --- a/examples/GuiFormatter.roc +++ b/examples/GuiFormatter.roc @@ -5,6 +5,8 @@ interface GuiFormatter ] imports [] +## Creates GUI representations of Roc values, for use in inspect-gui.roc + ## This can't depend on the platform, so I just copied all of this. Rgba : { r : F32, g : F32, b : F32, a : F32 } diff --git a/examples/LogFormatter.roc b/examples/LogFormatter.roc index 2a4dc4f5d0..a9a015e58c 100644 --- a/examples/LogFormatter.roc +++ b/examples/LogFormatter.roc @@ -5,6 +5,8 @@ interface LogFormatter ] imports [] +## Creates String representations of Roc values, for use in inspect-logging.roc + LogFormatter := { data : Str } implements [ InspectFormatter { diff --git a/examples/inspect-gui.roc b/examples/inspect-gui.roc index bd15a57119..d7100d57a9 100644 --- a/examples/inspect-gui.roc +++ b/examples/inspect-gui.roc @@ -1,3 +1,7 @@ +# +# Visualizes Roc values in a basic GUI +# + app "inspect-gui" packages { pf: "gui/platform/main.roc" } imports [ diff --git a/examples/inspect-logging.roc b/examples/inspect-logging.roc index ea9b8cbc29..620156603c 100644 --- a/examples/inspect-logging.roc +++ b/examples/inspect-logging.roc @@ -1,5 +1,9 @@ +# +# Shows how Roc values can be logged +# + app "inspect-logging" - packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.3.2/tE4xS_zLdmmxmHwHih9kHWQ7fsXtJr7W7h3425-eZFk.tar.br" } + packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.5.0/Cufzl36_SnJ4QbOoEmiJ5dIpUxBvdB3NEySvuH82Wio.tar.br" } imports [ pf.Stdout, LogFormatter, From ba8b7f656c58a909337f754477f206376741eb16 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Thu, 17 Aug 2023 00:07:04 -0400 Subject: [PATCH 128/176] roc fmt on inspect examples --- examples/inspect-gui.roc | 1 - examples/inspect-logging.roc | 1 - 2 files changed, 2 deletions(-) diff --git a/examples/inspect-gui.roc b/examples/inspect-gui.roc index d7100d57a9..a3e0aa120c 100644 --- a/examples/inspect-gui.roc +++ b/examples/inspect-gui.roc @@ -1,7 +1,6 @@ # # Visualizes Roc values in a basic GUI # - app "inspect-gui" packages { pf: "gui/platform/main.roc" } imports [ diff --git a/examples/inspect-logging.roc b/examples/inspect-logging.roc index 620156603c..fd284def02 100644 --- a/examples/inspect-logging.roc +++ b/examples/inspect-logging.roc @@ -1,7 +1,6 @@ # # Shows how Roc values can be logged # - app "inspect-logging" packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.5.0/Cufzl36_SnJ4QbOoEmiJ5dIpUxBvdB3NEySvuH82Wio.tar.br" } imports [ From 946ff053fd82ca7aa1b30bf995254c1b23ce3cad Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Thu, 17 Aug 2023 15:17:47 -0400 Subject: [PATCH 129/176] Trying out some new copy on the WIP homepage --- www/wip_new_website/content/index.md | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/www/wip_new_website/content/index.md b/www/wip_new_website/content/index.md index 92f7397d2c..55a82b1cc1 100644 --- a/www/wip_new_website/content/index.md +++ b/www/wip_new_website/content/index.md @@ -1,7 +1,7 @@ # Roc -Work in progress! +A work-in-progress programming language that aims to be fast, friendly, and functional. - [tutorial](/wip/tutorial.html) @@ -10,27 +10,26 @@ Work in progress! - [help / group chat](https://roc.zulipchat.com), we're friendly! -## Goals - +## Goals
-

Fast

-

Runs fast, compiles fast.
Learn more

+

Fast

+

Roc aims to help you make delightful software, and delightful software feels snappy. The Roc compiler should run fast, and the programs it produces should also be able to run fast. The goal is not to make the fastest possible language, but it is a goal to generally outperform mainstream garbage-collected languages.Learn more

Friendly

-

User-friendly language, friendly community.
Learn more

+

Roc aims to be a user-friendly language with a friendly community of users. This involves the set of tools Roc ships with, how helpful those tools are, as well as the values of the community of Roc programmers around the world.Learn more

Functional

-

Pure functional programming, keep it simple.
Learn more

+

Roc is a purely functional programming language. All Roc values are semantically immutable constants, and all effects are asynchronous. These create helpful guarantees and can make testing effects faster and more reliable. Learn more

## Try Roc -The code below shows a Roc application which prints `Hello World!` to the terminal. It does this using the [roc-lang/basic-cli](https://github.com/roc-lang/basic-cli) platform. +The code below shows a Roc application which prints `Hello World!` to the terminal. It does this using the [roc-lang/basic-cli](https://github.com/roc-lang/basic-cli) platform. ```roc app "hello-world" @@ -38,7 +37,7 @@ app "hello-world" imports [pf.Stdout] provides [main] to pf -main = +main = Stdout.line "Hello, World!" ``` From 12324a0ca8a8e2719c51e135ad51efcb1986fe48 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Sun, 23 Jul 2023 20:09:46 -0400 Subject: [PATCH 130/176] Trying some more WIP copy ideas --- www/wip_new_website/content/index.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/www/wip_new_website/content/index.md b/www/wip_new_website/content/index.md index 55a82b1cc1..bec6925d71 100644 --- a/www/wip_new_website/content/index.md +++ b/www/wip_new_website/content/index.md @@ -14,15 +14,16 @@ A work-in-progress programming language that aims to be fast, friendly, and func

Fast

-

Roc aims to help you make delightful software, and delightful software feels snappy. The Roc compiler should run fast, and the programs it produces should also be able to run fast. The goal is not to make the fastest possible language, but it is a goal to generally outperform mainstream garbage-collected languages.Learn more

+

Delightful software runs fast. The Roc compiler should run fast, and it should be able to produce programs that run fast too. The goal here is not to make the world's fastest possible language, but we benchmark against mainstream garbage-collected languages and aim to outperform them. (Currently we succeed in some benchmarks but not others.)Learn more

Friendly

-

Roc aims to be a user-friendly language with a friendly community of users. This involves the set of tools Roc ships with, how helpful those tools are, as well as the values of the community of Roc programmers around the world.Learn more

+

Friendly

+

Roc aims to be a user-friendly language with a friendly community of users. This involves the set of tools Roc ships with, how helpful those tools are, and also the spirit of the (currently small) community of Roc programmers around the world.Learn more

Functional

-

Roc is a purely functional programming language. All Roc values are semantically immutable constants, and all effects are asynchronous. These create helpful guarantees and can make testing effects faster and more reliable. Learn more

+

Roc is a purely functional programming language. All Roc values are semantically immutable constants, and all effects are asynchronous. The language is built on a small set of simple primitives, which create helpful guarantees and make automated tests nicer to develop. Learn more

## Try Roc From 2b7da02769072ec073a6154db0b3dd3c51c78cf7 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Tue, 25 Jul 2023 12:02:22 -0400 Subject: [PATCH 131/176] More website copy ideas --- www/wip_new_website/content/index.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/www/wip_new_website/content/index.md b/www/wip_new_website/content/index.md index bec6925d71..daf3d7d9dc 100644 --- a/www/wip_new_website/content/index.md +++ b/www/wip_new_website/content/index.md @@ -14,16 +14,16 @@ A work-in-progress programming language that aims to be fast, friendly, and func

Fast

-

Delightful software runs fast. The Roc compiler should run fast, and it should be able to produce programs that run fast too. The goal here is not to make the world's fastest possible language, but we benchmark against mainstream garbage-collected languages and aim to outperform them. (Currently we succeed in some benchmarks but not others.)Learn more

+

Delightful software runs fast. The Roc compiler should run fast, and it should be able to produce programs that run fast too. What does fast mean here?

Friendly

Friendly

-

Roc aims to be a user-friendly language with a friendly community of users. This involves the set of tools Roc ships with, how helpful those tools are, and also the spirit of the (currently small) community of Roc programmers around the world.Learn more

+

Roc aims to be a user-friendly language with a friendly community of users. This involves the set of tools Roc includes, and also the spirit of the community of Roc programmers. What does friendly mean here?

Functional

-

Roc is a purely functional programming language. All Roc values are semantically immutable constants, and all effects are asynchronous. The language is built on a small set of simple primitives, which create helpful guarantees and make automated tests nicer to develop. Learn more

+

Roc is a purely functional programming language. The language is built on a small set of simple primitives, which together give you a toolset that's more than the sum of its parts. What does functional mean here?

## Try Roc From c2ff76e4802711e0c9f667fe0fb820cdc10012c4 Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Fri, 18 Aug 2023 11:43:34 +0200 Subject: [PATCH 132/176] test wasm repl inside nix --- .github/workflows/nix_linux_x86_64.yml | 6 ++++++ .github/workflows/nix_macos_apple_silicon.yml | 10 ++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/.github/workflows/nix_linux_x86_64.yml b/.github/workflows/nix_linux_x86_64.yml index 647adf6fa5..bda3880502 100644 --- a/.github/workflows/nix_linux_x86_64.yml +++ b/.github/workflows/nix_linux_x86_64.yml @@ -31,3 +31,9 @@ jobs: - name: test the dev backend # these tests require an explicit feature flag run: nix develop -c cargo test --locked --release --package test_gen --no-default-features --features gen-dev + + - name: wasm repl tests + run: nix develop -c crates/repl_test/test_wasm.sh + + - name: test building wasm repl + run: nix develop -c ./ci/www-repl.sh diff --git a/.github/workflows/nix_macos_apple_silicon.yml b/.github/workflows/nix_macos_apple_silicon.yml index 0f00277d2c..056424d209 100644 --- a/.github/workflows/nix_macos_apple_silicon.yml +++ b/.github/workflows/nix_macos_apple_silicon.yml @@ -39,11 +39,17 @@ jobs: run: cd examples/platform-switching/rust-platform && nix develop -c cargo test --release --locked - name: test launching the editor - run: cargo test --release --locked editor_launch_test::launch -- --ignored # `--ignored` to run this test that is ignored for "normal" runs + run: nix develop -c cargo test --release --locked editor_launch_test::launch -- --ignored # `--ignored` to run this test that is ignored for "normal" runs # we run the llvm wasm tests only on this machine because it is fast and wasm should be cross-target - name: execute llvm wasm tests with --release run: nix develop -c cargo test-gen-llvm-wasm --locked --release - name: test website build script - run: REPL_DEBUG=1 bash www/build.sh + run: nix develop -c REPL_DEBUG=1 bash www/build.sh + + - name: wasm repl tests + run: nix develop -c crates/repl_test/test_wasm.sh + + - name: test building wasm repl + run: nix develop -c ./ci/www-repl.sh From a77d249b9f4c70d5582d3c6c05874330a6399e35 Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Fri, 18 Aug 2023 12:30:55 +0200 Subject: [PATCH 133/176] added quotes for env var --- .github/workflows/nix_macos_apple_silicon.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nix_macos_apple_silicon.yml b/.github/workflows/nix_macos_apple_silicon.yml index 056424d209..30070d8ab2 100644 --- a/.github/workflows/nix_macos_apple_silicon.yml +++ b/.github/workflows/nix_macos_apple_silicon.yml @@ -46,7 +46,7 @@ jobs: run: nix develop -c cargo test-gen-llvm-wasm --locked --release - name: test website build script - run: nix develop -c REPL_DEBUG=1 bash www/build.sh + run: nix develop -c "REPL_DEBUG=1 bash www/build.sh" - name: wasm repl tests run: nix develop -c crates/repl_test/test_wasm.sh From 8073264d7ed2fa61020e5a7297e23dbde7ea3e5b Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Fri, 18 Aug 2023 13:19:03 +0200 Subject: [PATCH 134/176] ignore inspec_logging on windows the basic-cli build process does not yet include the necessary files for windows Signed-off-by: Anton-4 <17049058+Anton-4@users.noreply.github.com> --- crates/cli/tests/cli_run.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/cli/tests/cli_run.rs b/crates/cli/tests/cli_run.rs index ee26dca463..a1fb9c49f0 100644 --- a/crates/cli/tests/cli_run.rs +++ b/crates/cli/tests/cli_run.rs @@ -939,6 +939,7 @@ mod cli_run { } #[test] + #[cfg_attr(windows, ignore)] fn inspect_logging() { test_roc_app_slim( "examples", From a53d2defd67edf1ffefd7d59bd5c789cda9867d5 Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Fri, 18 Aug 2023 13:33:35 +0200 Subject: [PATCH 135/176] try to fix bash call Signed-off-by: Anton-4 <17049058+Anton-4@users.noreply.github.com> --- .github/workflows/nix_macos_apple_silicon.yml | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/.github/workflows/nix_macos_apple_silicon.yml b/.github/workflows/nix_macos_apple_silicon.yml index 30070d8ab2..c4a5a63c57 100644 --- a/.github/workflows/nix_macos_apple_silicon.yml +++ b/.github/workflows/nix_macos_apple_silicon.yml @@ -20,33 +20,33 @@ jobs: with: clean: "true" - - name: check formatting with rustfmt - run: nix develop -c cargo fmt --all -- --check + # - name: check formatting with rustfmt + # run: nix develop -c cargo fmt --all -- --check - - name: check code style with clippy - run: nix develop -c cargo clippy --workspace --tests -- --deny warnings + # - name: check code style with clippy + # run: nix develop -c cargo clippy --workspace --tests -- --deny warnings - - name: check code style with clippy --release - run: cargo clippy --workspace --tests --release -- --deny warnings + # - name: check code style with clippy --release + # run: cargo clippy --workspace --tests --release -- --deny warnings - - name: execute tests with --release - run: nix develop -c cargo test --locked --release + # - name: execute tests with --release + # run: nix develop -c cargo test --locked --release - - name: make a libapp.so for the next step - run: nix develop -c cargo run -- gen-stub-lib examples/platform-switching/rocLovesRust.roc + # - name: make a libapp.so for the next step + # run: nix develop -c cargo run -- gen-stub-lib examples/platform-switching/rocLovesRust.roc - - name: check that the platform`s produced dylib is loadable - run: cd examples/platform-switching/rust-platform && nix develop -c cargo test --release --locked + # - name: check that the platform`s produced dylib is loadable + # run: cd examples/platform-switching/rust-platform && nix develop -c cargo test --release --locked - - name: test launching the editor - run: nix develop -c cargo test --release --locked editor_launch_test::launch -- --ignored # `--ignored` to run this test that is ignored for "normal" runs + # - name: test launching the editor + # run: nix develop -c cargo test --release --locked editor_launch_test::launch -- --ignored # `--ignored` to run this test that is ignored for "normal" runs - # we run the llvm wasm tests only on this machine because it is fast and wasm should be cross-target - - name: execute llvm wasm tests with --release - run: nix develop -c cargo test-gen-llvm-wasm --locked --release + # # we run the llvm wasm tests only on this machine because it is fast and wasm should be cross-target + # - name: execute llvm wasm tests with --release + # run: nix develop -c cargo test-gen-llvm-wasm --locked --release - name: test website build script - run: nix develop -c "REPL_DEBUG=1 bash www/build.sh" + run: nix develop -c "REPL_DEBUG=1 ./www/build.sh" - name: wasm repl tests run: nix develop -c crates/repl_test/test_wasm.sh From 04134f6b0650c7de07f1902e2e0af4809ebf0c50 Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Fri, 18 Aug 2023 14:14:24 +0200 Subject: [PATCH 136/176] use `--env` for env var Signed-off-by: Anton-4 <17049058+Anton-4@users.noreply.github.com> --- .github/workflows/nix_macos_apple_silicon.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nix_macos_apple_silicon.yml b/.github/workflows/nix_macos_apple_silicon.yml index c4a5a63c57..010f9bd4c5 100644 --- a/.github/workflows/nix_macos_apple_silicon.yml +++ b/.github/workflows/nix_macos_apple_silicon.yml @@ -46,7 +46,7 @@ jobs: # run: nix develop -c cargo test-gen-llvm-wasm --locked --release - name: test website build script - run: nix develop -c "REPL_DEBUG=1 ./www/build.sh" + run: nix develop --env REPL_DEBUG=1 -c ./www/build.sh" - name: wasm repl tests run: nix develop -c crates/repl_test/test_wasm.sh From 9d81fbca975a1a254751cf68699bf6504aa052aa Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Fri, 18 Aug 2023 14:15:28 +0200 Subject: [PATCH 137/176] remove old dangling quote Signed-off-by: Anton-4 <17049058+Anton-4@users.noreply.github.com> --- .github/workflows/nix_macos_apple_silicon.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nix_macos_apple_silicon.yml b/.github/workflows/nix_macos_apple_silicon.yml index 010f9bd4c5..c4c85a2ee3 100644 --- a/.github/workflows/nix_macos_apple_silicon.yml +++ b/.github/workflows/nix_macos_apple_silicon.yml @@ -46,7 +46,7 @@ jobs: # run: nix develop -c cargo test-gen-llvm-wasm --locked --release - name: test website build script - run: nix develop --env REPL_DEBUG=1 -c ./www/build.sh" + run: nix develop --env REPL_DEBUG=1 -c ./www/build.sh - name: wasm repl tests run: nix develop -c crates/repl_test/test_wasm.sh From cb088e54fd1154a2455d1394921ddb162aafcaa4 Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Fri, 18 Aug 2023 14:19:37 +0200 Subject: [PATCH 138/176] try single quotes Signed-off-by: Anton-4 <17049058+Anton-4@users.noreply.github.com> --- .github/workflows/nix_macos_apple_silicon.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nix_macos_apple_silicon.yml b/.github/workflows/nix_macos_apple_silicon.yml index c4c85a2ee3..c66bfc8156 100644 --- a/.github/workflows/nix_macos_apple_silicon.yml +++ b/.github/workflows/nix_macos_apple_silicon.yml @@ -46,7 +46,7 @@ jobs: # run: nix develop -c cargo test-gen-llvm-wasm --locked --release - name: test website build script - run: nix develop --env REPL_DEBUG=1 -c ./www/build.sh + run: nix develop -c 'REPL_DEBUG=1 ./www/build.sh' - name: wasm repl tests run: nix develop -c crates/repl_test/test_wasm.sh From dd4e510384f0f4d37e5da744c1af693c4b3373a6 Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Fri, 18 Aug 2023 14:35:17 +0200 Subject: [PATCH 139/176] change env var approach Signed-off-by: Anton-4 <17049058+Anton-4@users.noreply.github.com> --- .github/workflows/nix_macos_apple_silicon.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/nix_macos_apple_silicon.yml b/.github/workflows/nix_macos_apple_silicon.yml index c66bfc8156..ef86e6f624 100644 --- a/.github/workflows/nix_macos_apple_silicon.yml +++ b/.github/workflows/nix_macos_apple_silicon.yml @@ -46,7 +46,10 @@ jobs: # run: nix develop -c cargo test-gen-llvm-wasm --locked --release - name: test website build script - run: nix develop -c 'REPL_DEBUG=1 ./www/build.sh' + run: | + sed -i '1aREPL_DEBUG=1' ./www/build.sh + cat ./www/build.sh + nix develop -c ./www/build.sh - name: wasm repl tests run: nix develop -c crates/repl_test/test_wasm.sh From ef6b2e97ae1378c2bbf45e3346772cdcaa08f733 Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Fri, 18 Aug 2023 14:36:33 +0200 Subject: [PATCH 140/176] use explicit bash Signed-off-by: Anton-4 <17049058+Anton-4@users.noreply.github.com> --- .github/workflows/nix_macos_apple_silicon.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nix_macos_apple_silicon.yml b/.github/workflows/nix_macos_apple_silicon.yml index ef86e6f624..68ef2536d5 100644 --- a/.github/workflows/nix_macos_apple_silicon.yml +++ b/.github/workflows/nix_macos_apple_silicon.yml @@ -49,7 +49,7 @@ jobs: run: | sed -i '1aREPL_DEBUG=1' ./www/build.sh cat ./www/build.sh - nix develop -c ./www/build.sh + nix develop -c bash www/build.sh - name: wasm repl tests run: nix develop -c crates/repl_test/test_wasm.sh From 4888d0fd623bd59107d052e1b63c5a49dcb4612a Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Fri, 18 Aug 2023 14:37:28 +0200 Subject: [PATCH 141/176] don't use dot Signed-off-by: Anton-4 <17049058+Anton-4@users.noreply.github.com> --- .github/workflows/nix_macos_apple_silicon.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/nix_macos_apple_silicon.yml b/.github/workflows/nix_macos_apple_silicon.yml index 68ef2536d5..b7ec7af799 100644 --- a/.github/workflows/nix_macos_apple_silicon.yml +++ b/.github/workflows/nix_macos_apple_silicon.yml @@ -47,8 +47,8 @@ jobs: - name: test website build script run: | - sed -i '1aREPL_DEBUG=1' ./www/build.sh - cat ./www/build.sh + sed -i '1aREPL_DEBUG=1' www/build.sh + cat www/build.sh nix develop -c bash www/build.sh - name: wasm repl tests From b0e24c3cc1959c765af2200b7dc74e57df0dc916 Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Fri, 18 Aug 2023 14:39:42 +0200 Subject: [PATCH 142/176] ls for debug Signed-off-by: Anton-4 <17049058+Anton-4@users.noreply.github.com> --- .github/workflows/nix_macos_apple_silicon.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/nix_macos_apple_silicon.yml b/.github/workflows/nix_macos_apple_silicon.yml index b7ec7af799..a94865b592 100644 --- a/.github/workflows/nix_macos_apple_silicon.yml +++ b/.github/workflows/nix_macos_apple_silicon.yml @@ -47,6 +47,7 @@ jobs: - name: test website build script run: | + ls sed -i '1aREPL_DEBUG=1' www/build.sh cat www/build.sh nix develop -c bash www/build.sh From 58af5d1fd1069d45ba9a70d3f789826bdc337d67 Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Fri, 18 Aug 2023 14:42:29 +0200 Subject: [PATCH 143/176] try different quotes Signed-off-by: Anton-4 <17049058+Anton-4@users.noreply.github.com> --- .github/workflows/nix_macos_apple_silicon.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/nix_macos_apple_silicon.yml b/.github/workflows/nix_macos_apple_silicon.yml index a94865b592..140da42dc0 100644 --- a/.github/workflows/nix_macos_apple_silicon.yml +++ b/.github/workflows/nix_macos_apple_silicon.yml @@ -47,8 +47,8 @@ jobs: - name: test website build script run: | - ls - sed -i '1aREPL_DEBUG=1' www/build.sh + ls www + sed -i "1aREPL_DEBUG=1" www/build.sh cat www/build.sh nix develop -c bash www/build.sh From 746c7d921f792fb8eb79557707afb5d7417404c6 Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Fri, 18 Aug 2023 15:00:25 +0200 Subject: [PATCH 144/176] sed is weird Signed-off-by: Anton-4 <17049058+Anton-4@users.noreply.github.com> --- .github/workflows/nix_macos_apple_silicon.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nix_macos_apple_silicon.yml b/.github/workflows/nix_macos_apple_silicon.yml index 140da42dc0..bc51715d7a 100644 --- a/.github/workflows/nix_macos_apple_silicon.yml +++ b/.github/workflows/nix_macos_apple_silicon.yml @@ -48,7 +48,7 @@ jobs: - name: test website build script run: | ls www - sed -i "1aREPL_DEBUG=1" www/build.sh + sed -i "" "1aREPL_DEBUG=1" www/build.sh cat www/build.sh nix develop -c bash www/build.sh From b0f72bab586deb6ec1ff9f90c7e98a6365dd344f Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Fri, 18 Aug 2023 15:54:15 +0200 Subject: [PATCH 145/176] 1a with space Signed-off-by: Anton-4 <17049058+Anton-4@users.noreply.github.com> --- .github/workflows/nix_macos_apple_silicon.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nix_macos_apple_silicon.yml b/.github/workflows/nix_macos_apple_silicon.yml index bc51715d7a..0b85e55828 100644 --- a/.github/workflows/nix_macos_apple_silicon.yml +++ b/.github/workflows/nix_macos_apple_silicon.yml @@ -48,7 +48,7 @@ jobs: - name: test website build script run: | ls www - sed -i "" "1aREPL_DEBUG=1" www/build.sh + sed -i "" "1a REPL_DEBUG=1" www/build.sh cat www/build.sh nix develop -c bash www/build.sh From 2c2978ae35484452669837cfebccb293abb0f43e Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Fri, 18 Aug 2023 15:55:13 +0200 Subject: [PATCH 146/176] try with slash Signed-off-by: Anton-4 <17049058+Anton-4@users.noreply.github.com> --- .github/workflows/nix_macos_apple_silicon.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nix_macos_apple_silicon.yml b/.github/workflows/nix_macos_apple_silicon.yml index 0b85e55828..a575893800 100644 --- a/.github/workflows/nix_macos_apple_silicon.yml +++ b/.github/workflows/nix_macos_apple_silicon.yml @@ -48,7 +48,7 @@ jobs: - name: test website build script run: | ls www - sed -i "" "1a REPL_DEBUG=1" www/build.sh + sed -i "" "1a\REPL_DEBUG=1" www/build.sh cat www/build.sh nix develop -c bash www/build.sh From 504ec74f6c2385746a57ee5b64fe8f40f11273b2 Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Fri, 18 Aug 2023 15:56:15 +0200 Subject: [PATCH 147/176] trying single quotes Signed-off-by: Anton-4 <17049058+Anton-4@users.noreply.github.com> --- .github/workflows/nix_macos_apple_silicon.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nix_macos_apple_silicon.yml b/.github/workflows/nix_macos_apple_silicon.yml index a575893800..f9bc5b38dc 100644 --- a/.github/workflows/nix_macos_apple_silicon.yml +++ b/.github/workflows/nix_macos_apple_silicon.yml @@ -48,7 +48,7 @@ jobs: - name: test website build script run: | ls www - sed -i "" "1a\REPL_DEBUG=1" www/build.sh + sed -i "" '1a\REPL_DEBUG=1' www/build.sh cat www/build.sh nix develop -c bash www/build.sh From 5ecb88bd8074377c4a977245f920c11620b909ac Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Fri, 18 Aug 2023 15:59:46 +0200 Subject: [PATCH 148/176] trying awk instead Signed-off-by: Anton-4 <17049058+Anton-4@users.noreply.github.com> --- .github/workflows/nix_macos_apple_silicon.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nix_macos_apple_silicon.yml b/.github/workflows/nix_macos_apple_silicon.yml index f9bc5b38dc..9dc99c817a 100644 --- a/.github/workflows/nix_macos_apple_silicon.yml +++ b/.github/workflows/nix_macos_apple_silicon.yml @@ -48,7 +48,7 @@ jobs: - name: test website build script run: | ls www - sed -i "" '1a\REPL_DEBUG=1' www/build.sh + awk 'NR==1 {print; print "REPL_DEBUG=1"; next} 1' www/build.sh > tmpfile.txt && mv tmpfile.txt www/build.sh cat www/build.sh nix develop -c bash www/build.sh From 8acaf6811f21a88ddf3479061d4cb9d6d9308262 Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Fri, 18 Aug 2023 16:23:52 +0200 Subject: [PATCH 149/176] add libcurl for wasm Signed-off-by: Anton-4 <17049058+Anton-4@users.noreply.github.com> --- flake.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/flake.nix b/flake.nix index 4493103d8f..091c11bb1c 100644 --- a/flake.nix +++ b/flake.nix @@ -56,6 +56,7 @@ Foundation Metal Security + curl # for wasm-bindgen-cli libcurl (see ./ci/www-repl.sh) ]); # For debugging LLVM IR From b349b3308f1ae931fafc1a600e3c70fe7badbc18 Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Fri, 18 Aug 2023 17:18:35 +0200 Subject: [PATCH 150/176] re-enable all steps Signed-off-by: Anton-4 <17049058+Anton-4@users.noreply.github.com> --- .github/workflows/nix_macos_apple_silicon.yml | 38 +++++++++---------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/.github/workflows/nix_macos_apple_silicon.yml b/.github/workflows/nix_macos_apple_silicon.yml index 9dc99c817a..441e0b376e 100644 --- a/.github/workflows/nix_macos_apple_silicon.yml +++ b/.github/workflows/nix_macos_apple_silicon.yml @@ -20,36 +20,34 @@ jobs: with: clean: "true" - # - name: check formatting with rustfmt - # run: nix develop -c cargo fmt --all -- --check + - name: check formatting with rustfmt + run: nix develop -c cargo fmt --all -- --check - # - name: check code style with clippy - # run: nix develop -c cargo clippy --workspace --tests -- --deny warnings + - name: check code style with clippy + run: nix develop -c cargo clippy --workspace --tests -- --deny warnings - # - name: check code style with clippy --release - # run: cargo clippy --workspace --tests --release -- --deny warnings + - name: check code style with clippy --release + run: cargo clippy --workspace --tests --release -- --deny warnings - # - name: execute tests with --release - # run: nix develop -c cargo test --locked --release + - name: execute tests with --release + run: nix develop -c cargo test --locked --release - # - name: make a libapp.so for the next step - # run: nix develop -c cargo run -- gen-stub-lib examples/platform-switching/rocLovesRust.roc + - name: make a libapp.so for the next step + run: nix develop -c cargo run -- gen-stub-lib examples/platform-switching/rocLovesRust.roc - # - name: check that the platform`s produced dylib is loadable - # run: cd examples/platform-switching/rust-platform && nix develop -c cargo test --release --locked + - name: check that the platform`s produced dylib is loadable + run: cd examples/platform-switching/rust-platform && nix develop -c cargo test --release --locked - # - name: test launching the editor - # run: nix develop -c cargo test --release --locked editor_launch_test::launch -- --ignored # `--ignored` to run this test that is ignored for "normal" runs + - name: test launching the editor + run: nix develop -c cargo test --release --locked editor_launch_test::launch -- --ignored # `--ignored` to run this test that is ignored for "normal" runs - # # we run the llvm wasm tests only on this machine because it is fast and wasm should be cross-target - # - name: execute llvm wasm tests with --release - # run: nix develop -c cargo test-gen-llvm-wasm --locked --release + # we run the llvm wasm tests only on this machine because it is fast and wasm should be cross-target + - name: execute llvm wasm tests with --release + run: nix develop -c cargo test-gen-llvm-wasm --locked --release - - name: test website build script + - name: set env var and test website build script run: | - ls www awk 'NR==1 {print; print "REPL_DEBUG=1"; next} 1' www/build.sh > tmpfile.txt && mv tmpfile.txt www/build.sh - cat www/build.sh nix develop -c bash www/build.sh - name: wasm repl tests From 365e8a2f91e24fec8defcc95d74190b3eaa47d32 Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Fri, 18 Aug 2023 17:34:27 +0200 Subject: [PATCH 151/176] test nightly on macos 13 --- .github/workflows/benchmarks.yml | 2 +- .github/workflows/macos_x86_64.yml | 2 +- .github/workflows/markdown_link_check.yml | 2 +- .github/workflows/nix_linux_x86_64.yml | 2 +- .github/workflows/nix_macos_apple_silicon.yml | 2 +- .github/workflows/nix_macos_x86_64.yml | 2 +- .github/workflows/spellcheck.yml | 2 +- .github/workflows/test_nightly_many_os.yml | 8 ++++---- .github/workflows/ubuntu_x86_64.yml | 2 +- .github/workflows/windows_release_build.yml | 2 +- .github/workflows/windows_tests.yml | 2 +- 11 files changed, 14 insertions(+), 14 deletions(-) diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index 4d016a3e3c..fca4c6d865 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -1,5 +1,5 @@ on: - pull_request: +# pull_request: name: Benchmarks diff --git a/.github/workflows/macos_x86_64.yml b/.github/workflows/macos_x86_64.yml index fc3527fa29..b70aabd719 100644 --- a/.github/workflows/macos_x86_64.yml +++ b/.github/workflows/macos_x86_64.yml @@ -1,5 +1,5 @@ on: - pull_request: +# pull_request: name: Macos x86-64 rust tests diff --git a/.github/workflows/markdown_link_check.yml b/.github/workflows/markdown_link_check.yml index 1b60da4f8c..87941eb28c 100644 --- a/.github/workflows/markdown_link_check.yml +++ b/.github/workflows/markdown_link_check.yml @@ -1,5 +1,5 @@ on: - pull_request: +# pull_request: schedule: - cron: '0 9 * * *' # 9=9am utc+0 diff --git a/.github/workflows/nix_linux_x86_64.yml b/.github/workflows/nix_linux_x86_64.yml index 647adf6fa5..7b28fd69fa 100644 --- a/.github/workflows/nix_linux_x86_64.yml +++ b/.github/workflows/nix_linux_x86_64.yml @@ -1,5 +1,5 @@ on: - pull_request: +# pull_request: name: Nix linux x86_64 cargo test diff --git a/.github/workflows/nix_macos_apple_silicon.yml b/.github/workflows/nix_macos_apple_silicon.yml index 0f00277d2c..5dcb37608e 100644 --- a/.github/workflows/nix_macos_apple_silicon.yml +++ b/.github/workflows/nix_macos_apple_silicon.yml @@ -1,5 +1,5 @@ on: - pull_request: +# pull_request: name: Nix apple silicon cargo test diff --git a/.github/workflows/nix_macos_x86_64.yml b/.github/workflows/nix_macos_x86_64.yml index 7c9e43aa28..19201b606c 100644 --- a/.github/workflows/nix_macos_x86_64.yml +++ b/.github/workflows/nix_macos_x86_64.yml @@ -1,5 +1,5 @@ on: - pull_request: +# pull_request: name: Nix macOS x86_64 cargo test diff --git a/.github/workflows/spellcheck.yml b/.github/workflows/spellcheck.yml index fb7f9284c0..39a1af91bf 100644 --- a/.github/workflows/spellcheck.yml +++ b/.github/workflows/spellcheck.yml @@ -1,5 +1,5 @@ on: - pull_request: +# pull_request: name: SpellCheck diff --git a/.github/workflows/test_nightly_many_os.yml b/.github/workflows/test_nightly_many_os.yml index aeb25e52d6..2a5ab9ccac 100644 --- a/.github/workflows/test_nightly_many_os.yml +++ b/.github/workflows/test_nightly_many_os.yml @@ -1,16 +1,16 @@ on: - #pull_request: + pull_request: workflow_dispatch: -name: Test latest nightly release for macOS, ubu 20.04, ubu 22.04 x86_64 +name: Test latest nightly releases for macOS and Linux x86_64 jobs: test-nightly: - name: test nightly macos 11, macos 12, ubu 20.04, ubu 22.04 + name: test nightly macos 11/12/13, ubuntu 20.04/22.04 strategy: fail-fast: false matrix: - os: [ macos-11, macos-12, ubuntu-20.04, ubuntu-22.04 ] + os: [ macos-11, macos-12, macos-13, ubuntu-20.04, ubuntu-22.04 ] runs-on: ${{ matrix.os }} timeout-minutes: 90 steps: diff --git a/.github/workflows/ubuntu_x86_64.yml b/.github/workflows/ubuntu_x86_64.yml index a411f73d12..1968844a35 100644 --- a/.github/workflows/ubuntu_x86_64.yml +++ b/.github/workflows/ubuntu_x86_64.yml @@ -1,5 +1,5 @@ on: - pull_request: +# pull_request: name: CI diff --git a/.github/workflows/windows_release_build.yml b/.github/workflows/windows_release_build.yml index fee39a873a..dfe1063d90 100644 --- a/.github/workflows/windows_release_build.yml +++ b/.github/workflows/windows_release_build.yml @@ -1,5 +1,5 @@ on: - pull_request: +# pull_request: name: windows - release build diff --git a/.github/workflows/windows_tests.yml b/.github/workflows/windows_tests.yml index 82920c2a5f..de7be4da84 100644 --- a/.github/workflows/windows_tests.yml +++ b/.github/workflows/windows_tests.yml @@ -1,5 +1,5 @@ on: - pull_request: +# pull_request: name: windows - subset of tests From 5975e06722a903e3a0586a6dd964a5bebc999bcb Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Fri, 18 Aug 2023 18:18:04 +0200 Subject: [PATCH 152/176] try to reproduce #5765 --- ci/basic_nightly_test.sh | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/ci/basic_nightly_test.sh b/ci/basic_nightly_test.sh index dca5da8ae0..aa26e39acb 100755 --- a/ci/basic_nightly_test.sh +++ b/ci/basic_nightly_test.sh @@ -29,11 +29,29 @@ mv roc_nightly* roc_nightly cd roc_nightly # test roc hello world -./roc examples/helloWorld.roc +./roc examples/helloWorld.roc + +./roc dev examples/helloWorld.roc ./roc examples/platform-switching/rocLovesRust.roc -./roc examples/platform-switching/rocLovesZig.roc +run_zig_test=true +# Detect macOS version +if [[ "$(uname)" == "Darwin" ]]; then + macos_version=$(sw_vers -productVersion) + major_version=$(echo $macos_version | cut -d. -f1) + minor_version=$(echo $macos_version | cut -d. -f2) + + # If macOS 13, then set the flag to skip + if [[ $major_version -eq 10 && $minor_version -eq 13 ]]; then + echo "Skipping zig test on macOS 13 due to https://github.com/roc-lang/roc/issues/5590..." + run_zig_test=false + fi +fi + +if $run_zig_test ; then + ./roc examples/platform-switching/rocLovesZig.roc +fi ./roc examples/platform-switching/rocLovesC.roc From 935dbf5c8cba378ce470a5dc2ead6b3b63b3ca6f Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Fri, 18 Aug 2023 18:22:20 +0200 Subject: [PATCH 153/176] fix version check --- ci/basic_nightly_test.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ci/basic_nightly_test.sh b/ci/basic_nightly_test.sh index aa26e39acb..639548d3b2 100755 --- a/ci/basic_nightly_test.sh +++ b/ci/basic_nightly_test.sh @@ -40,10 +40,9 @@ run_zig_test=true if [[ "$(uname)" == "Darwin" ]]; then macos_version=$(sw_vers -productVersion) major_version=$(echo $macos_version | cut -d. -f1) - minor_version=$(echo $macos_version | cut -d. -f2) # If macOS 13, then set the flag to skip - if [[ $major_version -eq 10 && $minor_version -eq 13 ]]; then + if [[ $major_version -eq 13 ]]; then echo "Skipping zig test on macOS 13 due to https://github.com/roc-lang/roc/issues/5590..." run_zig_test=false fi From 89a950d3bf2da851c58249256fd5e00de0f3a0b8 Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Fri, 18 Aug 2023 19:11:52 +0200 Subject: [PATCH 154/176] remove debug dev, re-enable other CI --- .github/workflows/benchmarks.yml | 2 +- .github/workflows/macos_x86_64.yml | 2 +- .github/workflows/markdown_link_check.yml | 2 +- .github/workflows/nix_linux_x86_64.yml | 2 +- .github/workflows/nix_macos_apple_silicon.yml | 2 +- .github/workflows/nix_macos_x86_64.yml | 2 +- .github/workflows/spellcheck.yml | 2 +- .github/workflows/test_nightly_many_os.yml | 2 +- .github/workflows/ubuntu_x86_64.yml | 2 +- .github/workflows/windows_release_build.yml | 2 +- .github/workflows/windows_tests.yml | 2 +- ci/basic_nightly_test.sh | 2 -- 12 files changed, 11 insertions(+), 13 deletions(-) diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index fca4c6d865..4d016a3e3c 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -1,5 +1,5 @@ on: -# pull_request: + pull_request: name: Benchmarks diff --git a/.github/workflows/macos_x86_64.yml b/.github/workflows/macos_x86_64.yml index b70aabd719..fc3527fa29 100644 --- a/.github/workflows/macos_x86_64.yml +++ b/.github/workflows/macos_x86_64.yml @@ -1,5 +1,5 @@ on: -# pull_request: + pull_request: name: Macos x86-64 rust tests diff --git a/.github/workflows/markdown_link_check.yml b/.github/workflows/markdown_link_check.yml index 87941eb28c..1b60da4f8c 100644 --- a/.github/workflows/markdown_link_check.yml +++ b/.github/workflows/markdown_link_check.yml @@ -1,5 +1,5 @@ on: -# pull_request: + pull_request: schedule: - cron: '0 9 * * *' # 9=9am utc+0 diff --git a/.github/workflows/nix_linux_x86_64.yml b/.github/workflows/nix_linux_x86_64.yml index 7b28fd69fa..647adf6fa5 100644 --- a/.github/workflows/nix_linux_x86_64.yml +++ b/.github/workflows/nix_linux_x86_64.yml @@ -1,5 +1,5 @@ on: -# pull_request: + pull_request: name: Nix linux x86_64 cargo test diff --git a/.github/workflows/nix_macos_apple_silicon.yml b/.github/workflows/nix_macos_apple_silicon.yml index 5dcb37608e..0f00277d2c 100644 --- a/.github/workflows/nix_macos_apple_silicon.yml +++ b/.github/workflows/nix_macos_apple_silicon.yml @@ -1,5 +1,5 @@ on: -# pull_request: + pull_request: name: Nix apple silicon cargo test diff --git a/.github/workflows/nix_macos_x86_64.yml b/.github/workflows/nix_macos_x86_64.yml index 19201b606c..7c9e43aa28 100644 --- a/.github/workflows/nix_macos_x86_64.yml +++ b/.github/workflows/nix_macos_x86_64.yml @@ -1,5 +1,5 @@ on: -# pull_request: + pull_request: name: Nix macOS x86_64 cargo test diff --git a/.github/workflows/spellcheck.yml b/.github/workflows/spellcheck.yml index 39a1af91bf..fb7f9284c0 100644 --- a/.github/workflows/spellcheck.yml +++ b/.github/workflows/spellcheck.yml @@ -1,5 +1,5 @@ on: -# pull_request: + pull_request: name: SpellCheck diff --git a/.github/workflows/test_nightly_many_os.yml b/.github/workflows/test_nightly_many_os.yml index 2a5ab9ccac..c4160648f1 100644 --- a/.github/workflows/test_nightly_many_os.yml +++ b/.github/workflows/test_nightly_many_os.yml @@ -1,5 +1,5 @@ on: - pull_request: + #pull_request: workflow_dispatch: name: Test latest nightly releases for macOS and Linux x86_64 diff --git a/.github/workflows/ubuntu_x86_64.yml b/.github/workflows/ubuntu_x86_64.yml index 1968844a35..a411f73d12 100644 --- a/.github/workflows/ubuntu_x86_64.yml +++ b/.github/workflows/ubuntu_x86_64.yml @@ -1,5 +1,5 @@ on: -# pull_request: + pull_request: name: CI diff --git a/.github/workflows/windows_release_build.yml b/.github/workflows/windows_release_build.yml index dfe1063d90..fee39a873a 100644 --- a/.github/workflows/windows_release_build.yml +++ b/.github/workflows/windows_release_build.yml @@ -1,5 +1,5 @@ on: -# pull_request: + pull_request: name: windows - release build diff --git a/.github/workflows/windows_tests.yml b/.github/workflows/windows_tests.yml index de7be4da84..545be60e78 100644 --- a/.github/workflows/windows_tests.yml +++ b/.github/workflows/windows_tests.yml @@ -1,5 +1,5 @@ on: -# pull_request: + pull_request: name: windows - subset of tests diff --git a/ci/basic_nightly_test.sh b/ci/basic_nightly_test.sh index 639548d3b2..ea60517be6 100755 --- a/ci/basic_nightly_test.sh +++ b/ci/basic_nightly_test.sh @@ -31,8 +31,6 @@ cd roc_nightly # test roc hello world ./roc examples/helloWorld.roc -./roc dev examples/helloWorld.roc - ./roc examples/platform-switching/rocLovesRust.roc run_zig_test=true From 788c0fa00bff17fe80846abe1a2c6fe6f649f35f Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Fri, 18 Aug 2023 19:19:57 +0200 Subject: [PATCH 155/176] remove REPL_DEBUG=1 This env var may not be needed, trying to see how it goes without. --- .github/workflows/nix_macos_apple_silicon.yml | 1 - .github/workflows/ubuntu_x86_64.yml | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/nix_macos_apple_silicon.yml b/.github/workflows/nix_macos_apple_silicon.yml index 441e0b376e..065456ad7d 100644 --- a/.github/workflows/nix_macos_apple_silicon.yml +++ b/.github/workflows/nix_macos_apple_silicon.yml @@ -47,7 +47,6 @@ jobs: - name: set env var and test website build script run: | - awk 'NR==1 {print; print "REPL_DEBUG=1"; next} 1' www/build.sh > tmpfile.txt && mv tmpfile.txt www/build.sh nix develop -c bash www/build.sh - name: wasm repl tests diff --git a/.github/workflows/ubuntu_x86_64.yml b/.github/workflows/ubuntu_x86_64.yml index a411f73d12..86a6eb8040 100644 --- a/.github/workflows/ubuntu_x86_64.yml +++ b/.github/workflows/ubuntu_x86_64.yml @@ -65,4 +65,4 @@ jobs: #TODO verify-no-git-changes - name: test website build script - run: REPL_DEBUG=1 bash www/build.sh + run: bash www/build.sh From 7be590fae9ab0a5ef65abd23190a499f5c9e99ca Mon Sep 17 00:00:00 2001 From: Folkert Date: Mon, 28 Aug 2023 21:31:50 +0200 Subject: [PATCH 156/176] glue: find platform main file --- crates/glue/src/load.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/crates/glue/src/load.rs b/crates/glue/src/load.rs index 8c6aea99ee..834d66e3b7 100644 --- a/crates/glue/src/load.rs +++ b/crates/glue/src/load.rs @@ -340,7 +340,6 @@ pub fn load_types( let function_kind = FunctionKind::LambdaSet; let arena = &Bump::new(); let LoadedModule { - module_id: home, mut can_problems, mut type_problems, mut declarations_by_id, @@ -372,6 +371,13 @@ pub fn load_types( } }); + // find the platform's main module + let home = declarations_by_id + .keys() + .find(|id| format!("{id:?}").trim_start_matches("pf.").is_empty()) + .copied() + .unwrap(); + let decls = declarations_by_id.remove(&home).unwrap(); let subs = solved.inner_mut(); From a0d291b1a730a9650d1fdd812d5bf29f8fe8d1b6 Mon Sep 17 00:00:00 2001 From: Folkert Date: Fri, 1 Sep 2023 20:01:16 +0200 Subject: [PATCH 157/176] force the alignment of include_bytes! for Subs --- crates/compiler/load/src/lib.rs | 69 +++++++++++++++++++++------------ 1 file changed, 45 insertions(+), 24 deletions(-) diff --git a/crates/compiler/load/src/lib.rs b/crates/compiler/load/src/lib.rs index 75cc9bf1b3..3dc1ecc6a7 100644 --- a/crates/compiler/load/src/lib.rs +++ b/crates/compiler/load/src/lib.rs @@ -200,19 +200,27 @@ pub fn load_and_typecheck_str<'a>( } } +macro_rules! include_bytes_align_as { + ($align_ty:ty, $path:expr) => {{ + // const block expression to encapsulate the static + + #[repr(C)] + pub struct AlignedAs { + pub _align: [Align; 0], + pub bytes: Bytes, + } + + // this assignment is made possible by CoerceUnsized + static ALIGNED: &AlignedAs<$align_ty, [u8]> = &AlignedAs { + _align: [], + bytes: *include_bytes!($path), + }; + + &ALIGNED.bytes + }}; +} + // IFTTT: crates/compiler/load/build.rs -const BOOL: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/Bool.dat")) as &[_]; -const DICT: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/Dict.dat")) as &[_]; -const SET: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/Set.dat")) as &[_]; -const RESULT: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/Result.dat")) as &[_]; -const NUM: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/Num.dat")) as &[_]; -const LIST: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/List.dat")) as &[_]; -const STR: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/Str.dat")) as &[_]; -const BOX: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/Box.dat")) as &[_]; -const ENCODE: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/Encode.dat")) as &[_]; -const DECODE: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/Decode.dat")) as &[_]; -const HASH: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/Hash.dat")) as &[_]; -const INSPECT: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/Inspect.dat")) as &[_]; fn deserialize_help(bytes: &[u8]) -> TypeState { let (state, _offset) = TypeState::deserialize(bytes); @@ -222,28 +230,41 @@ fn deserialize_help(bytes: &[u8]) -> TypeState { } fn read_cached_types() -> MutMap { + let mod_bool = include_bytes_align_as!(u128, concat!(env!("OUT_DIR"), "/Bool.dat")); + let mod_dict = include_bytes_align_as!(u128, concat!(env!("OUT_DIR"), "/Dict.dat")); + let mod_set = include_bytes_align_as!(u128, concat!(env!("OUT_DIR"), "/Set.dat")); + let mod_result = include_bytes_align_as!(u128, concat!(env!("OUT_DIR"), "/Result.dat")); + let mod_num = include_bytes_align_as!(u128, concat!(env!("OUT_DIR"), "/Num.dat")); + let mod_list = include_bytes_align_as!(u128, concat!(env!("OUT_DIR"), "/List.dat")); + let mod_str = include_bytes_align_as!(u128, concat!(env!("OUT_DIR"), "/Str.dat")); + let mod_box = include_bytes_align_as!(u128, concat!(env!("OUT_DIR"), "/Box.dat")); + let mod_encode = include_bytes_align_as!(u128, concat!(env!("OUT_DIR"), "/Encode.dat")); + let mod_decode = include_bytes_align_as!(u128, concat!(env!("OUT_DIR"), "/Decode.dat")); + let mod_hash = include_bytes_align_as!(u128, concat!(env!("OUT_DIR"), "/Hash.dat")); + let mod_inspect = include_bytes_align_as!(u128, concat!(env!("OUT_DIR"), "/Inspect.dat")); + let mut output = MutMap::default(); // Wasm seems to re-order definitions between build time and runtime, but only in release mode. // That is very strange, but we can solve it separately if !cfg!(target_family = "wasm") && !cfg!(windows) && !SKIP_SUBS_CACHE { - output.insert(ModuleId::BOOL, deserialize_help(BOOL)); + output.insert(ModuleId::BOOL, deserialize_help(mod_bool)); - output.insert(ModuleId::RESULT, deserialize_help(RESULT)); - output.insert(ModuleId::NUM, deserialize_help(NUM)); + output.insert(ModuleId::RESULT, deserialize_help(mod_result)); + output.insert(ModuleId::NUM, deserialize_help(mod_num)); - output.insert(ModuleId::LIST, deserialize_help(LIST)); - output.insert(ModuleId::STR, deserialize_help(STR)); - output.insert(ModuleId::BOX, deserialize_help(BOX)); + output.insert(ModuleId::LIST, deserialize_help(mod_list)); + output.insert(ModuleId::STR, deserialize_help(mod_str)); + output.insert(ModuleId::BOX, deserialize_help(mod_box)); - output.insert(ModuleId::DICT, deserialize_help(DICT)); - output.insert(ModuleId::SET, deserialize_help(SET)); + output.insert(ModuleId::DICT, deserialize_help(mod_dict)); + output.insert(ModuleId::SET, deserialize_help(mod_set)); - output.insert(ModuleId::ENCODE, deserialize_help(ENCODE)); - output.insert(ModuleId::DECODE, deserialize_help(DECODE)); + output.insert(ModuleId::ENCODE, deserialize_help(mod_encode)); + output.insert(ModuleId::DECODE, deserialize_help(mod_decode)); - output.insert(ModuleId::HASH, deserialize_help(HASH)); - output.insert(ModuleId::INSPECT, deserialize_help(INSPECT)); + output.insert(ModuleId::HASH, deserialize_help(mod_hash)); + output.insert(ModuleId::INSPECT, deserialize_help(mod_inspect)); } output From cec6d7424efa7b419d4e23165813bed87b5f0233 Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Sat, 2 Sep 2023 14:39:55 +0200 Subject: [PATCH 158/176] set NIX_LIBGCC_S_PATH in default.nix too I did this earlier in flake.nix but forgot about default.nix Signed-off-by: Anton-4 <17049058+Anton-4@users.noreply.github.com> --- default.nix | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/default.nix b/default.nix index fe59200244..4e0ba26fb5 100644 --- a/default.nix +++ b/default.nix @@ -14,7 +14,10 @@ let llvmPkgs = pkgs.llvmPackages_13; # nix does not store libs in /usr/lib or /lib - nixGlibcPath = if pkgs.stdenv.isLinux then "${pkgs.glibc.out}/lib" else ""; + glibcPath = + if pkgs.stdenv.isLinux then "${pkgs.glibc.out}/lib" else ""; + libGccSPath = + if pkgs.stdenv.isLinux then "${pkgs.stdenv.cc.cc.lib}/lib" else ""; in assert pkgs.lib.assertMsg rustVersionsMatch '' @@ -104,7 +107,7 @@ in # wrapProgram pkgs.stdenv.cc: to make ld available for compiler/build/src/link.rs postInstall = if pkgs.stdenv.isLinux then '' - wrapProgram $out/bin/roc --set NIX_GLIBC_PATH ${nixGlibcPath} --prefix PATH : ${ + wrapProgram $out/bin/roc --set NIX_GLIBC_PATH ${glibcPath} --set NIX_LIBGCC_S_PATH ${libGccSPath} --prefix PATH : ${ pkgs.lib.makeBinPath [ pkgs.stdenv.cc ] } '' else '' From 1856695b0b66e698831f3a6c2ea2cd04fd07f00e Mon Sep 17 00:00:00 2001 From: Luke Boswell Date: Sun, 3 Sep 2023 20:16:29 +1000 Subject: [PATCH 159/176] only generate roc panic if running tests --- crates/compiler/gen_dev/src/lib.rs | 7 ++++ crates/compiler/gen_dev/src/object_builder.rs | 32 +++++++++++-------- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/crates/compiler/gen_dev/src/lib.rs b/crates/compiler/gen_dev/src/lib.rs index 87a341d230..efd734864f 100644 --- a/crates/compiler/gen_dev/src/lib.rs +++ b/crates/compiler/gen_dev/src/lib.rs @@ -45,6 +45,13 @@ impl AssemblyBackendMode { AssemblyBackendMode::Test => true, } } + + fn generate_roc_panic(self) -> bool { + match self { + AssemblyBackendMode::Binary => false, + AssemblyBackendMode::Test => true, + } + } } pub struct Env<'a> { diff --git a/crates/compiler/gen_dev/src/object_builder.rs b/crates/compiler/gen_dev/src/object_builder.rs index d3b79d14c8..8b92fad67c 100644 --- a/crates/compiler/gen_dev/src/object_builder.rs +++ b/crates/compiler/gen_dev/src/object_builder.rs @@ -1,5 +1,5 @@ use crate::generic64::{aarch64, new_backend_64bit, x86_64}; -use crate::{Backend, Env, Relocation}; +use crate::{AssemblyBackendMode, Backend, Env, Relocation}; use bumpalo::collections::Vec; use object::write::{self, SectionId, SymbolId}; use object::write::{Object, StandardSection, StandardSegment, Symbol, SymbolSection}; @@ -312,11 +312,13 @@ fn build_object<'a, B: Backend<'a>>( ); */ - define_setlongjmp_buffer(&mut output); + if backend.env().mode.generate_roc_panic() { + define_setlongjmp_buffer(&mut output); - generate_roc_panic(&mut backend, &mut output); - generate_setjmp(&mut backend, &mut output); - generate_longjmp(&mut backend, &mut output); + generate_roc_panic(&mut backend, &mut output); + generate_setjmp(&mut backend, &mut output); + generate_longjmp(&mut backend, &mut output); + } if backend.env().mode.generate_allocators() { generate_wrapper( @@ -402,15 +404,17 @@ fn build_object<'a, B: Backend<'a>>( // println!("{}", test_helper.to_pretty(backend.interner(), 200, true)); - build_proc_symbol( - &mut output, - &mut layout_ids, - &mut procs, - &mut backend, - layout, - test_helper, - Exposed::TestMain, - ); + if let AssemblyBackendMode::Test = backend.env().mode { + build_proc_symbol( + &mut output, + &mut layout_ids, + &mut procs, + &mut backend, + layout, + test_helper, + Exposed::TestMain, + ); + } build_proc_symbol( &mut output, From 8123041d0a3bcd2114cc1d47568ddc2ccaf97b1c Mon Sep 17 00:00:00 2001 From: Luke Boswell Date: Sun, 3 Sep 2023 21:20:10 +1000 Subject: [PATCH 160/176] windows linker name matching --- crates/linker/src/pe.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/crates/linker/src/pe.rs b/crates/linker/src/pe.rs index 34a9f29514..dae5ee284c 100644 --- a/crates/linker/src/pe.rs +++ b/crates/linker/src/pe.rs @@ -1107,11 +1107,15 @@ impl<'a> AppSections<'a> { for (i, section) in file.sections().enumerate() { let kind = match section.name() { - Ok(".text") => SectionKind::Text, - // Ok(".data") => SectionKind::Data, - Ok(".rdata") => SectionKind::ReadOnlyData, - - _ => continue, + Ok(name) => { + match name { + _ if name.starts_with(".text") => SectionKind::Text, + // _ if name.starts_with(".data") => SectionKind::Data, + _ if name.starts_with(".rdata") => SectionKind::ReadOnlyData, + _ => continue, + } + }, + Err(_) => continue, }; let mut relocations: MutMap> = MutMap::default(); From 6ecc72f68e670a6542ab1da72473369217b01a1d Mon Sep 17 00:00:00 2001 From: Luke Boswell Date: Sun, 3 Sep 2023 23:53:56 +1000 Subject: [PATCH 161/176] log location of gen-test object location --- crates/compiler/test_gen/src/helpers/dev.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/compiler/test_gen/src/helpers/dev.rs b/crates/compiler/test_gen/src/helpers/dev.rs index e2238b2703..8cd7046888 100644 --- a/crates/compiler/test_gen/src/helpers/dev.rs +++ b/crates/compiler/test_gen/src/helpers/dev.rs @@ -215,9 +215,10 @@ pub fn helper( let builtins_host_tempfile = roc_bitcode::host_tempfile().expect("failed to write host builtins object to tempfile"); - // TODO make this an envrionment variable + // TODO make this an environment variable if false { let file_path = std::env::temp_dir().join("app.o"); + println!("gen-test object file written to {}", file_path.display()); std::fs::copy(&app_o_file, file_path).unwrap(); } From 5bda7dedc8b8ea9525c8bda7b71e17b9379bedc8 Mon Sep 17 00:00:00 2001 From: Folkert Date: Sat, 5 Aug 2023 20:41:07 +0200 Subject: [PATCH 162/176] windows calling convention for bigger structures also fixes roc_panic argument passing --- .../compiler/gen_dev/src/generic64/x86_64.rs | 171 ++++++++++++++---- 1 file changed, 139 insertions(+), 32 deletions(-) diff --git a/crates/compiler/gen_dev/src/generic64/x86_64.rs b/crates/compiler/gen_dev/src/generic64/x86_64.rs index e9de5194a4..455cd98ca6 100644 --- a/crates/compiler/gen_dev/src/generic64/x86_64.rs +++ b/crates/compiler/gen_dev/src/generic64/x86_64.rs @@ -546,7 +546,7 @@ impl CallConv for X86_64Syste } } -fn copy_symbol_to_stack<'a, CC>( +fn copy_symbol_to_stack_offset<'a, CC>( buf: &mut Vec<'a, u8>, storage_manager: &mut X86_64StorageManager<'a, '_, CC>, sym: Symbol, @@ -600,6 +600,61 @@ where size } +fn copy_to_base_offset<'a, 'r, GeneralReg, FloatReg, ASM, CC>( + buf: &mut Vec<'a, u8>, + storage_manager: &mut StorageManager<'a, 'r, GeneralReg, FloatReg, ASM, CC>, + dst_base_offset: i32, + stack_size: u32, + ptr_reg: GeneralReg, + tmp_reg: GeneralReg, + read_offset: i32, +) where + FloatReg: RegTrait, + GeneralReg: RegTrait, + ASM: Assembler, + CC: CallConv, +{ + let mut copied = 0; + let size = stack_size as i32; + let base_offset = dst_base_offset; + + if size - copied >= 8 { + for _ in (0..(size - copied)).step_by(8) { + ASM::mov_reg64_mem64_offset32(buf, tmp_reg, ptr_reg, read_offset + copied); + ASM::mov_base32_reg64(buf, base_offset + copied, tmp_reg); + + copied += 8; + } + } + + if size - copied >= 4 { + for _ in (0..(size - copied)).step_by(4) { + ASM::mov_reg32_mem32_offset32(buf, tmp_reg, ptr_reg, read_offset + copied); + ASM::mov_base32_reg32(buf, base_offset + copied, tmp_reg); + + copied += 4; + } + } + + if size - copied >= 2 { + for _ in (0..(size - copied)).step_by(2) { + ASM::mov_reg16_mem16_offset32(buf, tmp_reg, ptr_reg, read_offset + copied); + ASM::mov_base32_reg16(buf, base_offset + copied, tmp_reg); + + copied += 2; + } + } + + if size - copied >= 1 { + for _ in (0..(size - copied)).step_by(1) { + ASM::mov_reg8_mem8_offset32(buf, tmp_reg, ptr_reg, read_offset + copied); + ASM::mov_base32_reg8(buf, base_offset + copied, tmp_reg); + + copied += 1; + } + } +} + struct X64_64SystemVStoreArgs { general_i: usize, float_i: usize, @@ -658,7 +713,8 @@ impl X64_64SystemVStoreArgs { // Just copy onto the stack. let stack_offset = self.tmp_stack_offset; - let size = copy_symbol_to_stack(buf, storage_manager, sym, tmp_reg, stack_offset); + let size = + copy_symbol_to_stack_offset(buf, storage_manager, sym, tmp_reg, stack_offset); self.tmp_stack_offset += size as i32; } @@ -672,14 +728,16 @@ impl X64_64SystemVStoreArgs { LayoutRepr::Struct { .. } => { let stack_offset = self.tmp_stack_offset; - let size = copy_symbol_to_stack(buf, storage_manager, sym, tmp_reg, stack_offset); + let size = + copy_symbol_to_stack_offset(buf, storage_manager, sym, tmp_reg, stack_offset); self.tmp_stack_offset += size as i32; } LayoutRepr::Union(UnionLayout::NonRecursive(_)) => { let stack_offset = self.tmp_stack_offset; - let size = copy_symbol_to_stack(buf, storage_manager, sym, tmp_reg, stack_offset); + let size = + copy_symbol_to_stack_offset(buf, storage_manager, sym, tmp_reg, stack_offset); self.tmp_stack_offset += size as i32; } @@ -762,6 +820,8 @@ impl X64_64WindowsFastCallStoreArgs { sym: Symbol, in_layout: InLayout<'a>, ) { + type ASM = X86_64Assembler; + // we use the return register as a temporary register; it will be overwritten anyway let tmp_reg = Self::GENERAL_RETURN_REGS[0]; @@ -776,31 +836,50 @@ impl X64_64WindowsFastCallStoreArgs { let reg1 = Self::GENERAL_PARAM_REGS[self.general_i]; let reg2 = Self::GENERAL_PARAM_REGS[self.general_i + 1]; - X86_64Assembler::mov_reg64_base32(buf, reg1, offset); - X86_64Assembler::mov_reg64_base32(buf, reg2, offset + 8); + ASM::mov_reg64_base32(buf, reg1, offset); + ASM::mov_reg64_base32(buf, reg2, offset + 8); self.general_i += 2; } else { // Copy to stack using return reg as buffer. let reg = Self::GENERAL_RETURN_REGS[0]; - X86_64Assembler::mov_reg64_base32(buf, reg, offset); - X86_64Assembler::mov_stack32_reg64(buf, self.tmp_stack_offset, reg); + ASM::mov_reg64_base32(buf, reg, offset); + ASM::mov_stack32_reg64(buf, self.tmp_stack_offset, reg); - X86_64Assembler::mov_reg64_base32(buf, reg, offset + 8); - X86_64Assembler::mov_stack32_reg64(buf, self.tmp_stack_offset + 8, reg); + ASM::mov_reg64_base32(buf, reg, offset + 8); + ASM::mov_stack32_reg64(buf, self.tmp_stack_offset + 8, reg); self.tmp_stack_offset += 16; } } _ if layout_interner.stack_size(in_layout) == 0 => {} _ if layout_interner.stack_size(in_layout) > 16 => { - // for now, just copy onto the stack. - let stack_offset = self.tmp_stack_offset; + // Reference: https://learn.microsoft.com/en-us/cpp/build/x64-calling-convention?view=msvc-170#parameter-passing + match Self::GENERAL_PARAM_REGS.get(self.general_i) { + Some(reg) => { + // if there is a general purpose register available, use it to store a pointer to the value + let (base_offset, _size) = storage_manager.stack_offset_and_size(&sym); - let size = copy_symbol_to_stack(buf, storage_manager, sym, tmp_reg, stack_offset); + ASM::add_reg64_reg64_imm32(buf, *reg, X86_64GeneralReg::RBP, base_offset); - self.tmp_stack_offset += size as i32; + self.general_i += 1; + } + None => { + // else, pass the value implicitly by copying to the stack (of the new frame) + let stack_offset = self.tmp_stack_offset; + + let size = copy_symbol_to_stack_offset( + buf, + storage_manager, + sym, + tmp_reg, + stack_offset, + ); + + self.tmp_stack_offset += size as i32; + } + } } LayoutRepr::LambdaSet(lambda_set) => self.store_arg( buf, @@ -813,14 +892,16 @@ impl X64_64WindowsFastCallStoreArgs { // for now, just also store this on the stack let stack_offset = self.tmp_stack_offset; - let size = copy_symbol_to_stack(buf, storage_manager, sym, tmp_reg, stack_offset); + let size = + copy_symbol_to_stack_offset(buf, storage_manager, sym, tmp_reg, stack_offset); self.tmp_stack_offset += size as i32; } LayoutRepr::Union(UnionLayout::NonRecursive(_)) => { let stack_offset = self.tmp_stack_offset; - let size = copy_symbol_to_stack(buf, storage_manager, sym, tmp_reg, stack_offset); + let size = + copy_symbol_to_stack_offset(buf, storage_manager, sym, tmp_reg, stack_offset); self.tmp_stack_offset += size as i32; } @@ -977,11 +1058,14 @@ struct X64_64WindowsFastCallLoadArgs { impl X64_64WindowsFastCallLoadArgs { fn load_arg<'a>( &mut self, + buf: &mut Vec<'a, u8>, storage_manager: &mut X86_64StorageManager<'a, '_, X86_64WindowsFastcall>, layout_interner: &mut STLayoutInterner<'a>, sym: Symbol, in_layout: InLayout<'a>, ) { + type ASM = X86_64Assembler; + let stack_size = layout_interner.stack_size(in_layout); match layout_interner.get_repr(in_layout) { single_register_integers!() => self.load_arg_general(storage_manager, sym), @@ -991,11 +1075,34 @@ impl X64_64WindowsFastCallLoadArgs { storage_manager.no_data(&sym); } _ if stack_size > 16 => { - // TODO: Double check this. - storage_manager.complex_stack_arg(&sym, self.argument_offset, stack_size); - self.argument_offset += stack_size as i32; + // Reference: https://learn.microsoft.com/en-us/cpp/build/x64-calling-convention?view=msvc-170#parameter-passing + match X86_64WindowsFastcall::GENERAL_PARAM_REGS.get(self.general_i) { + Some(ptr_reg) => { + // if there is a general purpose register available, use it to store a pointer to the value + let base_offset = storage_manager.claim_stack_area(&sym, stack_size); + let tmp_reg = X86_64WindowsFastcall::GENERAL_RETURN_REGS[0]; + + copy_to_base_offset( + buf, + storage_manager, + base_offset, + stack_size, + *ptr_reg, + tmp_reg, + 0, + ); + + self.general_i += 1; + } + None => { + // else, pass the value implicitly by copying to the stack (of the new frame) + storage_manager.complex_stack_arg(&sym, self.argument_offset, stack_size); + self.argument_offset += stack_size as i32; + } + } } LayoutRepr::LambdaSet(lambda_set) => self.load_arg( + buf, storage_manager, layout_interner, sym, @@ -1205,7 +1312,7 @@ impl CallConv for X86_64Windo #[inline(always)] fn load_args<'a>( - _buf: &mut Vec<'a, u8>, + buf: &mut Vec<'a, u8>, storage_manager: &mut X86_64StorageManager<'a, '_, X86_64WindowsFastcall>, layout_interner: &mut STLayoutInterner<'a>, args: &'a [(InLayout<'a>, Symbol)], @@ -1226,7 +1333,7 @@ impl CallConv for X86_64Windo } for (in_layout, sym) in args.iter() { - state.load_arg(storage_manager, layout_interner, *sym, *in_layout); + state.load_arg(buf, storage_manager, layout_interner, *sym, *in_layout); } } @@ -1474,12 +1581,16 @@ impl CallConv for X86_64Windo type ASM = X86_64Assembler; // a *const RocStr - let roc_str_ptr = R11; - ASM::add_reg64_reg64_imm32(buf, roc_str_ptr, RSP, 16 + 24); // 24 is width of a rocstr + let roc_str_ptr = RCX; + debug_assert_eq!(roc_str_ptr, Self::GENERAL_PARAM_REGS[0]); // a 32-bit integer - let panic_tag = RCX; - debug_assert_eq!(panic_tag, Self::GENERAL_PARAM_REGS[0]); + let panic_tag = RDX; + debug_assert_eq!(panic_tag, Self::GENERAL_PARAM_REGS[1]); + + // move the crash tag into a temporary register. We add 1 to it because the 0 value + // is already used for "no crash occurred" + ASM::add_reg64_reg64_imm32(buf, R10, panic_tag, 0x01); // the setlongjmp_buffer let env = R8; @@ -1513,16 +1624,12 @@ impl CallConv for X86_64Windo ASM::mov_reg64_mem64_offset32(buf, result_pointer, env, 0x58); // a pointer to the error message - ASM::mov_reg64_imm64(buf, R10, 0x60); - ASM::add_reg64_reg64_reg64(buf, R10, R10, env); + ASM::add_reg64_reg64_imm32(buf, R11, env, 0x60); // write a pointer to the error message into result_pointer - ASM::mov_mem64_offset32_reg64(buf, result_pointer, 0x00, R10); + ASM::mov_mem64_offset32_reg64(buf, result_pointer, 0x00, R11); - // the panic_tag; 1 is added to differentiate from 0 (which indicates success) - ASM::add_reg64_reg64_imm32(buf, R10, panic_tag, 1); - - // write the panic tag into the result_pointer + // write the panic tag (now in R10) into the result_pointer ASM::mov_mem64_offset32_reg64(buf, result_pointer, 0x08, R10); jmp_reg64_offset8(buf, env, 0x50) From adf36109ab77251e3fbb222098e0f645dd7bc81d Mon Sep 17 00:00:00 2001 From: Folkert Date: Sun, 3 Sep 2023 16:57:44 +0200 Subject: [PATCH 163/176] clippy --- crates/compiler/gen_dev/src/generic64/x86_64.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/crates/compiler/gen_dev/src/generic64/x86_64.rs b/crates/compiler/gen_dev/src/generic64/x86_64.rs index 455cd98ca6..a5d969f1d7 100644 --- a/crates/compiler/gen_dev/src/generic64/x86_64.rs +++ b/crates/compiler/gen_dev/src/generic64/x86_64.rs @@ -600,9 +600,8 @@ where size } -fn copy_to_base_offset<'a, 'r, GeneralReg, FloatReg, ASM, CC>( - buf: &mut Vec<'a, u8>, - storage_manager: &mut StorageManager<'a, 'r, GeneralReg, FloatReg, ASM, CC>, +fn copy_to_base_offset( + buf: &mut Vec<'_, u8>, dst_base_offset: i32, stack_size: u32, ptr_reg: GeneralReg, @@ -612,7 +611,6 @@ fn copy_to_base_offset<'a, 'r, GeneralReg, FloatReg, ASM, CC>( FloatReg: RegTrait, GeneralReg: RegTrait, ASM: Assembler, - CC: CallConv, { let mut copied = 0; let size = stack_size as i32; @@ -1082,9 +1080,8 @@ impl X64_64WindowsFastCallLoadArgs { let base_offset = storage_manager.claim_stack_area(&sym, stack_size); let tmp_reg = X86_64WindowsFastcall::GENERAL_RETURN_REGS[0]; - copy_to_base_offset( + copy_to_base_offset::<_, _, ASM>( buf, - storage_manager, base_offset, stack_size, *ptr_reg, From 2f88d0579de3a2bb932fc2aef48f2e89109f9697 Mon Sep 17 00:00:00 2001 From: Folkert Date: Sun, 3 Sep 2023 17:01:32 +0200 Subject: [PATCH 164/176] fmt --- crates/linker/src/pe.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/linker/src/pe.rs b/crates/linker/src/pe.rs index dae5ee284c..6a3831f464 100644 --- a/crates/linker/src/pe.rs +++ b/crates/linker/src/pe.rs @@ -1114,7 +1114,7 @@ impl<'a> AppSections<'a> { _ if name.starts_with(".rdata") => SectionKind::ReadOnlyData, _ => continue, } - }, + } Err(_) => continue, }; From 356d3abc30e94657e115b1f29a1965ce899ef536 Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Wed, 6 Sep 2023 15:02:35 +0200 Subject: [PATCH 165/176] updated devtools nix files --- devtools/README.md | 2 +- devtools/flake.lock | 28 ++++++++++++++-------------- devtools/flake.nix | 4 ++-- 3 files changed, 17 insertions(+), 17 deletions(-) mode change 100644 => 100755 devtools/README.md mode change 100644 => 100755 devtools/flake.lock mode change 100644 => 100755 devtools/flake.nix diff --git a/devtools/README.md b/devtools/README.md old mode 100644 new mode 100755 index 57916ade6f..2825119d97 --- a/devtools/README.md +++ b/devtools/README.md @@ -10,7 +10,7 @@ Further steps: 1. Copy the flake.nix and flake.lock file to a new folder outside of the roc repo folder. 1. Run `git init` in the new folder. 1. Execute `git add flake.nix`, nix will error if you don't do this. -1. Change `roc.url = "path:/home/username/gitrepos/roc9/roc";` to the location of the roc folder on your machine. +1. Change `roc.url = "path:/home/anton/gitrepos/roc";` to the location of the roc folder on your machine. 1. Follow instructions about vscode extensions [here](#extensions). 1. add other dev tools you like in the `devInputs` list. You can search for those [here](https://search.nixos.org/packages). 1. Run `nix develop`. diff --git a/devtools/flake.lock b/devtools/flake.lock old mode 100644 new mode 100755 index beb73d0808..c15d838e56 --- a/devtools/flake.lock +++ b/devtools/flake.lock @@ -5,11 +5,11 @@ "systems": "systems" }, "locked": { - "lastModified": 1681202837, - "narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=", + "lastModified": 1692799911, + "narHash": "sha256-3eihraek4qL744EvQXsK1Ha6C3CR7nnT8X2qWap4RNk=", "owner": "numtide", "repo": "flake-utils", - "rev": "cfacdce06f30d2b68473a46042957675eebb3401", + "rev": "f9e7cf818399d17d347f847525c5a5a8032e4e44", "type": "github" }, "original": { @@ -93,17 +93,17 @@ }, "nixpkgs": { "locked": { - "lastModified": 1674860021, - "narHash": "sha256-ES4XUf/AlPp8RetKR6WlWgYEZ7bLWI7k6reHp2q9rqY=", + "lastModified": 1690279121, + "narHash": "sha256-XoPGhV1UJQPue6RiehAu7lQwKss3J1B/K0QtVOMD83A=", "owner": "nixos", "repo": "nixpkgs", - "rev": "9f4346eac544cc0db5eb7d889e71eac0f9c8b9eb", + "rev": "821c72743ceae44bdd09718d47cab98fd5fd90af", "type": "github" }, "original": { "owner": "nixos", "repo": "nixpkgs", - "rev": "9f4346eac544cc0db5eb7d889e71eac0f9c8b9eb", + "rev": "821c72743ceae44bdd09718d47cab98fd5fd90af", "type": "github" } }, @@ -115,13 +115,13 @@ "rust-overlay": "rust-overlay" }, "locked": { - "lastModified": 1682784625, - "narHash": "sha256-QUncKiwgpmHajo601NNHOjeUG2/vrGp1oMgxnPhq900=", - "path": "/home/username/gitrepos/roc9/roc", + "lastModified": 1694000770, + "narHash": "sha256-92bAbPmwXxD6rwaAViG5O9r91ZBh9bqaZhM3egPCjuw=", + "path": "/home/anton/gitrepos/roc", "type": "path" }, "original": { - "path": "/home/username/gitrepos/roc9/roc", + "path": "/home/anton/gitrepos/roc", "type": "path" } }, @@ -140,11 +140,11 @@ ] }, "locked": { - "lastModified": 1682389182, - "narHash": "sha256-8t2nmFnH+8V48+IJsf8AK51ebXNlVbOSVYOpiqJKvJE=", + "lastModified": 1690252178, + "narHash": "sha256-9oEz822bvbHobfCUjJLDor2BqW3I5tycIauzDlzOALY=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "74f1a64dd28faeeb85ef081f32cad2989850322c", + "rev": "8d64353ca827002fb8459e44d49116c78d868eba", "type": "github" }, "original": { diff --git a/devtools/flake.nix b/devtools/flake.nix old mode 100644 new mode 100755 index cf86267083..d2087fcef0 --- a/devtools/flake.nix +++ b/devtools/flake.nix @@ -3,7 +3,7 @@ inputs = { # change this path to the path of your roc folder - roc.url = "path:/home/username/gitrepos/roc9/roc"; + roc.url = "path:/home/anton/gitrepos/roc"; # to easily make configs for multiple architectures flake-utils.url = "github:numtide/flake-utils"; }; @@ -35,7 +35,7 @@ publisher = "benjamin-thomas"; version = "0.0.4"; # keep this sha for the first run, nix will tell you the correct one to change it to - sha256 = "sha256-mabNegZ+XPQ6EIHFk6jz2mAPLHAU6Pm3w0SiFB7IE+s="; + sha256 = "sha256-USZiXdvYa8hxj62cy6hdiS5c2tIDIQxSyux684lyAEY="; } ] ; From a93f62c1964f68451e00420a438da2b7bf8b4acf Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Wed, 6 Sep 2023 16:20:55 +0200 Subject: [PATCH 166/176] added workflow to test devtools nix files --- .github/workflows/devtools_test.yml | 41 +++++++++++++++++++++++++++++ devtools/README.md | 4 +-- 2 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/devtools_test.yml diff --git a/.github/workflows/devtools_test.yml b/.github/workflows/devtools_test.yml new file mode 100644 index 0000000000..6a31e0bd95 --- /dev/null +++ b/.github/workflows/devtools_test.yml @@ -0,0 +1,41 @@ +on: + pull_request: + +name: Test the devtools nix files + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + devtools-test: + name: devtools-test + runs-on: [ubuntu-20.04] + timeout-minutes: 120 + steps: + - uses: actions/checkout@v3 + # TODO only run if flake.lock changed + + - name: test devtools/flake.nix + id: devtools_test_step + run: | + echo "ROC_FOLDER=$(realpath .)" >> $GITHUB_ENV + mkdir -p ../temp + cp devtools/flake.nix ../temp + cp devtools/flake.lock ../temp + cd ../temp + git init + git add flake.nix flake.lock + sed -i 's|/home/username/gitrepos/roc|${{ env.ROC_FOLDER }}|g' flake.nix + nix develop + + - name: Print tip on fail + if: steps.devtools_test_step.outcome == 'failure' + run: | + echo "The devtools test failed, this can likely be fixed by" + echo "locally deleting devtools/flake.lock and following the" + echo "instructions in devtools/README.md. This will create a" + echo "new flake.lock you should use to replace the old devtools/flake.lock" + + + \ No newline at end of file diff --git a/devtools/README.md b/devtools/README.md index 2825119d97..c8c0f93383 100755 --- a/devtools/README.md +++ b/devtools/README.md @@ -7,9 +7,9 @@ The flake in this folder is meant for vscode, feel free to create a PR if you'li Further steps: -1. Copy the flake.nix and flake.lock file to a new folder outside of the roc repo folder. +1. Copy the flake.nix and flake.lock file from the devtools folder to a new folder outside of the roc repo folder. 1. Run `git init` in the new folder. -1. Execute `git add flake.nix`, nix will error if you don't do this. +1. Execute `git add flake.nix flake.lock`, nix will error if you don't do this. 1. Change `roc.url = "path:/home/anton/gitrepos/roc";` to the location of the roc folder on your machine. 1. Follow instructions about vscode extensions [here](#extensions). 1. add other dev tools you like in the `devInputs` list. You can search for those [here](https://search.nixos.org/packages). From ebcd3255010dfa9b9c4ebdbdee2b7b66918e3219 Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Wed, 6 Sep 2023 16:55:58 +0200 Subject: [PATCH 167/176] install nix Signed-off-by: Anton-4 <17049058+Anton-4@users.noreply.github.com> --- .github/workflows/devtools_test.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/devtools_test.yml b/.github/workflows/devtools_test.yml index 6a31e0bd95..90f4108635 100644 --- a/.github/workflows/devtools_test.yml +++ b/.github/workflows/devtools_test.yml @@ -15,6 +15,9 @@ jobs: steps: - uses: actions/checkout@v3 # TODO only run if flake.lock changed + - uses: cachix/install-nix-action@v23 + with: + nix_path: nixpkgs=channel:nixos-unstable - name: test devtools/flake.nix id: devtools_test_step @@ -38,4 +41,4 @@ jobs: echo "new flake.lock you should use to replace the old devtools/flake.lock" - \ No newline at end of file + From 8ed9cf66c353c6194fbdb3712936d76bf7f3e490 Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Wed, 6 Sep 2023 17:01:32 +0200 Subject: [PATCH 168/176] seperated out sed step Signed-off-by: Anton-4 <17049058+Anton-4@users.noreply.github.com> --- .github/workflows/devtools_test.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/devtools_test.yml b/.github/workflows/devtools_test.yml index 90f4108635..1abf363b3e 100644 --- a/.github/workflows/devtools_test.yml +++ b/.github/workflows/devtools_test.yml @@ -19,17 +19,21 @@ jobs: with: nix_path: nixpkgs=channel:nixos-unstable + - name: update roc folder path + run: | + echo "ROC_FOLDER=$(realpath .)" >> $GITHUB_ENV + sed -i 's|/home/username/gitrepos/roc|${{ env.ROC_FOLDER }}|g' flake.nix + cat flake.nix + - name: test devtools/flake.nix id: devtools_test_step run: | - echo "ROC_FOLDER=$(realpath .)" >> $GITHUB_ENV mkdir -p ../temp cp devtools/flake.nix ../temp cp devtools/flake.lock ../temp cd ../temp git init git add flake.nix flake.lock - sed -i 's|/home/username/gitrepos/roc|${{ env.ROC_FOLDER }}|g' flake.nix nix develop - name: Print tip on fail From 0017f4c55b3dce8db3e954e487b2a7a5eccc5d63 Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Wed, 6 Sep 2023 17:03:56 +0200 Subject: [PATCH 169/176] do set on correct flake Signed-off-by: Anton-4 <17049058+Anton-4@users.noreply.github.com> --- .github/workflows/devtools_test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/devtools_test.yml b/.github/workflows/devtools_test.yml index 1abf363b3e..96514511d4 100644 --- a/.github/workflows/devtools_test.yml +++ b/.github/workflows/devtools_test.yml @@ -22,8 +22,8 @@ jobs: - name: update roc folder path run: | echo "ROC_FOLDER=$(realpath .)" >> $GITHUB_ENV - sed -i 's|/home/username/gitrepos/roc|${{ env.ROC_FOLDER }}|g' flake.nix - cat flake.nix + sed -i 's|/home/username/gitrepos/roc|${{ env.ROC_FOLDER }}|g' devtools/flake.nix + cat devtools/flake.nix - name: test devtools/flake.nix id: devtools_test_step From d181e6dfac7b849e0afe0ead0bcc42aa11b14545 Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Wed, 6 Sep 2023 17:05:44 +0200 Subject: [PATCH 170/176] ditched env var Signed-off-by: Anton-4 <17049058+Anton-4@users.noreply.github.com> --- .github/workflows/devtools_test.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/devtools_test.yml b/.github/workflows/devtools_test.yml index 96514511d4..afea2745ea 100644 --- a/.github/workflows/devtools_test.yml +++ b/.github/workflows/devtools_test.yml @@ -21,8 +21,7 @@ jobs: - name: update roc folder path run: | - echo "ROC_FOLDER=$(realpath .)" >> $GITHUB_ENV - sed -i 's|/home/username/gitrepos/roc|${{ env.ROC_FOLDER }}|g' devtools/flake.nix + sed -i 's|/home/username/gitrepos/roc|$(realpath .)|g' devtools/flake.nix cat devtools/flake.nix - name: test devtools/flake.nix From 1b14e8dcb1fb664878bc4b6e5c61e999fc4ad40f Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Wed, 6 Sep 2023 17:07:18 +0200 Subject: [PATCH 171/176] fix path anton Signed-off-by: Anton-4 <17049058+Anton-4@users.noreply.github.com> --- .github/workflows/devtools_test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/devtools_test.yml b/.github/workflows/devtools_test.yml index afea2745ea..83f9e38f15 100644 --- a/.github/workflows/devtools_test.yml +++ b/.github/workflows/devtools_test.yml @@ -21,7 +21,7 @@ jobs: - name: update roc folder path run: | - sed -i 's|/home/username/gitrepos/roc|$(realpath .)|g' devtools/flake.nix + sed -i 's|/home/anton/gitrepos/roc|$(realpath .)|g' devtools/flake.nix cat devtools/flake.nix - name: test devtools/flake.nix From cd41c814cb3eec02c4e9993d569816e680d33a7d Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Wed, 6 Sep 2023 17:09:27 +0200 Subject: [PATCH 172/176] double quotes for bash replacement Signed-off-by: Anton-4 <17049058+Anton-4@users.noreply.github.com> --- .github/workflows/devtools_test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/devtools_test.yml b/.github/workflows/devtools_test.yml index 83f9e38f15..4e07670707 100644 --- a/.github/workflows/devtools_test.yml +++ b/.github/workflows/devtools_test.yml @@ -21,7 +21,7 @@ jobs: - name: update roc folder path run: | - sed -i 's|/home/anton/gitrepos/roc|$(realpath .)|g' devtools/flake.nix + sed -i "s|/home/anton/gitrepos/roc|$(realpath .)|g" devtools/flake.nix cat devtools/flake.nix - name: test devtools/flake.nix From 8852ee1e559b279704db397672807ab31d90ebb4 Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Wed, 6 Sep 2023 17:17:23 +0200 Subject: [PATCH 173/176] only run if flake.lock changed Signed-off-by: Anton-4 <17049058+Anton-4@users.noreply.github.com> --- .github/workflows/devtools_test.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/devtools_test.yml b/.github/workflows/devtools_test.yml index 4e07670707..c798046f54 100644 --- a/.github/workflows/devtools_test.yml +++ b/.github/workflows/devtools_test.yml @@ -14,7 +14,16 @@ jobs: timeout-minutes: 120 steps: - uses: actions/checkout@v3 - # TODO only run if flake.lock changed + + - name: Only run all steps if flake.lock changed + run: | + if git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep 'flake.lock'; then + echo "Flake.lock was changed. Testing devtools nix files..." + else + echo "Flake.lock was not changed. No need to run tests. Exiting..." + exit 0 + fi + - uses: cachix/install-nix-action@v23 with: nix_path: nixpkgs=channel:nixos-unstable From 886bd26acf465e755225cd6938ec1ce95bef996c Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Wed, 6 Sep 2023 17:22:23 +0200 Subject: [PATCH 174/176] fiexd change check Signed-off-by: Anton-4 <17049058+Anton-4@users.noreply.github.com> --- .github/workflows/devtools_test.yml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/devtools_test.yml b/.github/workflows/devtools_test.yml index c798046f54..513acc6da7 100644 --- a/.github/workflows/devtools_test.yml +++ b/.github/workflows/devtools_test.yml @@ -16,26 +16,27 @@ jobs: - uses: actions/checkout@v3 - name: Only run all steps if flake.lock changed + id: checklock run: | if git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep 'flake.lock'; then echo "Flake.lock was changed. Testing devtools nix files..." + echo "::set-output name=changed::true" else - echo "Flake.lock was not changed. No need to run tests. Exiting..." - exit 0 + echo "Flake.lock was not changed. No need to run tests." + echo "::set-output name=changed::false" fi - uses: cachix/install-nix-action@v23 + if: steps.checklock.outputs.changed == 'true' with: nix_path: nixpkgs=channel:nixos-unstable - - name: update roc folder path + - name: test devtools/flake.nix + if: steps.checklock.outputs.changed == 'true' + id: devtools_test_step run: | sed -i "s|/home/anton/gitrepos/roc|$(realpath .)|g" devtools/flake.nix cat devtools/flake.nix - - - name: test devtools/flake.nix - id: devtools_test_step - run: | mkdir -p ../temp cp devtools/flake.nix ../temp cp devtools/flake.lock ../temp From b2df3362bfd1080f8c501d1a85e3ef8401fe1991 Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Wed, 6 Sep 2023 19:42:25 +0200 Subject: [PATCH 175/176] path change: anton -> username --- .github/workflows/devtools_test.yml | 2 +- devtools/README.md | 2 +- devtools/flake.nix | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/devtools_test.yml b/.github/workflows/devtools_test.yml index 513acc6da7..42910f8085 100644 --- a/.github/workflows/devtools_test.yml +++ b/.github/workflows/devtools_test.yml @@ -35,7 +35,7 @@ jobs: if: steps.checklock.outputs.changed == 'true' id: devtools_test_step run: | - sed -i "s|/home/anton/gitrepos/roc|$(realpath .)|g" devtools/flake.nix + sed -i "s|/home/username/gitrepos/roc|$(realpath .)|g" devtools/flake.nix cat devtools/flake.nix mkdir -p ../temp cp devtools/flake.nix ../temp diff --git a/devtools/README.md b/devtools/README.md index c8c0f93383..5b197d9ecc 100755 --- a/devtools/README.md +++ b/devtools/README.md @@ -10,7 +10,7 @@ Further steps: 1. Copy the flake.nix and flake.lock file from the devtools folder to a new folder outside of the roc repo folder. 1. Run `git init` in the new folder. 1. Execute `git add flake.nix flake.lock`, nix will error if you don't do this. -1. Change `roc.url = "path:/home/anton/gitrepos/roc";` to the location of the roc folder on your machine. +1. Change `roc.url = "path:/home/username/gitrepos/roc";` to the location of the roc folder on your machine. 1. Follow instructions about vscode extensions [here](#extensions). 1. add other dev tools you like in the `devInputs` list. You can search for those [here](https://search.nixos.org/packages). 1. Run `nix develop`. diff --git a/devtools/flake.nix b/devtools/flake.nix index d2087fcef0..a37b707bed 100755 --- a/devtools/flake.nix +++ b/devtools/flake.nix @@ -3,7 +3,7 @@ inputs = { # change this path to the path of your roc folder - roc.url = "path:/home/anton/gitrepos/roc"; + roc.url = "path:/home/username/gitrepos/roc"; # to easily make configs for multiple architectures flake-utils.url = "github:numtide/flake-utils"; }; From cecde60a5e7d5d34b813b446659d56456c6c542d Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Fri, 8 Sep 2023 12:02:25 -0400 Subject: [PATCH 176/176] Revert "glue: find platform main file" This reverts commit 7be590fae9ab0a5ef65abd23190a499f5c9e99ca. --- crates/glue/src/load.rs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/crates/glue/src/load.rs b/crates/glue/src/load.rs index 834d66e3b7..8c6aea99ee 100644 --- a/crates/glue/src/load.rs +++ b/crates/glue/src/load.rs @@ -340,6 +340,7 @@ pub fn load_types( let function_kind = FunctionKind::LambdaSet; let arena = &Bump::new(); let LoadedModule { + module_id: home, mut can_problems, mut type_problems, mut declarations_by_id, @@ -371,13 +372,6 @@ pub fn load_types( } }); - // find the platform's main module - let home = declarations_by_id - .keys() - .find(|id| format!("{id:?}").trim_start_matches("pf.").is_empty()) - .copied() - .unwrap(); - let decls = declarations_by_id.remove(&home).unwrap(); let subs = solved.inner_mut();