Skip to content

Commit

Permalink
Generate Pelican site
Browse files Browse the repository at this point in the history
  • Loading branch information
nevillelyh committed May 19, 2017
1 parent bdab5ae commit 74dbacb
Show file tree
Hide file tree
Showing 45 changed files with 1,112 additions and 251 deletions.
6 changes: 5 additions & 1 deletion archives.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@
<section id="content">
<h1>Archives for Das Keyboard Shredder</h1>
<div id="archives">
<p>
<span class="categories-timestamp"><time datetime="2017-05-18T09:46:00-04:00">Thu 18 May 2017</time></span>
<a href="http://www.lyh.me/canbuildfrom.html">CanBuildFrom</a>
</p>
<p>
<span class="categories-timestamp"><time datetime="2017-05-06T17:14:00-04:00">Sat 06 May 2017</time></span>
<a href="http://www.lyh.me/decompiling-scala-code.html">Decompiling Scala&nbsp;code</a>
Expand Down Expand Up @@ -203,11 +207,11 @@ <h4><i class="fa fa-home fa-lg"></i><span class="icon-label">Social</span></h4>
<li class="list-group-item">
<h4><i class="fa fa-home fa-lg"></i><span class="icon-label">Recent Posts</span></h4>
<ul class="list-group" id="recentposts">
<li class="list-group-item"><a href="http://www.lyh.me/canbuildfrom.html">CanBuildFrom</a></li>
<li class="list-group-item"><a href="http://www.lyh.me/decompiling-scala-code.html">Decompiling Scala&nbsp;code</a></li>
<li class="list-group-item"><a href="http://www.lyh.me/implicits.html">Implicits</a></li>
<li class="list-group-item"><a href="http://www.lyh.me/scio-at-philly-ete.html">Scio at Philly <span class="caps">ETE</span></a></li>
<li class="list-group-item"><a href="http://www.lyh.me/joins.html">Joins</a></li>
<li class="list-group-item"><a href="http://www.lyh.me/for-comprehensions.html">For&nbsp;comprehensions</a></li>
</ul>
</li>
<!-- End Sidebar/Recent Posts -->
Expand Down
78 changes: 48 additions & 30 deletions author/neville-li.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,53 @@
<div class="container">
<div class="row">
<div class="col-sm-9">
<article>
<h2><a href="http://www.lyh.me/canbuildfrom.html">CanBuildFrom</a></h2>
<div class="well well-sm">
<footer class="post-info">
<span class="label label-default">Date</span>
<span class="published">
<i class="fa fa-calendar"></i><time datetime="2017-05-18T09:46:00-04:00"> Thu 18 May 2017</time>
</span>



<span class="label label-default">Category</span>
<a href="http://www.lyh.me/category/code.html">code</a>


<span class="label label-default">Tags</span>
<a href="http://www.lyh.me/tag/scala.html">scala</a>
/
<a href="http://www.lyh.me/tag/fp.html">fp</a>

</footer><!-- /.post-info --> </div>
<div class="summary"><p>We recently had an internal knowledge sharing on higher-kinded types and <code>CanBuildFrom</code> type classes in Scala. Here&#8217;s a short&nbsp;summary.</p>
<h2>Basics</h2>
<p>Let&#8217;s start by implementing <code>map</code>.</p>
<div class="highlight"><pre><span></span><span class="k">def</span> <span class="n">map</span><span class="o">(</span><span class="n">xs</span><span class="k">:</span> <span class="kt">Seq</span><span class="o">[</span><span class="kt">Int</span><span class="o">],</span> <span class="n">f</span><span class="k">:</span> <span class="kt">Int</span> <span class="o">=&gt;</span> <span class="nc">Double</span><span class="o">)</span><span class="k">:</span> <span class="kt">Seq</span><span class="o">[</span><span class="kt">Double</span><span class="o">]</span> <span class="k">=</span> <span class="n">xs</span><span class="o">.</span><span class="n">map</span><span class="o">(</span><span class="n">f</span><span class="o">)</span>
<span class="n">map</span><span class="o">(</span><span class="nc">Seq</span><span class="o">(</span><span class="mi">1</span><span class="o">,</span> <span class="mi">2</span><span class="o">,</span> <span class="mi">3</span><span class="o">),</span> <span class="k">_</span> <span class="o">+</span> <span class="mf">0.1</span><span class="o">)</span>
</pre></div>


