Skip to content

Instantly share code, notes, and snippets.

View jyrimatti's full-sized avatar

Jyri-Matti Lähteenmäki jyrimatti

View GitHub Profile
@etorreborre
etorreborre / gist:3870064
Created October 11, 2012 03:54
Unboxed union types with a context bound
/**
* this is an experiment to create unboxed union types with a phantom type and a context bound.
* All the good ideas come from @milessabin post, comments and links: http://www.chuusai.com/2011/06/09/scala-union-types-curry-howard/#comment-22
*/
/** trait for anything that can be A or B */
trait Or[A, B] {
// a phantom type, there will be no instance of this type that we'll use
type l[T]
// an alias for l[t]
@noidi
noidi / gist:3751951
Created September 19, 2012 20:11
Why functional programming matters to enterprise programmers

Why functional programming matters to enterprise programmers

tl;dr: Solving a very specific problem using FP tends to produce a very general solution that's applicable to a wide range of problems.

Let's start with some Java code that we'll simplify using functional programming.

class Department {
  Employee getYoungestEmployee() {

if (employees.isEmpty()) return null;