My main reason is that unsigned integers make working with indices painful .
Are you able to provide a concrete example? I think that would be helpful.
Here is the sort of thing I tend to bump into:
rowRange = List.range { start : At (Num.toU64((Num.toI64 row) - 1)), end : At (row + 2) }
The default int type is I64. So something else must be going on here.
How is row defined?
If I mapWithIndex over a list the index is a U64. That's the default I'm referring to. Sorry for not being more clear.
I thought it was U64 for indexes too
Yeah like
walkWithIndex :
List elem,
state,
(state,
elem,
U64
-> state)
-> state
Slight aside -- why is the type annotation in the builtins for range using an underscoreList.range : _?
Francois Green said:
Here is the sort of thing I tend to bump into:
rowRange = List.range { start : At (Num.toU64((Num.toI64 row) - 1)), end : At (row + 2) }
I don't really understand the issue here, why cant you just do the maths using an U64?
» row = 1u64
… rowRange = List.range { start : At (row - 1), end : At (row + 2) }
[0, 1, 2, 3] : List U64
Yes indices are U64 while the default int numeric is I64.
@Luke Boswell That works just fine. The weird thing is I've encountered issues where somehow the number being subtracted is seen as an I64. I just removed the extraneous code from the range and it's working like there was never a problem.
Have you seen something like this maybe?
» row = 1u64
… rowRange = List.range { start : At (row - 1i64), end : At (row + 2i64) }
This Roc code crashed with: "Hit an erroneous type when creating a layout for `4.IdentId(19)`"
── TYPE MISMATCH ───────────────────────────────────────────────────────────────
This 2nd argument to + has an unexpected type:
5│ rowRange = List.range { start : At (row - 1i64), end : At (row + 2i64) }
^^^^
The argument is an integer of type:
I64
But + needs its 2nd argument to be:
Int Unsigned64
Where your trying to subtract an I64 from a U64?
That seems to be the case. I'm looking back through some old advent of code solutions and I see where I've been the cause of some type mismatches.
Last updated: Jun 16 2026 at 16:19 UTC