<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">On 07/11/2018 09:36 AM, Damian Nadales
      wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAM7nXecyeqiAB6ytDeZ7Xo19qjJzOj0dKS9pPMVFg0USVJuhzg@mail.gmail.com">
      <div dir="ltr"><span class="gmail-hljs-keyword" style="box-sizing:border-box;font-weight:bold;color:rgb(51,51,51);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:13.6px;white-space:pre;text-decoration-style:initial;text-decoration-color:initial">import</span><span style="color:rgb(51,51,51);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:13.6px;font-weight:normal;white-space:pre;background-color:rgb(248,248,248);text-decoration-style:initial;text-decoration-color:initial;display:inline;float:none"> </span><span class="gmail-hljs-keyword" style="box-sizing:border-box;font-weight:bold;color:rgb(51,51,51);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:13.6px;white-space:pre;text-decoration-style:initial;text-decoration-color:initial">static</span><span style="color:rgb(51,51,51);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:13.6px;font-weight:normal;white-space:pre;background-color:rgb(248,248,248);text-decoration-style:initial;text-decoration-color:initial;display:inline;float:none"> java.util.Arrays.asList;
</span>
        <div><span class="gmail-hljs-keyword" style="box-sizing:border-box;font-weight:bold;color:rgb(51,51,51);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:13.6px;white-space:pre;text-decoration-style:initial;text-decoration-color:initial">import</span><span style="color:rgb(51,51,51);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:13.6px;font-weight:normal;white-space:pre;background-color:rgb(248,248,248);text-decoration-style:initial;text-decoration-color:initial;display:inline;float:none"> </span><span class="gmail-hljs-keyword" style="box-sizing:border-box;font-weight:bold;color:rgb(51,51,51);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:13.6px;white-space:pre;text-decoration-style:initial;text-decoration-color:initial">static</span><span style="color:rgb(51,51,51);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:13.6px;font-weight:normal;white-space:pre;background-color:rgb(248,248,248);text-decoration-style:initial;text-decoration-color:initial;display:inline;float:none"> java.util.Collections.emptyList;
</span><span class="gmail-hljs-keyword" style="box-sizing:border-box;font-weight:bold;color:rgb(51,51,51);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:13.6px;white-space:pre;text-decoration-style:initial;text-decoration-color:initial">import</span><span style="color:rgb(51,51,51);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:13.6px;font-weight:normal;white-space:pre;background-color:rgb(248,248,248);text-decoration-style:initial;text-decoration-color:initial;display:inline;float:none"> </span><span class="gmail-hljs-keyword" style="box-sizing:border-box;font-weight:bold;color:rgb(51,51,51);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:13.6px;white-space:pre;text-decoration-style:initial;text-decoration-color:initial">static</span><span style="color:rgb(51,51,51);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:13.6px;font-weight:normal;white-space:pre;background-color:rgb(248,248,248);text-decoration-style:initial;text-decoration-color:initial;display:inline;float:none"> java.util.Optional.of;
</span><span class="gmail-hljs-keyword" style="box-sizing:border-box;font-weight:bold;color:rgb(51,51,51);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:13.6px;white-space:pre;text-decoration-style:initial;text-decoration-color:initial">import</span><span style="color:rgb(51,51,51);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:13.6px;font-weight:normal;white-space:pre;background-color:rgb(248,248,248);text-decoration-style:initial;text-decoration-color:initial;display:inline;float:none"> </span><span class="gmail-hljs-keyword" style="box-sizing:border-box;font-weight:bold;color:rgb(51,51,51);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:13.6px;white-space:pre;text-decoration-style:initial;text-decoration-color:initial">static</span><span style="color:rgb(51,51,51);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:13.6px;font-weight:normal;white-space:pre;background-color:rgb(248,248,248);text-decoration-style:initial;text-decoration-color:initial;display:inline;float:none"> java.util.stream.Collectors.toList;
 
</span><span class="gmail-hljs-keyword" style="box-sizing:border-box;font-weight:bold;color:rgb(51,51,51);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:13.6px;white-space:pre;text-decoration-style:initial;text-decoration-color:initial">import</span><span style="color:rgb(51,51,51);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:13.6px;font-weight:normal;white-space:pre;background-color:rgb(248,248,248);text-decoration-style:initial;text-decoration-color:initial;display:inline;float:none"> java.util.List;
 
