Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/file-upload-form.roc
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ respond! = \req, _ ->
{ headers: req.headers, body: req.body }
|> MultipartFormData.parse_multipart_form_data
|> Result.try(List.first)
|> Result.map(.data)
|> Result.map(Base64.encode)
|> Result.map_ok(.data)
|> Result.map_ok(Base64.encode)

when maybe_image is
Ok(img) ->
Expand Down
2 changes: 1 addition & 1 deletion examples/file.roc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ init! : {} => Result Model [Exit I32 Str]_
init! = \{} ->
# Read the contents of examples/file.roc
File.read_utf8!("examples/file.roc")
|> Result.map(\contents -> "Source code of current program:\n\n${contents}")
|> Result.map_ok(\contents -> "Source code of current program:\n\n${contents}")
|> Result.map_err(
\err ->
when err is
Expand Down
4 changes: 2 additions & 2 deletions platform/File.roc
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ open_reader! = \path_str ->
# 0 means with default capacity
Host.file_reader!(Str.to_utf8(path_str), 0)
|> Result.map_err(\err -> GetFileReadErr(path, InternalIOErr.handle_err(err)))
|> Result.map(\reader -> @Reader({ reader, path }))
|> Result.map_ok(\reader -> @Reader({ reader, path }))

## Try to open a `File.Reader` for buffered (= part by part) reading given a path string.
## The buffer will be created with the specified capacity.
Expand All @@ -244,7 +244,7 @@ open_reader_with_capacity! = \path_str, capacity ->

Host.file_reader!(Str.to_utf8(path_str), capacity)
|> Result.map_err(\err -> GetFileReadErr(path, InternalIOErr.handle_err(err)))
|> Result.map(\reader -> @Reader({ reader, path }))
|> Result.map_ok(\reader -> @Reader({ reader, path }))

## Try to read a line from a file given a Reader.
## The line will be provided as the list of bytes (`List U8`) until a newline (`0xA` byte).
Expand Down
2 changes: 1 addition & 1 deletion platform/Path.roc
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ type! : Path => Result [IsFile, IsDir, IsSymLink] [PathErr IOErr]
type! = \path ->
Host.path_type!(InternalPath.to_bytes(path))
|> Result.map_err(\err -> PathErr(InternalIOErr.handle_err(err)))
|> Result.map(
|> Result.map_ok(
\path_type ->
if path_type.is_sym_link then
IsSymLink
Expand Down
6 changes: 3 additions & 3 deletions platform/Sqlite.roc
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ prepare! :
=> Result Stmt [SqliteErr ErrCode Str]
prepare! = \{ path, query: q } ->
Host.sqlite_prepare!(path, q)
|> Result.map(@Stmt)
|> Result.map_ok(@Stmt)
|> Result.map_err(internal_to_external_error)

# internal use only
Expand Down Expand Up @@ -603,7 +603,7 @@ nullable_int_decoder = \cast ->
decoder(
\val ->
when val is
Integer(i) -> cast(i) |> Result.map(NotNull) |> Result.map_err(FailedToDecodeInteger)
Integer(i) -> cast(i) |> Result.map_ok(NotNull) |> Result.map_err(FailedToDecodeInteger)
Null -> Ok(Null)
_ -> to_unexpected_type_err(val),
)
Expand All @@ -614,7 +614,7 @@ nullable_real_decoder = \cast ->
decoder(
\val ->
when val is
Real(r) -> cast(r) |> Result.map(NotNull) |> Result.map_err(FailedToDecodeReal)
Real(r) -> cast(r) |> Result.map_ok(NotNull) |> Result.map_err(FailedToDecodeReal)
Null -> Ok(Null)
_ -> to_unexpected_type_err(val),
)
Expand Down
2 changes: 1 addition & 1 deletion platform/Tcp.roc
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ parse_stream_err = \err ->
connect! : Str, U16 => Result Stream ConnectErr
connect! = \host, port ->
Host.tcp_connect!(host, port)
|> Result.map(@Stream)
|> Result.map_ok(@Stream)
|> Result.map_err(parse_connect_err)

## Read up to a number of bytes from the TCP stream.
Expand Down
Loading