10 May 05:39 2013

## Flip around type parameters?

Christopher Howard <christopher.howard <at> frigidcode.com>

2013-05-10 03:39:12 GMT

2013-05-10 03:39:12 GMT

Hi. Does Haskell allow you to flip around type parameters somehow? I was playing around with toy code (still learning the fundamentals) and I came up with a class like this: code: -------- class Rotatable2D a where rotate :: (Num b) => (a b) -> b -> (a b) -------- It was easy to make an instance of a generic single-parameter type: code: -------- data Angle a = Angle a deriving (Show) instance Rotatable2D Angle where rotate (Angle a) b = Angle (a + b) -------- But let's say I have something a little more complicated: code: -------- data CircAppr a b = CircAppr a a b -- radius, rotation angle, number of points --------(Continue reading)