···11# Changelog
2233-## v1.9.0-rc2 - 2025-03-07
44-55-### Compiler
66-77-- Made runtime warnings regarding the use of deprecated BitArray properties in
88- JavaScript FFI code more compact. They are now one line instead of three.
99- ([Richard Viney](https://github.com/richard-viney))
1010-1111-### Bug fixes
1212-1313-- Fixed a bug that would result in displaying the wrong name when running
1414- `gleam --version`.
1515- ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
1616-1717-- Fixed a bug in the `generate json encoder` and `generate dynamic decoder` that
1818- would result in generating invalid code for variants with no fields.
1919- ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
2020-2121-## v1.9.0-rc1 - 2025-03-04
33+## Unreleased
224235### Compiler
2462525-- You can now use the `echo` keyword to debug print any value: `echo` can be
2626- followed by any expression and it will print it to stderr alongside the module
2727- it comes from and its line number. This:
2828-2929- ```gleam
3030- pub fn main() {
3131- echo [1, 2, 3]
3232- }
3333- ```
3434-3535- Will output to stderr:
3636-3737- ```txt
3838- /src/module.gleam:2
3939- [1, 2, 3]
4040- ```
4141-4242- `echo` can also be used in the middle of a pipeline. This:
4343-4444- ```gleam
4545- pub fn main() {
4646- [1, 2, 3]
4747- |> echo
4848- |> list.map(fn(x) { x * 2 })
4949- |> echo
5050- }
5151- ```
5252-5353- Will output to stderr:
5454-5555- ```txt
5656- /src/module.gleam:3
5757- [1, 2, 3]
5858- /src/module.gleam:5
5959- [2, 4, 6]
6060- ```
6161-6262- ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
6363-6464-- Generated Erlang `.app` files now include external modules written in Elixir
6565- and Erlang.
6666- ([LostKobrakai](https://github.com/lostkobrakai))
6767-6868-- On the JavaScript target, bit array expressions and patterns no longer need to
6969- be byte aligned, and the `bits` segment type is now supported in patterns.
7070- ([Richard Viney](https://github.com/richard-viney))
7171-7272-- The code generated for list pattern matching on the JavaScript target is now
7373- more efficient. Gleam code that relies heavily on list pattern matching can
7474- now be up to twice as fast.
7575- ([yoshi~](https://github.com/yoshi-monster))
7676-7777-- On the JavaScript target, bit array patterns can now match segments of dynamic
7878- size.
7979- ([Surya Rose](https://github.com/GearsDatapacks))
8080-817### Build tool
8288383-- The build tool now supports Git dependencies. For example:
8484-8585- ```
8686- [dependencies]
8787- gleam_stdlib = { git = "https://github.com/gleam-lang/stdlib.git", ref = "957b83b" }
8888- ```
8989-9090- ([Surya Rose](https://github.com/GearsDatapacks))
9191-9292-- The build tool now refuses to publish any incomplete package that has any
9393- `echo` debug printing left.
9494- ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
9595-9696-- HexDocs documentation of Gleam packages now uses the ExDocs search data model,
9797- allowing for global indexing of Gleam packages in HexDocs, and
9898- making Gleam packages discoverable through global search of HexDocs.
9999- ([Diemo Gebhardt](https://github.com/diemogebhardt))
100100-101101-- Improved the styling of constructor argument descriptions in the generated
102102- documentation.
103103- ([Mikko Ahlroth](https://git.ahlcode.fi/nicd))
104104-105105-- Allow users to set the `GLEAM_CACERTS_PATH` environment variable to specify a
106106- path to a directory containing CA certificates to install Hex packages.
107107- ([winstxnhdw](https://github.com/winstxnhdw))
108108-1099### Language server
11010111111-- The language server now has the ability to jump to the type definition of any
112112- hovered value.
113113- ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
114114-115115-- The language server now offers a code action to convert the first step of a
116116- pipeline to a regular function call. For example, this code:
117117-118118- ```gleam
119119- import gleam/list
120120-121121- pub fn main() {
122122- [1, 2, 3] |> list.map(fn(n) { n * 2 })
123123- }
124124- ```
125125-126126- Will be rewritten as:
127127-128128- ```gleam
129129- import gleam/list
130130-131131- pub fn main() {
132132- list.map([1, 2, 3], fn(n) { n * 2 })
133133- }
134134- ```
135135-136136- ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
137137-138138-- The language server now offers a code action to convert a function call into
139139- a pipeline. For example, this code:
140140-141141- ```gleam
142142- import gleam/list
143143-144144- pub fn main() {
145145- list.map([1, 2, 3], fn(n) { n * 2 })
146146- }
147147- ```
148148-149149- Will be rewritten as:
150150-151151- ```gleam
152152- import gleam/list
153153-154154- pub fn main() {
155155- [1, 2, 3] |> list.map(fn(n) { n * 2 })
156156- }
157157- ```
158158-159159- You can also pick which argument is going to be piped. In this case:
160160-161161- ```gleam
162162- import gleam/list
163163-164164- pub fn main() {
165165- list.map([1, 2, 3], fn(n) { n * 2 })
166166- // ^ If you put your cursor over here
167167- }
168168- ```
169169-170170- The code will be rewritten as:
171171-172172- ```gleam
173173- import gleam/list
174174-175175- pub fn main() {
176176- fn(n) { n * 2 } |> list.map([1, 2, 3], _)
177177- }
178178- ```
179179-180180- ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
181181-182182-- The language server now suggests a code action to generate a function to
183183- encode a custom type as JSON using the `gleam_json` package. For example:
184184-185185- ```gleam
186186- pub type Person {
187187- Person(name: String, age: Int)
188188- }
189189- ```
190190-191191- Will become:
192192-193193- ```gleam
194194- import gleam/json
195195-196196- pub type Person {
197197- Person(name: String, age: Int)
198198- }
199199-200200- fn encode_person(person: Person) -> json.Json {
201201- json.object([
202202- #("name", json.string(person.name)),
203203- #("age", json.int(person.age)),
204204- ])
205205- }
206206- ```
207207-208208- ([Surya Rose](https://github.com/GearsDatapacks))
209209-210210-- The language server now suggests a code action to inline a variable
211211- which is only used once. For example, this code:
212212-213213- ```gleam
214214- import gleam/io
215215-216216- pub fn main() {
217217- let greeting = "Hello!"
218218- io.println(greeting)
219219- }
220220- ```
221221-222222- Will be rewritten as:
223223-224224- ```gleam
225225- import gleam/io
226226-227227- pub fn main() {
228228- io.println("Hello!")
229229- }
230230- ```
231231-232232- ([Surya Rose](https://github.com/GearsDatapacks))
233233-234234-- The code action to generate a dynamic decoder for a custom type can now
235235- generate decoders for types with multiple variants. For example this code:
236236-237237- ```gleam
238238- pub type Person {
239239- Adult(age: Int, job: String)
240240- Child(age: Int, height: Float)
241241- }
242242- ```
243243-244244- Becomes:
245245-246246- ```gleam
247247- import gleam/dynamic/decode
248248-249249- pub type Person {
250250- Adult(age: Int, job: String)
251251- Child(age: Int, height: Float)
252252- }
253253-254254- fn person_decoder() -> decode.Decoder(Person) {
255255- use variant <- decode.field("type", decode.string)
256256- case variant {
257257- "adult" -> {
258258- use age <- decode.field("age", decode.int)
259259- use job <- decode.field("job", decode.string)
260260- decode.success(Adult(age:, job:))
261261- }
262262- "child" -> {
263263- use age <- decode.field("age", decode.int)
264264- use height <- decode.field("height", decode.float)
265265- decode.success(Child(age:, height:))
266266- }
267267- _ -> decode.failure(todo as "Zero value for Person", "Person")
268268- }
269269- }
270270- ```
271271-272272- ([Surya Rose](https://github.com/GearsDatapacks))
273273-274274-- The language server now suggests a code action to easily interpolate a value
275275- into a string. If the cursor is inside a literal string the language server
276276- will offer to split it:
277277-278278- ```gleam
279279- "wibble | wobble"
280280- // ^ Triggering the action with the cursor
281281- // here will produce this:
282282- "wibble " <> todo <> " wobble"
283283- ```
284284-285285- And if the cursor is selecting a valid Gleam name, the language server will
286286- offer to interpolate it as a variable:
287287-288288- ```gleam
289289- "wibble wobble woo"
290290- // ^^^^^^ Triggering the code action if you're
291291- // selecting an entire name, will produce this:
292292- "wibble " <> wobble <> " woo"
293293- ```
294294-295295- ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
296296-297297-- The language server now shows module documentation when hovering over a module
298298- name.
299299- ([Surya Rose](https://github.com/GearsDatapacks))
300300-30111### Formatter
30212303303-- Redundant function captures that take no additional arguments are now
304304- rewritten to not use the function capture syntax.
305305-306306- ```gleam
307307- some_module.some_function(_)
308308- ```
309309-310310- This code is reformatted like so:
311311-312312- ```gleam
313313- some_module.some_function
314314- ```
315315-316316- ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
317317-31813### Bug fixes
319319-320320-- Fixed a bug where division and remainder operators would not work correctly
321321- in guards on the JavaScript target.
322322- ([Surya Rose](https://github.com/GearsDatapacks))
323323-324324-- Fixed a bug where the "Generate function" code action would ignore the
325325- provided labels.
326326- ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
327327-328328-- Fixed a bug where the "Pattern match on argument" and
329329- "Pattern match on variable" code actions would not allow to pattern match on a
330330- private type used in the same module it's defined in.
331331- ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
332332-333333-- Fixed a bug where `gleam export package-interface` would not properly generate
334334- the package interface file if some modules were cached.
335335- ([Pedro Francisco](https://github.com/mine-tech-oficial)) and
336336- ([Surya Rose](https://github.com/GearsDatapacks))
337337-338338-- Fixed a bug where pattern matching using a UTF-8 string constant would not
339339- work correctly on the JavaScript target when the string contained escape
340340- characters.
341341- ([Richard Viney](https://github.com/richard-viney))
342342-343343-- Fixed a bug where `gleam publish` wouldn't include gitignored or nested native
344344- files.
345345- ([PgBiel](https://github.com/PgBiel))
346346-347347-## v1.8.1 - 2025-02-11
348348-349349-### Bug fixes
350350-351351-- Fixed a metadata caching bug where accessors for opaque types could sometimes
352352- be used in other modules.
353353- ([Louis Pilfold](https://github.com/lpil))
···11+# Changelog
22+33+## v1.9.0 - 2025-03-09
44+55+## v1.9.0-rc2 - 2025-03-07
66+77+### Compiler
88+99+- Made runtime warnings regarding the use of deprecated BitArray properties in
1010+ JavaScript FFI code more compact. They are now one line instead of three.
1111+ ([Richard Viney](https://github.com/richard-viney))
1212+1313+### Bug fixes
1414+1515+- Fixed a bug that would result in displaying the wrong name when running
1616+ `gleam --version`.
1717+ ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
1818+1919+- Fixed a bug in the `generate json encoder` and `generate dynamic decoder` that
2020+ would result in generating invalid code for variants with no fields.
2121+ ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
2222+2323+## v1.9.0-rc1 - 2025-03-04
2424+2525+### Compiler
2626+2727+- You can now use the `echo` keyword to debug print any value: `echo` can be
2828+ followed by any expression and it will print it to stderr alongside the module
2929+ it comes from and its line number. This:
3030+3131+ ```gleam
3232+ pub fn main() {
3333+ echo [1, 2, 3]
3434+ }
3535+ ```
3636+3737+ Will output to stderr:
3838+3939+ ```txt
4040+ /src/module.gleam:2
4141+ [1, 2, 3]
4242+ ```
4343+4444+ `echo` can also be used in the middle of a pipeline. This:
4545+4646+ ```gleam
4747+ pub fn main() {
4848+ [1, 2, 3]
4949+ |> echo
5050+ |> list.map(fn(x) { x * 2 })
5151+ |> echo
5252+ }
5353+ ```
5454+5555+ Will output to stderr:
5656+5757+ ```txt
5858+ /src/module.gleam:3
5959+ [1, 2, 3]
6060+ /src/module.gleam:5
6161+ [2, 4, 6]
6262+ ```
6363+6464+ ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
6565+6666+- Generated Erlang `.app` files now include external modules written in Elixir
6767+ and Erlang.
6868+ ([LostKobrakai](https://github.com/lostkobrakai))
6969+7070+- On the JavaScript target, bit array expressions and patterns no longer need to
7171+ be byte aligned, and the `bits` segment type is now supported in patterns.
7272+ ([Richard Viney](https://github.com/richard-viney))
7373+7474+- The code generated for list pattern matching on the JavaScript target is now
7575+ more efficient. Gleam code that relies heavily on list pattern matching can
7676+ now be up to twice as fast.
7777+ ([yoshi~](https://github.com/yoshi-monster))
7878+7979+- On the JavaScript target, bit array patterns can now match segments of dynamic
8080+ size.
8181+ ([Surya Rose](https://github.com/GearsDatapacks))
8282+8383+### Build tool
8484+8585+- The build tool now supports Git dependencies. For example:
8686+8787+ ```
8888+ [dependencies]
8989+ gleam_stdlib = { git = "https://github.com/gleam-lang/stdlib.git", ref = "957b83b" }
9090+ ```
9191+9292+ ([Surya Rose](https://github.com/GearsDatapacks))
9393+9494+- The build tool now refuses to publish any incomplete package that has any
9595+ `echo` debug printing left.
9696+ ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
9797+9898+- HexDocs documentation of Gleam packages now uses the ExDocs search data model,
9999+ allowing for global indexing of Gleam packages in HexDocs, and
100100+ making Gleam packages discoverable through global search of HexDocs.
101101+ ([Diemo Gebhardt](https://github.com/diemogebhardt))
102102+103103+- Improved the styling of constructor argument descriptions in the generated
104104+ documentation.
105105+ ([Mikko Ahlroth](https://git.ahlcode.fi/nicd))
106106+107107+- Allow users to set the `GLEAM_CACERTS_PATH` environment variable to specify a
108108+ path to a directory containing CA certificates to install Hex packages.
109109+ ([winstxnhdw](https://github.com/winstxnhdw))
110110+111111+### Language server
112112+113113+- The language server now has the ability to jump to the type definition of any
114114+ hovered value.
115115+ ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
116116+117117+- The language server now offers a code action to convert the first step of a
118118+ pipeline to a regular function call. For example, this code:
119119+120120+ ```gleam
121121+ import gleam/list
122122+123123+ pub fn main() {
124124+ [1, 2, 3] |> list.map(fn(n) { n * 2 })
125125+ }
126126+ ```
127127+128128+ Will be rewritten as:
129129+130130+ ```gleam
131131+ import gleam/list
132132+133133+ pub fn main() {
134134+ list.map([1, 2, 3], fn(n) { n * 2 })
135135+ }
136136+ ```
137137+138138+ ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
139139+140140+- The language server now offers a code action to convert a function call into
141141+ a pipeline. For example, this code:
142142+143143+ ```gleam
144144+ import gleam/list
145145+146146+ pub fn main() {
147147+ list.map([1, 2, 3], fn(n) { n * 2 })
148148+ }
149149+ ```
150150+151151+ Will be rewritten as:
152152+153153+ ```gleam
154154+ import gleam/list
155155+156156+ pub fn main() {
157157+ [1, 2, 3] |> list.map(fn(n) { n * 2 })
158158+ }
159159+ ```
160160+161161+ You can also pick which argument is going to be piped. In this case:
162162+163163+ ```gleam
164164+ import gleam/list
165165+166166+ pub fn main() {
167167+ list.map([1, 2, 3], fn(n) { n * 2 })
168168+ // ^ If you put your cursor over here
169169+ }
170170+ ```
171171+172172+ The code will be rewritten as:
173173+174174+ ```gleam
175175+ import gleam/list
176176+177177+ pub fn main() {
178178+ fn(n) { n * 2 } |> list.map([1, 2, 3], _)
179179+ }
180180+ ```
181181+182182+ ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
183183+184184+- The language server now suggests a code action to generate a function to
185185+ encode a custom type as JSON using the `gleam_json` package. For example:
186186+187187+ ```gleam
188188+ pub type Person {
189189+ Person(name: String, age: Int)
190190+ }
191191+ ```
192192+193193+ Will become:
194194+195195+ ```gleam
196196+ import gleam/json
197197+198198+ pub type Person {
199199+ Person(name: String, age: Int)
200200+ }
201201+202202+ fn encode_person(person: Person) -> json.Json {
203203+ json.object([
204204+ #("name", json.string(person.name)),
205205+ #("age", json.int(person.age)),
206206+ ])
207207+ }
208208+ ```
209209+210210+ ([Surya Rose](https://github.com/GearsDatapacks))
211211+212212+- The language server now suggests a code action to inline a variable
213213+ which is only used once. For example, this code:
214214+215215+ ```gleam
216216+ import gleam/io
217217+218218+ pub fn main() {
219219+ let greeting = "Hello!"
220220+ io.println(greeting)
221221+ }
222222+ ```
223223+224224+ Will be rewritten as:
225225+226226+ ```gleam
227227+ import gleam/io
228228+229229+ pub fn main() {
230230+ io.println("Hello!")
231231+ }
232232+ ```
233233+234234+ ([Surya Rose](https://github.com/GearsDatapacks))
235235+236236+- The code action to generate a dynamic decoder for a custom type can now
237237+ generate decoders for types with multiple variants. For example this code:
238238+239239+ ```gleam
240240+ pub type Person {
241241+ Adult(age: Int, job: String)
242242+ Child(age: Int, height: Float)
243243+ }
244244+ ```
245245+246246+ Becomes:
247247+248248+ ```gleam
249249+ import gleam/dynamic/decode
250250+251251+ pub type Person {
252252+ Adult(age: Int, job: String)
253253+ Child(age: Int, height: Float)
254254+ }
255255+256256+ fn person_decoder() -> decode.Decoder(Person) {
257257+ use variant <- decode.field("type", decode.string)
258258+ case variant {
259259+ "adult" -> {
260260+ use age <- decode.field("age", decode.int)
261261+ use job <- decode.field("job", decode.string)
262262+ decode.success(Adult(age:, job:))
263263+ }
264264+ "child" -> {
265265+ use age <- decode.field("age", decode.int)
266266+ use height <- decode.field("height", decode.float)
267267+ decode.success(Child(age:, height:))
268268+ }
269269+ _ -> decode.failure(todo as "Zero value for Person", "Person")
270270+ }
271271+ }
272272+ ```
273273+274274+ ([Surya Rose](https://github.com/GearsDatapacks))
275275+276276+- The language server now suggests a code action to easily interpolate a value
277277+ into a string. If the cursor is inside a literal string the language server
278278+ will offer to split it:
279279+280280+ ```gleam
281281+ "wibble | wobble"
282282+ // ^ Triggering the action with the cursor
283283+ // here will produce this:
284284+ "wibble " <> todo <> " wobble"
285285+ ```
286286+287287+ And if the cursor is selecting a valid Gleam name, the language server will
288288+ offer to interpolate it as a variable:
289289+290290+ ```gleam
291291+ "wibble wobble woo"
292292+ // ^^^^^^ Triggering the code action if you're
293293+ // selecting an entire name, will produce this:
294294+ "wibble " <> wobble <> " woo"
295295+ ```
296296+297297+ ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
298298+299299+- The language server now shows module documentation when hovering over a module
300300+ name.
301301+ ([Surya Rose](https://github.com/GearsDatapacks))
302302+303303+### Formatter
304304+305305+- Redundant function captures that take no additional arguments are now
306306+ rewritten to not use the function capture syntax.
307307+308308+ ```gleam
309309+ some_module.some_function(_)
310310+ ```
311311+312312+ This code is reformatted like so:
313313+314314+ ```gleam
315315+ some_module.some_function
316316+ ```
317317+318318+ ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
319319+320320+### Bug fixes
321321+322322+- Fixed a bug where division and remainder operators would not work correctly
323323+ in guards on the JavaScript target.
324324+ ([Surya Rose](https://github.com/GearsDatapacks))
325325+326326+- Fixed a bug where the "Generate function" code action would ignore the
327327+ provided labels.
328328+ ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
329329+330330+- Fixed a bug where the "Pattern match on argument" and
331331+ "Pattern match on variable" code actions would not allow to pattern match on a
332332+ private type used in the same module it's defined in.
333333+ ([Giacomo Cavalieri](https://github.com/giacomocavalieri))
334334+335335+- Fixed a bug where `gleam export package-interface` would not properly generate
336336+ the package interface file if some modules were cached.
337337+ ([Pedro Francisco](https://github.com/mine-tech-oficial)) and
338338+ ([Surya Rose](https://github.com/GearsDatapacks))
339339+340340+- Fixed a bug where pattern matching using a UTF-8 string constant would not
341341+ work correctly on the JavaScript target when the string contained escape
342342+ characters.
343343+ ([Richard Viney](https://github.com/richard-viney))
344344+345345+- Fixed a bug where `gleam publish` wouldn't include gitignored or nested native
346346+ files.
347347+ ([PgBiel](https://github.com/PgBiel))
348348+349349+## v1.8.1 - 2025-02-11
350350+351351+### Bug fixes
352352+353353+- Fixed a metadata caching bug where accessors for opaque types could sometimes
354354+ be used in other modules.
355355+ ([Louis Pilfold](https://github.com/lpil))