circleArea is function to calculate the area of a circle given the radius r:
circleArea r = r^2 * pi
However, adding the type signature circleArea :: Num a => a -> a causes this error:
* Could not deduce (Floating a) arising from a use of `pi'
from the context: Num a
bound by the type signature for:
circleArea :: forall a. Num a => a -> a
Possible fix:
add (Floating a) to the context of
the type signature for:
circleArea :: forall a. Num a => a -> a
* In the second argument of `(*)', namely `pi'
In the expression: r * r * pi
In an equation for `circleArea': circleArea r = r * r * pi
Using circleArea :: Floating a => a -> a, as suggested, resolves the issue.
I'm running this on repl.it.
Why isn't Num a valid typeclass here? pi has a type of Floating a -> a, isn't pi a Num as well?