Just want to give feedback, ask some questions and say thanks. I have ocaml and zig background and work just with basic editor with syntax highlighting and no lsp. Which means I work much with the compiler.
expect |> (coming from ocaml, love this, best operator ever)|pa| pa.permissions |> List.map(path_permission_to_str) ! and ?Try(List(Str), [StdinErr(Str)]) and Try(List(Str), [StdinErr(Str), ..]){} |{}| or () || (I prefer the second one)List.for_each with try option so this works: Stdin.lines!()? |> List.for_each!(|line| Stdout.print!(line)) ## Allowed system calls.
SystemOperation : [
## gives accesss to Stdin: (this does not show in generated docs)
StdinStdoutStderrAndBasicFunctionality,
ReadFromFilesystem,
https://codeberg.org/removewingman/restricted-roc/actions/runs/3/jobs/0/attempt/1
Installing Roc version: nightly-new-compiler
Detected OS: Linux
Detected architecture: x86_64
curl: (22) The requested URL returned error: 401
I also tried earlier with specific commit. Something in the action is not publicly accessible.
as described in #beginners > Roc on Alpine Linux , maybe something like this would be nice:
Instead of default and v1 have a build option compatible and performant and one can choose when building rock which to use.
I know roc is highly experimental, but I like the it and the state it is in, thanks.
On the support for OpenBSD front, I imagine we just need users and contributors willing to support it, or some kind of sponsorship to put resources into it I guess. Do you know what the gaps are currently?
I tried to setup a spare machine I have with OpenBSD and didn't quite get zig 0.16.0 setup before getting distracted on other things. :sweat_smile:
Great feedback, @removewingman!
Regarding tagged unions, the difference between a closed union like [A, B] and an open union like [A, B, ..] is that the open union is extensible, meaning it can be assigned to a superset union. For example, the following code works fine:
foo : [A, B, ..]
foo = A
bar : [A, B, C, D]
bar = foo
But if you replace foo : [A, B, ..] with foo : [A, B] in the code above, then the compiler will give a type mismatch error.
The confusing thing (to me) is that you can actually do exhaustive matches with both open and closed unions. For example, the following works fine, even though the .. syntax makes it look like other tags are possible, so the match doesn't look exhaustive, even though it actually is:
f : [A, B, ..] -> Str
f = |x| {
match x {
A => "A"
B => "B"
}
}
I think I might prefer a syntax like [A, B]* for open unions (or some other syntax with a symbol outside of [A, B]), as it would be clearer that A and B are the only possible tags, but the * would indicate that it can be assigned to a superset union.
Also, the following code doesn't work at the moment, there's a type mismatch on the last line because [A, B] cannot be converted to [A, B, C]:
f : U64 -> Try(U64, [A, B])
f = |x| if x < 10 { Ok(x) } else if x < 100 { Err(A) } else { Err(B) }
g : U64 -> Try(U64, [A, B, C])
g = |x| if x > 1000 { Err(C) } else { f(x) }
To work around this issue, you can either make f return an open union (f : U64 -> Try(U64, [A, B, ..]), which is usually the simplest solution, or you can map the [A, B] tags returned by f to [A, B, C] tags using map_err, like this:
f : U64 -> Try(U64, [A, B])
f = |x| if x < 10 { Ok(x) } else if x < 100 { Err(A) } else { Err(B) }
g : U64 -> Try(U64, [A, B, C])
g = |x| if x > 1000 { Err(C) } else {
f(x).map_err(
|err| match err {
A => A
B => B
}
)
}
This ain't great, but luckily it will be fixed soon: there's a PR to allow a closed union in an output position to be extended when needed, so the first implementation of g will work just fine.
might prefer a syntax like
[A, B]*for open unions.
This was the syntax before we changed it to .. ] because people found it more confusing.
Yeah, perhaps [A, B]* isn't clear enough. But I really don't like [A, B, ..], it reads like "A, B, or anything else", which is really _not_ what it means.
This was the tracking issue from around that time https://github.com/roc-lang/roc/issues/7091
Could we perhaps use .. outside of [A, B]? For example:
f : U64 -> Try(U64, [A, B]..)
I personally find this much less confusing: it says "the possible values are A and B, but we could extend this".
Maybe we move this to an ideas thread?
Thanks for the explanation around tagged unions, I think I understand now, still a little bit complex.
I hope this https://github.com/roc-lang/roc/pull/10434 lands, would hide the complexity and make it simpler.
Regarding OpenBSD, it is more like a longterm wish. I would be probably the only user, for now. OpenBSD is Tier 2 Target Support in zig, so one can just download the binary and it works: https://ziglang.org/download/0.16.0/release-notes.html#Support-Table There is also a port: https://codeberg.org/OpenBSD/ports/src/branch/master/lang/zig/Makefile
Aurélien Geron said:
The confusing thing (to me) is that you can actually do exhaustive matches with both open and closed unions. For example, the following works fine, even though the
..syntax makes it look like other tags are possible, so thematchdoesn't look exhaustive, even though it actually is:f : [A, B, ..] -> Str f = |x| { match x { A => "A" B => "B" } }
this is surprising to me! i think this match should require a _ => … base case. can you open an issue?
I does not actually work, the following example, throws an error when compiling with the hint that the _ is missing as pattern:
f : [A, B, ..] -> Str
f = |x| {
match x {
A => "A"
B => "B"
}
}
expect f(A) == "A"
Oh interesting, I tested this code in the REPL:
» f : [A, B, ..] -> Str
f = |x| {
match x {
A => "A"
B => "B"
}
}
assigned `f`
» f(A)
"A"
» f(B)
"B"
» f(C)
This Roc code crashed with: "hit a runtime error"
I've opened issue #10985.
I guess the [A, B, ..] syntax is fine, then, sorry for the noise.
Last updated: Sep 03 2026 at 15:16 UTC