Fork of daniellemaywood.uk/gleam — Wasm codegen work
2

Configure Feed

Select the types of activity you want to include in your feed.

Use fat-arrow functions for custom type API

author
GearsDatapacks
committer
Louis Pilfold
date (Sep 19, 2025, 11:58 AM +0100) commit 8f495435 parent a5603a20 change-id ntvplqxy
+278 -763
+22 -37
compiler-core/src/javascript.rs
··· 374 374 // Only generate accessors for the API if the constructors are public 375 375 && constructor_publicity.is_public() 376 376 { 377 - let function_head = if opaque || publicity.is_private() { 378 - "function " 379 - } else { 380 - "export function " 381 - }; 382 - definitions.push(self.shared_custom_type_fields( 383 - name, 384 - &accessors_map.shared_accessors, 385 - function_head, 386 - )); 377 + definitions.push(self.shared_custom_type_fields(name, &accessors_map.shared_accessors)); 387 378 } 388 379 389 380 definitions ··· 433 424 } 434 425 435 426 let construction = docvec![ 436 - line(), 437 - "return new ", 427 + break_("", " "), 428 + "new ", 438 429 constructor.name.as_str(), 439 430 "(", 440 - join(arguments.clone(), break_(",", ", ")), 431 + join(arguments.clone(), break_(",", ", ")).group(), 441 432 ");" 442 - ]; 433 + ] 434 + .group(); 443 435 444 436 docvec![ 445 - "export function ", 437 + "export const ", 446 438 type_name, 447 439 "$", 448 440 constructor.name.as_str(), 449 - "(", 441 + " = (", 450 442 join(arguments, break_(",", ", ")), 451 - ") {", 443 + ") =>", 452 444 construction.nest(INDENT), 453 - line(), 454 - "}" 455 445 ] 456 446 } 457 447 ··· 461 451 type_name: &'a str, 462 452 ) -> Document<'a> { 463 453 let construction = docvec![ 464 - line(), 465 - "return value instanceof ", 454 + break_("", " "), 455 + "value instanceof ", 466 456 constructor.name.as_str(), 467 457 ";" 468 - ]; 458 + ] 459 + .group(); 469 460 470 461 docvec![ 471 - "export function ", 462 + "export const ", 472 463 type_name, 473 464 "$is", 474 465 constructor.name.as_str(), 475 - "(value) {", 466 + " = (value) =>", 476 467 construction.nest(INDENT), 477 - line(), 478 - "}" 479 468 ] 480 469 } 481 470 ··· 504 493 field = eco_format!("[{index}]"); 505 494 }; 506 495 507 - let contents = docvec![line(), "return value", field, ";"]; 496 + let contents = docvec![break_("", " "), "value", field, ";"].group(); 508 497 509 498 functions.push(docvec![ 510 499 line(), 511 - "export function ", 500 + "export const ", 512 501 function_name, 513 - "(value) {", 502 + " = (value) =>", 514 503 contents.nest(INDENT), 515 - line(), 516 - "}" 517 504 ]); 518 505 } 519 506 ··· 524 511 &self, 525 512 type_name: &'a str, 526 513 shared_accessors: &HashMap<EcoString, RecordAccessor>, 527 - function_head: &'a str, 528 514 ) -> Document<'a> { 529 515 let mut functions = Vec::new(); 530 516 531 517 for field in shared_accessors.keys().sorted() { 532 518 let function_name = eco_format!("{type_name}${field}"); 533 519 534 - let contents = docvec![line(), "return value.", maybe_escape_property(field), ";"]; 520 + let contents = 521 + docvec![break_("", " "), "value.", maybe_escape_property(field), ";"].group(); 535 522 536 523 functions.push(docvec![ 537 524 line(), 538 - function_head, 525 + "export const ", 539 526 function_name, 540 - "(value) {", 527 + " = (value) =>", 541 528 contents.nest(INDENT), 542 - line(), 543 - "}" 544 529 ]); 545 530 } 546 531
+6 -18
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__bools__shadowed_bools_and_nil.snap
··· 18 18 const FILEPATH = "src/module.gleam"; 19 19 20 20 export class True extends $CustomType {} 21 - export function True$True() { 22 - return new True(); 23 - } 24 - export function True$isTrue(value) { 25 - return value instanceof True; 26 - } 21 + export const True$True = () => new True(); 22 + export const True$isTrue = (value) => value instanceof True; 27 23 28 24 export class False extends $CustomType {} 29 - export function True$False() { 30 - return new False(); 31 - } 32 - export function True$isFalse(value) { 33 - return value instanceof False; 34 - } 25 + export const True$False = () => new False(); 26 + export const True$isFalse = (value) => value instanceof False; 35 27 36 28 export class Nil extends $CustomType {} 37 - export function True$Nil() { 38 - return new Nil(); 39 - } 40 - export function True$isNil(value) { 41 - return value instanceof Nil; 42 - } 29 + export const True$Nil = () => new Nil(); 30 + export const True$isNil = (value) => value instanceof Nil; 43 31 44 32 export function go(x, y) { 45 33 if (!(x instanceof True)) {
+7 -21
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__case__case_building_record_with_labels_matched_by_pattern_1.snap
··· 26 26 this.string = string; 27 27 } 28 28 } 29 - export function Wibble$Wibble(int, string) { 30 - return new Wibble(int, string); 31 - } 32 - export function Wibble$isWibble(value) { 33 - return value instanceof Wibble; 34 - } 35 - export function Wibble$Wibble$int(value) { 36 - return value.int; 37 - } 38 - export function Wibble$Wibble$string(value) { 39 - return value.string; 40 - } 29 + export const Wibble$Wibble = (int, string) => new Wibble(int, string); 30 + export const Wibble$isWibble = (value) => value instanceof Wibble; 31 + export const Wibble$Wibble$int = (value) => value.int; 32 + export const Wibble$Wibble$string = (value) => value.string; 41 33 42 34 export class Wobble extends $CustomType { 43 35 constructor($0) { ··· 45 37 this[0] = $0; 46 38 } 47 39 } 48 - export function Wibble$Wobble($0) { 49 - return new Wobble($0); 50 - } 51 - export function Wibble$isWobble(value) { 52 - return value instanceof Wobble; 53 - } 54 - export function Wibble$Wobble$0(value) { 55 - return value[0]; 56 - } 40 + export const Wibble$Wobble = ($0) => new Wobble($0); 41 + export const Wibble$isWobble = (value) => value instanceof Wobble; 42 + export const Wibble$Wobble$0 = (value) => value[0]; 57 43 58 44 export function go(x) { 59 45 if (x instanceof Wibble) {
+7 -21
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__case__case_building_record_with_labels_matched_by_pattern_2.snap
··· 26 26 this.string = string; 27 27 } 28 28 } 29 - export function Wibble$Wibble(int, string) { 30 - return new Wibble(int, string); 31 - } 32 - export function Wibble$isWibble(value) { 33 - return value instanceof Wibble; 34 - } 35 - export function Wibble$Wibble$int(value) { 36 - return value.int; 37 - } 38 - export function Wibble$Wibble$string(value) { 39 - return value.string; 40 - } 29 + export const Wibble$Wibble = (int, string) => new Wibble(int, string); 30 + export const Wibble$isWibble = (value) => value instanceof Wibble; 31 + export const Wibble$Wibble$int = (value) => value.int; 32 + export const Wibble$Wibble$string = (value) => value.string; 41 33 42 34 export class Wobble extends $CustomType { 43 35 constructor($0) { ··· 45 37 this[0] = $0; 46 38 } 47 39 } 48 - export function Wibble$Wobble($0) { 49 - return new Wobble($0); 50 - } 51 - export function Wibble$isWobble(value) { 52 - return value instanceof Wobble; 53 - } 54 - export function Wibble$Wobble$0(value) { 55 - return value[0]; 56 - } 40 + export const Wibble$Wobble = ($0) => new Wobble($0); 41 + export const Wibble$isWobble = (value) => value instanceof Wobble; 42 + export const Wibble$Wobble$0 = (value) => value[0]; 57 43 58 44 export function go(x) { 59 45 if (x instanceof Wibble) {
+7 -21
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__case__case_building_record_with_labels_matched_by_pattern_3.snap
··· 27 27 this.string = string; 28 28 } 29 29 } 30 - export function Wibble$Wibble(int, string) { 31 - return new Wibble(int, string); 32 - } 33 - export function Wibble$isWibble(value) { 34 - return value instanceof Wibble; 35 - } 36 - export function Wibble$Wibble$int(value) { 37 - return value.int; 38 - } 39 - export function Wibble$Wibble$string(value) { 40 - return value.string; 41 - } 30 + export const Wibble$Wibble = (int, string) => new Wibble(int, string); 31 + export const Wibble$isWibble = (value) => value instanceof Wibble; 32 + export const Wibble$Wibble$int = (value) => value.int; 33 + export const Wibble$Wibble$string = (value) => value.string; 42 34 43 35 export class Wobble extends $CustomType { 44 36 constructor($0) { ··· 46 38 this[0] = $0; 47 39 } 48 40 } 49 - export function Wibble$Wobble($0) { 50 - return new Wobble($0); 51 - } 52 - export function Wibble$isWobble(value) { 53 - return value instanceof Wobble; 54 - } 55 - export function Wibble$Wobble$0(value) { 56 - return value[0]; 57 - } 41 + export const Wibble$Wobble = ($0) => new Wobble($0); 42 + export const Wibble$isWobble = (value) => value instanceof Wobble; 43 + export const Wibble$Wobble$0 = (value) => value[0]; 58 44 59 45 export function go(x) { 60 46 if (x instanceof Wibble) {
+7 -21
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__case__case_building_record_with_labels_matched_by_pattern_4.snap
··· 26 26 this.string = string; 27 27 } 28 28 } 29 - export function Wibble$Wibble(int, string) { 30 - return new Wibble(int, string); 31 - } 32 - export function Wibble$isWibble(value) { 33 - return value instanceof Wibble; 34 - } 35 - export function Wibble$Wibble$int(value) { 36 - return value.int; 37 - } 38 - export function Wibble$Wibble$string(value) { 39 - return value.string; 40 - } 29 + export const Wibble$Wibble = (int, string) => new Wibble(int, string); 30 + export const Wibble$isWibble = (value) => value instanceof Wibble; 31 + export const Wibble$Wibble$int = (value) => value.int; 32 + export const Wibble$Wibble$string = (value) => value.string; 41 33 42 34 export class Wobble extends $CustomType { 43 35 constructor($0) { ··· 45 37 this[0] = $0; 46 38 } 47 39 } 48 - export function Wibble$Wobble($0) { 49 - return new Wobble($0); 50 - } 51 - export function Wibble$isWobble(value) { 52 - return value instanceof Wobble; 53 - } 54 - export function Wibble$Wobble$0(value) { 55 - return value[0]; 56 - } 40 + export const Wibble$Wobble = ($0) => new Wobble($0); 41 + export const Wibble$isWobble = (value) => value instanceof Wobble; 42 + export const Wibble$Wobble$0 = (value) => value[0]; 57 43 58 44 export function go(x) { 59 45 if (x instanceof Wibble) {
+7 -21
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__case__case_building_record_with_labels_matched_by_pattern_5.snap
··· 26 26 this.string = string; 27 27 } 28 28 } 29 - export function Wibble$Wibble(int, string) { 30 - return new Wibble(int, string); 31 - } 32 - export function Wibble$isWibble(value) { 33 - return value instanceof Wibble; 34 - } 35 - export function Wibble$Wibble$int(value) { 36 - return value.int; 37 - } 38 - export function Wibble$Wibble$string(value) { 39 - return value.string; 40 - } 29 + export const Wibble$Wibble = (int, string) => new Wibble(int, string); 30 + export const Wibble$isWibble = (value) => value instanceof Wibble; 31 + export const Wibble$Wibble$int = (value) => value.int; 32 + export const Wibble$Wibble$string = (value) => value.string; 41 33 42 34 export class Wobble extends $CustomType { 43 35 constructor($0) { ··· 45 37 this[0] = $0; 46 38 } 47 39 } 48 - export function Wibble$Wobble($0) { 49 - return new Wobble($0); 50 - } 51 - export function Wibble$isWobble(value) { 52 - return value instanceof Wobble; 53 - } 54 - export function Wibble$Wobble$0(value) { 55 - return value[0]; 56 - } 40 + export const Wibble$Wobble = ($0) => new Wobble($0); 41 + export const Wibble$isWobble = (value) => value instanceof Wobble; 42 + export const Wibble$Wobble$0 = (value) => value[0]; 57 43 58 44 export function go(x) { 59 45 if (x instanceof Wibble) {
+7 -21
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__case__case_building_record_with_labels_matched_by_pattern_6.snap
··· 26 26 this.string = string; 27 27 } 28 28 } 29 - export function Wibble$Wibble(int, string) { 30 - return new Wibble(int, string); 31 - } 32 - export function Wibble$isWibble(value) { 33 - return value instanceof Wibble; 34 - } 35 - export function Wibble$Wibble$int(value) { 36 - return value.int; 37 - } 38 - export function Wibble$Wibble$string(value) { 39 - return value.string; 40 - } 29 + export const Wibble$Wibble = (int, string) => new Wibble(int, string); 30 + export const Wibble$isWibble = (value) => value instanceof Wibble; 31 + export const Wibble$Wibble$int = (value) => value.int; 32 + export const Wibble$Wibble$string = (value) => value.string; 41 33 42 34 export class Wobble extends $CustomType { 43 35 constructor($0) { ··· 45 37 this[0] = $0; 46 38 } 47 39 } 48 - export function Wibble$Wobble($0) { 49 - return new Wobble($0); 50 - } 51 - export function Wibble$isWobble(value) { 52 - return value instanceof Wobble; 53 - } 54 - export function Wibble$Wobble$0(value) { 55 - return value[0]; 56 - } 40 + export const Wibble$Wobble = ($0) => new Wobble($0); 41 + export const Wibble$isWobble = (value) => value instanceof Wobble; 42 + export const Wibble$Wobble$0 = (value) => value[0]; 57 43 58 44 export function go(x) { 59 45 if (x instanceof Wibble) {
+4 -12
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__case__record_update_in_pipeline_in_case_clause.snap
··· 33 33 this.wobble = wobble; 34 34 } 35 35 } 36 - export function Wibble$Wibble(wibble, wobble) { 37 - return new Wibble(wibble, wobble); 38 - } 39 - export function Wibble$isWibble(value) { 40 - return value instanceof Wibble; 41 - } 42 - export function Wibble$Wibble$wibble(value) { 43 - return value.wibble; 44 - } 45 - export function Wibble$Wibble$wobble(value) { 46 - return value.wobble; 47 - } 36 + export const Wibble$Wibble = (wibble, wobble) => new Wibble(wibble, wobble); 37 + export const Wibble$isWibble = (value) => value instanceof Wibble; 38 + export const Wibble$Wibble$wibble = (value) => value.wibble; 39 + export const Wibble$Wibble$wobble = (value) => value.wobble; 48 40 49 41 function identity(x) { 50 42 return x;
+6 -15
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__case_clause_guards__field_access.snap
··· 28 28 this.age = age; 29 29 } 30 30 } 31 - export function Person$Person(username, name, age) { 32 - return new Person(username, name, age); 33 - } 34 - export function Person$isPerson(value) { 35 - return value instanceof Person; 36 - } 37 - export function Person$Person$username(value) { 38 - return value.username; 39 - } 40 - export function Person$Person$name(value) { 41 - return value.name; 42 - } 43 - export function Person$Person$age(value) { 44 - return value.age; 45 - } 31 + export const Person$Person = (username, name, age) => 32 + new Person(username, name, age); 33 + export const Person$isPerson = (value) => value instanceof Person; 34 + export const Person$Person$username = (value) => value.username; 35 + export const Person$Person$name = (value) => value.name; 36 + export const Person$Person$age = (value) => value.age; 46 37 47 38 export function main() { 48 39 let given_name = "jack";
+2 -6
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__case_clause_guards__imported_aliased_ok.snap
··· 20 20 import { Ok as Y, CustomType as $CustomType, isEqual } from "../gleam.mjs"; 21 21 22 22 export class Ok extends $CustomType {} 23 - export function X$Ok() { 24 - return new Ok(); 25 - } 26 - export function X$isOk(value) { 27 - return value instanceof Ok; 28 - } 23 + export const X$Ok = () => new Ok(); 24 + export const X$isOk = (value) => value instanceof Ok; 29 25 30 26 export function func() { 31 27 let $ = (var0) => { return new Y(var0); };
+2 -6
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__case_clause_guards__imported_ok.snap
··· 20 20 import { Ok, toList, CustomType as $CustomType, isEqual } from "../gleam.mjs"; 21 21 22 22 export class Ok extends $CustomType {} 23 - export function X$Ok() { 24 - return new Ok(); 25 - } 26 - export function X$isOk(value) { 27 - return value instanceof Ok; 28 - } 23 + export const X$Ok = () => new Ok(); 24 + export const X$isOk = (value) => value instanceof Ok; 29 25 30 26 export function func(x) { 31 27 let $ = (var0) => { return new $gleam.Ok(var0); };
+9 -27
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__case_clause_guards__nested_record_access.snap
··· 33 33 this.b = b; 34 34 } 35 35 } 36 - export function A$A(b) { 37 - return new A(b); 38 - } 39 - export function A$isA(value) { 40 - return value instanceof A; 41 - } 42 - export function A$A$b(value) { 43 - return value.b; 44 - } 36 + export const A$A = (b) => new A(b); 37 + export const A$isA = (value) => value instanceof A; 38 + export const A$A$b = (value) => value.b; 45 39 46 40 export class B extends $CustomType { 47 41 constructor(c) { ··· 49 43 this.c = c; 50 44 } 51 45 } 52 - export function B$B(c) { 53 - return new B(c); 54 - } 55 - export function B$isB(value) { 56 - return value instanceof B; 57 - } 58 - export function B$B$c(value) { 59 - return value.c; 60 - } 46 + export const B$B = (c) => new B(c); 47 + export const B$isB = (value) => value instanceof B; 48 + export const B$B$c = (value) => value.c; 61 49 62 50 export class C extends $CustomType { 63 51 constructor(d) { ··· 65 53 this.d = d; 66 54 } 67 55 } 68 - export function C$C(d) { 69 - return new C(d); 70 - } 71 - export function C$isC(value) { 72 - return value instanceof C; 73 - } 74 - export function C$C$d(value) { 75 - return value.d; 76 - } 56 + export const C$C = (d) => new C(d); 57 + export const C$isC = (value) => value instanceof C; 58 + export const C$C$d = (value) => value.d; 77 59 78 60 export function a(a) { 79 61 if (a.b.c.d) {
+4 -12
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__consts__constant_constructor_gets_pure_annotation.snap
··· 22 22 this[1] = $1; 23 23 } 24 24 } 25 - export function X$X($0, $1) { 26 - return new X($0, $1); 27 - } 28 - export function X$isX(value) { 29 - return value instanceof X; 30 - } 31 - export function X$X$0(value) { 32 - return value[0]; 33 - } 34 - export function X$X$1(value) { 35 - return value[1]; 36 - } 25 + export const X$X = ($0, $1) => new X($0, $1); 26 + export const X$isX = (value) => value instanceof X; 27 + export const X$X$0 = (value) => value[0]; 28 + export const X$X$1 = (value) => value[1]; 37 29 38 30 export const x = /* @__PURE__ */ new X(1, /* @__PURE__ */ toList(["1"])); 39 31
+4 -12
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__consts__constant_list_with_constructors_gets_pure_annotation.snap
··· 22 22 this[1] = $1; 23 23 } 24 24 } 25 - export function X$X($0, $1) { 26 - return new X($0, $1); 27 - } 28 - export function X$isX(value) { 29 - return value instanceof X; 30 - } 31 - export function X$X$0(value) { 32 - return value[0]; 33 - } 34 - export function X$X$1(value) { 35 - return value[1]; 36 - } 25 + export const X$X = ($0, $1) => new X($0, $1); 26 + export const X$isX = (value) => value instanceof X; 27 + export const X$X$0 = (value) => value[0]; 28 + export const X$X$1 = (value) => value[1]; 37 29 38 30 export const x = /* @__PURE__ */ toList([ 39 31 /* @__PURE__ */ new X(1, /* @__PURE__ */ toList(["1"])),
+4 -12
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__consts__constant_tuple_with_constructors_gets_pure_annotation.snap
··· 22 22 this[1] = $1; 23 23 } 24 24 } 25 - export function X$X($0, $1) { 26 - return new X($0, $1); 27 - } 28 - export function X$isX(value) { 29 - return value instanceof X; 30 - } 31 - export function X$X$0(value) { 32 - return value[0]; 33 - } 34 - export function X$X$1(value) { 35 - return value[1]; 36 - } 25 + export const X$X = ($0, $1) => new X($0, $1); 26 + export const X$isX = (value) => value instanceof X; 27 + export const X$X$0 = (value) => value[0]; 28 + export const X$X$1 = (value) => value[1]; 37 29 38 30 export const x = [/* @__PURE__ */ new X(1, /* @__PURE__ */ toList(["1"]))]; 39 31
+2 -6
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__consts__imported_aliased_ok.snap
··· 17 17 import { Ok as Y, CustomType as $CustomType } from "../gleam.mjs"; 18 18 19 19 export class Ok extends $CustomType {} 20 - export function X$Ok() { 21 - return new Ok(); 22 - } 23 - export function X$isOk(value) { 24 - return value instanceof Ok; 25 - } 20 + export const X$Ok = () => new Ok(); 21 + export const X$isOk = (value) => value instanceof Ok; 26 22 27 23 export const y = (var0) => { return new Y(var0); };
+2 -6
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__consts__imported_ok.snap
··· 17 17 import { Ok, CustomType as $CustomType } from "../gleam.mjs"; 18 18 19 19 export class Ok extends $CustomType {} 20 - export function X$Ok() { 21 - return new Ok(); 22 - } 23 - export function X$isOk(value) { 24 - return value instanceof Ok; 25 - } 20 + export const X$Ok = () => new Ok(); 21 + export const X$isOk = (value) => value instanceof Ok; 26 22 27 23 export const y = (var0) => { return new Ok(var0); };
+4 -12
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__custom_types__const_with_fields.snap
··· 22 22 this.b = b; 23 23 } 24 24 } 25 - export function Mine$Mine(a, b) { 26 - return new Mine(a, b); 27 - } 28 - export function Mine$isMine(value) { 29 - return value instanceof Mine; 30 - } 31 - export function Mine$Mine$a(value) { 32 - return value.a; 33 - } 34 - export function Mine$Mine$b(value) { 35 - return value.b; 36 - } 25 + export const Mine$Mine = (a, b) => new Mine(a, b); 26 + export const Mine$isMine = (value) => value instanceof Mine; 27 + export const Mine$Mine$a = (value) => value.a; 28 + export const Mine$Mine$b = (value) => value.b; 37 29 38 30 export const labels = /* @__PURE__ */ new Mine(1, 2); 39 31
+7 -21
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__custom_types__constructors_get_their_own_jsdoc.snap
··· 25 25 this.field = field; 26 26 } 27 27 } 28 - export function Wibble$Wibble(field) { 29 - return new Wibble(field); 30 - } 31 - export function Wibble$isWibble(value) { 32 - return value instanceof Wibble; 33 - } 34 - export function Wibble$Wibble$field(value) { 35 - return value.field; 36 - } 28 + export const Wibble$Wibble = (field) => new Wibble(field); 29 + export const Wibble$isWibble = (value) => value instanceof Wibble; 30 + export const Wibble$Wibble$field = (value) => value.field; 37 31 38 32 /** 39 33 * Wobbling!! ··· 44 38 this.field = field; 45 39 } 46 40 } 47 - export function Wibble$Wobble(field) { 48 - return new Wobble(field); 49 - } 50 - export function Wibble$isWobble(value) { 51 - return value instanceof Wobble; 52 - } 53 - export function Wibble$Wobble$field(value) { 54 - return value.field; 55 - } 41 + export const Wibble$Wobble = (field) => new Wobble(field); 42 + export const Wibble$isWobble = (value) => value instanceof Wobble; 43 + export const Wibble$Wobble$field = (value) => value.field; 56 44 57 45 58 - export function Wibble$field(value) { 59 - return value.field; 60 - } 46 + export const Wibble$field = (value) => value.field;
+7 -21
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__custom_types__custom_type_with_named_fields.snap
··· 48 48 this.cuteness = cuteness; 49 49 } 50 50 } 51 - export function Cat$Cat(name, cuteness) { 52 - return new Cat(name, cuteness); 53 - } 54 - export function Cat$isCat(value) { 55 - return value instanceof Cat; 56 - } 57 - export function Cat$Cat$name(value) { 58 - return value.name; 59 - } 60 - export function Cat$Cat$cuteness(value) { 61 - return value.cuteness; 62 - } 51 + export const Cat$Cat = (name, cuteness) => new Cat(name, cuteness); 52 + export const Cat$isCat = (value) => value instanceof Cat; 53 + export const Cat$Cat$name = (value) => value.name; 54 + export const Cat$Cat$cuteness = (value) => value.cuteness; 63 55 64 56 export class Box extends $CustomType { 65 57 constructor(occupant) { ··· 67 59 this.occupant = occupant; 68 60 } 69 61 } 70 - export function Box$Box(occupant) { 71 - return new Box(occupant); 72 - } 73 - export function Box$isBox(value) { 74 - return value instanceof Box; 75 - } 76 - export function Box$Box$occupant(value) { 77 - return value.occupant; 78 - } 62 + export const Box$Box = (occupant) => new Box(occupant); 63 + export const Box$isBox = (value) => value instanceof Box; 64 + export const Box$Box$occupant = (value) => value.occupant; 79 65 80 66 export function go() { 81 67 new Cat("Nubi", 1);
+4 -12
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__custom_types__destructure_custom_type_with_mixed_fields_first_unlabelled.snap
··· 27 27 this.cuteness = cuteness; 28 28 } 29 29 } 30 - export function Cat$Cat($0, cuteness) { 31 - return new Cat($0, cuteness); 32 - } 33 - export function Cat$isCat(value) { 34 - return value instanceof Cat; 35 - } 36 - export function Cat$Cat$0(value) { 37 - return value[0]; 38 - } 39 - export function Cat$Cat$cuteness(value) { 40 - return value.cuteness; 41 - } 30 + export const Cat$Cat = ($0, cuteness) => new Cat($0, cuteness); 31 + export const Cat$isCat = (value) => value instanceof Cat; 32 + export const Cat$Cat$0 = (value) => value[0]; 33 + export const Cat$Cat$cuteness = (value) => value.cuteness; 42 34 43 35 export function go(cat) { 44 36 let x;
+4 -12
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__custom_types__destructure_custom_type_with_named_fields.snap
··· 29 29 this.cuteness = cuteness; 30 30 } 31 31 } 32 - export function Cat$Cat(name, cuteness) { 33 - return new Cat(name, cuteness); 34 - } 35 - export function Cat$isCat(value) { 36 - return value instanceof Cat; 37 - } 38 - export function Cat$Cat$name(value) { 39 - return value.name; 40 - } 41 - export function Cat$Cat$cuteness(value) { 42 - return value.cuteness; 43 - } 32 + export const Cat$Cat = (name, cuteness) => new Cat(name, cuteness); 33 + export const Cat$isCat = (value) => value instanceof Cat; 34 + export const Cat$Cat$name = (value) => value.name; 35 + export const Cat$Cat$cuteness = (value) => value.cuteness; 44 36 45 37 export function go(cat) { 46 38 let x;
+4 -12
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__custom_types__keyword_label_name.snap
··· 18 18 this.class = class$; 19 19 } 20 20 } 21 - export function Thing$Thing(in$, class$) { 22 - return new Thing(in$, class$); 23 - } 24 - export function Thing$isThing(value) { 25 - return value instanceof Thing; 26 - } 27 - export function Thing$Thing$in(value) { 28 - return value.in; 29 - } 30 - export function Thing$Thing$class(value) { 31 - return value.class; 32 - } 21 + export const Thing$Thing = (in$, class$) => new Thing(in$, class$); 22 + export const Thing$isThing = (value) => value instanceof Thing; 23 + export const Thing$Thing$in = (value) => value.in; 24 + export const Thing$Thing$class = (value) => value.class;
+14 -21
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__custom_types__long_name_variant_without_labels.snap
··· 27 27 this[4] = $4; 28 28 } 29 29 } 30 - export function TypeWithALongNameAndSeveralArguments$TypeWithALongNameAndSeveralArguments($0, $1, $2, $3, $4) { 31 - return new TypeWithALongNameAndSeveralArguments($0, $1, $2, $3, $4); 32 - } 33 - export function TypeWithALongNameAndSeveralArguments$isTypeWithALongNameAndSeveralArguments(value) { 34 - return value instanceof TypeWithALongNameAndSeveralArguments; 35 - } 36 - export function TypeWithALongNameAndSeveralArguments$TypeWithALongNameAndSeveralArguments$0(value) { 37 - return value[0]; 38 - } 39 - export function TypeWithALongNameAndSeveralArguments$TypeWithALongNameAndSeveralArguments$1(value) { 40 - return value[1]; 41 - } 42 - export function TypeWithALongNameAndSeveralArguments$TypeWithALongNameAndSeveralArguments$2(value) { 43 - return value[2]; 44 - } 45 - export function TypeWithALongNameAndSeveralArguments$TypeWithALongNameAndSeveralArguments$3(value) { 46 - return value[3]; 47 - } 48 - export function TypeWithALongNameAndSeveralArguments$TypeWithALongNameAndSeveralArguments$4(value) { 49 - return value[4]; 50 - } 30 + export const TypeWithALongNameAndSeveralArguments$TypeWithALongNameAndSeveralArguments = ($0, $1, $2, $3, $4) => 31 + new TypeWithALongNameAndSeveralArguments($0, $1, $2, $3, $4); 32 + export const TypeWithALongNameAndSeveralArguments$isTypeWithALongNameAndSeveralArguments = (value) => 33 + value instanceof TypeWithALongNameAndSeveralArguments; 34 + export const TypeWithALongNameAndSeveralArguments$TypeWithALongNameAndSeveralArguments$0 = (value) => 35 + value[0]; 36 + export const TypeWithALongNameAndSeveralArguments$TypeWithALongNameAndSeveralArguments$1 = (value) => 37 + value[1]; 38 + export const TypeWithALongNameAndSeveralArguments$TypeWithALongNameAndSeveralArguments$2 = (value) => 39 + value[2]; 40 + export const TypeWithALongNameAndSeveralArguments$TypeWithALongNameAndSeveralArguments$3 = (value) => 41 + value[3]; 42 + export const TypeWithALongNameAndSeveralArguments$TypeWithALongNameAndSeveralArguments$4 = (value) => 43 + value[4]; 51 44 52 45 export function go() { 53 46 return (var0, var1, var2, var3, var4) => {
+4 -12
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__custom_types__nested_pattern_with_labels.snap
··· 22 22 this.b = b; 23 23 } 24 24 } 25 - export function Box$Box(a, b) { 26 - return new Box(a, b); 27 - } 28 - export function Box$isBox(value) { 29 - return value instanceof Box; 30 - } 31 - export function Box$Box$a(value) { 32 - return value.a; 33 - } 34 - export function Box$Box$b(value) { 35 - return value.b; 36 - } 25 + export const Box$Box = (a, b) => new Box(a, b); 26 + export const Box$isBox = (value) => value instanceof Box; 27 + export const Box$Box$a = (value) => value.a; 28 + export const Box$Box$b = (value) => value.b; 37 29 38 30 export function go(x) { 39 31 let a = x.b.a;
+3 -9
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__custom_types__record_access_in_guard_with_reserved_field_name.snap
··· 26 26 this.constructor$ = constructor; 27 27 } 28 28 } 29 - export function Thing$Thing(constructor) { 30 - return new Thing(constructor); 31 - } 32 - export function Thing$isThing(value) { 33 - return value instanceof Thing; 34 - } 35 - export function Thing$Thing$constructor(value) { 36 - return value.constructor$; 37 - } 29 + export const Thing$Thing = (constructor) => new Thing(constructor); 30 + export const Thing$isThing = (value) => value instanceof Thing; 31 + export const Thing$Thing$constructor = (value) => value.constructor$; 38 32 39 33 export function main() { 40 34 let a = new Thing(undefined);
+3 -9
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__custom_types__record_access_in_pattern_with_reserved_field_name.snap
··· 28 28 this.constructor$ = constructor; 29 29 } 30 30 } 31 - export function Thing$Thing(constructor) { 32 - return new Thing(constructor); 33 - } 34 - export function Thing$isThing(value) { 35 - return value instanceof Thing; 36 - } 37 - export function Thing$Thing$constructor(value) { 38 - return value.constructor$; 39 - } 31 + export const Thing$Thing = (constructor) => new Thing(constructor); 32 + export const Thing$isThing = (value) => value instanceof Thing; 33 + export const Thing$Thing$constructor = (value) => value.constructor$; 40 34 41 35 export function main() { 42 36 let a = new Thing(undefined);
+3 -9
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__custom_types__record_with_field_named_constructor.snap
··· 24 24 this.constructor$ = constructor; 25 25 } 26 26 } 27 - export function Thing$Thing(constructor) { 28 - return new Thing(constructor); 29 - } 30 - export function Thing$isThing(value) { 31 - return value instanceof Thing; 32 - } 33 - export function Thing$Thing$constructor(value) { 34 - return value.constructor$; 35 - } 27 + export const Thing$Thing = (constructor) => new Thing(constructor); 28 + export const Thing$isThing = (value) => value instanceof Thing; 29 + export const Thing$Thing$constructor = (value) => value.constructor$; 36 30 37 31 export function main() { 38 32 let a = new Thing(undefined);
+3 -9
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__custom_types__record_with_field_named_then.snap
··· 24 24 this.then$ = then$; 25 25 } 26 26 } 27 - export function Thing$Thing(then$) { 28 - return new Thing(then$); 29 - } 30 - export function Thing$isThing(value) { 31 - return value instanceof Thing; 32 - } 33 - export function Thing$Thing$then(value) { 34 - return value.then$; 35 - } 27 + export const Thing$Thing = (then$) => new Thing(then$); 28 + export const Thing$isThing = (value) => value instanceof Thing; 29 + export const Thing$Thing$then = (value) => value.then$; 36 30 37 31 export function main() { 38 32 let a = new Thing(undefined);
+2 -6
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__custom_types__types_must_be_rendered_before_functions.snap
··· 12 12 import { CustomType as $CustomType } from "../gleam.mjs"; 13 13 14 14 export class One extends $CustomType {} 15 - export function One$One() { 16 - return new One(); 17 - } 18 - export function One$isOne(value) { 19 - return value instanceof One; 20 - } 15 + export const One$One = () => new One(); 16 + export const One$isOne = (value) => value instanceof One; 21 17 22 18 export function one() { 23 19 return new One();
+3 -9
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__custom_types__unnamed_fields.snap
··· 34 34 this[0] = $0; 35 35 } 36 36 } 37 - export function Ip$Ip($0) { 38 - return new Ip($0); 39 - } 40 - export function Ip$isIp(value) { 41 - return value instanceof Ip; 42 - } 43 - export function Ip$Ip$0(value) { 44 - return value[0]; 45 - } 37 + export const Ip$Ip = ($0) => new Ip($0); 38 + export const Ip$isIp = (value) => value instanceof Ip; 39 + export const Ip$Ip$0 = (value) => value[0]; 46 40 47 41 export function build(x) { 48 42 return x("1.2.3.4");
+6 -12
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__custom_types__zero_arity_const.snap
··· 17 17 import { CustomType as $CustomType } from "../gleam.mjs"; 18 18 19 19 export class This extends $CustomType {} 20 - export function Mine$This() { 21 - return new This(); 22 - } 23 - export function Mine$isThis(value) { 24 - return value instanceof This; 25 - } 20 + export const Mine$This = () => new This(); 21 + export const Mine$isThis = (value) => value instanceof This; 26 22 27 23 export class ThatOneIsAMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchLongerVariant extends $CustomType {} 28 - export function Mine$ThatOneIsAMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchLongerVariant() { 29 - return new ThatOneIsAMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchLongerVariant(); 30 - } 31 - export function Mine$isThatOneIsAMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchLongerVariant(value) { 32 - return value instanceof ThatOneIsAMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchLongerVariant; 33 - } 24 + export const Mine$ThatOneIsAMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchLongerVariant = () => 25 + new ThatOneIsAMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchLongerVariant(); 26 + export const Mine$isThatOneIsAMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchLongerVariant = (value) => 27 + value instanceof ThatOneIsAMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchLongerVariant; 34 28 35 29 export const this$ = /* @__PURE__ */ new This(); 36 30
+6 -12
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__custom_types__zero_arity_literal.snap
··· 19 19 import { CustomType as $CustomType } from "../gleam.mjs"; 20 20 21 21 export class This extends $CustomType {} 22 - export function Mine$This() { 23 - return new This(); 24 - } 25 - export function Mine$isThis(value) { 26 - return value instanceof This; 27 - } 22 + export const Mine$This = () => new This(); 23 + export const Mine$isThis = (value) => value instanceof This; 28 24 29 25 export class ThatOneIsAMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchLongerVariant extends $CustomType {} 30 - export function Mine$ThatOneIsAMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchLongerVariant() { 31 - return new ThatOneIsAMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchLongerVariant(); 32 - } 33 - export function Mine$isThatOneIsAMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchLongerVariant(value) { 34 - return value instanceof ThatOneIsAMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchLongerVariant; 35 - } 26 + export const Mine$ThatOneIsAMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchLongerVariant = () => 27 + new ThatOneIsAMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchLongerVariant(); 28 + export const Mine$isThatOneIsAMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchLongerVariant = (value) => 29 + value instanceof ThatOneIsAMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchLongerVariant; 36 30 37 31 export function go() { 38 32 new This();
+4 -12
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__functions__immediately_invoked_function_expressions_include_statement_level.snap
··· 26 26 this.b = b; 27 27 } 28 28 } 29 - export function Wibble$Wibble(a, b) { 30 - return new Wibble(a, b); 31 - } 32 - export function Wibble$isWibble(value) { 33 - return value instanceof Wibble; 34 - } 35 - export function Wibble$Wibble$a(value) { 36 - return value.a; 37 - } 38 - export function Wibble$Wibble$b(value) { 39 - return value.b; 40 - } 29 + export const Wibble$Wibble = (a, b) => new Wibble(a, b); 30 + export const Wibble$isWibble = (value) => value instanceof Wibble; 31 + export const Wibble$Wibble$a = (value) => value.a; 32 + export const Wibble$Wibble$b = (value) => value.b; 41 33 42 34 function identity(x) { 43 35 return x;
+3 -9
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__functions__two_pipes_in_a_row.snap
··· 22 22 this[0] = $0; 23 23 } 24 24 } 25 - export function Function$Function($0) { 26 - return new Function($0); 27 - } 28 - export function Function$isFunction(value) { 29 - return value instanceof Function; 30 - } 31 - export function Function$Function$0(value) { 32 - return value[0]; 33 - } 25 + export const Function$Function = ($0) => new Function($0); 26 + export const Function$isFunction = (value) => value instanceof Function; 27 + export const Function$Function$0 = (value) => value[0]; 34 28 35 29 export function main() { 36 30 return toList([
+4 -12
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__inlining__inlining_works_properly_with_record_updates.snap
··· 28 28 this.b = b; 29 29 } 30 30 } 31 - export function Wibble$Wibble(a, b) { 32 - return new Wibble(a, b); 33 - } 34 - export function Wibble$isWibble(value) { 35 - return value instanceof Wibble; 36 - } 37 - export function Wibble$Wibble$a(value) { 38 - return value.a; 39 - } 40 - export function Wibble$Wibble$b(value) { 41 - return value.b; 42 - } 31 + export const Wibble$Wibble = (a, b) => new Wibble(a, b); 32 + export const Wibble$isWibble = (value) => value instanceof Wibble; 33 + export const Wibble$Wibble$a = (value) => value.a; 34 + export const Wibble$Wibble$b = (value) => value.b; 43 35 44 36 export function main() { 45 37 let w = new Wibble(1, 2);
+6 -18
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__prelude__qualified_prelude_value_does_not_conflict_with_local_value.snap
··· 26 26 this[0] = $0; 27 27 } 28 28 } 29 - export function Result$Ok($0) { 30 - return new Ok($0); 31 - } 32 - export function Result$isOk(value) { 33 - return value instanceof Ok; 34 - } 35 - export function Result$Ok$0(value) { 36 - return value[0]; 37 - } 29 + export const Result$Ok = ($0) => new Ok($0); 30 + export const Result$isOk = (value) => value instanceof Ok; 31 + export const Result$Ok$0 = (value) => value[0]; 38 32 39 33 export class Error extends $CustomType { 40 34 constructor($0) { ··· 42 36 this[0] = $0; 43 37 } 44 38 } 45 - export function Result$Error($0) { 46 - return new Error($0); 47 - } 48 - export function Result$isError(value) { 49 - return value instanceof Error; 50 - } 51 - export function Result$Error$0(value) { 52 - return value[0]; 53 - } 39 + export const Result$Error = ($0) => new Error($0); 40 + export const Result$isError = (value) => value instanceof Error; 41 + export const Result$Error$0 = (value) => value[0]; 54 42 55 43 export function main() { 56 44 return new $gleam.Ok(10);
+6 -18
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__prelude__qualified_prelude_value_does_not_conflict_with_local_value_constant.snap
··· 24 24 this[0] = $0; 25 25 } 26 26 } 27 - export function Result$Ok($0) { 28 - return new Ok($0); 29 - } 30 - export function Result$isOk(value) { 31 - return value instanceof Ok; 32 - } 33 - export function Result$Ok$0(value) { 34 - return value[0]; 35 - } 27 + export const Result$Ok = ($0) => new Ok($0); 28 + export const Result$isOk = (value) => value instanceof Ok; 29 + export const Result$Ok$0 = (value) => value[0]; 36 30 37 31 export class Error extends $CustomType { 38 32 constructor($0) { ··· 40 34 this[0] = $0; 41 35 } 42 36 } 43 - export function Result$Error($0) { 44 - return new Error($0); 45 - } 46 - export function Result$isError(value) { 47 - return value instanceof Error; 48 - } 49 - export function Result$Error$0(value) { 50 - return value[0]; 51 - } 37 + export const Result$Error = ($0) => new Error($0); 38 + export const Result$isError = (value) => value instanceof Error; 39 + export const Result$Error$0 = (value) => value[0]; 52 40 53 41 export const error = /* @__PURE__ */ new $gleam.Error("Bad");
+6 -18
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__prelude__qualified_prelude_value_does_not_conflict_with_local_value_pattern.snap
··· 29 29 this[0] = $0; 30 30 } 31 31 } 32 - export function Result$Ok($0) { 33 - return new Ok($0); 34 - } 35 - export function Result$isOk(value) { 36 - return value instanceof Ok; 37 - } 38 - export function Result$Ok$0(value) { 39 - return value[0]; 40 - } 32 + export const Result$Ok = ($0) => new Ok($0); 33 + export const Result$isOk = (value) => value instanceof Ok; 34 + export const Result$Ok$0 = (value) => value[0]; 41 35 42 36 export class Error extends $CustomType { 43 37 constructor($0) { ··· 45 39 this[0] = $0; 46 40 } 47 41 } 48 - export function Result$Error($0) { 49 - return new Error($0); 50 - } 51 - export function Result$isError(value) { 52 - return value instanceof Error; 53 - } 54 - export function Result$Error$0(value) { 55 - return value[0]; 56 - } 42 + export const Result$Error = ($0) => new Error($0); 43 + export const Result$isError = (value) => value instanceof Error; 44 + export const Result$Error$0 = (value) => value[0]; 57 45 58 46 export function go(x) { 59 47 if (x instanceof $gleam.Ok) {
+3 -9
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__records__field_named_constructor_is_escaped.snap
··· 18 18 this.constructor$ = constructor; 19 19 } 20 20 } 21 - export function Wibble$Wibble(constructor) { 22 - return new Wibble(constructor); 23 - } 24 - export function Wibble$isWibble(value) { 25 - return value instanceof Wibble; 26 - } 27 - export function Wibble$Wibble$constructor(value) { 28 - return value.constructor$; 29 - } 21 + export const Wibble$Wibble = (constructor) => new Wibble(constructor); 22 + export const Wibble$isWibble = (value) => value instanceof Wibble; 23 + export const Wibble$Wibble$constructor = (value) => value.constructor$;
+3 -9
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__records__field_named_prototype_is_escaped.snap
··· 18 18 this.prototype$ = prototype; 19 19 } 20 20 } 21 - export function Wibble$Wibble(prototype) { 22 - return new Wibble(prototype); 23 - } 24 - export function Wibble$isWibble(value) { 25 - return value instanceof Wibble; 26 - } 27 - export function Wibble$Wibble$prototype(value) { 28 - return value.prototype$; 29 - } 21 + export const Wibble$Wibble = (prototype) => new Wibble(prototype); 22 + export const Wibble$isWibble = (value) => value instanceof Wibble; 23 + export const Wibble$Wibble$prototype = (value) => value.prototype$;
+3 -9
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__records__field_named_then_is_escaped.snap
··· 18 18 this.then$ = then$; 19 19 } 20 20 } 21 - export function Wibble$Wibble(then$) { 22 - return new Wibble(then$); 23 - } 24 - export function Wibble$isWibble(value) { 25 - return value instanceof Wibble; 26 - } 27 - export function Wibble$Wibble$then(value) { 28 - return value.then$; 29 - } 21 + export const Wibble$Wibble = (then$) => new Wibble(then$); 22 + export const Wibble$isWibble = (value) => value instanceof Wibble; 23 + export const Wibble$Wibble$then = (value) => value.then$;
+4 -12
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__records__field_named_x0.snap
··· 19 19 this.x0 = x0; 20 20 } 21 21 } 22 - export function Wibble$Wibble($0, x0) { 23 - return new Wibble($0, x0); 24 - } 25 - export function Wibble$isWibble(value) { 26 - return value instanceof Wibble; 27 - } 28 - export function Wibble$Wibble$0(value) { 29 - return value[0]; 30 - } 31 - export function Wibble$Wibble$x0(value) { 32 - return value.x0; 33 - } 22 + export const Wibble$Wibble = ($0, x0) => new Wibble($0, x0); 23 + export const Wibble$isWibble = (value) => value instanceof Wibble; 24 + export const Wibble$Wibble$0 = (value) => value[0]; 25 + export const Wibble$Wibble$x0 = (value) => value.x0;
+9 -27
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__records__record_accessor_multiple_variants.snap
··· 20 20 this.title = title; 21 21 } 22 22 } 23 - export function Person$Teacher(name, title) { 24 - return new Teacher(name, title); 25 - } 26 - export function Person$isTeacher(value) { 27 - return value instanceof Teacher; 28 - } 29 - export function Person$Teacher$name(value) { 30 - return value.name; 31 - } 32 - export function Person$Teacher$title(value) { 33 - return value.title; 34 - } 23 + export const Person$Teacher = (name, title) => new Teacher(name, title); 24 + export const Person$isTeacher = (value) => value instanceof Teacher; 25 + export const Person$Teacher$name = (value) => value.name; 26 + export const Person$Teacher$title = (value) => value.title; 35 27 36 28 export class Student extends $CustomType { 37 29 constructor(name, age) { ··· 40 32 this.age = age; 41 33 } 42 34 } 43 - export function Person$Student(name, age) { 44 - return new Student(name, age); 45 - } 46 - export function Person$isStudent(value) { 47 - return value instanceof Student; 48 - } 49 - export function Person$Student$name(value) { 50 - return value.name; 51 - } 52 - export function Person$Student$age(value) { 53 - return value.age; 54 - } 35 + export const Person$Student = (name, age) => new Student(name, age); 36 + export const Person$isStudent = (value) => value instanceof Student; 37 + export const Person$Student$name = (value) => value.name; 38 + export const Person$Student$age = (value) => value.age; 55 39 56 40 57 - export function Person$name(value) { 58 - return value.name; 59 - } 41 + export const Person$name = (value) => value.name; 60 42 61 43 export function get_name(person) { 62 44 return person.name;
+12 -33
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__records__record_accessor_multiple_variants_parameterised_types.snap
··· 22 22 this.title = title; 23 23 } 24 24 } 25 - export function Person$Teacher(name, age, title) { 26 - return new Teacher(name, age, title); 27 - } 28 - export function Person$isTeacher(value) { 29 - return value instanceof Teacher; 30 - } 31 - export function Person$Teacher$name(value) { 32 - return value.name; 33 - } 34 - export function Person$Teacher$age(value) { 35 - return value.age; 36 - } 37 - export function Person$Teacher$title(value) { 38 - return value.title; 39 - } 25 + export const Person$Teacher = (name, age, title) => 26 + new Teacher(name, age, title); 27 + export const Person$isTeacher = (value) => value instanceof Teacher; 28 + export const Person$Teacher$name = (value) => value.name; 29 + export const Person$Teacher$age = (value) => value.age; 30 + export const Person$Teacher$title = (value) => value.title; 40 31 41 32 export class Student extends $CustomType { 42 33 constructor(name, age) { ··· 45 36 this.age = age; 46 37 } 47 38 } 48 - export function Person$Student(name, age) { 49 - return new Student(name, age); 50 - } 51 - export function Person$isStudent(value) { 52 - return value instanceof Student; 53 - } 54 - export function Person$Student$name(value) { 55 - return value.name; 56 - } 57 - export function Person$Student$age(value) { 58 - return value.age; 59 - } 39 + export const Person$Student = (name, age) => new Student(name, age); 40 + export const Person$isStudent = (value) => value instanceof Student; 41 + export const Person$Student$name = (value) => value.name; 42 + export const Person$Student$age = (value) => value.age; 60 43 61 44 62 - export function Person$age(value) { 63 - return value.age; 64 - } 65 - export function Person$name(value) { 66 - return value.name; 67 - } 45 + export const Person$age = (value) => value.age; 46 + export const Person$name = (value) => value.name; 68 47 69 48 export function get_name(person) { 70 49 return person.name;
+12 -33
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__records__record_accessor_multiple_variants_positions_other_than_first.snap
··· 22 22 this.title = title; 23 23 } 24 24 } 25 - export function Person$Teacher(name, age, title) { 26 - return new Teacher(name, age, title); 27 - } 28 - export function Person$isTeacher(value) { 29 - return value instanceof Teacher; 30 - } 31 - export function Person$Teacher$name(value) { 32 - return value.name; 33 - } 34 - export function Person$Teacher$age(value) { 35 - return value.age; 36 - } 37 - export function Person$Teacher$title(value) { 38 - return value.title; 39 - } 25 + export const Person$Teacher = (name, age, title) => 26 + new Teacher(name, age, title); 27 + export const Person$isTeacher = (value) => value instanceof Teacher; 28 + export const Person$Teacher$name = (value) => value.name; 29 + export const Person$Teacher$age = (value) => value.age; 30 + export const Person$Teacher$title = (value) => value.title; 40 31 41 32 export class Student extends $CustomType { 42 33 constructor(name, age) { ··· 45 36 this.age = age; 46 37 } 47 38 } 48 - export function Person$Student(name, age) { 49 - return new Student(name, age); 50 - } 51 - export function Person$isStudent(value) { 52 - return value instanceof Student; 53 - } 54 - export function Person$Student$name(value) { 55 - return value.name; 56 - } 57 - export function Person$Student$age(value) { 58 - return value.age; 59 - } 39 + export const Person$Student = (name, age) => new Student(name, age); 40 + export const Person$isStudent = (value) => value instanceof Student; 41 + export const Person$Student$name = (value) => value.name; 42 + export const Person$Student$age = (value) => value.age; 60 43 61 44 62 - export function Person$age(value) { 63 - return value.age; 64 - } 65 - export function Person$name(value) { 66 - return value.name; 67 - } 45 + export const Person$age = (value) => value.age; 46 + export const Person$name = (value) => value.name; 68 47 69 48 export function get_name(person) { 70 49 return person.name;
+9 -27
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__records__record_accessor_multiple_with_first_position_different_types.snap
··· 20 20 this.age = age; 21 21 } 22 22 } 23 - export function Person$Teacher(name, age) { 24 - return new Teacher(name, age); 25 - } 26 - export function Person$isTeacher(value) { 27 - return value instanceof Teacher; 28 - } 29 - export function Person$Teacher$name(value) { 30 - return value.name; 31 - } 32 - export function Person$Teacher$age(value) { 33 - return value.age; 34 - } 23 + export const Person$Teacher = (name, age) => new Teacher(name, age); 24 + export const Person$isTeacher = (value) => value instanceof Teacher; 25 + export const Person$Teacher$name = (value) => value.name; 26 + export const Person$Teacher$age = (value) => value.age; 35 27 36 28 export class Student extends $CustomType { 37 29 constructor(name, age) { ··· 40 32 this.age = age; 41 33 } 42 34 } 43 - export function Person$Student(name, age) { 44 - return new Student(name, age); 45 - } 46 - export function Person$isStudent(value) { 47 - return value instanceof Student; 48 - } 49 - export function Person$Student$name(value) { 50 - return value.name; 51 - } 52 - export function Person$Student$age(value) { 53 - return value.age; 54 - } 35 + export const Person$Student = (name, age) => new Student(name, age); 36 + export const Person$isStudent = (value) => value instanceof Student; 37 + export const Person$Student$name = (value) => value.name; 38 + export const Person$Student$age = (value) => value.age; 55 39 56 40 57 - export function Person$age(value) { 58 - return value.age; 59 - } 41 + export const Person$age = (value) => value.age; 60 42 61 43 export function get_age(person) { 62 44 return person.age;
+4 -12
compiler-core/src/javascript/tests/snapshots/gleam_core__javascript__tests__records__record_accessors.snap
··· 19 19 this.age = age; 20 20 } 21 21 } 22 - export function Person$Person(name, age) { 23 - return new Person(name, age); 24 - } 25 - export function Person$isPerson(value) { 26 - return value instanceof Person; 27 - } 28 - export function Person$Person$name(value) { 29 - return value.name; 30 - } 31 - export function Person$Person$age(value) { 32 - return value.age; 33 - } 22 + export const Person$Person = (name, age) => new Person(name, age); 23 + export const Person$isPerson = (value) => value instanceof Person; 24 + export const Person$Person$name = (value) => value.name; 25 + export const Person$Person$age = (value) => value.age; 34 26 35 27 export function get_age(person) { 36 28 return person.age;
+2 -6
test-package-compiler/src/snapshots/test_package_compiler__generated_tests__javascript_d_ts.snap
··· 35 35 import { CustomType as $CustomType } from "./gleam.mjs"; 36 36 37 37 export class Woo extends $CustomType {} 38 - export function Wibble$Woo() { 39 - return new Woo(); 40 - } 41 - export function Wibble$isWoo(value) { 42 - return value instanceof Woo; 43 - } 38 + export const Wibble$Woo = () => new Woo(); 39 + export const Wibble$isWoo = (value) => value instanceof Woo; 44 40 45 41 export function wobble() { 46 42 return new Woo();
+2 -6
test-package-compiler/src/snapshots/test_package_compiler__generated_tests__javascript_import.snap
··· 42 42 import { CustomType as $CustomType } from "../gleam.mjs"; 43 43 44 44 export class A extends $CustomType {} 45 - export function A$A() { 46 - return new A(); 47 - } 48 - export function A$isA(value) { 49 - return value instanceof A; 50 - } 45 + export const A$A = () => new A(); 46 + export const A$isA = (value) => value instanceof A; 51 47 52 48 53 49 //// /out/lib/the_package/two.d.mts