[GHC] #12387: Template Haskell ignores class instance definitions with methods that don't belong to the class
GHC
ghc-devs at haskell.org
Thu May 17 12:53:02 UTC 2018
#12387: Template Haskell ignores class instance definitions with methods that don't
belong to the class
-------------------------------------+-------------------------------------
Reporter: RyanGlScott | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone:
Component: Template Haskell | Version: 8.0.1
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: GHC accepts | Unknown/Multiple
invalid program | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by RyanGlScott):
Well, perhaps the phrase "postponing" isn't quite accurate. It turns out
that for associated type family instances, membership in a class is tested
//twice//, once during renaming and once during typechecking. comment:3
shows an example of the latter, and this demonstrates the former:
{{{#!hs
{-# LANGUAGE TypeFamilies #-}
module Foo where
import GHC.Generics
instance Eq () where
type Rep () = Maybe
}}}
{{{
$ /opt/ghc/8.4.2/bin/ghc Bug.hs
[1 of 1] Compiling Foo ( Bug.hs, Bug.o )
Bug.hs:7:8: error:
‘Rep’ is not a (visible) associated type of class ‘Eq’
|
7 | type Rep () = Maybe
| ^^^
}}}
So it might suffice to just check class membership for class methods
additionally during typechecking, just like we do for associated type
family instances.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12387#comment:4>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list