roc nightly pre-release, built from commit 3abc2769375 on Fri Jul 5 09:39:37 UTC 2024
This compiles fine:
cons = \h, t -> Cons h t
empty = Empty
consList = \l -> l |> List.walkBackwards empty \state, elem -> cons elem state
but if type annotations are added:
ConsList a : [Cons a (ConsList a), Empty]
cons : a, ConsList a -> ConsList a
cons = \h, t -> Cons h t
empty : ConsList a
empty = Empty
consList : List a -> ConsList a
consList = \l -> l |> List.walkBackwards empty \state, elem -> cons elem state
results in odd error messages:
── TYPE MISMATCH in test.roc ───────────────────────────────────────────────────
This 3rd argument to |> has an unexpected type:
12│ consList = \l -> l |> List.walkBackwards empty \state, elem -> cons elem state
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The argument is an anonymous function of type:
ConsList a, a -> ConsList a
But |> needs its 3rd argument to be:
ConsList a, a -> ConsList a
── TYPE MISMATCH in test.roc ───────────────────────────────────────────────────
Something is off with the body of the consList definition:
11│ consList : List a -> ConsList a
12│ consList = \l -> l |> List.walkBackwards empty \state, elem -> cons elem state
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This walkBackwards call produces:
ConsList a
But the type annotation on consList says it should be:
ConsList a
────────────────────────────────────────────────────────────────────────────────
roc nightly pre-release, built from commit 3abc2769375 on Fri Jul 5 09:39:37 UTC 2024
This compiles fine:
but if type annotations are added:
results in odd error messages: