<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>How about this:</div><div><br></div><div><div></div></div><blockquote type="cite"><div><div>class (a x, b x) => (a `And` b) x</div><div>instance (a x, b x) => (a `And` b) x</div><div>infixr 3 `And`</div><div><br></div><div>data S c e where</div><div> SC :: c d => d -> e -> S c e</div><div><br></div><div>foo :: S (Show `And` Read `And` Num) Int</div><div>foo = SC (5.0 :: Double) (6 :: Int)</div></div></blockquote><div><br></div><div>Richard</div><br><div><div>On Jun 19, 2015, at 4:13 PM, Leza Morais Lutonda <<a href="mailto:leza.ml@fecrd.cujae.edu.cu">leza.ml@fecrd.cujae.edu.cu</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<div text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">On 06/19/2015 08:44 AM, Sean Leather
wrote:<br>
</div>
<blockquote cite="mid:CACz_ru0o48s4xc6EnriKdg5M_4L0S-5vKUHGj0JAd8X4DkPNPg@mail.gmail.com" type="cite">
<div>Note this won't work for a <font face="monospace, monospace">Num</font> instance
mentioned earlier because the existentially quantified <font face="monospace, monospace">d</font> types in two <font face="monospace, monospace">SC</font> values are not provably
the same type. In other words, you can't write</div>
<div><br>
</div>
<div>
<div><font face="monospace, monospace">instance Num e => Show
(S Num e) where</font></div>
<div><font face="monospace, monospace"> SC x1 y1 + SC x2 y2 =
SC (x1 + x2) (y1 + y2)</font></div>
</div>
<div><br>
</div>
<div>because <font face="monospace, monospace">x1</font> and <font face="monospace, monospace">x2</font> can have different
types.</div>
</blockquote>
Another issue is: what if I want to constraint the type `e` to more
classes and make `d` to have the same constrains? I have to
re-declare the `S` data type like?:<br>
<br>
<pre>data S c1 c2 ... cN e where</pre>
<pre> SC :: (c1 d, c2 d, ..., cN d) -> d -> e -> S c1 c2 ... cN e</pre>
<br>
Does anyone ever needed such a feature?<br>
<pre class="moz-signature" cols="72">--
Leza Morais Lutonda, Lemol-C
<a class="moz-txt-link-freetext" href="http://lemol.github.io/">http://lemol.github.io</a></pre>
</div>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<div><p>
50 Aniversario de la Cujae. Inaugurada por Fidel el 2 de diciembre de 1964 <a href="http://cujae.edu.cu/"> http://cujae.edu.cu </a>
</p>
<br>
<img src="x-msg://77/etc/postfix/correo50.gif">
</div>
_______________________________________________<br>Haskell-Cafe mailing list<br><a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe<br></blockquote></div><br></body></html>