Would like to declare
data (Coord a) => Triangle a = Triangle{t0 :: a, t1 :: a, t2 :: a}
However I am getting
Geometry.hs:15:19:Kind mis-match
Expected kind* -> *', butp’ has kind*'Coord’
In the class declaration for
where Coord is defined as
class (Traversable p, Functor p, Foldable p, Applicative p) => Coord p where
getComponents :: Num a => p a -> [a]
getComponents = toList
fromComponents :: Num a => [a] -> p a
magSq :: Num a => p a -> a
magSq = Prelude.sum . map (\x -> x * x) . getComponents
dotProduct :: Num a => p a -> p a -> a
dotProduct a b = Prelude.sum $ zipWith (*) (getComponents a) (getComponents b)
Any ideas?
PS. Code is a slightly modified version of what is found in the Data.SG package
This might work for you:
In short, a type that has the typeclass
Coordis a parameterized type. You have to supply the parameter.(The kind of a type tells you whether it has any parameters. Types of kind
*can have actual values. All other types are parameterized. Any type that has the typeclassCoordis of kind* -> *, which means it takes one argument of kind*.)