From 1bb3c3d1dd46f3c58f63a7c498821f67ef1eb6b6 Mon Sep 17 00:00:00 2001 From: Kiryl Dziamura Date: Tue, 4 Jul 2023 11:24:40 +0200 Subject: [PATCH] Make `has` have 4 identation spaces --- crates/compiler/builtins/roc/Dict.roc | 36 ++++---- crates/compiler/builtins/roc/Set.roc | 16 ++-- .../compiler/builtins/roc/TotallyNotJson.roc | 86 +++++++++---------- crates/compiler/fmt/src/def.rs | 2 +- .../opaque_has_abilities.expr.formatted.roc | 6 +- crates/compiler/test_syntax/tests/test_fmt.rs | 16 ++-- examples/cli/cli-platform/EnvDecoding.roc | 42 ++++----- 7 files changed, 102 insertions(+), 102 deletions(-) diff --git a/crates/compiler/builtins/roc/Dict.roc b/crates/compiler/builtins/roc/Dict.roc index 180033b008..ec316cf351 100644 --- a/crates/compiler/builtins/roc/Dict.roc +++ b/crates/compiler/builtins/roc/Dict.roc @@ -101,14 +101,14 @@ Dict k v := { data : List (k, v), size : Nat, } | k has Hash & Eq - has [ - Eq { - isEq, - }, - Hash { - hash: hashDict, - }, - ] + has [ + Eq { + isEq, + }, + Hash { + hash: hashDict, + }, + ] isEq : Dict k v, Dict k v -> Bool | k has Hash & Eq, v has Eq isEq = \xs, ys -> @@ -1011,16 +1011,16 @@ expect # 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 [ - Hasher { - addBytes, - addU8, - addU16, - addU32, - addU64, - addU128, - complete, - }, - ] + Hasher { + addBytes, + addU8, + addU16, + addU32, + addU64, + addU128, + complete, + }, + ] # unsafe primitive that does not perform a bounds check # TODO hide behind an InternalList.roc module diff --git a/crates/compiler/builtins/roc/Set.roc b/crates/compiler/builtins/roc/Set.roc index f8b2072d0d..7fc76c9807 100644 --- a/crates/compiler/builtins/roc/Set.roc +++ b/crates/compiler/builtins/roc/Set.roc @@ -30,14 +30,14 @@ 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 has Hash & Eq - has [ - Eq { - isEq, - }, - Hash { - hash: hashSet, - }, - ] + has [ + Eq { + isEq, + }, + Hash { + hash: hashSet, + }, + ] isEq : Set k, Set k -> Bool | k has Hash & Eq isEq = \xs, ys -> diff --git a/crates/compiler/builtins/roc/TotallyNotJson.roc b/crates/compiler/builtins/roc/TotallyNotJson.roc index 93c0feb912..6df2a9cf7c 100644 --- a/crates/compiler/builtins/roc/TotallyNotJson.roc +++ b/crates/compiler/builtins/roc/TotallyNotJson.roc @@ -44,49 +44,49 @@ interface TotallyNotJson ## An opaque type with the `EncoderFormatting` and ## `DecoderFormatting` abilities. Json := { fieldNameMapping : FieldNameMapping } - has [ - EncoderFormatting { - u8: encodeU8, - u16: encodeU16, - u32: encodeU32, - u64: encodeU64, - u128: encodeU128, - i8: encodeI8, - i16: encodeI16, - i32: encodeI32, - i64: encodeI64, - i128: encodeI128, - f32: encodeF32, - f64: encodeF64, - dec: encodeDec, - bool: encodeBool, - string: encodeString, - list: encodeList, - record: encodeRecord, - tuple: encodeTuple, - tag: encodeTag, - }, - DecoderFormatting { - u8: decodeU8, - u16: decodeU16, - u32: decodeU32, - u64: decodeU64, - u128: decodeU128, - i8: decodeI8, - i16: decodeI16, - i32: decodeI32, - i64: decodeI64, - i128: decodeI128, - f32: decodeF32, - f64: decodeF64, - dec: decodeDec, - bool: decodeBool, - string: decodeString, - list: decodeList, - record: decodeRecord, - tuple: decodeTuple, - }, - ] + has [ + EncoderFormatting { + u8: encodeU8, + u16: encodeU16, + u32: encodeU32, + u64: encodeU64, + u128: encodeU128, + i8: encodeI8, + i16: encodeI16, + i32: encodeI32, + i64: encodeI64, + i128: encodeI128, + f32: encodeF32, + f64: encodeF64, + dec: encodeDec, + bool: encodeBool, + string: encodeString, + list: encodeList, + record: encodeRecord, + tuple: encodeTuple, + tag: encodeTag, + }, + DecoderFormatting { + u8: decodeU8, + u16: decodeU16, + u32: decodeU32, + u64: decodeU64, + u128: decodeU128, + i8: decodeI8, + i16: decodeI16, + i32: decodeI32, + i64: decodeI64, + i128: decodeI128, + f32: decodeF32, + f64: decodeF64, + dec: decodeDec, + bool: decodeBool, + string: decodeString, + list: decodeList, + record: decodeRecord, + tuple: decodeTuple, + }, + ] ## Returns a JSON `Encoder` and `Decoder` json = @Json { fieldNameMapping: Default } diff --git a/crates/compiler/fmt/src/def.rs b/crates/compiler/fmt/src/def.rs index bb5268bcc2..997edb8a37 100644 --- a/crates/compiler/fmt/src/def.rs +++ b/crates/compiler/fmt/src/def.rs @@ -117,7 +117,7 @@ impl<'a> Formattable for TypeDef<'a> { buf, Parens::NotNeeded, Newlines::from_bool(make_multiline), - indent + 1 + INDENT, + indent + INDENT, ); } } 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..768b1dab9d 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 has [Eq, Hash] A := a | a has Other - has [Eq, Hash] + has [Eq, Hash] A := a | a has Other - has [Eq, Hash] + has [Eq, Hash] A := U8 has [Eq { eq }, Hash { hash }] @@ -17,7 +17,7 @@ A := U8 has [Hash, Eq { eq, eq1 }] A := U8 has [] A := a | a has Other - has [Eq { eq }, Hash { hash }] + has [Eq { eq }, Hash { hash }] A := U8 has [Eq {}] diff --git a/crates/compiler/test_syntax/tests/test_fmt.rs b/crates/compiler/test_syntax/tests/test_fmt.rs index 751b3f080b..ff7cb5dd04 100644 --- a/crates/compiler/test_syntax/tests/test_fmt.rs +++ b/crates/compiler/test_syntax/tests/test_fmt.rs @@ -5447,7 +5447,7 @@ mod test_fmt { indoc!( r#" A := U8 - has [Eq, Hash] + has [Eq, Hash] 0 "# @@ -5465,7 +5465,7 @@ mod test_fmt { indoc!( r#" A := a | a has Hash - has [Eq, Hash] + has [Eq, Hash] 0 "# @@ -5555,11 +5555,11 @@ mod test_fmt { r#" A := U8 has [Eq { eq, eq1 }] A := U8 has [ - Eq { - eq, - eq1, - }, - ] + Eq { + eq, + eq1, + }, + ] 0 "# @@ -5569,7 +5569,7 @@ mod test_fmt { expr_formats_same(indoc!( r#" A := a | a has Other - has [Eq { eq }, Hash { hash }] + has [Eq { eq }, Hash { hash }] 0 "# diff --git a/examples/cli/cli-platform/EnvDecoding.roc b/examples/cli/cli-platform/EnvDecoding.roc index ccc4a9f2bb..d6be7f2b2c 100644 --- a/examples/cli/cli-platform/EnvDecoding.roc +++ b/examples/cli/cli-platform/EnvDecoding.roc @@ -1,27 +1,27 @@ interface EnvDecoding exposes [EnvFormat, format] imports [] EnvFormat := {} has [ - DecoderFormatting { - u8: envU8, - u16: envU16, - u32: envU32, - u64: envU64, - u128: envU128, - i8: envI8, - i16: envI16, - i32: envI32, - i64: envI64, - i128: envI128, - f32: envF32, - f64: envF64, - dec: envDec, - bool: envBool, - string: envString, - list: envList, - record: envRecord, - tuple: envTuple, - }, - ] + DecoderFormatting { + u8: envU8, + u16: envU16, + u32: envU32, + u64: envU64, + u128: envU128, + i8: envI8, + i16: envI16, + i32: envI32, + i64: envI64, + i128: envI128, + f32: envF32, + f64: envF64, + dec: envDec, + bool: envBool, + string: envString, + list: envList, + record: envRecord, + tuple: envTuple, + }, + ] format : {} -> EnvFormat format = \{} -> @EnvFormat {}