 Your new post is loading...
 Your new post is loading...
|
Scooped by
Srdjan Strbanovic
April 25, 2014 4:31 PM
|
|
Scooped by
Srdjan Strbanovic
April 25, 2014 1:12 PM
|
|
Scooped by
Srdjan Strbanovic
April 25, 2014 12:14 PM
|
|
Scooped by
Srdjan Strbanovic
April 24, 2014 4:16 PM
|
One of the more powerful features Scala has is the ability to generically abstract across things that take type parameters. This feature is known as Higher Kinded Types (HKT). This feature allows us to write a library that works with a much wider array of classes, whereas without the feature you are condemned to bespoke and error ridden code duplication for each class that may want the functionality. Type constructors Essentially what HKT gives us is the ability to generalize across type constructors – where a type constructor is anything that has a type parameter. For instance List[_]* is not a type, the underscore is a hole into which another type may be plugged, constructing a complete type. List[String] and List[Int] being examples of complete (or distinct) types. Kinds Now that we have a type constructor we can think of several different kinds of them, classified by how many type parameters they take. The simplest – like List[_] – that take a single param have the kind: (* -> *) This says: given one type, produce another. For instance, given String produce the type List[String]. Something that takes two parameters, say Map[_, _], or Function1[_, _] has the kind: (* -> * -> *) This says: given one type, then another, produce the final type. For instance given the key type Int and the value type String produce the type Map[Int, String]. Furthermore, you can have kinds that are themselves parameterized by higher kinded types. So, something could not only take a type, but take something that itself takes type parameters. An example would be the covariant functor: Functor[F[_]], it has the kind: ((* -> *) -> *) This says: given a simple higher kinded type, produce the final type. For instance given a type constructor like List produce the final type Functor[List]. Utility Say we have some standard pattern for our data-structures where we want to be able to consistently apply an operation of the same shape. Functors are a nice example, the covariant functor allows us to take a box holding things of type A, and a function of A => B and get back a box holding things of type B. In Java, there is no way to specify that these things share a common interface, or that we simply want transformable boxes. We need to either make this static eg. Guava’s Lists and Iterables, or bespoke on the interface, eg: fugue’s Option or atlassian-util-concurrent’s Promise. There is simply no way to unify these methods on either some super interface or to specify that you have – or require – a “mappable/transformable” box. With HKT I can represent the covariant functor described above as: 1234567891011121314151617181920212223242526272829303132333435trait Functor[F[_]] { def map[A, B](fa: F[A])(f: A => B): F[B] } // implement for java's List // note that the presence of mutation in the Java collections // breaks the Functor laws import java.util.{ List => JList } implicit object JavaListFunctor extends Functor[JList] { import collection.JavaConverters._ def […]
|
Scooped by
Srdjan Strbanovic
April 24, 2014 3:29 PM
|
Recently I was doing some data processing and since it fit nicely in a parallel setup, I changed my pipeline to use the Array.Parallel module. An easy and simple change that can speed up your task ...
|
Scooped by
Srdjan Strbanovic
April 24, 2014 9:41 AM
|
Vagrant - A library for distributing dynamic assemblies
|
Scooped by
Srdjan Strbanovic
April 24, 2014 9:30 AM
|
|
Scooped by
Srdjan Strbanovic
April 23, 2014 8:55 AM
|
|
Scooped by
Srdjan Strbanovic
April 22, 2014 9:41 AM
|
|
Scooped by
Srdjan Strbanovic
April 11, 2014 11:25 AM
|
A higher kind of request to Don Syme... please please please,,,, we desperately need higher kinds!
|
Scooped by
Srdjan Strbanovic
April 10, 2014 4:33 PM
|
Functional programming is increasing in popularity these days given the inherent problems with shared mutable state that is rife in the imperative world. As we march on to a world of multi and many-co
|
Scooped by
Srdjan Strbanovic
April 10, 2014 10:17 AM
|
|
Scooped by
Srdjan Strbanovic
April 9, 2014 6:20 PM
|
|
|
Scooped by
Srdjan Strbanovic
April 25, 2014 1:24 PM
|
Functional reactive programming ( FRP) is a programming paradigm for reactive programming using the building blocks of functional programming. FRP has been used for programming GUIs, robotics, and music, aiming to simplify these problems by explicitly modeling time.
|
Scooped by
Srdjan Strbanovic
April 25, 2014 12:50 PM
|
Inspired by languages like Concurrent ML and Cilk, Hopac is a library for F# with the aim of making it easier to write correct, modular and efficient parallel, asynchronous and concurrent programs.
|
Scooped by
Srdjan Strbanovic
April 25, 2014 11:26 AM
|
|
Scooped by
Srdjan Strbanovic
April 24, 2014 3:31 PM
|
The following example uses sequence and array operators to implement a simple digital filter. The example builds on the previous WAV I/O example. A digital filter frequently needs multiply-add oper...
|
Scooped by
Srdjan Strbanovic
April 24, 2014 9:43 AM
|
FsAttoparsec - A port of Bryan O'Sullivan's attoparsec from Haskell to F#
|
Scooped by
Srdjan Strbanovic
April 24, 2014 9:39 AM
|
HyperF - F# async service framework
|
Scooped by
Srdjan Strbanovic
April 23, 2014 9:18 AM
|
|
Scooped by
Srdjan Strbanovic
April 22, 2014 9:43 AM
|
|
Scooped by
Srdjan Strbanovic
April 22, 2014 9:25 AM
|
Blog and open source projects by Tim Jones.
|
Scooped by
Srdjan Strbanovic
April 11, 2014 11:23 AM
|
An implementation of session types in F#. Inspired from the paper "Haskell Session Types with (Almost) No Class"
|
Scooped by
Srdjan Strbanovic
April 10, 2014 4:33 PM
|
|
Scooped by
Srdjan Strbanovic
April 9, 2014 6:34 PM
|
|