haskell / alex

A lexical analyser generator for Haskell
https://hackage.haskell.org/package/alex
BSD 3-Clause "New" or "Revised" License
297 stars 82 forks source link

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

Closed IgorErin closed 8 months ago

IgorErin commented 8 months ago

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 commented 8 months ago

The generated code is not entirely warning-free. In the test-suite we suppress some warnings, one of them is about unused imports: https://github.com/haskell/alex/blob/24d786c26f97d60251c9883dd79ba01cd5d664be/tests/Makefile#L42

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 commented 8 months ago

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