<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 class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">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.</blockquote></div><br></div>