You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using a nested with block to inspect the next step of a lazy recursive view, such as String's AsList, does not currently compile without manually forcing the value
Steps to Reproduce
Consider the following function that inspects two characters from a string at a time
doubleLetter: String ->Bool
doubleLetter str with (asList str)
doubleLetter ""| [] =False
doubleLetter (strCons c str) | (c :: x) with (x)
doubleLetter (strCons c "") | (c :: x) | [] =False
doubleLetter (strCons c (strCons d str)) | (c :: x) | (d :: y) =if c == d
thenTrueelse doubleLetter (strCons d str) | x
Expected Behavior
This function should either compile and work, or at least fail with a less confusing error message.
Observed Behavior
This function fails to compile, unless you replace the (x) in the inner with block with (force x), with the following error message:
-- src/Years/Y2015/Day5.md line 72 col 14:
While processing right hand side of with block in with block in doubleLetter. d is not accessible in
this context.
Years.Y2015.Day5:72:15--72:16
68 | doubleLetter "" | [] = False
69 | doubleLetter (strCons c str) | (c :: x) with (x)
70 | doubleLetter (strCons c "") | (c :: x) | [] = False
71 | doubleLetter (strCons c (strCons d str)) | (c :: x) | (d :: y) =
72 | if c == d
The text was updated successfully, but these errors were encountered:
At the same time, the original code snippet may show some troubles with the termination checker, since if you try to use strCons instead of _ on the LHS of with-clauses, compiler starts to complain as if the function is non-covering
Using a nested
with
block to inspect the next step of a lazy recursive view, such asString
'sAsList
, does not currently compile without manually forcing the valueSteps to Reproduce
Consider the following function that inspects two characters from a string at a time
Expected Behavior
This function should either compile and work, or at least fail with a less confusing error message.
Observed Behavior
This function fails to compile, unless you replace the
(x)
in the innerwith
block with(force x)
, with the following error message:The text was updated successfully, but these errors were encountered: