library

This is a page from my book, Functional Programming, Simplified

Type Classes 103: The Cats Library

As a final example of how to use type classes in Scala, I’ll show how to repeat the example from the previous lesson using the open source “Cats” FP library for Scala. With the examples you’ve seen already, this will be a quick process.

Source code

Step 1 is to clone my source code for this lesson, which is available at this URL:

This is a page from my book, Functional Programming, Simplified

Type Classes 101: Introduction

“A type class is an interface that defines some behavior. More specifically, a type class specifies a bunch of functions, and when we decide to make a type an instance of a type class, we define what those functions mean for that type.”

Learn You a Haskell for Great Good!

Source code

The source code for all of the type class lessons is available at the following URL:

This is a page from my book, Functional Programming, Simplified

Signpost: Type Classes

In this section of the book I’ll cover Scala type classes, a programming technique that lets you add new behavior to closed data types. The use of type classes isn’t strictly limited to the functional programming style, but because they’re used so much in the Cats library — an FP library for Scala — it’s important to know how they work.

Android Room, database I/O, and Java 8 threads

I just started working with the Android Room database persistence library, and since you’re not supposed to run things like database queries on the main thread (the UI thread), I was looking at other ways to run them.

In general, you probably won’t want to run database queries using a Thread, but just to see how Room works, I wrote this Java Thread code, and confirmed that it works as expected:

Android Room database persistence library examples

As a note to self, here are some Android Room database persistence library examples:

Those tutorials don’t show how to properly use Room database access methods, so they’ll lead to Android “Application Not Responding” (ANR) errors. Therefore, here are some related Google/Android docs:

Finally, here’s my own Android AsyncTask REST example, which also shows how to use an AsyncTask.

The karma of bad software documentation

Tried to use someone’s software library.
Documentation was bad, couldn’t get it to work.
Used someone else’s.

#haiku-ish