</span><span class="gmail-hljs-keyword" style="box-sizing:border-box;font-weight:bold;color:rgb(51,51,51);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:13.6px;white-space:pre;text-decoration-style:initial;text-decoration-color:initial">public</span><span style="color:rgb(51,51,51);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:13.6px;font-weight:normal;white-space:pre;background-color:rgb(248,248,248);text-decoration-style:initial;text-decoration-color:initial;display:inline;float:none"> </span><span class="gmail-hljs-class" style="box-sizing:border-box;color:rgb(51,51,51);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:13.6px;font-weight:normal;white-space:pre;text-decoration-style:initial;text-decoration-color:initial"><span class="gmail-hljs-keyword" style="box-sizing:border-box;font-weight:bold;color:rgb(51,51,51)">class</span> <span class="gmail-hljs-title" style="box-sizing:border-box;color:rgb(68,85,136);font-weight:bold">CartesianProduct</span> </span><span style="color:rgb(51,51,51);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:13.6px;font-weight:normal;white-space:pre;background-color:rgb(248,248,248);text-decoration-style:initial;text-decoration-color:initial;display:inline;float:none">{
 
    </span><span class="gmail-hljs-keyword" style="box-sizing:border-box;font-weight:bold;color:rgb(51,51,51);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:13.6px;white-space:pre;text-decoration-style:initial;text-decoration-color:initial">public</span><span style="color:rgb(51,51,51);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:13.6px;font-weight:normal;white-space:pre;background-color:rgb(248,248,248);text-decoration-style:initial;text-decoration-color:initial;display:inline;float:none"> List<?> product(List<?>... a) {
        </span><span class="gmail-hljs-keyword" style="box-sizing:border-box;font-weight:bold;color:rgb(51,51,51);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:13.6px;white-space:pre;text-decoration-style:initial;text-decoration-color:initial">if</span><span style="color:rgb(51,51,51);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:13.6px;font-weight:normal;white-space:pre;background-color:rgb(248,248,248);text-decoration-style:initial;text-decoration-color:initial;display:inline;float:none"> (a.length >= </span><span class="gmail-hljs-number" style="box-sizing:border-box;color:rgb(0,128,128);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:13.6px;font-weight:normal;white-space:pre;text-decoration-style:initial;text-decoration-color:initial">2</span><span style="color:rgb(51,51,51);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:13.6px;font-weight:normal;white-space:pre;background-color:rgb(248,248,248);text-decoration-style:initial;text-decoration-color:initial;display:inline;float:none">) {
            List<?> product = a[</span><span class="gmail-hljs-number" style="box-sizing:border-box;color:rgb(0,128,128);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:13.6px;font-weight:normal;white-space:pre;text-decoration-style:initial;text-decoration-color:initial">0</span><span style="color:rgb(51,51,51);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:13.6px;font-weight:normal;white-space:pre;background-color:rgb(248,248,248);text-decoration-style:initial;text-decoration-color:initial;display:inline;float:none">];
            </span><span class="gmail-hljs-keyword" style="box-sizing:border-box;font-weight:bold;color:rgb(51,51,51);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:13.6px;white-space:pre;text-decoration-style:initial;text-decoration-color:initial">for</span><span style="color:rgb(51,51,51);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:13.6px;font-weight:normal;white-space:pre;background-color:rgb(248,248,248);text-decoration-style:initial;text-decoration-color:initial;display:inline;float:none"> (</span><span class="gmail-hljs-keyword" style="box-sizing:border-box;font-weight:bold;color:rgb(51,51,51);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:13.6px;white-space:pre;text-decoration-style:initial;text-decoration-color:initial">int</span><span style="color:rgb(51,51,51);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:13.6px;font-weight:normal;white-space:pre;background-color:rgb(248,248,248);text-decoration-style:initial;text-decoration-color:initial;display:inline;float:none"> i = </span><span class="gmail-hljs-number" style="box-sizing:border-box;color:rgb(0,128,128);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:13.6px;font-weight:normal;white-space:pre;text-decoration-style:initial;text-decoration-color:initial">1</span><span style="color:rgb(51,51,51);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:13.6px;font-weight:normal;white-space:pre;background-color:rgb(248,248,248);text-decoration-style:initial;text-decoration-color:initial;display:inline;float:none">; i < a.length; i++) {
                product = product(product, a[i]);
            }
            </span><span class="gmail-hljs-keyword" style="box-sizing:border-box;font-weight:bold;color:rgb(51,51,51);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:13.6px;white-space:pre;text-decoration-style:initial;text-decoration-color:initial">return</span><span style="color:rgb(51,51,51);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:13.6px;font-weight:normal;white-space:pre;background-color:rgb(248,248,248);text-decoration-style:initial;text-decoration-color:initial;display:inline;float:none"> product;
        }
 
        </span><span class="gmail-hljs-keyword" style="box-sizing:border-box;font-weight:bold;color:rgb(51,51,51);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:13.6px;white-space:pre;text-decoration-style:initial;text-decoration-color:initial">return</span><span style="color:rgb(51,51,51);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:13.6px;font-weight:normal;white-space:pre;background-color:rgb(248,248,248);text-decoration-style:initial;text-decoration-color:initial;display:inline;float:none"> emptyList();
    }
 
    </span><span class="gmail-hljs-keyword" style="box-sizing:border-box;font-weight:bold;color:rgb(51,51,51);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:13.6px;white-space:pre;text-decoration-style:initial;text-decoration-color:initial">private</span><span style="color:rgb(51,51,51);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:13.6px;font-weight:normal;white-space:pre;background-color:rgb(248,248,248);text-decoration-style:initial;text-decoration-color:initial;display:inline;float:none"> <A, B> List<?> product(List<A> a, List<B> b) {
        </span><span class="gmail-hljs-keyword" style="box-sizing:border-box;font-weight:bold;color:rgb(51,51,51);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:13.6px;white-space:pre;text-decoration-style:initial;text-decoration-color:initial">return</span><span style="color:rgb(51,51,51);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:13.6px;font-weight:normal;white-space:pre;background-color:rgb(248,248,248);text-decoration-style:initial;text-decoration-color:initial;display:inline;float:none"> of(a.stream()
                .map(e1 -> of(b.stream().map(e2 -> asList(e1, e2)).collect(toList())).orElse(emptyList()))
                .flatMap(List::stream)
                .collect(toList())).orElse(emptyList());
    }
}</span><br>
        </div>
        <div><br>
        </div>
        <div>A programmer that spent a lot of time studying Monads and
          playing around with them, and that understands the Monad
          instances for lists, might come up with the following solution
          in Haskell:</div>
        <div><br>
        </div>
        <div><span class="gmail-hljs-title" style="box-sizing:border-box;color:rgb(153,0,0);font-weight:bold;font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:13.6px;white-space:pre;text-decoration-style:initial;text-decoration-color:initial">cartProdN</span><span style="color:rgb(51,51,51);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:13.6px;font-weight:normal;white-space:pre;background-color:rgb(248,248,248);text-decoration-style:initial;text-decoration-color:initial;display:inline;float:none"> :: [[a]] -> [[a]]
</span><span class="gmail-hljs-title" style="box-sizing:border-box;color:rgb(153,0,0);font-weight:bold;font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:13.6px;white-space:pre;text-decoration-style:initial;text-decoration-color:initial">cartProdN</span><span style="color:rgb(51,51,51);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:13.6px;font-weight:normal;white-space:pre;background-color:rgb(248,248,248);text-decoration-style:initial;text-decoration-color:initial;display:inline;float:none"> = sequence</span></div>
        <div><br>
        </div>
        <div>This also made me realize of two things:</div>
        <div>0. Haskell will never be mainstream, because there are not
          a lot of programmers out there who are willing to do the
          investment required for learning the necessary concepts to
          understand and write code like the one shown above.</div>
      </div>
    </blockquote>
    <br>
    Replace "Haskell" with "Java" in the previous sentence, and you
    would have an equally truthful statement. :) I spent years getting
    comfortable with OO languages, and then I spent years getting
    familiar with Haskell. For someone who only knows Haskell (and I
    know such a person), I couldn't imagine teaching them Java well
    enough to write that code!<br>
    <br>
    Semicolons... Brackets *and* whitespace delineation (which is
    required, and which is customary?) ... import "static" ... "public",
    "class", "private" ... eager evaluation ...
    pass-by-reference/whatever ... procedural statements  ... these
    things are all mind-boggling if you don't learn them early.<br>
    <br>
    In short, I don't think the investment required in Haskell is
    different than any other programming language. As with natural
    languages, there are no absolute difficulties, only relative ones.<br>
    <br>
    (This might actually be a useful point to bring up when speaking to
    non-Haskellers, so perhaps this message isn't as off-topic as I
    initially assumed.)<br>
  </body>
</html>