learning Scalaz: day 12

in

Hey there. There's an updated html5 book version, if you want.

reynaldo f. tamayo for openphoto.net

On day 11 we looked at Lens as a way of abstracting access to nested immutable data structure.

Today, let's skim some papers. First is Origami programming by Jeremy Gibbons.

Origami programming

Gibbons says:

In this chapter we will look at folds and unfolds as abstractions. In a precise technical sense, folds and unfolds are the natural patterns of computation over recursive datatypes; unfolds generate data structures and folds consume them.

learning Scalaz: day 11

in

Hey there. There's an updated html5 book version, if you want.

Darren Hester for openphoto.net

Yesterday we looked at Reader monad as a way of abstracting configuration, and introduced monad transformers.

Today, let's look at lenses. It's a hot topic many people are talking, and looks like it has clear use case.

Go turtle go

Seth Tisue (@SethTisue) gave a talk on shapeless lenses at Scalathon this year. I missed the talk, but I am going to borrow his example.

scala> case class Point(x: Double, y: Double)
defined class Point
 
scala> case class Color(r: Byte, g: Byte, b: Byte)
defined class Color
 
scala> case class Turtle(
         position: Point,
         heading: Double,
         color: Color)
 
scala> Turtle(Point(2.0, 3.0), 0.0,
         Color(255.toByte, 255.toByte, 255.toByte))
res0: Turtle = Turtle(Point(2.0,3.0),0.0,Color(-1,-1,-1))

learning Scalaz: day 10

in

Hey there. There's an updated html5 book version, if you want.

On day 9 we looked at how to update immutable data structure using TreeLoc for Trees and Zipper for Streams. We also picked up a few typeclasses like Id, Index and Length. Now that we are done with Learn You a Haskell for Great Good, we need to find our own topic.

learning Scalaz: day 9

in

Hey there. There's an updated html5 book version, if you want.

On day 8 we reviewed monadic functions join, filterM, and foldLeftM, implemented safe RPN calculator, looked at Kleisli to compose monadic functions, and implemented our own monad Prob.

Tree

Let's start the final chapter of Learn You a Haskell for Great Good: Zippers:

learning Scalaz: day 8

in

Hey there. There's an updated html5 book version, if you want.

On day 7 we reviewed Applicative Builder, and looked at State monad, \/ monad, and Validation. Let's continue on.

Some useful monadic functions

Learn You a Haskell for Great Good says:

learning Scalaz: day 7

in

Hey there. There's an updated html5 book version, if you want.

On day 6 we reviewed for syntax and checked out the Writer monad and the reader monad, which is basically using functions as monads.

Applicative Builder

learning Scalaz: day 6

in

Hey there. There's an updated html5 book version, if you want.

Yesterday we looked at Monad typeclass, which introduces flatMap. We looked at how monadic chaining can add contexts to values. Because both Option and List already have flatMap in the standard library, it was more about changing the way we see things rather than introducing new code. We also reviewed for syntax as a way of chaining monadic operations.

for syntax again

learning Scalaz: day 5

in

Hey there. There's an updated html5 book version, if you want.

On day 4 we reviewed typeclass laws like Functor laws and used ScalaCheck to validate on arbitrary examples of a typeclass. We also looked at three different ways of using Option as Monoid, and looked at Foldable that can foldMap etc.

A fist full of Monads

We get to start a new chapter today on Learn You a Haskell for Great Good.

learning Scalaz: day 4

in

Hey there. There's an updated html5 book version, if you want.

Yesterday we reviewed kinds and types, explored Tagged type, and started looking at Semigroup and Monoid as a way of abstracting binary operations over various types.

I've gotten a few feedbacks. First, paulp suggested that I could use companion type like Option.type for our kind calculator. Using the updated version, we get the following:

scala> kind[Functor.type]

learning Scalaz: day 3

in

Hey there. There's an updated html5 book version, if you want.

Yesterday we started with Functor, which adds map operator, and ended with polymorphic sequenceA function that uses Pointed[F].point and Applicative ^(f1, f2) {_ :: _} syntax.

Kinds and some type-foo

Syndicate content