<html><head></head><body><div>Hi!</div><div><br></div><div>I must say that I do not really understand this, but I nevertheless doubt that it solves my problem. In your code, you are already starting with the value <font face="monospace">IsListType</font> whose type you specify as <font face="monospace">[a]</font>. In this case, there is nothing to find out about the element type; you already know that it is <font face="monospace">a</font>. My situation is that I have some type <font face="monospace">l</font> and a value <font face="monospace">p :: IsListType l</font>. A successful match of <font face="monospace">p</font> against the pattern <font face="monospace">IsListType</font> tells me that there is an <font face="monospace">a</font> with <font face="monospace">l ~ [a]</font>. However, I cannot refer to this <font face="monospace">a</font>.</div><div><br></div><div>All the best,</div><div>Wolfgang</div><div><br></div><div>Am Donnerstag, den 10.08.2017, 16:35 -0700 schrieb Michael Burge:</div><blockquote type="cite"><div dir="ltr"><div><font face="arial, helvetica, sans-serif">Could something like this work for you? Here, a ~ b and you have access to b:</font></div><div><font face="monospace, monospace"><br></font></div><font face="monospace, monospace">case (IsListType :: IsListType [a], Proxy :: Proxy a) of</font><div><font face="monospace, monospace">    (_, proxy :: Proxy b) -> asProxyTypeOf undefined proxy :: b</font><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Aug 10, 2017 at 4:16 PM, Wolfgang Jeltsch <span dir="ltr"><<a href="mailto:wolfgang-it@jeltsch.info" target="_blank">wolfgang-it@jeltsch.info</a>></span> wrote:<br><blockquote type="cite">Hi!<br>
<br>
GHC has some support for referring to existentially quantified type<br>
variables. For example, consider the following definition:<br>
<br>
> data SomeList = forall a . SomeList [a]<br>
<br>
With the ScopedTypeVariables extension, you can get hold of the concrete<br>
type a used in a SomeList value:<br>
<br>
> f :: SomeList -> SomeList<br>
> f (SomeList [x :: a]) = SomeList xs where<br>
><br>
>     xs :: [a]<br>
>     xs = [x, x]<br>
<br>
However, this approach does not work if there are no fields whose type<br>
involves the existentially quantified type variable. Consider, for<br>
example, the following definition:<br>
<br>
> data IsListType a where<br>
><br>
>     IsListType :: IsListType [b]<br>
<br>
For each type T, we can match a value of type IsListType T against the<br>
pattern IsListType. If this succeeds, we know that T is a list type, but<br>
we do not have access to the respective element type.<br>
<br>
Is there a way to determine existentially quantified type variables like<br>
the b in the above example?<br>
<br>
All the best,<br>
Wolfgang<br>
______________________________<wbr>_________________<br>
Haskell-Cafe mailing list<br>
To (un)subscribe, modify options or view archives go to:<br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-<wbr>bin/mailman/listinfo/haskell-<wbr>cafe</a><br>
Only members subscribed via the mailman list are allowed to post.<br></blockquote></div><br></div>
</blockquote></body></html>