<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1253">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Hello Francesco,</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Yes, that helped. However, I believe I shouldn't remove the `makeSentence`. A user of the module is not supposed to know what a `Sentence` is, hence I must provide a function such as `makeSentence`. Right now, its implementation is just a type conversion, but
 may change later.</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
This would be my logic in different languages; does it make sense in Haskell?</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Do you have any feedback on my questions 1,2 and 3?</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Thanks,</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
-P</div>
<div>
<div id="appendonsend"></div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Beginners <beginners-bounces@haskell.org> on behalf of Francesco Ariis <fa-ml@ariis.it><br>
<b>Sent:</b> Sunday, December 13, 2020 6:25 PM<br>
<b>To:</b> beginners@haskell.org <beginners@haskell.org><br>
<b>Subject:</b> Re: [Haskell-beginners] Nested folds</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt">
<div class="PlainText">Hello Pietro,<br>
<br>
Il 13 dicembre 2020 alle 10:39 Pietro Grandinetti ha scritto:<br>
> Hello,<br>
> I have a piece of code to represents Sentences, Paragraphs and the Content of an article. I added functions to count the words, code below. My questions:<br>
> <br>
> […]<br>
> <br>
> I also have two more practical questions on the following two functions:<br>
> <br>
> makeSentence :: String -> Sentence<br>
> makeSentence x = x::Sentence<br>
<br>
You can omit the `:: Sentence` part, since it is specified in the<br>
signature above. You can omit the whole function itself to be fair,<br>
Sentence is a type synonym!<br>
<br>
> sentCharCount :: Sentence -> Int<br>
> sentCharCount x = length $ filter (/= ' ') x<br>
<br>
You can write this point-free like this<br>
<br>
    sentCharCount :: Sentence -> Int<br>
    sentCharCount = length . filter (/= ' ')<br>
<br>
In this example you can regard `$` as «evaluate everything on the right<br>
before anything else», so<br>
<br>
    length $ filter (/= ' ')<br>
    ^^^^^^   ^^^^^^^^^^^^^^^<br>
      |            |<br>
      |            |<br>
      |            +-- this has type :: [Char] -> [Char]<br>
      |<br>
      +-- length does not work on `[Char] -> [Char]`<br>
<br>
`.` instead is appropriate<br>
<br>
    ë> :t (.)<br>
    (.) :: (b -> c) -> (a -> b) -> a -> c<br>
<br>
Does this clear your doubts?<br>
—F<br>
_______________________________________________<br>
Beginners mailing list<br>
Beginners@haskell.org<br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners">http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners</a><br>
</div>
</span></font></div>
</div>
</body>
</html>