Stream: compiler development

Topic: module params - type annotations


view this post on Zulip Luke Boswell (Nov 09 2024 at 07:00):

Is it possible to add type annotations for module params, maybe it's not implemented yet?

I expected to be able to do something like this but I get parsing errors.

module {
    stdin : {} -> Task {} _,
    stdout : {} -> Task {} _,
    time : {} -> Task U128 _,
} -> [Solution, solve]
$ roc check package/AoC.roc
── UNFINISHED RECORD PATTERN in package/AoC.roc ────────────────────────────────

I am partway through parsing a record pattern, but I got stuck here:

1│  module {
2│      stdin : {} -> Task {} _,
                   ^

I was expecting to see a closing curly brace before this, so try
adding a } and see if that helps?%

view this post on Zulip Sam Mohr (Nov 09 2024 at 07:19):

Try putting the function type in parentheses?

view this post on Zulip Sam Mohr (Nov 09 2024 at 07:19):

They usually don't like being bare in record types

view this post on Zulip Sam Mohr (Nov 09 2024 at 07:20):

I might spend some time consolidating our record parsing this weekend

view this post on Zulip Luke Boswell (Nov 09 2024 at 07:20):

No joy

module {
    stdin : ({} -> Task {} _),
    stdout : ({} -> Task {} _),
    time : ({} -> Task U128 _),
} -> [Solution, solve]
── UNFINISHED PARENTHESES in package/AoC.roc ───────────────────────────────────

I am partway through parsing a pattern in parentheses, but I got stuck
here:

2│      stdin : ({} -> Task {} _),
                    ^

I was expecting to see a closing parenthesis before this, so try
adding a ) and see if that helps?%

view this post on Zulip Sam Mohr (Nov 09 2024 at 09:12):

Try making an alias?

view this post on Zulip Agus Zubiaga (Nov 09 2024 at 12:11):

There’s no syntax for annotating module params in the proposal. That part of the header is literally parsed as a record pattern now.

view this post on Zulip Agus Zubiaga (Nov 09 2024 at 12:12):

I agree it’d be nice to be able to do that, though


Last updated: Jul 06 2025 at 12:14 UTC