<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-GB" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:#1F497D;mso-fareast-language:EN-US">Iavor<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:#1F497D;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:#1F497D;mso-fareast-language:EN-US">Shouldn’t (+) be a closed type family (now that we have such things)?  Then the user couldn’t give new instances.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:#1F497D;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:#1F497D;mso-fareast-language:EN-US">Simon<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:#1F497D;mso-fareast-language:EN-US"><o:p> </o:p></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:haskell-cafe-bounces@haskell.org]
<b>On Behalf Of </b>Iavor Diatchki<br>
<b>Sent:</b> 29 December 2013 18:30<br>
<b>To:</b> oleg@okmij.org<br>
<b>Cc:</b> Haskell Cafe<br>
<b>Subject:</b> Re: [Haskell-cafe] Consistency issue with type level numeric literals<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">Hi Oleg,<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></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.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Happy holidays,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">-Iavor<o:p></o:p></p>
</div>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><o:p> </o:p></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:<o:p></o:p></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">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><o:p></o:p></p>
</blockquote>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
</body>
</html>