<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html;
      charset=windows-1252">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p>I have several short examples that I quite like:<br>
      <br>
      #1: changes a probability density function into a cumulative
      density function</p>
    <pre><code class="hljs rust"><p>cdf :: (Num a) => [a] -> [a]
cdf = <span class="hljs-built_in">drop</span> <span class="hljs-number">2</span> . (scanl (+) <span class="hljs-number">0</span>) . ((:) <span class="hljs-number">0</span>)

</p></code></pre>
    #2: enumerate all strings on an alphabet (this uses laziness!)<br>
    <pre><code class="haskell hljs"><p><span class="hljs-title">allStrings</span> :: [a] -> [[a]]
<span class="hljs-title">allStrings</span> = sequence <=< (inits . repeat)
</p></code></pre>
    <h1><code class="hljs rust"></code></h1>
    #3: enumerate the Fibonacci numbers (this one uses laziness too)<br>
    <pre><code class="haskell hljs"><p><span class="hljs-title">fibonacci</span> :: (<span class="hljs-type">Integral</span> a) => [a]
<span class="hljs-title">fibonacci</span> = <span class="hljs-number">1</span> : <span class="hljs-number">1</span> : zipWith (+) fibonacci (tail fibonacci)

</p></code></pre>
    <div class="moz-cite-prefix">#4: Return all subsets of a list<br>
      <pre><code class="haskell hljs"><p><span class="hljs-title">allSubsets</span> :: [a] -> [[a]]
<span class="hljs-title">allSubsets</span> = filterM (pure [<span class="hljs-type">True</span>, <span class="hljs-type">False</span>])</p></code></pre>
      <br>
      I also have two blog posts I wrote that contain lots of short
      examples. The first contains lots of short-but-interesting
      programs and the second contains examples of how expressive
      Haskell is (by doing the same thing multiple times):<br>
      <br>
      <a class="moz-txt-link-freetext" href="http://blog.vmchale.com/article/haskell-aphorisms">http://blog.vmchale.com/article/haskell-aphorisms</a><br>
      <a class="moz-txt-link-freetext" href="http://blog.vmchale.com/article/sum">http://blog.vmchale.com/article/sum</a><br>
      <br>
      On 07/11/2018 07:10 AM, Simon Peyton Jones via Haskell-Cafe wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:AM0PR83MB03082E77516AA35BC5955792AD5A0@AM0PR83MB0308.EURPRD83.prod.outlook.com">
      <meta http-equiv="Content-Type" content="text/html;
        charset=windows-1252">
      <meta name="Generator" content="Microsoft Word 15 (filtered
        medium)">
      <style><!--
