Skip to content

Commit c7c81b0

Browse files
committed
minimal
1 parent 9cc944f commit c7c81b0

5 files changed

Lines changed: 3 additions & 41 deletions

File tree

pkgs/roc/applications/hello/rust-minimal-cli/main.roc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ main! = |_|
1010
line!(hello language)?
1111
line!("Roc ❤️ ${language}")?
1212
line!(hello!(user)?)?
13-
Ok({})
13+
Ok
0 Bytes
Binary file not shown.
Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,6 @@
11
module [
2-
Arg,
3-
display,
4-
to_os_raw,
52
from_os_raw,
63
]
74
Arg := [Unix (List U8), Windows (List U16)]
8-
implements [Eq, Inspect { to_inspector: arg_inspector }]
9-
arg_inspector : Arg -> Inspector f where f implements InspectFormatter
10-
arg_inspector = |arg| Inspect.str(display(arg))
11-
test_hello : Arg
12-
test_hello = Arg.from_os_raw(Unix([72, 101, 108, 108, 111]))
13-
expect Arg.display(test_hello) == "Hello"
14-
expect Inspect.to_str(test_hello) == "\"Hello\""
15-
to_os_raw : Arg -> [Unix (List U8), Windows (List U16)]
16-
to_os_raw = |@Arg(inner)| inner
175
from_os_raw : [Unix (List U8), Windows (List U16)] -> Arg
186
from_os_raw = @Arg
19-
display : Arg -> Str
20-
display = |@Arg(inner)|
21-
when inner is
22-
Unix(bytes) ->
23-
# TODO replace with Str.from_utf8_lossy : List U8 -> Str
24-
# see https://github.com/roc-lang/roc/issues/7390
25-
when Str.from_utf8(bytes) is
26-
Ok(str) -> str
27-
Err(_) -> crash("tried to display Arg containing invalid utf-8")
28-
29-
Windows(_) ->
30-
# TODO replace with Str.from_utf16_lossy : List U16 -> Str
31-
# see https://github.com/roc-lang/roc/issues/7390
32-
crash("display for utf-16 Arg not yet supported")

pkgs/roc/platforms/rust-minimal-cli/platform/InternalArg.roc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module [ArgToAndFromHost, to_os_raw]
1+
module [to_os_raw]
22
ArgToAndFromHost := {
33
type : [Unix, Windows],
44
unix : List U8,

pkgs/roc/platforms/rust-minimal-cli/platform/Stdout.roc

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,10 @@ module [
44
]
55
import Host
66
import InternalIOErr
7-
handle_err : InternalIOErr.IOErrFromHost -> [StdoutErr InternalIOErr.IOErr]
8-
handle_err = |{ tag, msg }|
9-
when tag is
10-
NotFound -> StdoutErr(NotFound)
11-
PermissionDenied -> StdoutErr(PermissionDenied)
12-
BrokenPipe -> StdoutErr(BrokenPipe)
13-
AlreadyExists -> StdoutErr(AlreadyExists)
14-
Interrupted -> StdoutErr(Interrupted)
15-
Unsupported -> StdoutErr(Unsupported)
16-
OutOfMemory -> StdoutErr(OutOfMemory)
17-
Other | EndOfFile -> StdoutErr(Other(msg))
18-
line! : Str => Result {} [StdoutErr InternalIOErr.IOErr]
7+
handle_err = |io_err_from_host| StdoutErr InternalIOErr.handle_err(io_err_from_host)
198
line! = |str|
209
Host.stdout_line!(str)
2110
|> Result.map_err(handle_err)
22-
hello! : Str => Result Str [StdoutErr InternalIOErr.IOErr]
2311
hello! = |str|
2412
Host.hello!(str)
2513
|> Result.map_err(handle_err)

0 commit comments

Comments
 (0)