By: Tom Sydney Kerckhove <syd@cs-syd.eu>
#1701, add a "Redundant module qualifier" hint
Type occurrences like 'Map.Map', 'Set.Set' or 'Text.Text' stutter: the
qualifier's last component repeats the type name. A module may be
imported twice, so the qualified import can stay and a second import can
bring just the type into scope unqualified:
import Data.Map (Map)
import Data.Map qualified as Map
The hint says so in a note, naming the module the qualifier resolves to.
It fires on any type occurrence of the shape <X>.<X>, so both 'Map.Map'
and 'Data.Map.Map' are flagged, in signatures, data and newtype
declarations, type synonyms, instance heads and expression type
annotations. Value-level occurrences are untouched.
Whether the extra import is worth it is a matter of taste, and the hint
fires often on real code, so it is off by default like "Use explicit
module export list". Enable it with:
- warn: {name: Redundant module qualifier}
Dropping the qualifier only compiles once the type is in scope
unqualified, which HLint cannot arrange, so the hint offers no
refactoring.
Claude-Session: https://claude.ai/code/session_01JbL9Ex7jZ7ANs2HMeSuWgd