Stream: beginners

Topic: ✔ Recursive union


view this post on Zulip AdrienDML [he/him] (Mar 20 2023 at 04:53):

I have an union declared as such:

Elem msg : [
    Text ({txt : Str}),
    Button ({ children: (List (Elem msg)), onPress: msg}),
]

And a function:

view : Model -> Elem Message
view = \_ -> Text { text: "Hello From Roc!\n" }

But i get this error:

Something is off with the body of the view definition:

14│  view : Model -> Elem Message
15│  view = \_ -> Text { text: "Hello From Roc!\n" }
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This Text tag application has the type:
    [Button {
        children : List [Button ∞, Text { txt : Str }]b as ∞,
        onPress : Message,
    }, Text { text : Str }]b
But the type annotation on view says it should be:
    [Button {
        children : List a,
        onPress : Message,
    }, Text { txt : Str }] as a

Am i doing something wrong ?

view this post on Zulip AdrienDML [he/him] (Mar 20 2023 at 05:02):

Ok nevermind i had a typo in the text field :P

view this post on Zulip Notification Bot (Mar 20 2023 at 07:27):

AdrienDML [he/him] has marked this topic as resolved.


Last updated: Jul 06 2025 at 12:14 UTC