Nicholls, Mark nicholls.mark at vimn.com
Mon Apr 27 11:52:53 UTC 2015

Hello,

working through

but a bit stuck...with an error...

> {-# LANGUAGE DataKinds, TypeFamilies, TypeOperators, UndecidableInstances, GADTs, StandaloneDeriving #-}

> data Nat = Z | S Nat

> data Vector a n where
>   Nil  :: Vector a Z
>   (:-) :: a -> Vector a n -> Vector a (S n)
> infixr 5 :-

I assume init...is a bit like tail but take n - 1 elements from the front....but...

> init' :: Vector a ('S n) -> Vector a n
> init' (x1 :- Nil) = Nil
> init' (x :- xs) = x :- (init' xs)

gives...(I could do with working out what haskell is tryign to tell me).

Could not deduce (n1 ~ 'S n0)
from the context ('S n ~ 'S n1)
bound by a pattern with constructor
:- :: forall a (n :: Nat). a -> Vector a n -> Vector a ('S n),
in an equation for 'init''
at cafe.lhs:13:10-16
'n1' is a rigid type variable bound by
a pattern with constructor
:- :: forall a (n :: Nat). a -> Vector a n -> Vector a ('S n),
in an equation for 'init''
at cafe.lhs:13:10
Expected type: Vector a n
Actual type: Vector a ('S n0)
Relevant bindings include
xs :: Vector a n1 (bound at cafe.lhs:13:15)
In the expression: x :- (init' xs)
In an equation for 'init'': init' (x :- xs) = x :- (init' xs)

so...
the ":-" in "init' (x :- xs)"
has type
forall a (n :: Nat). a -> Vector a n -> Vector a ('S n)

yep that makes sense....

if it knew "n ~ n1" then it knows "n1 ~ 'S n0"

so it would know "n ~ 'S n0"

but it only knows "'S n ~ 'S n1"

hmmmm...surely from the def of Nat, thats "obvious"

CONFIDENTIALITY NOTICE

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.

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.

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.

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.
-------------- next part --------------
An HTML attachment was scrubbed...