<div dir="ltr">Although the links (difflist, for-a-few-monads-more) that you posted are very interesting in their own right, you only need to understand the following in order to comprehend &quot;shows&quot; and &quot;ShowS&quot;...<div>

<br></div><div><div>* Type-Classes</div></div><div><div>* Type Synonyms</div></div><div>* Partial Application</div><div>* Function Composition<br></div><div><br></div><div><br></div><div>Type Classes</div><div>==========</div>

<div><br></div><div>There are many references for understanding how these work, but the &quot;shows&quot; function simply depends on its first parameter being able to be shown through the use of the &quot;Show&quot; type-class.</div>

<div><br></div><div><br></div><div>Type Synonyms</div><div>============</div><div><br></div><div>Any type can have an &quot;alias&quot; created in the form of a type-synonym. Although these can be parameterised, in the case of &quot;ShowS&quot; it is not:</div>

<div><br></div><div>`type ShowS = String -&gt; String`</div><div><br></div><div>This means that wherever you see a reference to &quot;ShowS&quot; in a type, you may replace it with &quot;String -&gt; String&quot;.</div><div>

<br></div><div><br></div><div>Partial application</div><div>=============</div><div><br></div><div>Look at a reference implementation of &quot;shows&quot; that Shrivats has described:</div><div><br></div><div><span style="font-family:arial,sans-serif;font-size:13px">`shows x s = show x ++ s`</span><br>

</div><div><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div><span style="font-family:arial,sans-serif;font-size:13px">The type signature of &quot;shows&quot; focuses on the partially applied viewpoint, because (thanks to the type-synonym) it is written as if it only takes one argument:</span></div>

<div><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div><span style="font-family:arial,sans-serif;font-size:13px">`</span><font face="arial, sans-serif">shows :: Show a =&gt; a -&gt; ShowS`</font></div>

<div><br></div><div>However, with the &quot;ShowS&quot; synonym resolved, you can see that it actually takes two:</div><div><br></div><div><span style="font-size:13px;font-family:arial,sans-serif">`</span><font face="arial, sans-serif">shows :: Show a =&gt; a -&gt; String -&gt; String</font><span style="font-family:arial,sans-serif">`</span></div>

<div><span style="font-family:arial,sans-serif"><br></span></div><div><span style="font-family:arial,sans-serif">Keep in mind that although Shrivats implementation is semantically equivalent to the one in GHC.List, the performance characteristics may be different.</span></div>

<div><span style="font-family:arial,sans-serif"><br></span></div><div><span style="font-family:arial,sans-serif"><br></span></div><div><span style="font-family:arial,sans-serif">Function Composition</span></div><div><span style="font-family:arial,sans-serif">================</span></div>

<div><span style="font-family:arial,sans-serif"><br></span></div><div><font face="arial, sans-serif">Although this isn&#39;t strictly required in order to understand &quot;shows&quot;, it provides a potential motivation for why the function exists.</font></div>

<div><span style="font-family:arial,sans-serif"><br></span></div><div><span style="font-family:arial,sans-serif">If you wished to chain together a bunch of String representations of various objects, leaving the possibility of adding more later, you would have to use many lambdas if you wished to constrain yourself to using &quot;show&quot; and &quot;++&quot;. For example:</span></div>

<div><span style="font-family:arial,sans-serif"><br></span></div><div><span style="font-family:arial,sans-serif">`showWithMore a = \x -&gt; show a ++ x`</span></div><div><span style="font-family:arial,sans-serif"><br></span></div>

<div><span style="font-family:arial,sans-serif">Applying these would become tedious:</span></div><div><span style="font-family:arial,sans-serif"><br></span></div><div><span style="font-family:arial,sans-serif">`myBools = \x -&gt; showWithMore True (showWithMore False x)`</span></div>

<div><span style="font-family:arial,sans-serif"><br></span></div><div><span style="font-family:arial,sans-serif">Thankfully, this can be avoided through the use of function-composition:</span></div><div><span style="font-family:arial,sans-serif"><br>