/* Font Definitions */
@font-face
        {font-family:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin-top:6.0pt;
        margin-right:0cm;
        margin-bottom:6.0pt;
        margin-left:0cm;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
        {mso-style-priority:34;
        margin-top:6.0pt;
        margin-right:0cm;
        margin-bottom:6.0pt;
        margin-left:36.0pt;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;}
p.Code, li.Code, div.Code
        {mso-style-name:Code;
        margin-top:0cm;
        margin-right:0cm;
        margin-bottom:0cm;
        margin-left:36.0pt;
        margin-bottom:.0001pt;
        font-size:9.0pt;
        font-family:"Courier New";}
span.EmailStyle18
        {mso-style-type:personal-compose;
        font-family:"Calibri",sans-serif;
        color:windowtext;
        font-weight:normal;
        font-style:normal;
        text-decoration:none none;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}
.MsoPapDefault
        {mso-style-type:export-only;
        margin-top:6.0pt;
        margin-right:0cm;
        margin-bottom:6.0pt;
        margin-left:0cm;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
/* List Definitions */
@list l0
        {mso-list-id:439761096;
        mso-list-type:hybrid;
        mso-list-template-ids:376759908 134807553 134807555 134807557 134807553 134807555 134807557 134807553 134807555 134807557;}
@list l0:level1
        {mso-level-number-format:bullet;
        mso-level-text:\F0B7;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:Symbol;}
@list l0:level2
        {mso-level-number-format:bullet;
        mso-level-text:o;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:"Courier New";}
@list l0:level3
        {mso-level-number-format:bullet;
        mso-level-text:\F0A7;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:Wingdings;}
@list l0:level4
        {mso-level-number-format:bullet;
        mso-level-text:\F0B7;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:Symbol;}
@list l0:level5
        {mso-level-number-format:bullet;
        mso-level-text:o;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:"Courier New";}
@list l0:level6
        {mso-level-number-format:bullet;
        mso-level-text:\F0A7;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:Wingdings;}
@list l0:level7
        {mso-level-number-format:bullet;
        mso-level-text:\F0B7;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:Symbol;}
@list l0:level8
        {mso-level-number-format:bullet;
        mso-level-text:o;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:"Courier New";}
@list l0:level9
        {mso-level-number-format:bullet;
        mso-level-text:\F0A7;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:Wingdings;}
ol
        {margin-bottom:0cm;}
ul
        {margin-bottom:0cm;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
      <div class="WordSection1">
        <p class="MsoNormal"><span
            style="font-family:"Calibri",sans-serif">Friends<o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-family:"Calibri",sans-serif">In a few
            weeks I’m giving a talk to a bunch of genomics folk at the
            <a href="https://www.sanger.ac.uk/" moz-do-not-send="true">Sanger
              Institute</a> about Haskell.   They do lots of
            programming, but they aren’t computer scientists.<o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-family:"Calibri",sans-serif">I can
            tell them plenty about Haskell, but I’m ill-equipped to
            answer the main question in their minds:
            <i>why should I even care about Haskell</i>?  I’m too much
            of a biased witness.<br>
            <br>
            <o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-family:"Calibri",sans-serif">So I
            thought I’d ask you for help.  War stories perhaps – how
            using Haskell worked (or didn’t) for you.  But rather than
            talk generalities, I’d love to illustrate with copious
            examples of beautiful code. <o:p></o:p></span></p>
        <ul style="margin-top:0cm" type="disc">
          <li class="MsoListParagraph"
            style="margin-left:0cm;mso-list:l0 level1 lfo1"><span
              style="font-family:"Calibri",sans-serif">Can you
              identify a few lines of Haskell that best characterise
              what you think makes Haskell distinctively worth caring
              about?   Something that gave you an “aha” moment, or that
              feeling of joy when you truly make sense of something for
              the first time.<o:p></o:p></span></li>
        </ul>
        <p class="MsoNormal"><span
            style="font-family:"Calibri",sans-serif">The
            challenge is, of course, that this audience will know no
            Haskell, so muttering about Cartesian Closed Categories
            isn’t going to do it for them.  I need examples that I can
            present in 5 minutes, without needing a long setup.<o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-family:"Calibri",sans-serif">To take a
            very basic example, consider Quicksort using list
            comprehensions, compared with its equivalent in C.  It’s so
            short, so obviously right, whereas doing the right thing
            with in-place update in C notoriously prone to fencepost
            errors etc.  But it also makes much less good use of memory,
            and is likely to run slower.  I think I can do that in 5
            minutes.<o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-family:"Calibri",sans-serif">Another
            thing that I think comes over easily is the ability to
            abstract: generalising sum and product to fold by
            abstracting out a functional argument; generalising at the
            type level by polymorphism, including polymorphism over
            higher-kinded type constructors.   Maybe 8 minutes.<o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-family:"Calibri",sans-serif">But you
            will have more and better ideas, and (crucially) ideas that
            are more credibly grounded in the day to day reality of
            writing programs that get work done.<o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-family:"Calibri",sans-serif">Pointers
            to your favourite blog posts would be another avenue.  (I
            love the Haskell Weekly News.)<o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-family:"Calibri",sans-serif">Finally,
            I know that some of you use Haskell specifically for
            genomics work, and maybe some of your insights would be
            particularly relevant for the Sanger audience.<o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-family:"Calibri",sans-serif">Thank
            you!  Perhaps your responses on this thread (if any) may be
            helpful to more than just me.<o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-family:"Calibri",sans-serif">Simon<o:p></o:p></span></p>
      </div>
      <!--'"--><br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
<a class="moz-txt-link-freetext" href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a>
Only members subscribed via the mailman list are allowed to post.</pre>
    </blockquote>
  </body>
</html>