aboutsummaryrefslogtreecommitdiff
path: root/src/Maybe.gleam
diff options
context:
space:
mode:
authorLouis Pilfold <louis@lpil.uk>2018-08-09 16:43:35 +0100
committerLouis Pilfold <louis@lpil.uk>2018-08-09 16:46:41 +0100
commit012273c4186317171f3405cc794ff9b3085c0e39 (patch)
tree838960bc358f3ba8fdb12c0f2a9bf493694e5017 /src/Maybe.gleam
parent817d9006dd4aaa1793fee68089ef53f9e188af3f (diff)
downloadgleam_stdlib-012273c4186317171f3405cc794ff9b3085c0e39.tar.gz
gleam_stdlib-012273c4186317171f3405cc794ff9b3085c0e39.zip
Unify function and closure syntax
I feel the `|x| x` syntax is less obvious than the `fn name(x) { x }` syntax used by top level named functions. Using the same syntax everywhere should be clearer.
Diffstat (limited to 'src/Maybe.gleam')
-rw-r--r--src/Maybe.gleam13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/Maybe.gleam b/src/Maybe.gleam
index c89f0e0..8ae6e7c 100644
--- a/src/Maybe.gleam
+++ b/src/Maybe.gleam
@@ -40,8 +40,8 @@ fn map(maybe, fun) {
}
test map() {
- map(Just(1), |x| x + 1) |> Assert.equal(_, Just(2))
- map(Nothing, |x| x + 1) |> Assert.equal(Nothing)
+ map(Just(1), fn(x) { x + 1 }) |> Assert.equal(_, Just(2))
+ map(Nothing, fn(x) { x + 1 }) |> Assert.equal(Nothing)
}
fn flatten(maybe) {
@@ -62,9 +62,12 @@ fn flat_map(maybe, fun) {
}
test flat_map() {
- flat_map(Nothing, |x| Just(x + 1)) |> Assert.equal(Nothing)
- flat_map(Just(1), |x| Just(x + 1)) |> Assert.equal(Just(2))
- flat_map(Just(1), |_| Nothing) |> Assert.equal(Nothing)
+ flat_map(Nothing, fn(x) { Just(x + 1) })
+ |> Assert.equal(_, Nothing)
+ flat_map(Just(1), fn(x) { Just(x + 1) })
+ |> Assert.equal(_, Just(2))
+ flat_map(Just(1), fn(_) { Nothing })
+ |> Assert.equal(_, Nothing)
}
fn unwrap(maybe, fallback) {