Skip to content
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

Silence warning for partial functions on ghc >=9.8 #385

Merged
merged 1 commit into from
Mar 27, 2024

Conversation

UlfNorell
Copy link
Collaborator

No description provided.

@MaximilianAlgehed
Copy link
Collaborator

What's the case against just removing said partial function calls from the code base?

@UlfNorell
Copy link
Collaborator Author

UlfNorell commented Mar 27, 2024

These are the partial functions we get warnings for:

  • | x' <- takeWhile (<< x) (0:[ x - i | i <- tail (iterate (`quot` 2) x) ])

    Could be drop 1.

  • abstract (Table xys) d x = head ([y | (x',y) <- xys, x == x'] ++ [d])

    head (someList ++ [d]) is a useful idiom. Not sure I want to change this to maybe fst d (uncons someList)... (when was uncons added to Data.List?). I suppose we could define headWithDefault locally.

  • once $ forAllShrink (return [-10000..10000]) shrink $ \ns ->
    map head (group (sort ns)) == sort ns ==> -- no duplicates

    map head . group is another common idiom that I'm not sure I want to rewrite just to avoid the warning.

@MaximilianAlgehed MaximilianAlgehed merged commit 78a3e64 into master Mar 27, 2024
108 checks passed
@MaximilianAlgehed MaximilianAlgehed deleted the x-partial branch March 27, 2024 12:11
@phadej
Copy link
Contributor

phadej commented Mar 27, 2024

FWIW, map head . group is exactly that if you use head and group from Data.List.NonEmpty

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants