Stream: beginners

Topic: Functions as tag payloads?


view this post on Zulip Ian McLerran (Sep 16 2024 at 21:19):

Hey all, I'm just trying to problem solve something here. I want to have a type alias which consists of a tag union where the tag payload includes a function.

However, I've tried defining this type several ways without success. One example error message is as follows:

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

5│      FromOne (\a -> return) a

for the code:

ZeroArity return : [
    FromOne (\a -> return) a
    FromTwo (\a, b -> return) a b
]

Is there anyway to include a function as a tag payload?

view this post on Zulip Brendan Hansknecht (Sep 16 2024 at 21:23):

No \

view this post on Zulip Brendan Hansknecht (Sep 16 2024 at 21:24):

That is only for function definitions

view this post on Zulip Ian McLerran (Sep 16 2024 at 21:24):

Ahhh.. of course! Derp 🤦🏻‍♂️

view this post on Zulip Brendan Hansknecht (Sep 16 2024 at 21:24):

ZeroArity a b return : [
    FromOne (a -> return),
    FromTwo (a, b -> return),
]

view this post on Zulip Brendan Hansknecht (Sep 16 2024 at 21:25):

We need a better error for that. Totally worth filing a bug


Last updated: Jul 06 2025 at 12:14 UTC