Skip to content

Instantly share code, notes, and snippets.

View markhibberd's full-sized avatar

markhibberd markhibberd

View GitHub Profile
import scalaz._, Scalaz._
import shapeless._
case class Codec[A](to: A => List[String], from: List[String] => String \/ (List[String], A)) {
def bimap[B](f: A => B, g: B => A): Codec[B] =
Codec[B](g andThen to, x => from(x).map(_.map(f)))
}
import scala.util.Try
import scala.util.{Success => TrySuccess}
/**
* Generated by Scrooge
* version: 3.12.0
* rev: acdb2135b6b8ab36c09a93fb3d502295ba9a27b6
* built at: 20140110-113906
*/
package com.example
import com.twitter.scrooge.{
TFieldBlob, ThriftException, ThriftStruct, ThriftStructCodec3, ThriftUtil}
def dsortNat[A](z: NatOrd, xs: Stream[(Int,A)]): Stream[Stream[A]] = {
val arr = new Array[MutableList[A]](z.i+1)
xs.foreach { arg: (Int,A) =>
val idx = arg._1
if(arr(idx) == null) arr(idx) = MutableList[A](arg._2)
else arr(idx) += arg._2
}
arr.toStream.filter(_ != null).map(_.toStream)
}
lens - more than a curiosity
Lenses are a simple but very useful construct that provide views
over data for retrieval and modification in a compositional way.
The `lens` library in haskell (a.k.a. Control.Lens) takes this idea
to an extreme. This talk will provide a bit of a history around
lens encodings, and then attempt to demonstrate that `lens` should be
an essential part of any haskellers toolkit, and not just a curiosity,
or nice toy.
def x[M[_]: MonadPlus, A, B](xs: List[A], f: A => M[B]): M[B] =
xs.foldLeft(implicitly[MonadPlus[M]].empty[B])((acc, a) => implicitly[MonadPlus[M]].plus(acc, f(a)))
the contents of a
Title: Introduction to Functional Programming (3-day workshop)
Presenters: Mark Hibberd, Katie Miller and Tony Morris
When: Monday 17, Tuesday 18 & Wednesday 19 March, 2014
Time: 9:00am- 5:00pm (lunch will be provided)
Where: Red Hat, Level 1, 193 North Quay, Brisbane QLD 4000
Cost: Free
Abstract: In conjunction with the Lambda Ladies group, NICTA will be hosting a free hands-on, three day Introduction to Functional Programming, for interested participants (internal and external). This event is targeted toward women who are interested in learning about functional programming and preference will be applied accordingly.
We will be using the Haskell programming language for our journey over the three days and this session requires no prior experience with functional programming.
Title: Introduction to Functional Programming (3-day workshop)
Presenters: Mark Hibberd, Katie Miller and Tony Morris
When: Monday 17, Tuesday 18 & Wednesday 19 March, 2014
Time: 9:00am- 5:00pm ( lunch will be provided)
Where: Red Hat, Level 1, 193 North Quay, Brisbane QLD 4000
Cost: Free
Abstract: In conjunction with the Lambda Ladies group, NICTA will be hosting a free hands-on, three day Introduction to Functional Programming, for interested participants (internal and external). This event is targeted toward women who are interested in learning about functional programming and preference will be applied accordingly.
We will be using the Haskell programming language for our journey over the three days and this session requires no prior experience with functional programming.
scala> import TypeCheckedTripleEquals._
warning: there were 1 deprecation warning(s); re-run with -deprecation for details
import TypeCheckedTripleEquals._
scala> def x[A](x: A, y: A): Boolean = x === y
warning: there were 1 deprecation warning(s); re-run with -deprecation for details
x: [A](x: A, y: A)Boolean
scala> x(1, ())
warning: there were 1 deprecation warning(s); re-run with -deprecation for details
scala> class X
defined class X
scala> class Y extends X
defined class Y
scala> def some[A](f: A)(implicit ev: A => X): X = ev(f)
some: [A](f: A)(implicit ev: A => X)X
scala> some(new X)