
I am working on https://ghc.haskell.org/trac/ghc/ticket/12105, and have a type to ensure that the `HsMatchContext` has either a `RdrName` or a `Name`, not an `Id`. type family NameOrRdrName id where NameOrRdrName Id = Name NameOrRdrName Name = Name NameOrRdrName RdrName = RdrName Is there any way to declare `Data` and `OutputableBndr` instances for this? Without it I am having to do something like instance (OutputableBndr name, OutputableBndr (NameOrRdrName name)) => Outputable (HsDecl name) where which requires UndecidableInstances. I get compiler/hsSyn/PlaceHolder.hs:114:19: Illegal type synonym family application in instance: NameOrRdrName id In the stand-alone deriving instance for ‘Data (NameOrRdrName id)’ for the parameterised version and compiler/hsSyn/PlaceHolder.hs:115:19: Illegal type synonym family application in instance: NameOrRdrName RdrName In the stand-alone deriving instance for ‘Data (NameOrRdrName RdrName)’ for the one specific to `RdrName`. Regards Alan

Can you give a small example? Certainly any instance like instance Data x => Data (F x) is not allowed, of course, if F is a type function. It’s like not allowing f (g x) = x in the term language. Only constructors in patterns! S From: ghc-devs [mailto:ghc-devs-bounces@haskell.org] On Behalf Of Alan & Kim Zimmerman Sent: 25 May 2016 18:39 To: ghc-devs@haskell.org Subject: instances for closed type families I am working on https://ghc.haskell.org/trac/ghc/ticket/12105, and have a type to ensure that the `HsMatchContext` has either a `RdrName` or a `Name`, not an `Id`. type family NameOrRdrName id where NameOrRdrName Id = Name NameOrRdrName Name = Name NameOrRdrName RdrName = RdrName Is there any way to declare `Data` and `OutputableBndr` instances for this? Without it I am having to do something like instance (OutputableBndr name, OutputableBndr (NameOrRdrName name)) => Outputable (HsDecl name) where which requires UndecidableInstances. I get compiler/hsSyn/PlaceHolder.hs:114:19: Illegal type synonym family application in instance: NameOrRdrName id In the stand-alone deriving instance for ‘Data (NameOrRdrName id)’ for the parameterised version and compiler/hsSyn/PlaceHolder.hs:115:19: Illegal type synonym family application in instance: NameOrRdrName RdrName In the stand-alone deriving instance for ‘Data (NameOrRdrName RdrName)’ for the one specific to `RdrName`. Regards Alan

There is an example at http://lpaste.net/164532 (attached as well)
The derived Data instance fails with
/home/alanz/Example.hs:19:19:
Illegal type synonym family application in instance:
NameOrRdrName id
In the stand-alone deriving instance for ‘Data (NameOrRdrName id)’
And how would an instance for Outputable be defined in terms of the
existing ones?
Alan
On Wed, May 25, 2016 at 8:03 PM, Simon Peyton Jones
Can you give a small example? Certainly any instance like
instance Data x => Data (F x)
is not allowed, of course, if F is a type function. It’s like not allowing
f (g x) = x
in the term language. Only constructors in patterns!
S
*From:* ghc-devs [mailto:ghc-devs-bounces@haskell.org] *On Behalf Of *Alan & Kim Zimmerman *Sent:* 25 May 2016 18:39 *To:* ghc-devs@haskell.org *Subject:* instances for closed type families
I am working on https://ghc.haskell.org/trac/ghc/ticket/12105, and have a type to ensure that the `HsMatchContext` has either a `RdrName` or a `Name`, not an `Id`.
type family NameOrRdrName id where NameOrRdrName Id = Name NameOrRdrName Name = Name NameOrRdrName RdrName = RdrName
Is there any way to declare `Data` and `OutputableBndr` instances for this?
Without it I am having to do something like
instance (OutputableBndr name, OutputableBndr (NameOrRdrName name)) => Outputable (HsDecl name) where
which requires UndecidableInstances.
I get
compiler/hsSyn/PlaceHolder.hs:114:19: Illegal type synonym family application in instance: NameOrRdrName id In the stand-alone deriving instance for ‘Data (NameOrRdrName id)’
for the parameterised version and
compiler/hsSyn/PlaceHolder.hs:115:19: Illegal type synonym family application in instance: NameOrRdrName RdrName In the stand-alone deriving instance for ‘Data (NameOrRdrName RdrName)’
for the one specific to `RdrName`.
Regards
Alan
participants (2)
-
Alan & Kim Zimmerman
-
Simon Peyton Jones