I posted an example in the mailing list before, but this issue keeps reappearing for me (Not to say it drives me crazy). So I have come up with a simpler example:
This code:
module Main where
data ClickIndex a =
CILabel Number
| CIAction (ActionDescription a)
data ActionDescription a = AD a | AB
clicked :: forall a. ClickIndex a -> ActionDescription a
clicked ci = test.ani
where
test = case ci of
CILabel n -> {ani: AB, num : n}
CIAction ad -> {ani: ad, num : 1}
doesn't compile with error message:
Error in declaration clicked
Cannot unify a13 with a7.
When I add this type annotation:
CILabel n -> {ani: (AB :: ActionDescription _), num : n}
it compiles (which I can't understand).
Now I use to write ugly code with big functions, and the line number of the error message is not
at the right point, and my brain doesn't tell me at all where I have to add
such type annotations to make the type checker happy. Hope I made my point clear.
Thanks again for providing the beautiful purescript language to us.
I posted an example in the mailing list before, but this issue keeps reappearing for me (Not to say it drives me crazy). So I have come up with a simpler example:
This code:
doesn't compile with error message:
When I add this type annotation:
it compiles (which I can't understand).
Now I use to write ugly code with big functions, and the line number of the error message is not
at the right point, and my brain doesn't tell me at all where I have to add
such type annotations to make the type checker happy. Hope I made my point clear.
Thanks again for providing the beautiful purescript language to us.