Functional Scala: Combinatoric Pattern Matching

Welcome to another episode of functional Scala!

In the last episode we were introducing ourself to the idea of Pattern matching – a powerful mechanism for operating on algebraic datatypes by examining different occurrences for a certain type separately, each within an individual case expression. So far, we only matched single values of some sum types by their given value constructors. In this episode we’re going to see how to match against a combination of sum type values. Read the rest of this entry »

Functional Scala: Algebraic Datatypes – Sum and Product Types

Welcome back to another episode of Functional Scala!

This one is the continuation of the last episode, where we introduced algebraic datatypes. Within this installment we’ll broaden the scope and find a more general definition for algebraic datatypes. Of course we don’t stop with definitions. Since we wanna write code (that’s Scala for, isn’t it?), we’ll see how to implement those extended new forms of algebraic datatypes (we’re going to meet today) within Scala! Read the rest of this entry »

Functional Scala: Algebraic Datatypes – Enumerated Types

Welcome to another episode of Functional Scala!

This episode is the first part of at least two episodes we’re gonna take a deeper look at what’s called Algebraic datatypes and how you could build some of them on your own in Scala. An algebraic datatype reflects the idea, that a type is – loosely spoken – a set of certain (data) values. So in it’s very simplest form, an algebraic datatype can be defined by giving an enumeration of all the individual data values for a given type (of course you always also need to give the type an appropriate name). Read the rest of this entry »

Functional Scala: Polymorphic Functions ?!?

Welcome to another episode of Functional Scala!

If you’re coming from the object oriented world, chances are good that you’ve already heard something about a concept called Polymorphism. You may also know that there are different classes of Polymorphism out there: most of us are familiar with so called (Sub-)Type polymorphism and Parametric polymorphism (you may call it Generics).

Since functions take a central role within Functional Programming (i need to mention this, in case you’ve forgotten it), we want to take a closer look if Scala allows for so called polymorphic functions, which plays in the area of parametric polymorphism. If you’re now asking what the heck do we need polymorphic functions for (if anything), you’re coming to the right place! Read the rest of this entry »

Functional Scala: Turning Methods into Functions (or WTF is eta expansion?)

Welcome back to another episode of Functional Scala!

First of all, a happy new year to all of you – this year will bring a bunch of new episodes about ‘Functional Scala’ to you, so i hope we’ll grasp a better and better understanding over time on how Scala enables us to write functional code. Again, we’ve only scratched the surface so far – there are far more basic functional concepts (like curried functions, algebraic datatypes, pattern matching, …) to come, before we dig down into some more advanced topis like catamorphisms (sounds cool, eh? But trust me, the idea behind is really simple – you even saw already some examples of it using folds) or type classes and some of their instances (i.e. Functors, Applicatives and even – drum roll – those ubiquitous mentioned ‘warm fuzzy things’ , ehm i mean Monads). Read the rest of this entry »

Merry Christmas – or let it snow with Akka

I just played with Akka the other day, in order to get proficient to some of the basic patterns and idioms which come with the underlying Actor model.  I chose Conway’s Game of Life as a little pet project.  But instead of calculating the state of each cell by using a discrete computation model (that is calculating the state of the next generation for all cells by the fixed state of the cells current generation – then switch to the next generation, and so on)  i did it in a rather asynchronous way. Read the rest of this entry »

Posted in general. 1 Comment »

Talking about ‘Functional Scala in Practice’ at Java User Group – Frankfurt/Main

I will give another ‘sequel’ talk about ‘Functional Scala’ at the Java User Group / Frankfurt at the ‘Brotfabrik’ on October 20, 2010 / 19.00 pm.

After a short summary and some addition to the core concepts of functional programming within Scala, this time we’ll focus on its practical application.

Based upon the functional mechanisms and ‘tools’ provided by Scala, we’ll develop some fundamental functions and pick up some more advanced features of functional Programming along the way (exploring how far it can be pushed within Scala).

This will include such topics as

  • Partial Application and Currying
  • Transformators and Combinators
  • Fundamental Functions (reduce, map, …)
  • Monads (well, a small introduction)
  • Type-Classes

All topics will be accompanied by some examples, allowing for a smooth entrance into the world of functional programming.

You’ll find the official site of the JUG / Frankfurt for the official announcement of my talk here.

Looking forward to see you there …