</span></div><div><span style="font-family:arial,sans-serif">``myBools = shows True . shows False`</span></div><div><span style="font-family:arial,sans-serif"><br></span></div><div><span style="font-family:arial,sans-serif"><br>

</span></div><div><span style="font-family:arial,sans-serif"><br></span></div><div><span style="font-family:arial,sans-serif">Hopefully this goes some way to getting you to the core of the construction and motivation of these functions and synonyms.</span></div>

<div><br></div><div><span style="font-family:arial,sans-serif">As always, for a true understanding of the motivations behind such a function, nothing beats looking at the source code [1].</span></div><div><span style="font-family:arial,sans-serif"><br>

</span></div><div><span style="font-family:arial,sans-serif"><br></span></div><div><span style="font-family:arial,sans-serif">[1] - </span><font face="arial, sans-serif"><a href="http://hackage.haskell.org/packages/archive/base/3.0.3.2/doc/html/src/GHC-Show.html#ShowS">http://hackage.haskell.org/packages/archive/base/3.0.3.2/doc/html/src/GHC-Show.html#ShowS</a></font></div>

<div><span style="font-family:arial,sans-serif"><br></span></div><div><span style="font-family:arial,sans-serif"><br></span></div><div><span style="font-family:arial,sans-serif"><br></span></div><div><span style="font-family:arial,sans-serif"><br>

</span></div><div><span style="font-family:arial,sans-serif"><br></span></div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Sep 25, 2013 at 10:15 AM, yi lu <span dir="ltr">&lt;<a href="mailto:zhiwudazhanjiangshi@gmail.com" target="_blank">zhiwudazhanjiangshi@gmail.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">to @<span><font color="#888888">Kim-Ee</font></span><br><br>I find it here. Thanks again.<br><a href="http://learnyouahaskell.com/for-a-few-monads-more" target="_blank">http://learnyouahaskell.com/for-a-few-monads-more</a><br>


<br></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Sep 24, 2013 at 8:36 PM, yi lu <span dir="ltr">&lt;<a href="mailto:zhiwudazhanjiangshi@gmail.com" target="_blank">zhiwudazhanjiangshi@gmail.com</a>&gt;</span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote"><div>On Tue, Sep 24, 2013 at 7:50 PM, Kim-Ee Yeoh <span dir="ltr">&lt;<a href="mailto:ky3@atamo.com" target="_blank">ky3@atamo.com</a>&gt;</span> wrote:<br>



<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Sep 24, 2013 at 6:43 PM, yi lu <span dir="ltr">&lt;<a href="mailto:zhiwudazhanjiangshi@gmail.com" target="_blank">zhiwudazhanjiangshi@gmail.com</a>&gt;</span> wrote:<br>





<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I have just looked at the API of Prelude, and I remember similar definition for parallel haskell.</blockquote></div><br>





</div></div><div class="gmail_extra">How far have you gotten with LYAH? Or Hutton&#39;s textbook?<br><br></div></div></blockquote></div><div>I don&#39;t know this problem is revealed in LYAH, and I will check it now. Thanks.<br>



</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div dir="ltr"><div class="gmail_extra"></div><div class="gmail_extra">What does a search on &quot;haskell intro type system&quot; reveal?<span><font color="#888888"><br>



</font></span></div><span><font color="#888888"><div class="gmail_extra">

<br clear="all"><div>-- Kim-Ee</div>
</div></font></span></div>
<br></div><div>_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org" target="_blank">Beginners@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/beginners" target="_blank">http://www.haskell.org/mailman/listinfo/beginners</a><br>
<br></div></blockquote></div><br></div></div>
</blockquote></div><br></div>
</div></div><br>_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org">Beginners@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/beginners" target="_blank">http://www.haskell.org/mailman/listinfo/beginners</a><br>
<br></blockquote></div><br></div>