[Haskell-cafe] fromIntegral not enough?

Tom Ellis tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk
Tue May 14 00:53:49 CEST 2013


On Mon, May 13, 2013 at 11:43:41PM +0100, Tom Ellis wrote:
> On Mon, May 13, 2013 at 02:08:26PM -0800, Christopher Howard wrote:
> > 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...
> 
> Your definition of "angles" forces "dAng" to be of type "a".  Then in order
> to define "dAng" as the result of a "/" there must be a "Fractional" instance for
> "a".

You probably want

    let angles = map ((* dAng) . fromInteger) [0..divns] in
    ...

instead.



More information about the Haskell-Cafe mailing list