aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gleam/iterator.gleam13
-rw-r--r--src/gleam/map.gleam4
2 files changed, 10 insertions, 7 deletions
diff --git a/src/gleam/iterator.gleam b/src/gleam/iterator.gleam
index ff2e020..25cc441 100644
--- a/src/gleam/iterator.gleam
+++ b/src/gleam/iterator.gleam
@@ -1,6 +1,7 @@
if erlang {
import gleam/list
import gleam/map.{Map}
+ import gleam/option.{None, Option, Some}
// Internal private representation of an Iterator
type Action(element) {
@@ -712,7 +713,7 @@ if erlang {
type SizedChunk(element) {
Another(List(element), fn() -> Action(element))
Last(List(element))
- None
+ NoMore
}
fn next_sized_chunk(
@@ -723,7 +724,7 @@ if erlang {
case continuation() {
Stop ->
case current_chunk {
- [] -> None
+ [] -> NoMore
remaining -> Last(list.reverse(remaining))
}
Continue(e, next) -> {
@@ -742,7 +743,7 @@ if erlang {
) -> fn() -> Action(List(element)) {
fn() {
case next_sized_chunk(continuation, count, []) {
- None -> Stop
+ NoMore -> Stop
Last(chunk) -> Continue(chunk, stop)
Another(chunk, next_element) ->
Continue(chunk, do_sized_chunk(next_element, count))
@@ -888,11 +889,11 @@ if erlang {
fn update_group_with(
el: element,
- ) -> fn(Result(List(element), Nil)) -> List(element) {
+ ) -> fn(Option(List(element))) -> List(element) {
fn(maybe_group) {
case maybe_group {
- Ok(group) -> [el, ..group]
- Error(Nil) -> [el]
+ Some(group) -> [el, ..group]
+ None -> [el]
}
}
}
diff --git a/src/gleam/map.gleam b/src/gleam/map.gleam
index ff8281d..7fd363f 100644
--- a/src/gleam/map.gleam
+++ b/src/gleam/map.gleam
@@ -1,5 +1,6 @@
if erlang {
import gleam/result
+ import gleam/option.{Option}
import gleam/list
/// A dictionary of keys and values.
@@ -279,10 +280,11 @@ if erlang {
pub fn update(
in map: Map(k, v),
update key: k,
- with fun: fn(Result(v, Nil)) -> v,
+ with fun: fn(Option(v)) -> v,
) -> Map(k, v) {
map
|> get(key)
+ |> option.from_result
|> fun
|> insert(map, key, _)
}