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