|
1 | 1 | # Changelog
|
2 | 2 |
|
3 |
| -## Unreleased |
| 3 | +## v1.9.0-rc1 - 2025-03-04 |
4 | 4 |
|
5 | 5 | ### Compiler
|
6 | 6 |
|
| 7 | +- You can now use the `echo` keyword to debug print any value: `echo` can be |
| 8 | + followed by any expression and it will print it to stderr alongside the module |
| 9 | + it comes from and its line number. This: |
| 10 | + |
| 11 | + ```gleam |
| 12 | + pub fn main() { |
| 13 | + echo [1, 2, 3] |
| 14 | + } |
| 15 | + ``` |
| 16 | + |
| 17 | + Will output to stderr: |
| 18 | + |
| 19 | + ```txt |
| 20 | + /src/module.gleam:2 |
| 21 | + [1, 2, 3] |
| 22 | + ``` |
| 23 | + |
| 24 | + `echo` can also be used in the middle of a pipeline. This: |
| 25 | + |
| 26 | + ```gleam |
| 27 | + pub fn main() { |
| 28 | + [1, 2, 3] |
| 29 | + |> echo |
| 30 | + |> list.map(fn(x) { x * 2 }) |
| 31 | + |> echo |
| 32 | + } |
| 33 | + ``` |
| 34 | + |
| 35 | + Will output to stderr: |
| 36 | + |
| 37 | + ```txt |
| 38 | + /src/module.gleam:3 |
| 39 | + [1, 2, 3] |
| 40 | + /src/module.gleam:5 |
| 41 | + [2, 4, 6] |
| 42 | + ``` |
| 43 | + |
| 44 | + ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) |
| 45 | + |
7 | 46 | - Generated Erlang `.app` files now include external modules written in Elixir
|
8 | 47 | and Erlang.
|
9 | 48 | ([LostKobrakai](https://github.com/lostkobrakai))
|
|
13 | 52 | making Gleam packages discoverable through global search of HexDocs.
|
14 | 53 | ([Diemo Gebhardt](https://github.com/diemogebhardt))
|
15 | 54 |
|
| 55 | +- Improved the styling of constructor argument descriptions in the generated |
| 56 | + documentation. |
| 57 | + ([Nicd](https://git.ahlcode.fi/nicd)) |
| 58 | + |
16 | 59 | - Allow users to set the `GLEAM_CACERTS_PATH` environment variable to specify a
|
17 | 60 | path to a directory containing CA certificates to install Hex packages.
|
18 | 61 | ([winstxnhdw](https://github.com/winstxnhdw))
|
19 | 62 |
|
| 63 | +- On the JavaScript target, bit array expressions and patterns no longer need to |
| 64 | + be byte aligned, and the `bits` segment type is now supported in patterns. |
| 65 | + ([Richard Viney](https://github.com/richard-viney)) |
| 66 | + |
| 67 | +- The code generated for list pattern matching on the JavaScript target is now |
| 68 | + more efficient. Gleam code that relies heavily on list pattern matching can |
| 69 | + now be up to twice as fast. |
| 70 | + ([yoshi~](https://github.com/yoshi-monster)) |
| 71 | + |
| 72 | +- On the JavaScript target, bit array patterns can now match segments of dynamic |
| 73 | + size. |
| 74 | + ([Surya Rose](https://github.com/GearsDatapacks)) |
| 75 | + |
| 76 | +### Build tool |
| 77 | + |
| 78 | +- The build tool now supports Git dependencies. For example: |
| 79 | + |
| 80 | + ``` |
| 81 | + [dependencies] |
| 82 | + gleam_stdlib = { git = "https://github.com/gleam-lang/stdlib.git", ref = "957b83b" } |
| 83 | + ``` |
| 84 | + |
| 85 | + ([Surya Rose](https://github.com/GearsDatapacks)) |
| 86 | + |
| 87 | +- The build tool now refuses to publish any incomplete package that has any |
| 88 | + `echo` debug printing left. |
| 89 | + ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) |
| 90 | + |
20 | 91 | ### Language server
|
21 | 92 |
|
| 93 | +- The language server now has the ability to jump to the type definition of any |
| 94 | + hovered value. |
| 95 | + ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) |
| 96 | + |
22 | 97 | - The language server now offers a code action to convert the first step of a
|
23 | 98 | pipeline to a regular function call. For example, this code:
|
24 | 99 |
|
|
42 | 117 |
|
43 | 118 | ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
|
44 | 119 |
|
45 |
| -- The Language Server now suggests a code action to generate a function to |
| 120 | +- The language server now offers a code action to convert a function call into |
| 121 | + a pipeline. For example, this code: |
| 122 | + |
| 123 | + ```gleam |
| 124 | + import gleam/list |
| 125 | +
|
| 126 | + pub fn main() { |
| 127 | + list.map([1, 2, 3], fn(n) { n * 2 }) |
| 128 | + } |
| 129 | + ``` |
| 130 | + |
| 131 | + Will be rewritten as: |
| 132 | + |
| 133 | + ```gleam |
| 134 | + import gleam/list |
| 135 | +
|
| 136 | + pub fn main() { |
| 137 | + [1, 2, 3] |> list.map(fn(n) { n * 2 }) |
| 138 | + } |
| 139 | + ``` |
| 140 | + |
| 141 | + You can also pick which argument is going to be piped. In this case: |
| 142 | + |
| 143 | + ```gleam |
| 144 | + import gleam/list |
| 145 | +
|
| 146 | + pub fn main() { |
| 147 | + list.map([1, 2, 3], fn(n) { n * 2 }) |
| 148 | + // ^ If you put your cursor over here |
| 149 | + } |
| 150 | + ``` |
| 151 | + |
| 152 | + The code will be rewritten as: |
| 153 | + |
| 154 | + ```gleam |
| 155 | + import gleam/list |
| 156 | +
|
| 157 | + pub fn main() { |
| 158 | + fn(n) { n * 2 } |> list.map([1, 2, 3], _) |
| 159 | + } |
| 160 | + ``` |
| 161 | + |
| 162 | + ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) |
| 163 | + |
| 164 | +- The language server now suggests a code action to generate a function to |
46 | 165 | encode a custom type as JSON using the `gleam_json` package. For example:
|
47 | 166 |
|
48 | 167 | ```gleam
|
|
70 | 189 |
|
71 | 190 | ([Surya Rose](https://github.com/GearsDatapacks))
|
72 | 191 |
|
| 192 | +- The language server now suggests a code action to inline a variable |
| 193 | + which is only used once. For example, this code: |
| 194 | + |
| 195 | + ```gleam |
| 196 | + import gleam/io |
| 197 | +
|
| 198 | + pub fn main() { |
| 199 | + let greeting = "Hello!" |
| 200 | + io.println(greeting) |
| 201 | + } |
| 202 | + ``` |
| 203 | + |
| 204 | + Will be rewritten as: |
| 205 | + |
| 206 | + ```gleam |
| 207 | + import gleam/io |
| 208 | +
|
| 209 | + pub fn main() { |
| 210 | + io.println("Hello!") |
| 211 | + } |
| 212 | + ``` |
| 213 | + |
| 214 | + ([Surya Rose](https://github.com/GearsDatapacks)) |
| 215 | + |
| 216 | +- The code action to generate a dynamic decoder for a custom type can now |
| 217 | + generate decoders for types with multiple variants. For example this code: |
| 218 | + |
| 219 | + ```gleam |
| 220 | + pub type Person { |
| 221 | + Adult(age: Int, job: String) |
| 222 | + Child(age: Int, height: Float) |
| 223 | + } |
| 224 | + ``` |
| 225 | + |
| 226 | + Becomes: |
| 227 | + |
| 228 | + ```gleam |
| 229 | + import gleam/dynamic/decode |
| 230 | +
|
| 231 | + pub type Person { |
| 232 | + Adult(age: Int, job: String) |
| 233 | + Child(age: Int, height: Float) |
| 234 | + } |
| 235 | +
|
| 236 | + fn person_decoder() -> decode.Decoder(Person) { |
| 237 | + use variant <- decode.field("type", decode.string) |
| 238 | + case variant { |
| 239 | + "adult" -> { |
| 240 | + use age <- decode.field("age", decode.int) |
| 241 | + use job <- decode.field("job", decode.string) |
| 242 | + decode.success(Adult(age:, job:)) |
| 243 | + } |
| 244 | + "child" -> { |
| 245 | + use age <- decode.field("age", decode.int) |
| 246 | + use height <- decode.field("height", decode.float) |
| 247 | + decode.success(Child(age:, height:)) |
| 248 | + } |
| 249 | + _ -> decode.failure(todo as "Zero value for Person", "Person") |
| 250 | + } |
| 251 | + } |
| 252 | + ``` |
| 253 | + |
| 254 | + ([Surya Rose](https://github.com/GearsDatapacks)) |
| 255 | + |
| 256 | +- The language server now suggests a code action to easily interpolate a value |
| 257 | + into a string. If the cursor is inside a literal string the language server |
| 258 | + will offer to split it: |
| 259 | + |
| 260 | + ```gleam |
| 261 | + "wibble | wobble" |
| 262 | + // ^ Triggering the action with the cursor |
| 263 | + // here will produce this: |
| 264 | + "wibble " <> todo <> " wobble" |
| 265 | + ``` |
| 266 | + |
| 267 | + And if the cursor is selecting a valid gleam name, the language server will |
| 268 | + offer to interpolate it as a variable: |
| 269 | + |
| 270 | + ```gleam |
| 271 | + "wibble wobble woo" |
| 272 | + // ^^^^^^ Triggering the code action if you're |
| 273 | + // selecting an entire name, will produce this: |
| 274 | + "wibble " <> wobble <> " woo" |
| 275 | + ``` |
| 276 | + |
| 277 | + ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) |
| 278 | + |
| 279 | +- The language server now shows module documentation when hovering over a module |
| 280 | + name. |
| 281 | + ([Surya Rose](https://github.com/GearsDatapacks)) |
| 282 | + |
73 | 283 | ### Formatter
|
74 | 284 |
|
| 285 | +- Redundant function captures that take no additional arguments are now |
| 286 | + rewritten to not use the function capture syntax. |
| 287 | + |
| 288 | + ```gleam |
| 289 | + some_module.some_function(_) |
| 290 | + ``` |
| 291 | + |
| 292 | + This code is reformatted like so: |
| 293 | + |
| 294 | + ```gleam |
| 295 | + some_module.some_function |
| 296 | + ``` |
| 297 | + |
| 298 | + ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) |
| 299 | + |
75 | 300 | ### Bug fixes
|
76 | 301 |
|
| 302 | +- Fixed a bug where division and remainder operators would not work correctly |
| 303 | + in guards on the JavaScript target. |
| 304 | + ([Surya Rose](https://github.com/GearsDatapacks)) |
| 305 | + |
| 306 | +- Fixed a bug where the "Generate function" code action would ignore the |
| 307 | + provided labels. |
| 308 | + ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) |
| 309 | + |
| 310 | +- Fixed a bug where the "Pattern match on argument" and |
| 311 | + "Pattern match on variable" code actions would not allow to pattern match on a |
| 312 | + private type used in the same module it's defined in. |
| 313 | + ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) |
| 314 | + |
| 315 | +- Fixed a bug where `gleam export package-interface` would not properly generate |
| 316 | + the package interface file if some modules were cached. |
| 317 | + ([Pedro Francisco](https://github.com/mine-tech-oficial)) and |
| 318 | + ([Surya Rose](https://github.com/GearsDatapacks)) |
| 319 | + |
| 320 | +- Fixed a bug where pattern matching using a UTF-8 string constant would not |
| 321 | + work correctly on the JavaScript target when the string contained escape |
| 322 | + characters. |
| 323 | + ([Richard Viney](https://github.com/richard-viney)) |
| 324 | + |
| 325 | +- Fixed a bug where `gleam publish` wouldn't include gitignored or nested native |
| 326 | + files. |
| 327 | + ([PgBiel](https://github.com/PgBiel)) |
| 328 | + |
77 | 329 | ## v1.8.1 - 2025-02-11
|
78 | 330 |
|
79 | 331 | ### Bug fixes
|
|
0 commit comments