Deriving Data for poly-kinded datatypes

2017-02-23 Thread Ryan Scott
Hi Pedro, I'm quite confused by a peculiarity of deriving Data (more info in Trac #13327 [1]). In particular, if you write this: data T phantom = T deriving Data Then the derived Data instance is NOT this: instance Typeable phantom => Data (T phantom) where ... But instead,

Re: Deriving Data for poly-kinded datatypes

2017-02-23 Thread José Pedro Magalhães
Hi Ryan, I can't recall any particular reason to avoid including dataCast1 in the Data instance for poly-kinded datatypes. Have you tried applying the example in #4028 to a poly-kinded datatype? It might be that it was done simply to avoid forcing the kind of the parameter to be *, and hence losin

Re: Deriving Data for poly-kinded datatypes

2017-02-23 Thread Edward Kmett
Some thoughts on the topic: admittedly, probably not very useful. A couple of obvious statements: 1) gcast1 itself operationally makes sense regardless of the kind of the argument you're skipping past. gcast1 :: forall c t t' a. (Typeable t, Typeable t') => c (t a) -> Maybe (c (t' a)) This i

Datacon RULES test

2017-02-23 Thread David Feuer
For good or ill, Simon doesn't want RULES for datacons. T12689 has to be removed (leaving T12689a, which is still fine). But I don't know enough about what you're doing with T12689broken to know how to make it express the right idea after this change. Can you please advise? Thanks, David Feuer

Re: Deriving Data for poly-kinded datatypes

2017-02-23 Thread Ryan Scott
> Supplying the default shouldn't lock our data instance to the form T a. If > for some reason adding this default would break the instance We can make a > more interesting default that does something like look at the kind of the > argument first to determine if it is kind * before proceeding af

Re: Deriving Data for poly-kinded datatypes

2017-02-23 Thread Edward Kmett
That is a right mess. I've now stepped a bit outside of what I think is a practical recommendation, but let's just keep playing for the fun of it. This is going to be hard to do without access to GHC at the moment but here goes: If phantom was of kind * then dataCast1 would need the (Data phanto