scalaz

warning: Creating default object from empty value in /opt/bitnami/apps/portal/htdocs/modules/taxonomy/taxonomy.pages.inc on line 34.

learning Scalaz: day 16

in

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

Yesterday we looked at Arrow as a way of abstracting function-like things and Unapply as a way of providing typeclass meta-instances. We also continued on with the applicative experiment by implementing XProduct that supports parallel compositions.

Memo

Pure functions don't imply they are computationally cheap. For example, calcuate a list of SHA-1 hash for all permutations of ASCII character string up to 8 characters length. If we don't count the tab character there are 95 printable characters in ASCII, so let's round that up to 100. 100 ^ 8 is 10 ^ 16. Even if we could handle 1000 hashing per second, it takes 10 ^ 13 secs, or 316888 years.

learning Scalaz: day 15

in

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

Rodolfo Cartas for openphoto.net

On day 14 we started hacking on Scalaz. First, typeclass instances for Vector was added to import Scalaz._. Next, we rolled back <*> to be infix ap. Finally, we added an implicit converter to unpack A as [α]A, which helps compiler find Applicative[({type λ[α]=Int})#λ].

All three of the pull requests were accepted by the upstream! Here's how to sync up:

$ git co scalaz-seven
$ git pull --rebase

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

Syndicate content