<p dir="ltr">Hello,</p>
<p dir="ltr">Yep, in 7.8 these are actually built-in constructors (which are not open families) so if you try to define a custom instance you get an error about an illegal instance for a closed type family.</p>
<p dir="ltr">Happy new year!<br>
Iavor</p>
<div class="gmail_quote">On Dec 30, 2013 6:23 AM, "Simon Peyton-Jones" <<a href="mailto:simonpj@microsoft.com">simonpj@microsoft.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">






<div lang="EN-GB" link="blue" vlink="purple">
<div>
<p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:#1f497d">Iavor<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:#1f497d">Shouldn’t (+) be a closed type family (now that we have such things)?  Then the user couldn’t give new instances.<u></u><u></u></span></p>

<p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:#1f497d">Simon<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><b><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif"">From:</span></b><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif""> Haskell-Cafe [mailto:<a href="mailto:haskell-cafe-bounces@haskell.org" target="_blank">haskell-cafe-bounces@haskell.org</a>]
<b>On Behalf Of </b>Iavor Diatchki<br>
<b>Sent:</b> 29 December 2013 18:30<br>
<b>To:</b> <a href="mailto:oleg@okmij.org" target="_blank">oleg@okmij.org</a><br>
<b>Cc:</b> Haskell Cafe<br>
<b>Subject:</b> Re: [Haskell-cafe] Consistency issue with type level numeric literals<u></u><u></u></span></p>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal">Hi Oleg,<u></u><u></u></p>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">yes, this is a bug, you are not supposed to define custom instances for the built-in operators.  I just left it open until we hook in the solver.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">Happy holidays,<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">-Iavor<u></u><u></u></p>
</div>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><u></u> <u></u></p>
<div>
<p class="MsoNormal">On Sat, Dec 28, 2013 at 12:54 AM, <<a href="mailto:oleg@okmij.org" target="_blank">oleg@okmij.org</a>> wrote:<u></u><u></u></p>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<p class="MsoNormal"><br>
GHC 7.6.3 has quite convenient type-level numeric literals. We can use<br>
numbers like 1 and 2 in types. However, using the type level numeral<br>
has been quite a bit of a challenge, illustrated, for example, by<br>
the following SO question.<br>
<br>
<a href="http://stackoverflow.com/questions/20809998/type-level-nats-with-literals-and-an-injective-successor" target="_blank">http://stackoverflow.com/questions/20809998/type-level-nats-with-literals-and-an-injective-successor</a><br>

<br>
It seems the challenge has the reason: the type level numerals and<br>
their operations provided in GHC.TypeLits have a consistency<br>
issue. The following code demonstrates the issue: it constructs two<br>
distinct values of the type Sing 2. Singletons aren't singletons.<br>
<br>
{-# LANGUAGE KindSignatures #-}<br>
{-# LANGUAGE DataKinds #-}<br>
{-# LANGUAGE ScopedTypeVariables #-}<br>
{-# LANGUAGE TypeOperators #-}<br>
{-# LANGUAGE TypeFamilies #-}<br>
{-# LANGUAGE GADTs #-}<br>
{-# LANGUAGE PolyKinds #-}<br>
<br>
module NotSing where<br>
<br>
import GHC.TypeLits<br>
<br>
-- GHC strangely enough lets us define instances for (+)<br>
type instance 1 + 1 = 0<br>
type instance 0 + 1 = 2<br>
<br>
-- A singular representative of 1::Nat<br>
s1 :: Sing 1<br>
s1 = withSing id<br>
<br>
-- A singular representative of 2::Nat<br>
s2 :: Sing 2<br>
s2 = withSing id<br>
<br>
is2 :: IsZero 0<br>
is2 = IsSucc s1<br>
<br>
tran :: IsZero 0 -> Sing 2<br>
tran (IsSucc x) = case isZero x of<br>
                   IsSucc y -> case isZero y of<br>
                                IsZero -> x<br>
<br>
-- Another singular representative of 2::Nat<br>
-- A singular representative of 2::Nat<br>
s2' :: Sing 2<br>
s2' = tran is2<br>
<br>
<br>
{-<br>
*NotSing> s2<br>
2<br>
*NotSing> s2'<br>
1<br>
-}<br>
<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://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><u></u><u></u></p>
</blockquote>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div>
</div>

</blockquote></div>