<div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><span class="Apple-style-span" style="font-size: small;">For example, which of these is easier to read?<br>
<br>
f,g :: Int -&gt; [Int]<br><br>
h1 :: Int -&gt; [Int]<br>
h1 x = do<br>
 &nbsp; &nbsp;fx &lt;- f x<br>
 &nbsp; &nbsp;gx &lt;- g x<br>
 &nbsp; &nbsp;return (fx + gx)<br><br>
h2 :: Int -&gt; [Int]<br>
h2 x = (+) &lt;$&gt; f x &lt;*&gt; g x<br><br>
h3 :: Int -&gt; [Int]<br>
h3 x = f x + g x &nbsp; -- not legal, of course, but wouldn&#39;t it be nice if it was?<br>



</span></blockquote><div class="gmail_quote"><span class="Apple-style-span" style="font-size: small;"><br></span></div><div class="gmail_quote"><span class="Apple-style-span" style="font-size: small;">Yes, all that lifting is something that takes away lot of the beauty and simplicity of Haskell, but as far as my limited knowledge goes, I don&#39;t think this problem is easily solved :)<br>
</span></div><div class="gmail_quote"><span class="Apple-style-span" style="font-size: small;"><br></span></div><div class="gmail_quote"><span class="Apple-style-span" style="font-size: small;">Anyway, for your particular example, for newbies I guess the clearest would be:</span></div>
<div class="gmail_quote"><span class="Apple-style-span" style="font-size: small;"><br></span></div><div class="gmail_quote"><div class="gmail_quote"><span class="Apple-style-span" style="font-size: small;">h0 x = [ fx+gx | fx &lt;- f x, gx &lt;- g x ]</span></div>
<div><span class="Apple-style-span" style="font-size: small;"><br></span></div><div><span class="Apple-style-span" style="font-size: small;">since one must recognize that a list monad exists and what it does...</span></div>
<div><span class="Apple-style-span" style="font-size: small;"><br></span></div><div><span class="Apple-style-span" style="font-size: small;">Now, for binary operators, Thomas Davie made a nice pair of combinators on Hackage (InfixApplicative) that would allow this to become:<br>
</span></div></div></div><div class="gmail_quote"><span class="Apple-style-span" style="font-size: small;"><br></span></div><div class="gmail_quote"><span class="Apple-style-span" style="font-size: small;">h3 x = f x &lt;^(+)^&gt; g x</span></div>
<div class="gmail_quote"><span class="Apple-style-span" style="font-size: small;"><br></span></div><div class="gmail_quote"><span class="Apple-style-span" style="font-size: small;">But in general, I guess you have a good point...</span></div>
<div class="gmail_quote"><span class="Apple-style-span" style="font-size: small;"><br></span></div><div class="gmail_quote"><span class="Apple-style-span" style="font-size: small;"><br></span></div><div class="gmail_quote">
<span class="Apple-style-span" style="font-size: small;">&nbsp;<br></span></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<span class="Apple-style-span" style="font-size: small;"><br>
Of course this raises problems of order of evaluation, etc, but as<br>
long as such things were well-defined, that seems fine. &nbsp;If you want<br>
finer control, you can always go back to more verbose syntax. &nbsp;These<br>
cases are dominated by the cases where you simply don&#39;t care!<br><br>
This said, I don&#39;t want to sound overly negative; all of this pain is<br>
*worth* the correctness guarantees that I get when writing in Haskell.<br>
&nbsp;I just wish I could get the same guarantees with less pain!<br><br>
 &nbsp;-- ryan<br><br><br>
2009/1/10 Peter Verswyvelen &lt;



