<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div></div><div>Another use:</div><div><br></div><div>class Foo a e | a -> e where</div><div> foo :: a -> Either e a</div><div><br></div><div>instance Foo Int Void where</div><div> foo :: Int -> Either Void Int</div><div> foo x = Right (x + 1)</div><div><br></div><div>Even though it's an "Either", we're saying we will never (ignoring bottom) return a "Left" value.</div><div><br></div><div>Tom</div><div><br></div><div><br>El 12 ago 2016, a las 11:28, Michael Burge <<a href="mailto:michaelburge@pobox.com">michaelburge@pobox.com</a>> escribió:<br><br></div><blockquote type="cite"><div><div dir="ltr">One use is when you want an open sum type rather than a closed one. For example, you might want users of your library to add their own 'constructors'. Then, they serve a purpose similar to a constructor that takes no arguments:<div><font face="monospace, monospace"><br></font></div><div><div><font face="monospace, monospace">{-# LANGUAGE EmptyDataDecls #-}</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">class Color a where</font></div><div><font face="monospace, monospace"> rgb :: a -> (Int, Int, Int)</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">data Red</font></div><div><font face="monospace, monospace">data Green</font></div><div><font face="monospace, monospace">data Blue</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">instance Color Red where</font></div><div><font face="monospace, monospace"> rgb _ = (255, 0, 0)</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">instance Color Green where</font></div><div><font face="monospace, monospace"> rgb _ = (0, 255, 0)</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">instance Color Blue where</font></div><div><font face="monospace, monospace"> rgb _ = (0, 0, 255)</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">data ColorADT = Color_Red | Color_Green | Color_Blue</font></div><div><font face="monospace, monospace">rgb_adt Color_Red = (255, 0, 0)</font></div><div><font face="monospace, monospace">rgb_adt Color_Green = (0, 255, 0)</font></div><div><font face="monospace, monospace">rgb_adt Color_Blue = (0, 0, 255)</font></div><div><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Aug 12, 2016 at 8:16 AM, James Brown <span dir="ltr"><<a href="mailto:james.brown5374@gmail.com" target="_blank">james.brown5374@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">What's the purpose to a<span style="color:rgb(0,0,0);font-family:Verdana,Arial,"Bitstream Vera Sans",Helvetica,sans-serif;font-size:13px">llow data declarations with no constructors?</span></div><div class="gmail_extra"><br><div class="gmail_quote"><span class="">On Fri, Aug 12, 2016 at 11:08 AM, Sergey N. Yashin <span dir="ltr"><<a href="mailto:yashin.sergey@gmail.com" target="_blank">yashin.sergey@gmail.com</a>></span> wrote:<br></span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><div dir="ltr">For zero data constructors you need to use only <a href="https://prime.haskell.org/wiki/EmptyDataDecls" target="_blank">EmptyDataDecls</a> extension.<br></div><br></span><span class="">______________________________<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-bi<wbr>n/mailman/listinfo/haskell-caf<wbr>e</a><br>
Only members subscribed via the mailman list are allowed to post.<br></span></blockquote></div><br></div>
<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>
</div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>Haskell-Cafe mailing list</span><br><span>To (un)subscribe, modify options or view archives go to:</span><br><span><a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a></span><br><span>Only members subscribed via the mailman list are allowed to post.</span></div></blockquote></body></html>