<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">Hello,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">working through <o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">https://www.fpcomplete.com/user/konn/prove-your-haskell-for-great-safety/dependent-types-in-haskell<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">but a bit stuck...with an error...<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">> {-# LANGUAGE DataKinds, TypeFamilies, TypeOperators, UndecidableInstances, GADTs, StandaloneDeriving #-}<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">> data Nat = Z | S Nat<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">> data Vector a n where<o:p></o:p></p>
<p class="MsoNormal">>   Nil  :: Vector a Z<o:p></o:p></p>
<p class="MsoNormal">>   (:-) :: a -> Vector a n -> Vector a (S n)<o:p></o:p></p>
<p class="MsoNormal">> infixr 5 :-<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I assume init...is a bit like tail but take n - 1 elements from the front....but...<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">> init' :: Vector a ('S n) -> Vector a n<o:p></o:p></p>
<p class="MsoNormal">> init' (x1 :- Nil) = Nil<o:p></o:p></p>
<p class="MsoNormal">> init' (x :- xs) = x :- (init' xs) <o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">gives...(I could do with working out what haskell is tryign to tell me).<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Could not deduce (n1 ~ 'S n0)<o:p></o:p></p>
<p class="MsoNormal">    from the context ('S n ~ 'S n1)<o:p></o:p></p>
<p class="MsoNormal">      bound by a pattern with constructor<o:p></o:p></p>
<p class="MsoNormal">                 :- :: forall a (n :: Nat). a -> Vector a n -> Vector a ('S n),<o:p></o:p></p>
<p class="MsoNormal">               in an equation for ‘init'’<o:p></o:p></p>
<p class="MsoNormal">      at cafe.lhs:13:10-16<o:p></o:p></p>
<p class="MsoNormal">      ‘n1’ is a rigid type variable bound by<o:p></o:p></p>
<p class="MsoNormal">           a pattern with constructor<o:p></o:p></p>
<p class="MsoNormal">             :- :: forall a (n :: Nat). a -> Vector a n -> Vector a ('S n),<o:p></o:p></p>
<p class="MsoNormal">           in an equation for ‘init'’<o:p></o:p></p>
<p class="MsoNormal">           at cafe.lhs:13:10<o:p></o:p></p>
<p class="MsoNormal">    Expected type: Vector a n<o:p></o:p></p>
<p class="MsoNormal">      Actual type: Vector a ('S n0)<o:p></o:p></p>
<p class="MsoNormal">    Relevant bindings include<o:p></o:p></p>
<p class="MsoNormal">      xs :: Vector a n1 (bound at cafe.lhs:13:15)<o:p></o:p></p>
<p class="MsoNormal">    In the expression: x :- (init' xs)<o:p></o:p></p>
<p class="MsoNormal">    In an equation for ‘init'’: init' (x :- xs) = x :- (init' xs)<o:p></o:p></p>
<p class="MsoNormal"><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">the ":-" in "init' (x :- xs)"<o:p></o:p></p>
<p class="MsoNormal">has type <o:p></o:p></p>
<p class="MsoNormal">forall a (n :: Nat). a -> Vector a n -> Vector a ('S n)<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">yep that makes sense....<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">if it knew "n ~ n1" then it knows "n1 ~ 'S n0"<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">so it would know "n ~ 'S n0"<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">but it only knows "'S n ~ 'S n1"<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">hmmmm...surely from the def of Nat, thats "obvious"<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<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>