<div dir="ltr">Hi Andreas,<br><br>No, GHC.Generics doesn't support existentials. <br><br>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:<br><br><blockquote style="margin:0 0 0 40px;border:none;padding:0px">Alexey Rodriguez Yakushev and Johan Jeuring.<div><a href="http://www.cs.uu.nl/research/techreps/UU-CS-2009-017.html">Enumerating Well-Typed Terms Generically.</a></div><div>In Proceedings workshop on Approaches and Applications of Inductive Programming 2009.</div><div>(This reference seems to be missing its references. You could also look at Chapter 5 of <a href="file:///C:/Users/Dreixel/Desktop/rodriguez.pdf">Alexey's thesis</a>.)</div></blockquote><div><br>If your existentials are used only as indices, then you could look at this:<br><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div>José Pedro Magalhães and Johan Jeuring.</div><div><a href="http://dreixel.net/research/pdf/gpid.pdf">Generic Programming for Indexed Datatypes.</a></div><div>In Proceedings of the 7th ACM SIGPLAN Workshop on Generic Programming (WGP'11), pp. 37–46, ACM, 2011.</div><div>(Chapter 10 of <a href="http://dreixel.net/index.php?content=thesis">my thesis</a> has a more up-to-date version.)</div></blockquote><div><br><br>Cheers,<br>Pedro<br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Jun 6, 2015 at 2:41 PM, Andreas Abel <span dir="ltr"><<a href="mailto:andreas.abel@ifi.lmu.de" target="_blank">andreas.abel@ifi.lmu.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I wonder whether GHC.Generics supports existential types yet...<br>
<br>
{-# LANGUAGE DeriveGeneric #-}<br>
{-# LANGUAGE ExistentialQuantification #-}<br>
{-# LANGUAGE StandaloneDeriving #-}<br>
<br>
import GHC.Generics<br>
<br>
data U = forall a. (Generic a) => U a<br>
  -- deriving (Generic)<br>
    -- Can't make a derived instance of ‘Generic U’:<br>
    --   Constructor ‘U’ has existentials or constraints in its type<br>
    --   Possible fix: use a standalone deriving declaration instead<br>
<br>
-- deriving instance Generic U<br>
    -- Can't make a derived instance of ‘Generic U’:<br>
    --   U must be a vanilla data constructor<br>
    -- In the stand-alone deriving instance for ‘Generic U’<br>
<br>
data D1Ser<br>
data C1_0Ser<br>
<br>
instance Generic U where<br>
  type Rep U = D D1Ser (C1 C1_0Ser (S1 NoSelector (Rep a)))<br>
    -- Not in scope: type variable ‘a’<br>
<br>
-- How to bring the existential type `a' into scope?<span class="HOEnZb"><font color="#888888"><br>
<br>
-- <br>
Andreas Abel  <><      Du bist der geliebte Mensch.<br>
<br>
Department of Computer Science and Engineering<br>
Chalmers and Gothenburg University, Sweden<br>
<br>
<a href="mailto:andreas.abel@gu.se" target="_blank">andreas.abel@gu.se</a><br>
<a href="http://www2.tcs.ifi.lmu.de/~abel/" target="_blank">http://www2.tcs.ifi.lmu.de/~abel/</a><br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org" target="_blank">Haskell-Cafe@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
</font></span></blockquote></div><br></div>