Alvin Alexander | Java, Scala, Unix, Perl, Mac OS X

As a quick note, if you’re interested in using the IO monad described in this IO Monad for Cats article, here’s the source code for a complete Scala App based on that article:

The people at underscore.io have made their books on Scala and functional programming free (or “donationware,” if you prefer). I’ve found the Advanced Scala with Cats book to be particularly good, and well worth a donation.

(Full disclosure: I didn’t pay for the Advanced Scala book when I first downloaded it, then went back and tried to pay for it, but the Gumroad website wouldn’t let me do that.)

underscore.io books

After the 0.1.2 release of Learning Functional Programming in Scala, it occurs to me that I need to be more explicit about my goals for the book. Some people seem to think that I’m trying to “sell” functional programming. That’s not the case at all. I’m just trying to be a reporter and explain what I’ve learned about FP after reading dozens (hundreds?!) of articles and many books on FP, learning Haskell, trying to apply these techniques to my own code, etc. I’ll explain this further in the next release of the book.

I haven’t watched all of this video yet, but it’s about how to build Scala projects with a tool named CBT.

"Enlightenment of the wave". From the book, Zen Speaks, Shouts of Nothingness. The book is filled with wonderful cartoons like this.

Zen Speaks: Enlightenment of the wave

“The mind can proceed only so far upon what it knows and can prove. There comes a point where the mind takes a higher plane of knowledge, but can never prove how it got there. All great discoveries have involved such a leap.”

As a quick note, if you want to embed a Scala source code example in your Scaladoc comments, just put the source code block in between {{{ and }}} characters in your comments, as shown in this example:

How to format source code blocks in Scaladoc comments


“The Precogs are never wrong. But occasionally they do disagree.”
~ Minority Report
 

This article shares the source code for a Monte Carlo simulation that I wrote in Scala. It was inspired by the movie Minority Report, as well as my own experience.

Background

For the purposes of this simulation, imagine that you have three people that are each “right” roughly 80% of the time. For instance, if they take a test with 100 questions, each of the three individuals will get 80 of the questions right, although they may not get the same questions right or wrong. Given these three people, my question to several statisticians was, “If two of the people have the same answer to a given question, what are the odds that they are correct? Furthermore, if all three of them give the same answer to a question, what are the odds that they are right?”

“And when things got hard, you started looking for something to blame, like a big shadow. Let me tell you something you already know. The world ain’t all sunshine and rainbows. It’s a very mean and nasty place and I don’t care how tough you are, it will beat you to your knees and keep you there permanently if you let it. You, me, or nobody is gonna hit as hard as life. But it ain’t about how hard you hit. It’s about how hard you can get hit and keep moving forward. How much you can take and keep moving forward. That’s how winning is done.”

I enjoyed this quote from Rocky Balboa the first time I saw the movie, and I appreciate it even more now after getting my a** kicked by this blood disease but still plodding along every day.

It's about how hard you can get hit and keep moving forward

“Meditation is to bring the complex consciousness to simplicity and innocence without pride and arrogance.”

B.K.S. Itengar, The Tree of Yoga

Had another dream this morning that I was running on all fours. Rather than ask myself, “Why in the world am I doing this?”, I now just accept that I’m a dog (or a cat, or some other animal) in the dream. That helps me go along with whatever is happening in the dream, rather than fight it and wake up.

(Notes from a dream on June 28, 2016)

I can’t remember the name of the motel where I saw this, but this is a photo of a painting of sled dogs that I came across in Healy, Alaska, just north of Denali. (I remember the motel because I used to work with a nice guy named Carson, and a guy that could have easily passed as his twin brother worked there.)

Sled dog painting in Healy, Alaska

In my younger days this wasn't much of a problem. Unfortunately gravity seems to have increased significantly since the 1980s.

Stuck basketball

Tin Man by Miranda Lambert is a bit of a downer, but it’s the prettiest song I’ve heard in a while.

“A thousand days of training to develop, ten thousand days of training to polish.”

“It takes a thousand days to forge the spirit, and ten thousand days to polish it.”

~ These are two variations of a quote I saw today by Miyamoto Musashi

Intellij IDEA has a reall nice help-tip hover tool that helps to explain some of Scala’s advanced language features. In this case the code Monad[M[_]] is a higher-kinded type, which I hope to explain more in my new book.

Scala advanced language features

“Everyday life is like programming, I guess. If you love something, you can put beauty into it.”

~ Donald Knuth

Back in 2011, I lived in Palmer, Alaska. I drove about an hour down to Anchorage to visit a friend, then drove back to Palmer just after 1:30am. During the drive back I didn’t need my headlights on to see, but I kept them on so other cars could see me more easily. It was like driving during a very long “dawn” or “dusk” period.

Let the Sun shine (Anchorage, Alaska)

“How to write ‘Hello, world’ in Haskell.” This was even more humorous this morning when I saw it shared on Twitter by someone who is recruiting Haskell developers.

How to write 'Hello, world' in Haskell

A funny thing about life is that the worst video I’ve ever made (about the vi/vim editor) now has over 175,000 views.