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

Unused import Data.Char in basic-bytestring lexer #255

Closed
IgorErin opened this issue Jan 25, 2024 · 2 comments · Fixed by #256
Closed

Unused import Data.Char in basic-bytestring lexer #255

IgorErin opened this issue Jan 25, 2024 · 2 comments · Fixed by #256
Assignees
Labels
re: warnings Concerning compiler warnings triggered by generated files
Milestone

Comments

@IgorErin
Copy link

IgorErin commented Jan 25, 2024

I get the following warning when using basic-bytestring, In this code.

The qualified import of ‘Data.Char’ is redundant
      except perhaps to import instances from ‘Data.Char’
    To import instances alone, use: import Data.Char()
52 | import qualified Data.Char

As far as I understand, this is a generated import.
Is this how it should be, or am I doing something wrong?

@andreasabel
Copy link
Member

The generated code is not entirely warning-free.
In the test-suite we suppress some warnings, one of them is about unused imports:

HC_OPTS=-Wall $(WARNS_DEP_GHC_GTEQ_9_8) -fwarn-incomplete-uni-patterns -fno-warn-missing-signatures -fno-warn-unused-imports -fno-warn-tabs -Werror

Maybe making the code actually warning-free is too much effort. A proper solution would be to make a DSL for lexers in Haskell, generate DSL code, extract import from this code, and then translate this into actual haskell. However, the current implementation spits out Haskell directly and isn't suitable for introspection.

I suppose we could suppress these warnings with {-# OPTIONS_GHC -Wno-<WarningName> #-} pragmas put into the generated code.

@andreasabel andreasabel added the re: warnings Concerning compiler warnings triggered by generated files label Jan 27, 2024
@andreasabel andreasabel added this to the 3.5.1.0 milestone Jan 27, 2024
@andreasabel andreasabel self-assigned this Jan 27, 2024
@andreasabel
Copy link
Member

I suppose fixing this minor issue does not warrant a release, does it?
The issue would then be fixed in the next regular release.

netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this issue Apr 12, 2024
## Changes in 3.5.1.0

* Drop generating output for GHC < 6.4.
* Use qualified imports in generated code (except for `Prelude`)
  ([Issue #258](haskell/alex#258)).
* Suppress warnings `tabs` and `unused-imports` for generated code
  ([Issue #255](haskell/alex#255)).
* Tested with GHC 8.0 - 9.8.2.

## Changes in 3.5.0.0

 * Add option `--numeric-version`.
 * Remove deprecated `-v` as alias for `--version`.
 * Add `-v` as placeholder for a future `--verbose` option.
 * Make `alex{G,S}etUserState` available with the `monadUserState-bytestring` wrapper
   ([Issue #220](haskell/alex#220)).
 * Debugging lexer: print character in addition to its ASCII code
   ([PR #252](haskell/alex#252)).
 * Tested with GHC 8.0 - 9.8.1.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
re: warnings Concerning compiler warnings triggered by generated files
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants