[Haskell-beginners] A question regarding the syntax behind the parenthesis and type class.

清羽 1625143974 at qq.com
Wed Apr 4 14:08:04 UTC 2018

this is the original question:

Write a function showAreaOfCircle which, given the radius of a circle, calculates the area of the circle,

showAreaOfCircle 12.3  ⇒ "The area of a circle with radius 12.3cm is about  475.2915525615999 cm^2"

Use the show function, as well as the predefined value pi :: Floating a => a to write showAreaOfCircle.

the type signature works for this function is: showAreaOfCircle :: (Show a, Floating a) => a -> a -> String

my question is : I don't quite understand the syntax behind the parenthesis and the type class Floating a. Since pi is not a function, and hence the entire function only takes one argument which belongs to the type class Show, why should i put a Floating a in the type signature in the first place?(i come up with this type signature because of the error message and the suggestion stated above) Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20180404/a9509ebf/attachment.html>

More information about the Beginners mailing list