<p>This implementation is not very good since it only works with <code>Seq[Int]</code> and <code>Int =&gt; Double</code>. It&#8217;s easy to parameterize <code>Int</code> and <code>Double</code>.</p>
<div class="highlight"><pre><span></span><span class="k">def</span> <span class="n">map</span><span class="o">[</span><span class="kt">A</span>, <span class="kt">B</span><span class="o">](</span><span class="n">xs</span><span class="k">:</span> <span class="kt">Seq</span><span class="o">[</span><span class="kt">A</span><span class="o">],</span> <span class="n">f</span><span class="k">:</span> <span class="kt">A</span> <span class="o">=&gt;</span> <span class="n">B</span><span class="o">)</span><span class="k">:</span> <span class="kt">Seq</span><span class="o">[</span><span class="kt">B</span><span class="o">]</span> <span class="k">=</span> <span class="n">xs</span><span class="o">.</span><span class="n">map</span><span class="o">(</span><span class="n">f</span><span class="o">)</span>
</pre></div>


<p>However <code>map(Seq(1, 2, 3), _ + 0.1)</code> now fails to compile with a message <code>missing parameter type for expanded function ((x$1) =&gt; x$1.$plus(10))</code></p>
<p>This is because inference of <code>A</code> in <code>f: A =&gt; B</code> depends on the type of <code>xs: Seq[A]</code>, and limitation of Scala type inference. A common workaround is to curry&nbsp;arguments.</p>
<div class="highlight"><pre><span></span><span class="k">def</span> <span class="n">map</span><span class="o">[</span><span class="kt">A</span>, <span class="kt">B</span><span class="o">](</span><span class="n">xs</span><span class="k">:</span> <span class="kt">Seq</span><span class="o">[</span><span class="kt">A</span><span class="o">])(</span><span class="n">f</span><span class="k">:</span> <span class="kt">A</span> <span class="o">=&gt;</span> <span class="n">B</span><span class="o">)</span><span class="k">:</span> <span class="kt">Seq</span><span class="o">[</span><span class="kt">B</span><span class="o">]</span> <span class="k">=</span> <span class="n">xs</span><span class="o">.</span><span class="n">map</span><span class="o">(</span><span class="n">f</span><span class="o">)</span>
<span class="n">map</span><span class="o">(</span><span class="nc">Seq</span><span class="o">(</span><span class="mi">1</span><span class="o">,</span> <span class="mi">2</span><span class="o">,</span> <span class="mi">3</span><span class="o">))(</span><span class="k">_</span> <span class="o">+</span> <span class="mi">10</span><span class="o">)</span>
</pre></div>


