Hi,
I have the following code:
interface A
exposes [
A,
withStr,
]
imports []
A : { lst: List Str }
withStr : A, Str -> A
withStr = \a, s -> A { lst: List.append a.lst s }
(Am I doing it right btw?) But the compiler (roc check
) tells me that I am having messed up types:
Something is off with the body of the withStr definition:
10│ withStr : A, Str -> A
11│ withStr = \a, s -> A { lst: List.append a.lst s }
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This A global tag application has the type:
[ A { lst : List Str } ]a
But the type annotation on withStr says it should be:
{ lst : List Str }
Can someone tell me what I am misunderstanding?
I think you don't need A
in the A { lst: List.append a.lst s }
Because Roc doesn't use record constructors as Haskell would.
so try just
\a, s -> { lst: List.append a.lst s }
Last updated: Jul 06 2025 at 12:14 UTC