14 May 00:08 2013

## fromIntegral not enough?

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

2013-05-13 22:08:26 GMT

2013-05-13 22:08:26 GMT

This is probably a haskell-beginners sort of question, but I usually get about 4x as many responses from cafe, about 10x as fast. I have code like so: code: -------- data Xy a = Xy a a class Coord2 a where coords2 :: Fractional b => a b -> Xy b data CircAppr a b = CircAppr a b b -- number of points, rotation angle, radius deriving (Show) instance Integral a => Coord2 (CircAppr a) where coords2 (CircAppr divns ang rad) = let dAng = 2 * pi / (fromIntegral divns) in let angles = map (* dAng) [0..divns] in undefined -- To be coded... -------- In the instance definition divns is an integral trying to divide a fractional. I hoped wrapping it in fromIntegral would coerce, but apparently not: quote:(Continue reading)