[Haskell-cafe] Types depending on tuples.

Mike Izbicki mike at izbicki.me
Tue Aug 26 07:59:24 UTC 2014


You never actually provided the Vector type class, so it's difficult
to tell what exactly you're trying to do.

On Tue, Aug 26, 2014 at 12:46 AM, Mike Meyer <mwm at mired.org> wrote:
> 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:
>
> type Vector2d = (Double, Double)
> type Vector3d = (Double, Double, Double)
>
> I've also got a typeclass Vector so I can do polymorphic things on them:
>
> type Vector3d = (Double, Double, Double)
>
> (Ok, polymorphic thing).
>
> 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.
>
> 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]'.
>
> Can I declare this typeclass?
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>


More information about the Haskell-Cafe mailing list