Skip to content

Commit 9e8f74b

Browse files
committed
2.0
1 parent 5b9b659 commit 9e8f74b

File tree

5 files changed

+28
-19
lines changed

5 files changed

+28
-19
lines changed

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
55

66
<!-- ## [Unreleased] -->
77

8+
## [2.0.0] - 2025-03-07
9+
10+
- Breaking changes:
11+
- Replaced `return` naming with `yield` to avoid confusing the user.
12+
- Replaced `where` with `fact` to make it easier to read, more concise and
13+
visually consistent in function name length.
14+
815
## [1.0.1] - 2025-03-06
916

1017
- Docs fixes.

README.md

+11-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Gond 🔠 · `cond` for Gleam
1+
# Gond 🚡 — `cond`-like multi-branch conditionals for Gleam
22

33
[![Package <a href="https://github.com/inoas/gleam-gond/releases"><img src="https://img.shields.io/github/release/inoas/gleam-gond" alt="GitHub release"></a> Version](https://img.shields.io/hexpm/v/gond)](https://hex.pm/packages/gond)
44
[![Erlang-compatible](https://img.shields.io/badge/target-erlang-b83998)](https://www.erlang.org/)
@@ -12,7 +12,8 @@
1212

1313
<p align="center">
1414
<i>
15-
Think of a <a href="https://en.wikipedia.org/wiki/Gondola_lift">gondola lift</a> ride, where you can hop off at any station.
15+
Think of a <a href="https://en.wikipedia.org/wiki/Gondola_lift">gondola lift 🚠</a> ride,
16+
where you can hop off at any station.
1617
</i>
1718
</p>
1819

@@ -21,7 +22,7 @@
2122
## Installation
2223

2324
```sh
24-
gleam add gond@1
25+
gleam add gond@2
2526
```
2627

2728
## Examples
@@ -31,16 +32,16 @@ import gleam/int
3132
import gleam/io
3233
import gleam/string
3334
import gond.{
34-
cond as cond, return as return, run as run, when as when, where as where,
35+
cond as cond, fact as fact, run as run, when as when, yield as yield,
3536
}
3637
3738
pub fn example() {
3839
cond(
3940
branches: [
4041
when(fn() { int.random(3) == 1 }) |> run(fn() { "Heads!" }),
41-
where(int.random(3) == 2) |> run(fn() { "Tails!" }),
42-
when(fn() { True }) |> return("This always occurs!"),
43-
where(False) |> return("This is never the fact!"),
42+
fact(int.random(3) == 2) |> run(fn() { "Tails!" }),
43+
when(fn() { True }) |> yield("This always occurs!"),
44+
fact(False) |> yield("This is never the fact!"),
4445
],
4546
default: fn() { "Lost the coin?" },
4647
)
@@ -65,6 +66,7 @@ gleam run # Run the project
6566
gleam test # Run the tests
6667
```
6768

68-
## Inspiration
69+
## Inspirations
6970

70-
Elixir's [`cond` macro](https://hexdocs.pm/elixir/case-cond-and-if.html#cond).
71+
- Clojure's [`cond` macro](https://clojuredocs.org/clojure.core/cond).
72+
- Elixir's [`cond` macro](https://hexdocs.pm/elixir/case-cond-and-if.html#cond).

gleam.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "gond"
2-
version = "1.0.1"
3-
description = "🔠 cond like multi-branch conditional expressions for Gleam"
2+
version = "2.0.0"
3+
description = "🚡 cond-like multi-branch conditionals for Gleam 🚠"
44
licences = ["MPL-2.0"]
55
repository = { type = "github", user = "inoas", repo = "gleam-gond" }
66
# links = [{ title = "Website", href = "" }]

src/gond.gleam

+4-4
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,11 @@ pub fn when(given condition_fun: fn() -> Bool) -> Condition {
6565

6666
/// Creates a condition that holds a literal boolean value.
6767
///
68-
pub fn where(given condition: Bool) -> Condition {
68+
pub fn fact(given condition: Bool) -> Condition {
6969
EagerCondition(condition:)
7070
}
7171

72-
/// Sets a consequence to run if a previous condition evaludated to true.
72+
/// Consequence to run if a previous condition evaluates to true.
7373
///
7474
pub fn run(
7575
on condition: Condition,
@@ -78,9 +78,9 @@ pub fn run(
7878
Branch(condition:, consequence: LazyConsequence(consequence_fun))
7979
}
8080

81-
/// Sets a literal consequence to return if a previous condition evaludated to
81+
/// Literal consequence to yield if a previous condition evaluates to
8282
/// true.
8383
///
84-
pub fn return(on condition: Condition, consequence consequence: a) -> Branch(a) {
84+
pub fn yield(on condition: Condition, consequence consequence: a) -> Branch(a) {
8585
Branch(condition:, consequence: EagerConsequence(consequence))
8686
}

src/gond/internal/usage_examples.gleam

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@ import gleam/int
22
import gleam/io
33
import gleam/string
44
import gond.{
5-
cond as cond, return as return, run as run, when as when, where as where,
5+
cond as cond, fact as fact, run as run, when as when, yield as yield,
66
}
77

88
pub fn example() {
99
cond(
1010
branches: [
1111
when(fn() { int.random(3) == 1 }) |> run(fn() { "Heads!" }),
12-
where(int.random(3) == 2) |> run(fn() { "Tails!" }),
13-
when(fn() { True }) |> return("This always occurs!"),
14-
where(False) |> return("This is never the fact!"),
12+
fact(int.random(3) == 2) |> run(fn() { "Tails!" }),
13+
when(fn() { True }) |> yield("This always occurs!"),
14+
fact(False) |> yield("This is never the fact!"),
1515
],
1616
default: fn() { "Lost the coin?" },
1717
)

0 commit comments

Comments
 (0)