-
-
Notifications
You must be signed in to change notification settings - Fork 195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Should strain test non-strict evaluation, like accumulate does? #208
Comments
The proposal rules out solutions that look like the commented solution in Accumulate example: keep f = keep' []
where keep' acc [] = reverse acc
keep' acc (x:xs) = keep' (if f x then x:acc else acc) xs Also this solution (but I expect this solution to be rare) keep f l = keep' [] (zip l (map f l))
where keep' acc [] = reverse acc
keep' acc ((_, False):xs) = keep' acc xs
keep' acc ((x, True) :xs) = keep' (x:acc) xs |
Preserved in this comment: Old versions of the proposal: , testCase "non-strict" $ do
let ws = ["yes", "yup", error "nope", error "no"]
["yes", "yup"] @=? take 2 (keep (const True) ws)
Another: , testCase "non-strict" $ do
let ws = ["yes", "yup", error "nope", error "no"]
["yes", "yup"] @=? take 2 (keep (`seq` True) ws) Both above versions have been superseded by |
Proposal changed: v2 proposal had this: let ws = ["yes", "yup", error "nope", error "no"]
["yes", "yup"] @=? take 2 (keep (`seq` True) ws) v3 proposal has this: let ws = "yes" : error "no"
["yes"] @=? take 1 (keep (const True) ws)
v2 proposal allows a CPS solution, v3 doesn't. Losing CPS solutions is unfortunate, but I'm not sure anyone is complaining. We can go back to v2 proposal if anyone really wants to keep CPS solutions in the running. Both v2 and v3 proposal reject the solutions in earlier comment, so no need to be concerned about that when comparing v2 and v3. |
|
We can make this part of #194.
Note that the accumulate tests have a test that make sure that the accumulate function is non-strict. That was added in d238a33
Is this a goal of the track that we promote non-strict evaluation when appropriate? And if so, do we want to add a similar test to strain?
They might look something like this:
Would want a more descriptive message than "no", of course.
The text was updated successfully, but these errors were encountered: