Closed rtfeldman closed 2 years ago
This is really a parsing bug. This code causes a MalformedClosure
partition : I64, I64, List (Num a) -> [ Pair I64 (List (Num a)) ]
partition = \low, high, initialList ->
when List.get initialList high is
Ok pivot ->
Pair newI newList = partitionHelp (low - 1) low initialList high pivot
Pair (newI + 1) (swap (newI + 1) high newList)
Err _ ->
Pair (low - 1) initialList
but everything is fine when we put parens around the pattern match:
partition : I64, I64, List (Num a) -> [ Pair I64 (List (Num a)) ]
partition = \low, high, initialList ->
when List.get initialList high is
Ok pivot ->
(Pair newI newList) = partitionHelp (low - 1) low initialList high pivot
Pair (newI + 1) (swap (newI + 1) high newList)
Err _ ->
Pair (low - 1) initialList
This works now, even without the parens!
To reproduce: change the Quicksort example to destructure
Pair
values inline where possible, instead of usingwhen
with one branch.Like so: