Stream: beginners

Topic: ✔ basic-cli main type


view this post on Zulip Hrishikesh Dharam (Apr 22 2024 at 14:41):

Edit: I think I get it now after re-reading the tutorial. * is the wildcard type and can resolve to any type since Stdout.line never fails. So its compatible with the I32 requirement.

Hi there. I have what I think is a basic type system question. I was reading through the basic-cli platform and saw that the platform requires a name main which main : Task {} I32
I'm confused why main = Stdout.line "hello" satisfies this constraint since its type isTask.Task {} *.
My understanding was that the * in the type annotation means "no value" while the platform seems to require an I32 on failure.

view this post on Zulip Anton (Apr 22 2024 at 14:51):

Hi @Hrishikesh Dharam,
I don't know how the type checking works in detail but I believe the following is happening; the * in Task {} * means that Stdout.line can not return an "error Task". With that type signature, the compiler knows line is guaranteed to return an empty success Task ({}) and because the success case ({}) matches the success case of Task {} I32 all is well :)

view this post on Zulip Hrishikesh Dharam (Apr 22 2024 at 15:06):

Thanks Anton, that mental model makes sense to me

view this post on Zulip Notification Bot (Apr 22 2024 at 15:07):

Hrishikesh Dharam has marked this topic as resolved.


Last updated: Jul 06 2025 at 12:14 UTC