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

Use list literal suggestions with :| #1590

Open
philderbeast opened this issue May 6, 2024 · 0 comments
Open

Use list literal suggestions with :| #1590

philderbeast opened this issue May 6, 2024 · 0 comments

Comments

@philderbeast
Copy link
Contributor

With agda/agda@0ff0741, and the following diff, I'm getting suggestions that don't compile.

git diff
diff --git a/.hlint.yaml b/.hlint.yaml
index ccd486368..8daec1b5e 100644
--- a/.hlint.yaml
+++ b/.hlint.yaml
@@ -74,7 +74,6 @@
 - ignore: {name: "Use isNothing"} # 2 hints
 - ignore: {name: "Use join"} # 2 hints
 - ignore: {name: "Use lambda-case"} # 11 hints
-- ignore: {name: "Use list literal"} # 12 hints
 - ignore: {name: "Use list literal pattern"} # 1 hint
 - ignore: {name: "Use map once"} # 1 hint
 - ignore: {name: "Use map with tuple-section"} # 4 hints

The suggestions look wrong to me. Here's one I ran through GHCI.

test/Internal/Utils/Cluster.hs:86:5-37: Suggestion: Use list literal
Found:
 "anabel" :| "bond" : "babel" : []
Perhaps:
 ["anabel" :| "bond", "babel"]

This is not the same.

$ ghci
GHCi, version 9.8.2: https://www.haskell.org/ghc/  :? for help
ghci> import Data.List.NonEmpty
ghci> "anabel" :| "bond" : "babel" : []
"anabel" :| ["bond","babel"]
ghci> ["anabel" :| "bond", "babel"]

<interactive>:3:3: error: [GHC-39999]
   • No instance for ‘Data.String.IsString Char’
       arising from the literal ‘"anabel"’
   • In the first argument of ‘(:|)’, namely ‘"anabel"’
     In the expression: "anabel" :| "bond"
     In the expression: ["anabel" :| "bond", "babel"]

<interactive>:3:23: error: [GHC-39999]
   • No instance for ‘Data.String.IsString (NonEmpty Char)’
       arising from the literal ‘"babel"’
   • In the expression: "babel"
     In the expression: ["anabel" :| "bond", "babel"]
     In an equation for ‘it’: it = ["anabel" :| "bond", "babel"]

In this instance, shouldn't the suggestion be changed to:

test/Internal/Utils/Cluster.hs:86:5-37: Suggestion: Use list literal
Found:
  "anabel" :| "bond" : "babel" : []
Perhaps:
- ["anabel" :| "bond", "babel"]
+ "anabel" :| ["bond","babel"]
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

No branches or pull requests

1 participant