이 같은 고정 된 크기의 벡터를 쓰기 위해 노력하고있어 고정 비교는 크기 벡터
Could not deduce (n2 ~ n1)
from the context (Eq a)
bound by the instance declaration at prog.hs:8:10-33
or from (n ~ (n1 + 1))
bound by a pattern with constructor
Cons :: forall a (n :: Nat). a -> NVector n a -> NVector (n + 1) a,
in an equation for `=='
at prog.hs:10:6-14
or from (n ~ (n2 + 1))
bound by a pattern with constructor
Cons :: forall a (n :: Nat). a -> NVector n a -> NVector (n + 1) a,
in an equation for `=='
at prog.hs:10:21-29
하지만을 나는 타입 수준을 소개하면 원주민 수동 성공적
{-# LANGUAGE GADTs, DataKinds, KindSignatures, TypeOperators, TypeFamilies #-}
data Nat = Z | S Nat
infixl 6 :+
type family (n :: Nat) :+ (m :: Nat) :: Nat
type instance Z :+ m = m
type instance (S n) :+ m = S (n :+ m)
data NVector (n :: Nat) a where
Nil :: NVector Z a
Cons :: a -> NVector n a -> NVector (S n) a
instance (Eq a) => Eq (NVector n a) where
Nil == Nil = True
(Cons x xs) == (Cons y ys) = x == y && xs == ys
GHC 버전 7.8.3
컴파일 0