
You could consider the 'linear' package [1]. Any type that is an instance
of the Linear.V2.R2 class could be considered to be a point on a 2D plane.
Adding and subtracting vectors can be achieved using the
Linear.Vector.Additive class.
Linear.Metric.Metric has dot product and length of vectors.
The Linear.Matrix module can be used for transformations. Combining
transformations is just matrix multiplication.
I'm quite happy with the 'linear' package as a whole, but it could use more
documentation showing simple operations. Its abstact nature can be a bit
daunting.
1 - https://hackage.haskell.org/package/linear
2016-02-12 16:45 GMT+01:00 Christopher Howard
Hi. What I'd like to have for a program I am working on is a generic typeclass for objects that can be treated like points on a 2D plane, and a few simple transform functions (e.g., addition, rotation around an origin) which I could combine to make more complex transformations. Of course, it would be trivial to do this myself, but it seems like the sort of thing somebody would have thought of already. Does anybody know of a package providing this? (I didn't see an obvious one when searching with hoogle.)