mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 13:59:08 +00:00
update internal references to Result.map
This commit is contained in:
parent
326558337c
commit
297dd0233e
6 changed files with 11 additions and 11 deletions
|
@ -32,7 +32,7 @@ cheapest_open = \cost_fn, model ->
|
||||||
)
|
)
|
||||||
|> Quicksort.sort_by(.cost)
|
|> Quicksort.sort_by(.cost)
|
||||||
|> List.first
|
|> List.first
|
||||||
|> Result.map(.position)
|
|> Result.map_ok(.position)
|
||||||
|> Result.map_err(\_ -> {})
|
|> Result.map_err(\_ -> {})
|
||||||
|
|
||||||
reconstruct_path : Dict position position, position -> List position where position implements Hash & Eq
|
reconstruct_path : Dict position position, position -> List position where position implements Hash & Eq
|
||||||
|
|
|
@ -12,7 +12,7 @@ main! = \{} ->
|
||||||
closure1 : {} -> Result {} []
|
closure1 : {} -> Result {} []
|
||||||
closure1 = \_ ->
|
closure1 = \_ ->
|
||||||
Ok(foo(to_unit_borrowed, "a long string such that it's malloced"))
|
Ok(foo(to_unit_borrowed, "a long string such that it's malloced"))
|
||||||
|> Result.map(\_ -> {})
|
|> Result.map_ok(\_ -> {})
|
||||||
|
|
||||||
to_unit_borrowed = \x -> Str.count_utf8_bytes(x)
|
to_unit_borrowed = \x -> Str.count_utf8_bytes(x)
|
||||||
|
|
||||||
|
@ -25,8 +25,8 @@ closure2 = \_ ->
|
||||||
x = "a long string such that it's malloced"
|
x = "a long string such that it's malloced"
|
||||||
|
|
||||||
Ok({})
|
Ok({})
|
||||||
|> Result.map(\_ -> x)
|
|> Result.map_ok(\_ -> x)
|
||||||
|> Result.map(to_unit)
|
|> Result.map_ok(to_unit)
|
||||||
|
|
||||||
to_unit = \_ -> {}
|
to_unit = \_ -> {}
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ closure3 = \_ ->
|
||||||
x = "a long string such that it's malloced"
|
x = "a long string such that it's malloced"
|
||||||
|
|
||||||
Ok({})
|
Ok({})
|
||||||
|> Result.try(\_ -> Ok(x) |> Result.map(\_ -> {}))
|
|> Result.try(\_ -> Ok(x) |> Result.map_ok(\_ -> {}))
|
||||||
|
|
||||||
# # ---
|
# # ---
|
||||||
closure4 : {} -> Result {} []
|
closure4 : {} -> Result {} []
|
||||||
|
@ -47,4 +47,4 @@ closure4 = \_ ->
|
||||||
|
|
||||||
Ok({})
|
Ok({})
|
||||||
|> Result.try(\_ -> Ok(x))
|
|> Result.try(\_ -> Ok(x))
|
||||||
|> Result.map(\_ -> {})
|
|> Result.map_ok(\_ -> {})
|
||||||
|
|
|
@ -54,8 +54,8 @@ with_default = \result, default ->
|
||||||
## function on it. Then returns a new `Ok` holding the transformed value. If the
|
## function on it. Then returns a new `Ok` holding the transformed value. If the
|
||||||
## result is `Err`, this has no effect. Use [map_err] to transform an `Err`.
|
## result is `Err`, this has no effect. Use [map_err] to transform an `Err`.
|
||||||
## ```roc
|
## ```roc
|
||||||
## Result.map(Ok(12), Num.neg)
|
## Result.map_ok(Ok(12), Num.neg)
|
||||||
## Result.map(Err("yipes!"), Num.neg)
|
## Result.map_ok(Err("yipes!"), Num.neg)
|
||||||
## ```
|
## ```
|
||||||
##
|
##
|
||||||
## Functions like `map` are common in Roc; see for example [List.map],
|
## Functions like `map` are common in Roc; see for example [List.map],
|
||||||
|
|
|
@ -37,7 +37,7 @@ cheapest_open = \cost_function, model ->
|
||||||
Ok(smallest_so_far)
|
Ok(smallest_so_far)
|
||||||
|
|
||||||
Set.walk(model.open_set, Err(KeyNotFound), folder)
|
Set.walk(model.open_set, Err(KeyNotFound), folder)
|
||||||
|> Result.map(\x -> x.position)
|
|> Result.map_ok(\x -> x.position)
|
||||||
|
|
||||||
reconstruct_path : Map position position, position -> List position
|
reconstruct_path : Map position position, position -> List position
|
||||||
reconstruct_path = \came_from, goal ->
|
reconstruct_path = \came_from, goal ->
|
||||||
|
|
|
@ -37,7 +37,7 @@ cheapest_open = \cost_function, model ->
|
||||||
Ok(smallest_so_far)
|
Ok(smallest_so_far)
|
||||||
|
|
||||||
Set.walk(model.open_set, Err(KeyNotFound), folder)
|
Set.walk(model.open_set, Err(KeyNotFound), folder)
|
||||||
|> Result.map(\x -> x.position)
|
|> Result.map_ok(\x -> x.position)
|
||||||
|
|
||||||
reconstruct_path : Dict position position, position -> List position where position implements Hash & Eq
|
reconstruct_path : Dict position position, position -> List position where position implements Hash & Eq
|
||||||
reconstruct_path = \came_from, goal ->
|
reconstruct_path = \came_from, goal ->
|
||||||
|
|
|
@ -37,7 +37,7 @@ decoder = @MDecoder \lst, fmt ->
|
||||||
#^^^^^^^{-1} MyU8#decoder(12): MDecoder MyU8 fmt where fmt implements MDecoderFormatting
|
#^^^^^^^{-1} MyU8#decoder(12): MDecoder MyU8 fmt where fmt implements MDecoderFormatting
|
||||||
when decode_with lst u8 fmt is
|
when decode_with lst u8 fmt is
|
||||||
{ result, rest } ->
|
{ result, rest } ->
|
||||||
{ result: Result.map result (\n -> @MyU8 n), rest }
|
{ result: Result.map_ok result (\n -> @MyU8 n), rest }
|
||||||
|
|
||||||
my_u8 : Result MyU8 _
|
my_u8 : Result MyU8 _
|
||||||
my_u8 = from_bytes [15] (@Linear {})
|
my_u8 = from_bytes [15] (@Linear {})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue