<div dir="ltr"><div class="gmail_default" style="font-family:georgia,serif;font-size:small">You only have a single plus sign before the second invocation of show:</div><div class="gmail_default" style="font-family:georgia,serif;font-size:small"><br></div><div class="gmail_default" style="font-family:georgia,serif;font-size:small"><pre style="white-space:pre-wrap;color:rgb(51,51,51);font-size:13px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;word-spacing:0px;text-decoration-style:initial;text-decoration-color:initial;padding:9.5px;font-family:Monaco,Menlo,Consolas,"Courier New",monospace;border-radius:4px;margin-top:0px;margin-bottom:10px;line-height:20px;word-break:break-all;background-color:rgb(245,245,245);border:1px solid rgba(0,0,0,0.15)">++ " " + show(pi * x * x) ++ "cm^2"</pre>Don't you mean concatenation?</div><div class="gmail_default" style="font-family:georgia,serif;font-size:small"><br></div><div class="gmail_default" style="font-family:georgia,serif;font-size:small"><pre style="white-space:pre-wrap;color:rgb(51,51,51);font-size:13px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;word-spacing:0px;text-decoration-style:initial;text-decoration-color:initial;padding:9.5px;font-family:Monaco,Menlo,Consolas,"Courier New",monospace;border-radius:4px;margin-top:0px;margin-bottom:10px;line-height:20px;word-break:break-all;background-color:rgb(245,245,245);border:1px solid rgba(0,0,0,0.15)">++ " " ++ show(pi * x * x) ++ "cm^2"</pre><br></div><div class="gmail_default" style="font-family:georgia,serif;font-size:small">Good luck,</div><div class="gmail_default" style="font-family:georgia,serif;font-size:small">-jn-</div><div class="gmail_default" style="font-family:georgia,serif;font-size:small"><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Apr 4, 2018 at 1:37 AM, 清羽 <span dir="ltr"><<a href="mailto:1625143974@qq.com" target="_blank">1625143974@qq.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br><span style="color:rgb(72,74,76);font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:13px"></span><div class="m_6897951926248639574post_region_text" id="m_6897951926248639574questionText" style="margin:5px 0px;color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:13px"><p style="margin:0px 0px 2px;word-break:break-word;min-height:15px">here is the question:</p><p style="margin:0px 0px 2px;word-break:break-word;min-height:15px">Write a function <code style="padding:2px 4px;font-family:Monaco,Menlo,Consolas,'Courier New',monospace;font-size:12px;color:rgb(221,17,68);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;background-color:rgb(247,247,249);border:1px solid rgb(225,225,232)">showAreaOfCircle</code> <wbr>which, given the radius of a circle, calculates the area of the circle,</p><blockquote style="padding:0px 0px 0px 15px;margin:0px 0px 20px;border-left-width:5px;border-left-style:solid;border-left-color:rgb(238,238,238)"><pre style="padding:9.5px;font-family:Monaco,Menlo,Consolas,'Courier New',monospace;border-top-left-radius:4px;border-top-right-radius:4px;border-bottom-right-radius:4px;border-bottom-left-radius:4px;margin-top:0px;margin-bottom:10px;line-height:20px;word-break:break-all;background-color:rgb(245,245,245);border:1px solid rgba(0,0,0,0.14902)"><code>showAreaOfCircle 12.3</code>  ⇒ <code>"The area of a circle with radius 12.3cm is about 475.2915525615999 cm^2"</code></pre></blockquote><p style="margin:0px 0px 2px;word-break:break-word;min-height:15px">my solution is:</p><pre style="padding:9.5px;font-family:Monaco,Menlo,Consolas,'Courier New',monospace;border-top-left-radius:4px;border-top-right-radius:4px;border-bottom-right-radius:4px;border-bottom-left-radius:4px;margin-top:0px;margin-bottom:10px;line-height:20px;word-break:break-all;background-color:rgb(245,245,245);border:1px solid rgba(0,0,0,0.14902)">showAreaOfCircle :: Show a => a -> String
showAreaOfCircle x = "The area of a circle with radius" ++ show x ++ "is about" ++ " " + show(pi * x * x) ++ "cm^2"</pre><p style="margin:0px 0px 2px;word-break:break-word;min-height:15px">but there is an error</p><p style="margin:0px 0px 2px;word-break:break-word;min-height:15px">• Could not deduce (Num a) arising from a use of ‘*’<br>from the context: Show a<br>bound by the type signature for:<br>showAreaOfCircle :: forall a. Show a => a -> String<br>at FirstStep.hs:20:1-41<br>Possible fix:<br>add (Num a) to the context of <br>the type signature for:<br>showAreaOfCircle :: forall a. Show a => a -> String<br>• In the first argument of ‘show’, namely ‘(pi * x * x)’<br>In the second argument of ‘(+)’, namely ‘show (pi * x * x)’<br>In the second argument of ‘(++)’, namely ‘" " + show (pi * x * x)’</p><p style="margin:0px 0px 2px;word-break:break-word;min-height:15px">I had tried to change the type declaration to </p><pre style="padding:9.5px;font-family:Monaco,Menlo,Consolas,'Courier New',monospace;border-top-left-radius:4px;border-top-right-radius:4px;border-bottom-right-radius:4px;border-bottom-left-radius:4px;margin-top:0px;margin-bottom:10px;line-height:20px;word-break:break-all;background-color:rgb(245,245,245);border:1px solid rgba(0,0,0,0.14902)">Show a => Num a => a -> String</pre><p style="margin:0px 0px 2px;word-break:break-word;min-height:15px">i guess there must be a problem with pi.</p><p style="margin:0px 0px 2px;word-break:break-word;min-height:15px">Can someone help me with the error message? Great thanks</p></div><br>______________________________<wbr>_________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org">Beginners@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-<wbr>bin/mailman/listinfo/beginners</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">Beauty of style and harmony and grace and good rhythm depend on simplicity. - Plato</div>
</div>