Lysxia / generic-data

Generic data types in Haskell, utilities for GHC.Generics
https://hackage.haskell.org/package/generic-data
MIT License
44 stars 9 forks source link

Incorrect instance of GShowSingle for (f :.: g) #16

Closed anka-213 closed 5 years ago

anka-213 commented 5 years ago

The left parameter (f) in f :.: g is not a generic representation, but a plain representation. Only the right parameter is a Generic representation. See example here.

The instance

instance (GShowSingle Identity f, GShowSingle p g)
  => GShowSingle p (f :.: g) where
  ...

should instead be

instance (Show1 f, GShowSingle p g)
  => GShowSingle p (f :.: g) where
  ...

similarly to the instance for Rec1 f.


A simple example of this would be trying to derive Show1 for a type equivalent to Compose.

newtype MyCompose f g a = MyCompose (f (g a))
  deriving Generic1
  deriving Show1 via Generically1 (MyCompose f g)

gives the error

    * Could not deduce (Generic.Data.Internal.Show.GShowSingle
                          Data.Functor.Identity.Identity f)
        arising from the 'deriving' clause of a data type 
declaration
      from the context: Show1 g
Lysxia commented 5 years ago

whoops. Thanks for catching this!

Lysxia commented 5 years ago

Fixed by 1bd6cfd4c379097d5554253fccc1b31a20fe85e7 Released in 0.6.0.1. Thanks again!