<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=us-ascii">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"MS Mincho";
        panose-1:2 2 6 9 4 2 5 8 3 4;}
@font-face
        {font-family:"MS Mincho";
        panose-1:2 2 6 9 4 2 5 8 3 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:"\@MS Mincho";
        panose-1:2 2 6 9 4 2 5 8 3 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-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;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
        {mso-style-priority:99;
        mso-style-link:"Balloon Text Char";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:8.0pt;
        font-family:"Tahoma","sans-serif";}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.BalloonTextChar
        {mso-style-name:"Balloon Text Char";
        mso-style-priority:99;
        mso-style-link:"Balloon Text";
        font-family:"Tahoma","sans-serif";}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";}
@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">Below is a very simple almost canonical natural number model.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I’m slightly confused by how type families work<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Wikipedia says….<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">“<span lang="EN">Type families are a feature of some <a href="https://en.wikipedia.org/wiki/Type_system" title="Type system">
type systems</a> that allow PARTIAL functions between types to be defined by <a href="https://en.wikipedia.org/wiki/Pattern_matching" title="Pattern matching">
pattern matching</a>”</span><o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">So…<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">> {-# LANGUAGE DataKinds #-}<o:p></o:p></p>
<p class="MsoNormal">> {-# LANGUAGE ExplicitForAll #-}<o:p></o:p></p>
<p class="MsoNormal">> {-# LANGUAGE FlexibleContexts #-}<o:p></o:p></p>
<p class="MsoNormal">> {-# LANGUAGE FlexibleInstances #-}<o:p></o:p></p>
<p class="MsoNormal">> {-# LANGUAGE GADTs #-}<o:p></o:p></p>
<p class="MsoNormal">> {-# LANGUAGE MultiParamTypeClasses #-}<o:p></o:p></p>
<p class="MsoNormal">> {-# LANGUAGE PolyKinds #-}<o:p></o:p></p>
<p class="MsoNormal">> {-# LANGUAGE StandaloneDeriving #-}<o:p></o:p></p>
<p class="MsoNormal">> {-# LANGUAGE TypeFamilies #-}<o:p></o:p></p>
<p class="MsoNormal">> {-# LANGUAGE TypeOperators #-}<o:p></o:p></p>
<p class="MsoNormal">> {-# LANGUAGE UndecidableInstances #-}<o:p></o:p></p>
<p class="MsoNormal">> {-# LANGUAGE ScopedTypeVariables #-}<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">lets do something simple<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">> data Z<o:p></o:p></p>
<p class="MsoNormal">> data S n<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">> type family Sub a b<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">> -- a - 0 == a<o:p></o:p></p>
<p class="MsoNormal">> type instance Sub a Z = a<o:p></o:p></p>
<p class="MsoNormal">> -- (a + 1) - (b + 1) == a - b<o:p></o:p></p>
<p class="MsoNormal">> type instance Sub (S a) (S b) = Sub a b<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">> oneMinusOne :: Z<o:p></o:p></p>
<p class="MsoNormal">> oneMinusOne = undefined :: Sub (S Z) (S Z)<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I want this to be a type error!...but the above type family appears to not be partial…this IS defined….”Sub Z (S Z)” is a type! (I thought it wasn’t)<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">> oneMinusTwo :: Sub Z (S Z)<o:p></o:p></p>
<p class="MsoNormal">> oneMinusTwo = undefined :: Sub (S Z) (S (S Z))<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<P></P>
<P><br><br>CONFIDENTIALITY NOTICE<br><br>This e-mail (and any attached files) is confidential and protected by copyright (and other intellectual property rights). If you are not the intended recipient please e-mail the sender and then delete the email and any attached files immediately. Any further use or dissemination is prohibited.<br><br>While MTV Networks Europe has taken steps to ensure that this email and any attachments are virus free, it is your responsibility to ensure that this message and any attachments are virus free and do not affect your systems / data.<br><br>Communicating by email is not 100% secure and carries risks such as delay, data corruption, non-delivery, wrongful interception and unauthorised amendment. If you communicate with us by e-mail, you acknowledge and assume these risks, and you agree to take appropriate measures to minimise these risks when e-mailing us.<br><br>MTV Networks International, MTV Networks UK & Ireland, Greenhouse, Nickelodeon Viacom Consumer Products, VBSi, Viacom Brand Solutions International, Be Viacom, Viacom International Media Networks and VIMN and Comedy Central are all trading names of MTV Networks Europe.  MTV Networks Europe is a partnership between MTV Networks Europe Inc. and Viacom Networks Europe Inc.  Address for service in Great Britain is 17-29 Hawley Crescent, London, NW1 8TT.<br></P></body>
</html>