Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
GHC
GHC
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,251
    • Issues 4,251
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 394
    • Merge Requests 394
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Security & Compliance
    • Security & Compliance
    • Dependency List
    • License Compliance
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #13064

Closed
Open
Opened Jan 04, 2017 by Oleg Grenrus@phadejDeveloper

Incorrect redudant imports warning

With a simple package:

issue.cabal:

name: issue
version: 0
cabal-version: >= 1.10
build-type: Simple

library
  build-depends: base, binary, binary-orphans==0.1.5.2
  exposed-modules: Issue

Issue.hs:

{-# LANGUAGE DeriveGeneric #-}
{-# OPTIONS_GHC -Wall #-}
module Issue (T (..)) where

import Prelude ()
import Data.Binary.Orphans
import Data.Binary (Binary (..))
import GHC.Generics (Generic)
import Data.Aeson (Value)

data T = T Value deriving (Generic)

instance Binary T

GHC 7.10.3 correctly reports:

Issue.hs:7:1: Warning:
    The import of ‘Data.Binary’ is redundant
      except perhaps to import instances from ‘Data.Binary’
    To import instances alone, use: import Data.Binary()

GHC 8.0.1 incorrectly (!!!) reports:

Issue.hs:6:1: warning: [-Wunused-imports]
    The import of ‘Data.Binary.Orphans’ is redundant
      except perhaps to import instances from ‘Data.Binary.Orphans’
    To import instances alone, use: import Data.Binary.Orphans(

but Binary Value instance is imported from Data.Binary.Orphans.


In real life while compiling https://github.com/futurice/haskell-mega-repo/blob/93c3f111f39c973769c35725d90c9b8ef9a57de3/futurice-github/src/Futurice/GitHub.hs the Data.Binary redundant import isn't reported, as Futurice.Prelude exports other stuff, which is used. See https://gist.github.com/phadej/bb26df19c611260ab8f867729def39b9 for minimal imports reported with -ddump-minimal-imports.

## Status

I've submitted some PRs to fix the impending unused import warnings:

  • MERGED https://github.com/haskell/cabal/pull/5673
  • MERGED https://github.com/kolmodin/binary/pull/159
  • MERGED https://github.com/haskell/bytestring/pull/168
  • MERGED https://github.com/haskell/containers/pull/576
  • MERGED https://github.com/haskell/text/pull/240

I've also added a new ghc patch here:

  • MERGED https://phabricator.haskell.org/D5312
Edited Mar 10, 2019 by davide
Assignee
Assign to
8.8.1
Milestone
8.8.1 (Past due)
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#13064