`showAreaOfCircle 12.3`

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

my solution is:
showAreaOfCircle :: Show a => a -> String showAreaOfCircle x = "The area of a circle with radius" ++ show x ++ "is about" ++ " " + show(pi * x * x) ++ "cm^2"
but there is an error
• Could not deduce (Num a) arising from a use of ‘*’
from the context: Show a
bound by the type signature for:
showAreaOfCircle :: forall a. Show a => a -> String
at FirstStep.hs:20:1-41
Possible fix:
add (Num a) to the context of
the type signature for:
showAreaOfCircle :: forall a. Show a => a -> String
• In the first argument of ‘show’, namely ‘(pi * x * x)’
In the second argument of ‘(+)’, namely ‘show (pi * x * x)’
In the second argument of ‘(++)’, namely ‘" " + show (pi * x * x)’
I had tried to change the type declaration to
Show a => Num a => a -> String
i guess there must be a problem with pi.
Can someone help me with the error message? Great thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: `showAreaOfCircle 12.3`

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

>
> my solution is:
>
> showAreaOfCircle :: Show a => a -> String
> showAreaOfCircle x = "The area of a circle with radius" ++ show x ++ "is about" ++ " " + show(pi * x * x) ++ "cm^2"
>
> but there is an error
>
> • Could not deduce (Num a) arising from a use of ‘*’
> from the context: Show a
> bound by the type signature for:
> showAreaOfCircle :: forall a. Show a => a -> String
> at FirstStep.hs:20:1-41
> Possible fix:
> add (Num a) to the context of
> the type signature for:
> showAreaOfCircle :: forall a. Show a => a -> String
> • In the first argument of ‘show’, namely ‘(pi * x * x)’
> In the second argument of ‘(+)’, namely ‘show (pi * x * x)’
> In the second argument of ‘(++)’, namely ‘" " + show (pi * x * x)’
>
> I had tried to change the type declaration to
>
> Show a => Num a => a -> String
>
> i guess there must be a problem with pi.
>
> Can someone help me with the error message? Great thanks
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: `showAreaOfCircle 12.3`

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

>
> my solution is:
>
> showAreaOfCircle :: Show a => a -> String
> showAreaOfCircle x = "The area of a circle with radius" ++ show x ++ "is about" ++ " " + show(pi * x * x) ++ "cm^2"
>
> but there is an error
>
> • Could not deduce (Num a) arising from a use of ‘*’
> from the context: Show a
> bound by the type signature for:
> showAreaOfCircle :: forall a. Show a => a -> String
> at FirstStep.hs:20:1-41
> Possible fix:
> add (Num a) to the context of
> the type signature for:
> showAreaOfCircle :: forall a. Show a => a -> String
> • In the first argument of ‘show’, namely ‘(pi * x * x)’
> In the second argument of ‘(+)’, namely ‘show (pi * x * x)’
> In the second argument of ‘(++)’, namely ‘" " + show (pi * x * x)’
>
> I had tried to change the type declaration to
>
> Show a => Num a => a -> String
>
> i guess there must be a problem with pi.
>
> Can someone help me with the error message? Great thanks
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
>
--
Beauty of style and harmony and grace and good rhythm depend on simplicity.
- Plato
-------------- next part --------------
An HTML attachment was scrubbed...
URL: `showAreaOfCircle 12.3`

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

my solution is:
showAreaOfCircle :: Show a => a -> String showAreaOfCircle x = "The area of a circle with radius" ++ show x ++ "is about" ++ " " + show(pi * x * x) ++ "cm^2"
but there is an error
• Could not deduce (Num a) arising from a use of ‘*’
from the context: Show a
bound by the type signature for:
showAreaOfCircle :: forall a. Show a => a -> String
at FirstStep.hs:20:1-41
Possible fix:
add (Num a) to the context of
the type signature for:
showAreaOfCircle :: forall a. Show a => a -> String
• In the first argument of ‘show’, namely ‘(pi * x * x)’
In the second argument of ‘(+)’, namely ‘show (pi * x * x)’
In the second argument of ‘(++)’, namely ‘" " + show (pi * x * x)’
I had tried to change the type declaration to
Show a => Num a => a -> String
i guess there must be a problem with pi.
Can someone help me with the error message? Great thanks
_______________________________________________
Beginners mailing list
Beginners at haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
--
Beauty of style and harmony and grace and good rhythm depend on simplicity. - Plato
-------------- next part --------------
An HTML attachment was scrubbed...
URL: