eed3si9n - scalaz
https://eed3si9n.com/taxonomy/term/2/0
enmonads are fractals
https://eed3si9n.com/monads-are-fractals
<p>On my way back from Uppsala, my mind wandered to a conversation I had with a collegue about the intuition of monads, which I pretty much butchered at the time. As I was mulling this over, it dawned on me.</p>
<p><img src="/images/200px-Sierpinski_triangle.png" alt="Sierpinski triangle" /></p>
<h3>monads are fractals</h3>
<p>The above is a fractal called Sierpinski triangle, the only fractal I can remember to draw. Fractals are self-similar structure like the above triangle, in which the parts are similar to the whole (in this case exactly half the scale as parent triangle).</p>
<p><a href="https://eed3si9n.com/monads-are-fractals" target="_blank">read more</a></p>https://eed3si9n.com/monads-are-fractals#commentsscalazMon, 20 Oct 2014 12:15:07 +0000eed3si9n175 at https://eed3si9n.comlearning Scalaz: nescala 2014
https://eed3si9n.com/learning-scalaz-nescala2014
<p>Here are the slide decks and video for learning Scalaz talk:</p>
<ul>
<li><a href="https://github.com/eed3si9n/learning-scalaz/raw/master/talks/nescala2014_learning_scalaz.pdf">nescala2014_learning_scalaz.pdf</a></li>
<li><a href="https://thenewcircle.com/s/post/1578/learning_scalaz_eugene_yokota_video">video of the talk</a></li>
</ul>
https://eed3si9n.com/learning-scalaz-nescala2014#commentsscalazSat, 01 Mar 2014 17:32:23 +0000eed3si9n162 at https://eed3si9n.comlearning Scalaz: day 21
https://eed3si9n.com/learning-scalaz-day21
<p>Added <a href="http://eed3si9n.com/learning-scalaz/day21.html">day 21</a> on html5 book.</p>
https://eed3si9n.com/learning-scalaz-day21#commentsscalazFri, 21 Feb 2014 13:00:00 +0000eed3si9n160 at https://eed3si9n.comlearning Scalaz: day 20
https://eed3si9n.com/learning-scalaz-day20
<p>Added <a href="http://eed3si9n.com/learning-scalaz/day20.html">day 20</a> on html5 book.</p>
https://eed3si9n.com/learning-scalaz-day20#commentsscalazThu, 13 Feb 2014 15:38:48 +0000eed3si9n158 at https://eed3si9n.comlearning Scalaz: day 19
https://eed3si9n.com/learning-scalaz-day19
<p>Added <a href="http://eed3si9n.com/learning-scalaz/day19.html">day 19</a> on the html5 book.</p>
https://eed3si9n.com/learning-scalaz-day19#commentsscalazSun, 09 Feb 2014 00:49:43 +0000eed3si9n156 at https://eed3si9n.comNotes on 'Monads Are Not Metaphors'
https://eed3si9n.com/notes-on-monads-are-not-metaphors
<blockquote><p>This is a translation of <a href="http://d.hatena.ne.jp/xuwei/20130505/1367742286">「モナドはメタファーではない」に関する補足</a> by Kenji Yoshida (<a href="https://twitter.com/xuwei_k">@xuwei_k</a>), one of the most active Scala bloggers in Japan covering wide range of topics from Play to Scalaz.</p>
</blockquote>
<p>Daniel Spiewak's <a href="http://www.codecommit.com/blog/ruby/monads-are-not-metaphors">Monads Are Not Metaphors</a> was written about two and a half years ago, but seeing how its <a href="http://eed3si9n.com/ja/monads-are-not-metaphors">Japanese translation</a> is still being tweeted and being bookmarked by 250 users on <a href="http://b.hatena.ne.jp/entry/eed3si9n.com/ja/monads-are-not-metaphors">Hantena</a>, its popularity doesn't seem to cease. I just remembered something to note about the example code used in the post, which could be an unstylish critique, but I'm going to jot it down here. It's an <em>unstylish critique</em>, because I'll be digging into the part where <em>the author likely knew from the beginning but omitted it intentionally for the sake of illustration</em>. Also I'll be using Scalaz in this post.</p>
<p><a href="https://eed3si9n.com/notes-on-monads-are-not-metaphors" target="_blank">read more</a></p>https://eed3si9n.com/notes-on-monads-are-not-metaphors#commentsscalazMon, 06 May 2013 14:00:00 +0000eed3si9n134 at https://eed3si9n.comlearning Scalaz, an html5 book
https://eed3si9n.com/learning-scalaz-html5-book
<p>Scalaz 7.0 is out. For easier reading and toc, I converted learning Scalaz series into an html5 book using @n8han's Pamflet:</p>
<ul>
<li><a href="http://eed3si9n.com/learning-scalaz/">learning Scalaz</a></li>
</ul>
https://eed3si9n.com/learning-scalaz-html5-book#commentsscalazMon, 22 Apr 2013 14:42:24 +0000eed3si9n132 at https://eed3si9n.comsudoku using Func
https://eed3si9n.com/sudoku-using-func
<blockquote><p>This is the 5th entry of <a href="http://partake.in/events/7211abc9-ebb8-4670-b912-3089dc5e0edd">Scalaz Advent Calendar 2012</a>.</p>
</blockquote>
<p>During the months of December, tech-savvy geeks in Japan take turns to post themed blog articles, known as the "Advent Calendar". For last year's <a href="http://partake.in/events/33870915-f25b-40b6-9456-b898b898d48b">Scala Advent Calendar 2011</a> I <a href="http://eed3si9n.com/ja/essence-of-iterator-pattern">translated</a> Eric Torreborre's post covering <a href="http://etorreborre.blogspot.com/2011/06/essence-of-iterator-pattern.html">The Essence of Iterator Pattern</a>. It was somewhat of a calculated move, knowing Japanese fondness for functional programming articles. Another selfish motive was that some of the concept would seep in to my thickness as I was translating the post word by word. In hindsight, both goals were achieved handsomely thanks to the quality of both Jeremy Gibbons, Bruno Oliveira and Eric's work. This seeped in knowledge was probably the secret sauce behind the learning Scalaz series that I worked on this year.</p>
<p>As covered in <a href="http://eed3si9n.com/learning-scalaz-day12">learning Scalaz day 12</a> Scalaz 7 already included <code>product</code> and <code>compose</code> methods in typeclass instances as well as <a href="https://github.com/scalaz/scalaz/blob/scalaz-seven/core/src/main/scala/scalaz/Traverse.scala"><code>Traverse</code></a>. It even has <a href="https://github.com/scalaz/scalaz/blob/c0f74398fdbc4f804fa06429fb58db4a9d3aafb0/example/src/main/scala/scalaz/example/WordCount.scala">the word count example</a> from the paper. What I realized missing was the value-level composition. One of the interesting points from the paper was "composition of applicative functors," which enables a kind of modular programming.</p>
<p>By "applicative functors" Gibbons and Oliveira actually mean composition of applicative functions, not just the typeclass instances. This is evident in the following snippet from the paper:</p>
<div class="geshifilter">
<pre class="haskell geshifilter-haskell"><span class="kw1">data</span> <span class="br0">(</span>m ⊠ n<span class="br0">)</span> a <span class="sy0">=</span> Prod <span class="br0">{</span> pfst <span class="sy0">::</span> m a<span class="sy0">,</span> psnd <span class="sy0">::</span> n a <span class="br0">}</span>
<span class="br0">(</span>⊗<span class="br0">)</span> <span class="sy0">::</span> <span class="br0">(</span><span class="kw4">Functor</span> m<span class="sy0">,</span> <span class="kw4">Functor</span> n<span class="br0">)</span> ⇒ <span class="br0">(</span>a → m b<span class="br0">)</span> → <span class="br0">(</span>a → n b<span class="br0">)</span> → <span class="br0">(</span>a → <span class="br0">(</span>m ⊠ n<span class="br0">)</span> b<span class="br0">)</span>
<span class="br0">(</span>f ⊗ g<span class="br0">)</span> x <span class="sy0">=</span> Prod<span class="br0">(</span>f x<span class="br0">)</span><span class="br0">(</span>gx<span class="br0">)</span></pre></div>
<p>The algebraic data type <code>⊠</code> is the type-level product, while the infix function <code>⊗</code> is the value-level product of two applicative functions, which returns applicative function of type <code>a → (m ⊠ n)</code>. In other words, the programmer would construct functions that return an applicative functor, and the type-level compositions are done automatically.</p>
<p><a href="https://eed3si9n.com/sudoku-using-func" target="_blank">read more</a></p>https://eed3si9n.com/sudoku-using-func#commentsscalazWed, 05 Dec 2012 04:00:00 +0000eed3si9n127 at https://eed3si9n.comlearning Scalaz: day 18
https://eed3si9n.com/learning-scalaz-day18
<blockquote><p>Hey there. There's an updated <a href="http://eed3si9n.com/learning-scalaz/">html5 book version</a>, if you want.</p>
</blockquote>
<p>On <a href="http://eed3si9n.com/learning-scalaz-day17">day 17</a> we looked at IO monad as a way of abstracting side effects, and Iteratees as a way of handling streams. And the series ended.</p>
<h3>Func</h3>
<p>I wanted to continue exploring a better way to compose applicative functions, and came up with a wrapper called <code>AppFunc</code>:</p>
<div class="geshifilter">
<pre class="scala geshifilter-scala"><span class="kw1">val</span> f <span class="sy0">=</span> AppFuncU <span class="br0">{</span> <span class="br0">(</span>x<span class="sy0">:</span> Int<span class="br0">)</span> <span class="sy0">=></span> x + 1 <span class="br0">}</span>
<span class="kw1">val</span> g <span class="sy0">=</span> AppFuncU <span class="br0">{</span> <span class="br0">(</span>x<span class="sy0">:</span> Int<span class="br0">)</span> <span class="sy0">=></span> List<span class="br0">(</span>x, <span class="nu0">5</span><span class="br0">)</span> <span class="br0">}</span>
<span class="br0">(</span>f <span class="sy0">@&&&</span> g<span class="br0">)</span> traverse List<span class="br0">(</span><span class="nu0">1</span>, <span class="nu0">2</span>, <span class="nu0">3</span><span class="br0">)</span></pre></div>
<p><a href="https://eed3si9n.com/learning-scalaz-day18" target="_blank">read more</a></p>https://eed3si9n.com/learning-scalaz-day18#commentsscalazMon, 15 Oct 2012 07:22:19 +0000eed3si9n125 at https://eed3si9n.comlearning Scalaz: day 17
https://eed3si9n.com/learning-scalaz-day17
<blockquote><p>Hey there. There's an updated <a href="http://eed3si9n.com/learning-scalaz/">html5 book version</a>, if you want.</p>
</blockquote>
<div class="floatingimage">
<img src="http://eed3si9n.com/images/openphoto-6987bw.jpg" />
<div class="credit">Daniel Steger for openphoto.net</div>
</div>
<p><a href="http://eed3si9n.com/learning-scalaz-day16">Yesterday</a> we looked at <code>Memo</code> for caching computation results, and <code>ST</code> as a way of encapsulating mutation. Today we'll continue into IO.</p>
<h3>IO Monad</h3>
<p>Instead of reading the second half of the paper, we can get the gist by reading <a href="http://apocalisp.wordpress.com/2011/12/19/towards-an-effect-system-in-scala-part-2-io-monad/">Towards an Effect System in Scala, Part 2: IO Monad</a> by <a href="http://twitter.com/runarorama">Rúnar (@runarorama)</a>:</p>
<blockquote><p>While ST gives us guarantees that mutable memory is never shared, it says nothing about reading/writing files, throwing exceptions, opening network sockets, database connections, etc.</p>
</blockquote>
<p><a href="https://eed3si9n.com/learning-scalaz-day17" target="_blank">read more</a></p>https://eed3si9n.com/learning-scalaz-day17#commentsscalazMon, 24 Sep 2012 06:24:47 +0000eed3si9n123 at https://eed3si9n.com