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

Configure Feed

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

gleam / docs / annoyances.md
1.7 kB 72 lines
1# Annoyances 2 3This document contains a list of issues and annoyances that we have writing 4Gleam code today, so that we can devise solutions to them in future. 5 6There are other annoyances that have known solutions that are yet to be 7implemented. These are tracked in the Gleam issue tracker instead. 8 9## Cannot infer what targets a package supports 10 11## Dynamic decoding boilerplate 12 13## JSON (de|en)coding boilerplate 14 15## Bundling compiled JavaScript is non-obvious 16 17## Cannot shift repeated work to compile or initialise time 18 19For example, regex compilation. 20 21## No good story for creating CLI programs 22 23The Erlang virtual machine is not typically installed on a user's computer, and 24bytecode compiled for it is not easy to distribute. 25 26JavaScript runtimes do better, but it is still not as good an experience as 27languages that compile to a single binary, and forcing Gleam programmers to use 28promises and a single thread is not ideal. 29 30## Runtime debugging is basic 31 32Rust's `dbg!` and Elixir's `dbg` were mentioned as good additions. 33 34## Last of if/else makes boolean logic less pretty and more alien 35 36With case: 37 38```gleam 39case str == "+" { 40 True -> Keep(Plus) 41 False -> 42 case all(str, is_ascii_letter) { 43 True -> Keep(Ident(str)) 44 False -> 45 case all(str, is_digit) { 46 True -> { 47 let assert Ok(int) = int.parse(str) 48 Keep(Number(int) 49 } 50 False -> Next 51 } 52} 53``` 54 55With use: 56 57```gleam 58use <- bool.guard( 59 when: str == "+", 60 return: Keep(Plus), 61) 62use <- bool.guard( 63 when: all(str, is_ascii_letter), 64 return: Keep(Ident(str), 65) 66use <- bool.guard( 67 when: !all(str, is_digit), 68 return: Next, 69) 70let assert Ok(int) = int.parse(str) 71Keep(Number(int)) 72```