Hi Andreas,

No, GHC.Generics doesn't support existentials.

If your existentials are used as arguments to constructors (like in the example you've provided), the only approach I'm aware of that might help you is this:

Alexey Rodriguez Yakushev and Johan Jeuring.
Enumerating Well-Typed Terms Generically.
In Proceedings workshop on Approaches and Applications of Inductive Programming 2009.
(This reference seems to be missing its references. You could also look at Chapter 5 of Alexey's thesis.)

If your existentials are used only as indices, then you could look at this:

José Pedro Magalhães and Johan Jeuring.
Generic Programming for Indexed Datatypes.
In Proceedings of the 7th ACM SIGPLAN Workshop on Generic Programming (WGP'11), pp. 37–46, ACM, 2011.
(Chapter 10 of my thesis has a more up-to-date version.)


Cheers,
Pedro

On Sat, Jun 6, 2015 at 2:41 PM, Andreas Abel <andreas.abel@ifi.lmu.de> wrote:
I wonder whether GHC.Generics supports existential types yet...

{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE StandaloneDeriving #-}

import GHC.Generics

data U = forall a. (Generic a) => U a
  -- deriving (Generic)
    -- Can't make a derived instance of ‘Generic U’:
    --   Constructor ‘U’ has existentials or constraints in its type
    --   Possible fix: use a standalone deriving declaration instead

-- deriving instance Generic U
    -- Can't make a derived instance of ‘Generic U’:
    --   U must be a vanilla data constructor
    -- In the stand-alone deriving instance for ‘Generic U’

data D1Ser
data C1_0Ser

instance Generic U where
  type Rep U = D D1Ser (C1 C1_0Ser (S1 NoSelector (Rep a)))
    -- Not in scope: type variable ‘a’

-- How to bring the existential type `a' into scope?

--
Andreas Abel  <><      Du bist der geliebte Mensch.

Department of Computer Science and Engineering
Chalmers and Gothenburg University, Sweden

andreas.abel@gu.se
http://www2.tcs.ifi.lmu.de/~abel/
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe