[GHC] #16362: Deriving a class via an instance that has a TypeError constraint using standalone deriving fails during compilation.
GHC
ghc-devs at haskell.org
Sun Feb 24 22:22:53 UTC 2019
#16362: Deriving a class via an instance that has a TypeError constraint using
standalone deriving fails during compilation.
-------------------------------------+-------------------------------------
Reporter: j9794 | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 8.6.3
Keywords: | Operating System: Unknown/Multiple
Architecture: | Type of failure: None/Unknown
Unknown/Multiple |
Test Case: | Blocked By:
Blocking: | Related Tickets:
Differential Rev(s): | Wiki Page:
-------------------------------------+-------------------------------------
This bug occurs if I define an instance for a typeclass adding a TypeError
constraint on the instance, and then I try to derive that instance using
Deriving Via in combination with StandaloneDeriving.
This is the shortest example I was able to come up with:
{{{
{-# Language DataKinds, UndecidableInstances, StandaloneDeriving,
DerivingVia #-}
import GHC.TypeLits
newtype NotNum a = NotNum a
instance (TypeError (Text "Not a num")) => Num (NotNum a) where
data Foo = Foo
deriving via (NotNum Foo) instance Num Foo
}}}
In this case, it'll fail in compilation with 'Not a Num'.
This only seems to happen when combining deriving via with standalone
deriving, because if I derive the class like:
{{{
data Foo = Foo deriving Num via (NotNum Foo)
}}}
It works as expected (doesn't fail with my custom error until I actually
try to use a Foo where I should use a Num)
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/16362>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list