Skip to content

Commit 5abb142

Browse files
authored
Merge pull request #226 from roc-lang/error-type-fixes
error unification fixes
2 parents 18709aa + d8611e5 commit 5abb142

File tree

6 files changed

+19
-19
lines changed

6 files changed

+19
-19
lines changed

examples/args.roc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import pf.Arg.Param as Param
1212
import pf.Arg
1313

1414
main =
15-
args = Arg.list!
15+
args = Arg.list! {}
1616

1717
when Cli.parseOrDisplayMessage cli args is
1818
Ok { command: subcommand } ->

flake.lock

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

platform/Arg.roc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ import Arg.ErrorFormatter exposing [formatArgExtractErr]
1010
import Arg.Help exposing [helpText, usageHelp]
1111

1212
## Gives a list of the program's command-line arguments.
13-
list : Task (List Str) []_
14-
list =
13+
## `{} ->` is a necessary workaround to make error accumulation/unification work.
14+
list : {} -> Task (List Str) []
15+
list = \_ ->
1516
Effect.args
1617
|> Effect.map Ok
1718
|> InternalTask.fromEffect
@@ -82,7 +83,7 @@ list =
8283
## ```
8384
parse : CliParser state -> Task state [Exit I32 Str, StdoutErr Stdout.Err]
8485
parse = \parser ->
85-
when parser.parser list! is
86+
when parser.parser (list {})! is
8687
SuccessfullyParsed data ->
8788
Task.ok data
8889

platform/Effect.roc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ cwd : Effect (List U8)
8585
sendRequest : Box InternalHttp.Request -> Effect InternalHttp.InternalResponse
8686

8787
tcpConnect : Str, U16 -> Effect (Result U64 Str)
88-
tcpClose : U64 -> Effect (Result {} *)
88+
tcpClose : U64 -> Effect {}
8989
tcpReadUpTo : U64, U64 -> Effect (Result (List U8) Str)
9090
tcpReadExactly : U64, U64 -> Effect (Result (List U8) Str)
9191
tcpReadUntil : U64, U8 -> Effect (Result (List U8) Str)

platform/Tcp.roc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,10 @@ connect = \host, port ->
112112
|> Result.mapErr parseConnectErr
113113
|> InternalTask.fromEffect
114114

115-
close : Stream -> Task {} *
115+
close : Stream -> Task {} []
116116
close = \@Stream stream ->
117117
Effect.tcpClose stream
118+
|> Effect.map Ok
118119
|> InternalTask.fromEffect
119120

120121
## Read up to a number of bytes from the TCP stream.

platform/src/lib.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -989,12 +989,10 @@ pub extern "C" fn roc_fx_tcpConnect(
989989
}
990990

991991
#[no_mangle]
992-
pub extern "C" fn roc_fx_tcpClose(stream_id: u64) -> RocResult<(), ()> {
992+
pub extern "C" fn roc_fx_tcpClose(stream_id: u64) {
993993
TCP_STREAMS.with(|tcp_streams_local| {
994994
tcp_streams_local.borrow_mut().remove(&stream_id);
995-
});
996-
997-
RocResult::ok(())
995+
})
998996
}
999997

1000998
#[no_mangle]

0 commit comments

Comments
 (0)