Stream: beginners

Topic: Type annotation causes failure to build


view this post on Zulip Ian McLerran (Jan 14 2026 at 15:21):

A few weeks ago this code would build successfully with the zig compiler. However I just build the latest main, and now I get an error message when building the following code. Not sure if My type annotation is incorrect, or if this is a compiler bug, so posting it up here.

view this post on Zulip Ian McLerran (Jan 14 2026 at 15:21):

keep_oks : List(a), (a -> Try(b, e)) -> List(b)
keep_oks = |vs, f| {
    vs.fold(
        [],
        |acc, v| {
            match f(v) {
                Ok(u) => acc.append(u)
                Err(_) => acc
            }
        },
    )
}

Produces the following error:

The first argument being passed to this function has the wrong type:
   ┌─ main.roc:29:2
   │
29 │    s.split_on("\n")
30 │    .map(extract_digits)

This argument has the type:

    List(List(U64))

But keep_oks needs the first argument to be:

    List(a)

Found 1 error(s) and 0 warning(s) for main.roc.

view this post on Zulip Ian McLerran (Jan 14 2026 at 15:22):

However, if I comment out the type annotation for keep_oks, it builds just fine.

view this post on Zulip Ian McLerran (Jan 14 2026 at 15:24):

Full code here: https://pastebin.com/Qn4xnhUY

view this post on Zulip Richard Feldman (Jan 14 2026 at 15:35):

@Ian McLerran would you mind opening a GH issue for this?

view this post on Zulip Ian McLerran (Jan 14 2026 at 15:36):

Sure thing!

view this post on Zulip Ian McLerran (Jan 14 2026 at 16:25):

Issue at #9018


Last updated: Feb 20 2026 at 12:27 UTC