Skip to content

Poor error message when trying to import non-existent class methods

$ cat A.hs 
module A where

class C a where
  foo :: a -> Int
  bar :: a -> Int
$ cat B.hs
module B where

import A (C (foo, bar, baz))

instance C Int where
  foo = id
  bar = id
$ ghci B.hs
GHCi, version 8.4.2: http://www.haskell.org/ghc/  :? for help
[1 of 2] Compiling A                ( A.hs, interpreted )
[2 of 2] Compiling B                ( B.hs, interpreted )

B.hs:3:11: error: Module ‘A’ does not export ‘C(foo, bar, baz)’
  |
3 | import A (C (foo, bar, baz))
  |           ^^^^^^^^^^^^^^^^^
Failed, one module loaded.

If you're importing a dozen or so methods, not mentioning the specific method that couldn't be imported gets quite annoying.

Trac metadata
Trac field Value
Version 8.4.2
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information