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,270
    • Issues 4,270
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 413
    • Merge Requests 413
  • 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
  • #10890

Closed
Open
Opened Sep 17, 2015 by quchen@trac-quchen

Incorrect redundant import warning for type classes

Given the three files below, the import marked with (!!!) is reported as redundant. Upon deleting it, GHC reports that "has" is not a visible class method of BClass.

This came up in the context of the MFP (#10751 (closed)), with the correspondences Base<->Control.Monad, Extends<->Control.Monad.Fail. We would like to have Control.Monad re-export Control.Monad.Fail.MonadFail without its (clashing) member "fail" for the time being. For future compatibility, some modules should implement MonadFail right now, requiring us to import Control.Monad.Fail explicitly in order to write an instance. Said procedure leads to the described import warning, which breaks the validation script for example.

-- Base.hs
module Base (AClass(..), BClass()) where

import Extends (BClass())

class AClass a where
    has :: a
-- Extends.hs
module Extends where

class BClass b where
    has :: b
-- UseSite.hs
module UseSite where

import Base
import Extends -- (!!!)

data Bar = Bar

instance AClass Bar where
    has = Bar

instance BClass Bar where
    has = Bar

We either get

UseSite.hs:12:5: error:
    ‘has’ is not a (visible) method of class ‘BClass’

or

UseSite.hs:4:1: warning:
    The import of ‘Extends’ is redundant
      except perhaps to import instances from ‘Extends’
    To import instances alone, use: import Extends()
Edited Mar 10, 2019 by quchen
Assignee
Assign to
8.0.1
Milestone
8.0.1 (Past due)
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#10890