Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 5,243
    • Issues 5,243
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 567
    • Merge requests 567
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell CompilerGlasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #10890
Closed
Open
Issue created 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
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking