Skip to content

Deriving instance conditionally compiles

{-# LANGUAGE GADTs #-}
{-# LANGUAGE StandaloneDeriving #-}

data Abstract
data Reified
data Player

data Elect p a where
    ElectRefAsTypeOf :: Int -> Elect Abstract a -> Elect Abstract a
    ElectHandle :: a -> Elect Reified a
    Controller :: Elect Abstract Player
    Owner :: Elect Abstract Player
    You :: Elect Abstract Player

deriving instance (Eq a) => Eq (Elect p a)
deriving instance (Ord a) => Ord (Elect p a)

As is, the above code fails to compile. But if I move ElectRefAsTypeOf to be the last constructor for the GADT, the code does compile. If I remove one of the Elect Abstract Player constructors, the code still won't compile even if the ElectRefAsTypeOf is moved.

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