</span><a href="mailto:bugfact@gmail.com"><span class="Apple-style-span" style="font-size: small;">bugfact@gmail.com</span></a><span class="Apple-style-span" style="font-size: small;">&gt;:<br>
</span><div><div></div><div class="Wj3C7c"><span class="Apple-style-span" style="font-size: small;">&gt; Related to this issue, I have a question here.<br>
&gt; I might &nbsp;be wrong, but it seems to me that some Haskellers don&#39;t like<br>
&gt; writing monads (with do notation) or arrows (with proc sugar) because of the<br>
&gt; fact they have to abandon the typical applicative syntax, which is so close<br>
&gt; to the beautiful lambda calculus core. Or is it maybe because some people<br>
&gt; choose monads were the less linear applicative style could be used instead,<br>
&gt; so the choice of monads is not always appropriate.<br>
&gt; Haskell is full of little hardcoded syntax extensions: list notation<br>
&gt; syntactic, list comprehensions, and even operator precedence that reduces<br>
&gt; the need for parentheses, etc...<br>
&gt;<br>
&gt; Of course IMHO the syntactic sugar is needed, e.g. a Yampa game written<br>
&gt; without the arrows syntax would be incomprehensible for the average<br>
&gt; programmer. But one could claim that this syntactic sugar hides what is<br>
&gt; really going on under the hood, so for newcomers these extensions might make<br>
&gt; it harder. It could also feel like a hack, a failure to keep things as<br>
&gt; simple as possible yet elegant.<br>
&gt; Some people I talked with like that about the Scheme/ &amp; LISP languages: the<br>
&gt; syntax remains ultimately close to the core, with very little hardcoded<br>
&gt; syntactic extensions. And when one wants to add syntactic extensions, one<br>
&gt; uses syntactic macros.<br>
&gt; I&#39;m not sure what others feel about the hardcoded syntax extensions in<br>
&gt; Haskell...<br>
&gt;<br>
&gt; Personally I&#39;m not that much of a purist, I&#39;m an old school hacker that<br>
&gt; mainly needs to get the job done. I like the syntax extensions in Haskell<br>
&gt; (and even C#/F# ;) because they let me write code shorter and clearer...<br>
&gt; On Fri, Jan 9, 2009 at 4:07 AM, Neal Alexander &lt;</span><a href="mailto:wqeqweuqy@hotmail.com"><span class="Apple-style-span" style="font-size: small;">wqeqweuqy@hotmail.com</span></a><span class="Apple-style-span" style="font-size: small;">&gt;<br>

&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; Ertugrul Soeylemez wrote:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Hello fellow Haskellers,<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; When I read questions from Haskell beginners, it somehow seems like they<br>
&gt;&gt;&gt; try to avoid monads and view them as a last resort, if there is no easy<br>
&gt;&gt;&gt; non-monadic way. &nbsp;I&#39;m really sure that the cause for this is that most<br>
&gt;&gt;&gt; tutorials deal with monads very sparingly and mostly in the context of<br>
&gt;&gt;&gt; input/output. &nbsp;Also usually monads are associated with the do-notation,<br>
&gt;&gt;&gt; which makes them appear even more special, although there is really<br>
&gt;&gt;&gt; nothing special about them.<br>
&gt;&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; Yea, i was the same way when i started learning Haskell. I understood how<br>
&gt;&gt; Monads worked, and what the motivation was for them, but not why i would<br>
&gt;&gt; want to restructure code to use them in specific instances.<br>
&gt;&gt;<br>
&gt;&gt; &quot;Why should i care about monads when i can use Arrows or (.)&quot; was also a<br>
&gt;&gt; factor.<br>
&gt;&gt;<br>
&gt;&gt; Its kinda like getting advice from an adult as a child. You have no<br>
&gt;&gt; particular reason to distrust the advice, but the value of it doesn&#39;t set in<br>
&gt;&gt; until something happens to you first hand to verify it.<br>
&gt;&gt;<br>
&gt;&gt; For me the turning point was writing some code that needed to handle<br>
&gt;&gt; running code locally/remotely in a transparent manner.<br>
&gt;&gt;<br>
&gt;&gt; Maybe having a list of real-world usage scenarios or exercises on the wiki<br>
&gt;&gt; may help.<br>
&gt;&gt;<br>
&gt;&gt; ______________________________ _________________<br>
&gt;&gt; Haskell-Cafe mailing list<br>
&gt;&gt; </span><a href="mailto:Haskell-Cafe@haskell.org"><span class="Apple-style-span" style="font-size: small;">Haskell-Cafe@haskell.org</span></a><span class="Apple-style-span" style="font-size: small;"><br>
&gt;&gt; </span><a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank"><span class="Apple-style-span" style="font-size: small;">http://www.haskell.org/</span><span class="Apple-style-span" style="font-size: small;">mailman/listinfo/haskell-cafe</span></a><span class="Apple-style-span" style="font-size: small;"><br>

&gt;<br>
&gt;<br>
</span></div></div><span class="Apple-style-span" style="font-size: small;">&gt; ______________________________</span><span class="Apple-style-span" style="font-size: small;">_________________<br>
</span><div><div></div><div class="Wj3C7c"><span class="Apple-style-span" style="font-size: small;">&gt; Haskell-Cafe mailing list<br>
&gt; </span><a href="mailto:Haskell-Cafe@haskell.org"><span class="Apple-style-span" style="font-size: small;">Haskell-Cafe@haskell.org</span></a><span class="Apple-style-span" style="font-size: small;"><br>
&gt; </span><a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank"><span class="Apple-style-span" style="font-size: small;">http://www.haskell.org/</span><span class="Apple-style-span" style="font-size: small;">mailman/listinfo/haskell-cafe</span></a><span class="Apple-style-span" style="font-size: small;"><br>

&gt;<br>
&gt;<br>
</span></div></div></blockquote></div><br>