<p>Similar pattern is commonly seen in Scala, like <code>foldLeft(z: B)(op: (B, A) =&gt; B)</code>. Another benefit is we can now write <code>f</code> in a multi-line <code>{}</code> block more&nbsp;elegantly.</p>
<div class="highlight"><pre><span></span><span class="n">map</span><span class="o">(</span><span class="nc">Seq …</span></pre></div>
<a class="btn btn-default btn-xs" href="http://www.lyh.me/canbuildfrom.html">more ...</a>
</div>
</article>
<hr/>
<article>
<h2><a href="http://www.lyh.me/decompiling-scala-code.html">Decompiling Scala&nbsp;code</a></h2>
<div class="well well-sm">
Expand Down Expand Up @@ -435,35 +482,6 @@ <h2><a href="http://www.lyh.me/scala-data-pipelines-spotify.html">Scala Data Pip
</div>
</article>
<hr/>
<article>
<h2><a href="http://www.lyh.me/primitives.html">Primitives</a></h2>
<div class="well well-sm">
<footer class="post-info">
<span class="label label-default">Date</span>
<span class="published">
<i class="fa fa-calendar"></i><time datetime="2015-05-14T08:50:00-04:00"> Thu 14 May 2015</time>
</span>



<span class="label label-default">Category</span>
<a href="http://www.lyh.me/category/code.html">code</a>


<span class="label label-default">Tags</span>
<a href="http://www.lyh.me/tag/java.html">java</a>
/
<a href="http://www.lyh.me/tag/scala.html">scala</a>
/
<a href="http://www.lyh.me/tag/fp.html">fp</a>

</footer><!-- /.post-info --> </div>
<div class="summary"><p>Another day, another talk. This one is on primitives and here are the <a href="/slides/primitives.html">slides</a></p>
<iframe src="/slides/primitives.html" width="800" height="450"></iframe>
<a class="btn btn-default btn-xs" href="http://www.lyh.me/primitives.html">more ...</a>
</div>
</article>
<hr/>

<ul class="pagination">
<li class="prev disabled"><a href="#">&laquo;</a></li>
Expand Down Expand Up @@ -512,11 +530,11 @@ <h4><i class="fa fa-home fa-lg"></i><span class="icon-label">Social</span></h4>
<li class="list-group-item">
<h4><i class="fa fa-home fa-lg"></i><span class="icon-label">Recent Posts</span></h4>
<ul class="list-group" id="recentposts">
<li class="list-group-item"><a href="http://www.lyh.me/canbuildfrom.html">CanBuildFrom</a></li>
<li class="list-group-item"><a href="http://www.lyh.me/decompiling-scala-code.html">Decompiling Scala&nbsp;code</a></li>
<li class="list-group-item"><a href="http://www.lyh.me/implicits.html">Implicits</a></li>
<li class="list-group-item"><a href="http://www.lyh.me/scio-at-philly-ete.html">Scio at Philly <span class="caps">ETE</span></a></li>
<li class="list-group-item"><a href="http://www.lyh.me/joins.html">Joins</a></li>
<li class="list-group-item"><a href="http://www.lyh.me/for-comprehensions.html">For&nbsp;comprehensions</a></li>
</ul>
</li>
<!-- End Sidebar/Recent Posts -->
Expand Down
60 changes: 30 additions & 30 deletions author/neville-li2.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,35 @@
<div class="container">
<div class="row">
<div class="col-sm-9">
<article>
<h2><a href="http://www.lyh.me/primitives.html">Primitives</a></h2>
<div class="well well-sm">
<footer class="post-info">
<span class="label label-default">Date</span>
<span class="published">
<i class="fa fa-calendar"></i><time datetime="2015-05-14T08:50:00-04:00"> Thu 14 May 2015</time>
</span>



<span class="label label-default">Category</span>
<a href="http://www.lyh.me/category/code.html">code</a>


<span class="label label-default">Tags</span>
<a href="http://www.lyh.me/tag/java.html">java</a>
/
<a href="http://www.lyh.me/tag/scala.html">scala</a>
/
<a href="http://www.lyh.me/tag/fp.html">fp</a>

</footer><!-- /.post-info --> </div>
<div class="summary"><p>Another day, another talk. This one is on primitives and here are the <a href="/slides/primitives.html">slides</a></p>
<iframe src="/slides/primitives.html" width="800" height="450"></iframe>
<a class="btn btn-default btn-xs" href="http://www.lyh.me/primitives.html">more ...</a>
</div>
</article>
<hr/>
<article>
<h2><a href="http://www.lyh.me/type-classes.html">Type&nbsp;Classes</a></h2>
<div class="well well-sm">
Expand Down Expand Up @@ -398,35 +427,6 @@ <h2>Java&nbsp;conversion</h2>
</div>
</article>
<hr/>
<article>
<h2><a href="http://www.lyh.me/why-functional-why-scala.html">Why Functional? Why&nbsp;Scala?</a></h2>
<div class="well well-sm">
<footer class="post-info">
<span class="label label-default">Date</span>
<span class="published">
<i class="fa fa-calendar"></i><time datetime="2014-07-28T23:03:00-04:00"> Mon 28 July 2014</time>
</span>



<span class="label label-default">Category</span>
<a href="http://www.lyh.me/category/code.html">code</a>


<span class="label label-default">Tags</span>
<a href="http://www.lyh.me/tag/fp.html">fp</a>
/
<a href="http://www.lyh.me/tag/scala.html">scala</a>
/
<a href="http://www.lyh.me/tag/data.html">data</a>

</footer><!-- /.post-info --> </div>
<div class="summary"><p>I recently did an internal talk at Spotify on why every data engineer should know something about functional programming languages and Scala. And here are the <a href="/slides/pitch.html">slides</a>.</p>
<iframe src="/slides/pitch.html" width="800" height="450"></iframe>
<a class="btn btn-default btn-xs" href="http://www.lyh.me/why-functional-why-scala.html">more ...</a>
</div>
</article>
<hr/>

<ul class="pagination">
<li class="prev"><a href="http://www.lyh.me/author/neville-li.html">&laquo;</a>
Expand Down Expand Up @@ -476,11 +476,11 @@ <h4><i class="fa fa-home fa-lg"></i><span class="icon-label">Social</span></h4>
<li class="list-group-item">
<h4><i class="fa fa-home fa-lg"></i><span class="icon-label">Recent Posts</span></h4>
<ul class="list-group" id="recentposts">
<li class="list-group-item"><a href="http://www.lyh.me/canbuildfrom.html">CanBuildFrom</a></li>
<li class="list-group-item"><a href="http://www.lyh.me/decompiling-scala-code.html">Decompiling Scala&nbsp;code</a></li>
<li class="list-group-item"><a href="http://www.lyh.me/implicits.html">Implicits</a></li>
<li class="list-group-item"><a href="http://www.lyh.me/scio-at-philly-ete.html">Scio at Philly <span class="caps">ETE</span></a></li>
<li class="list-group-item"><a href="http://www.lyh.me/joins.html">Joins</a></li>
<li class="list-group-item"><a href="http://www.lyh.me/for-comprehensions.html">For&nbsp;comprehensions</a></li>
</ul>
</li>
<!-- End Sidebar/Recent Posts -->
Expand Down
31 changes: 30 additions & 1 deletion author/neville-li3.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,35 @@
<div class="container">
<div class="row">
<div class="col-sm-9">
<article>
<h2><a href="http://www.lyh.me/why-functional-why-scala.html">Why Functional? Why&nbsp;Scala?</a></h2>
<div class="well well-sm">
<footer class="post-info">
<span class="label label-default">Date</span>
<span class="published">
<i class="fa fa-calendar"></i><time datetime="2014-07-28T23:03:00-04:00"> Mon 28 July 2014</time>
</span>



<span class="label label-default">Category</span>
<a href="http://www.lyh.me/category/code.html">code</a>


<span class="label label-default">Tags</span>
<a href="http://www.lyh.me/tag/fp.html">fp</a>
/
<a href="http://www.lyh.me/tag/scala.html">scala</a>
/
<a href="http://www.lyh.me/tag/data.html">data</a>

</footer><!-- /.post-info --> </div>
<div class="summary"><p>I recently did an internal talk at Spotify on why every data engineer should know something about functional programming languages and Scala. And here are the <a href="/slides/pitch.html">slides</a>.</p>
<iframe src="/slides/pitch.html" width="800" height="450"></iframe>
<a class="btn btn-default btn-xs" href="http://www.lyh.me/why-functional-why-scala.html">more ...</a>
</div>
</article>
<hr/>
<article>
<h2><a href="http://www.lyh.me/light-table.html">Light&nbsp;Table</a></h2>
<div class="well well-sm">
Expand Down Expand Up @@ -255,11 +284,11 @@ <h4><i class="fa fa-home fa-lg"></i><span class="icon-label">Social</span></h4>
<li class="list-group-item">
<h4><i class="fa fa-home fa-lg"></i><span class="icon-label">Recent Posts</span></h4>
<ul class="list-group" id="recentposts">
<li class="list-group-item"><a href="http://www.lyh.me/canbuildfrom.html">CanBuildFrom</a></li>
<li class="list-group-item"><a href="http://www.lyh.me/decompiling-scala-code.html">Decompiling Scala&nbsp;code</a></li>
<li class="list-group-item"><a href="http://www.lyh.me/implicits.html">Implicits</a></li>
<li class="list-group-item"><a href="http://www.lyh.me/scio-at-philly-ete.html">Scio at Philly <span class="caps">ETE</span></a></li>
<li class="list-group-item"><a href="http://www.lyh.me/joins.html">Joins</a></li>
<li class="list-group-item"><a href="http://www.lyh.me/for-comprehensions.html">For&nbsp;comprehensions</a></li>
</ul>
</li>
<!-- End Sidebar/Recent Posts -->
Expand Down
4 changes: 2 additions & 2 deletions authors.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
<div class="row">
<div class="col-sm-9">
<h1>Authors on Das Keyboard Shredder</h1>
<li><a href="http://www.lyh.me/author/neville-li.html">Neville Li</a> (24)</li>
<li><a href="http://www.lyh.me/author/neville-li.html">Neville Li</a> (25)</li>
</div>
<div class="col-sm-3" id="sidebar">
<aside>
Expand Down Expand Up @@ -104,11 +104,11 @@ <h4><i class="fa fa-home fa-lg"></i><span class="icon-label">Social</span></h4>
<li class="list-group-item">
<h4><i class="fa fa-home fa-lg"></i><span class="icon-label">Recent Posts</span></h4>
<ul class="list-group" id="recentposts">
<li class="list-group-item"><a href="http://www.lyh.me/canbuildfrom.html">CanBuildFrom</a></li>
<li class="list-group-item"><a href="http://www.lyh.me/decompiling-scala-code.html">Decompiling Scala&nbsp;code</a></li>
<li class="list-group-item"><a href="http://www.lyh.me/implicits.html">Implicits</a></li>
<li class="list-group-item"><a href="http://www.lyh.me/scio-at-philly-ete.html">Scio at Philly <span class="caps">ETE</span></a></li>
<li class="list-group-item"><a href="http://www.lyh.me/joins.html">Joins</a></li>
<li class="list-group-item"><a href="http://www.lyh.me/for-comprehensions.html">For&nbsp;comprehensions</a></li>
</ul>
</li>
<!-- End Sidebar/Recent Posts -->
Expand Down
Loading

0 comments on commit 74dbacb

Please sign in to comment.