I’m implementing a non linear function from U8 to U8. I could use a list of 256 elements and use List.get
but the never-existing errors might be annoying so I tried just writing a huge when n is ...
with all integers from 0 to 255.
when n is
0 -> 99
1 -> 124
...
255 -> 22
But the compiler tells me this:
330│> 254 -> 187
331│> 255 -> 22
Other possibilities include:
_
I would have to crash if I saw one of those! Add branches for them!
I should add that I put a type annotation:
sbox : U8 -> U8
sbox = \i ->
when i is
0 -> 99
1 -> 124
...
Is it expected that the type inference is not aware that 0..255 covers all numbers in U8? or is it a bug?
I would guess a bug
I think we just never implemented it!
Last updated: Jul 06 2025 at 12:14 UTC