Using:
{-# LANGUAGE GADTs #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE DeriveDataTypeable #-}
And given the following datatype:
data Event a where
PureE :: a -> Event a
MapE :: (a -> b) -> Event a -> Event b
deriving instance Typeable Event
deriving instance Data a => Data (Event a)
My goal is to use the uniplate package which requires the Data instance.
Is GHC able to derive Typeable and Data automatically? Since 7.8 GHC should be able to do so and afaik at least for Typeable it is mandatory.
I could probably write my own Data instance ... but why do if GHC can just derive it for me?
This seems to work with GHC 8.10.7:
The trick is the quantified constraint
(forall b. Data b) => ..., which allows GHC to instantiateData bfor any typebon-demand. It's like a "local instance declaration."