Re: To allow deriving poly-kinded Generic1 instances

2021-10-13 Thread Edward Kmett
I use the same F1 trick (with the same name and for the same reason) in the HEAD branch of hkd and distributive, but I admit it is a bit frustrating, because then I have to expose pattern synonyms to hide its boilerplate from users. e.g.

Re: To allow deriving poly-kinded Generic1 instances

2021-10-13 Thread Ryan Scott
> I figured out that this compiles: > > data HKD (f :: Type -> Type) = Foo (F1 Int f) (F1 Double f) > | Bar (F1 Bool f) > deriving Generic1 > > newtype F1 a f = F1 { unF1 :: f a } Yes, that's a useful trick to keep in mind. For what it's worth, I think your `F1` is the same thing as `Barbie`

Re: To allow deriving poly-kinded Generic1 instances

2021-10-13 Thread Ryan Scott
Thanks for posting an example—that's very helpful to figure out what is going on. > Currently, GHC rejects the following code: > > {-# LANGUAGE DeriveGeneric #-} > {-# LANGUAGE PolyKinds #-} > import GHC.Generics > > data HKD f = Foo (f Int) (f Double) > | Bar (f Bool) > deriving Generic1

Re: To allow deriving poly-kinded Generic1 instances

2021-10-13 Thread Ryan Scott
Hello, I'm not quite sure I understand the issue you're hitting. Generic1 is poly-kinded, so I would expect it to be able to handle data types where the last type parameter has differing kinds. Can you post a complete example of the program you expect to typecheck, but doesn't? Best, Ryan

To allow deriving poly-kinded Generic1 instances

2021-10-12 Thread Fumiaki Kinoshita
I was hacking GHC to see if it's able to derive Generic1 instance for datatypes with kind (Type -> Type) -> Type by omitting some checks. I noticed that the type parameter is substituted by GHC.Types.Any, preventing higher-kinded instances from typechecking. I found a comment implying that this is