<div dir="ltr">I'm doing some geometry in 2 and 3 dimensions. To do this, I've got Vector2d and Vector3d classes, which are basically just wrappers around 2 and 3-tuples of doubles:<div><br></div><div><div><div>type Vector2d = (Double, Double)</div>
</div></div><div><div>type Vector3d = (Double, Double, Double)</div></div><div><br></div><div>I've also got a typeclass Vector so I can do polymorphic things on them:<br></div><div><br></div><div><div>type Vector3d = (Double, Double, Double)</div>
</div><div><br></div><div>(Ok, polymorphic thing).</div><div><div><br></div><div>I now have a need to convert lists of Vector's to a list of lists of Doubles. I'd like that to be part of the Vector typeclass, but - well, declaring it is interesting.</div>
</div><div><br></div><div>I can't just add a method "toLists :: a -> [Double]", because (according to ghc), there's no match between the expected type 'Double' and the actual type '[t1]'. </div>
<div><br></div><div>Can I declare this typeclass?</div></div>