learning Scalaz: day 14

in

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

bman ojel for openphoto.net

Yesterday we looked at what import scalaz._ and Scalaz._ bring into the scope, and also talked about a la carte style import. Knowing how instances and syntax are organized prepares us for the next step, which is to hack on Scalaz.

mailing list

Before we start hacking on a project, it's probably good idea to join its Google Group.

git clone

$ git clone -b scalaz-seven git://github.com/scalaz/scalaz.git scalaz-seven

learning Scalaz: day 13

in

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

e.e d3si9n

Yesterday we skimmed two papers by Jeremy Gibbons and quickly looked at origami programming and applicative traversal. Instead of reading something, why don't we focus on using Scalaz today.

implicits review

Scalaz makes heavy use of implicits. Both as a user and an extender of the library, it's important to have general idea on where things are coming from. Let's quickly review Scala's imports and implicits!

In Scala, imports are used for two purposes:
1. To include names of values and types into the scope.
2. To include implicits into the scope.

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.

Syndicate content