Skip to content

Instantly share code, notes, and snippets.

View jedws's full-sized avatar

Jed Wesley-Smith jedws

View GitHub Profile
@pchiusano
pchiusano / partask.scala
Created February 12, 2014 22:10
Applicative for scalaz.concurrent.Task that 'automatically' parallelizes the applicative operations
import scalaz.Applicative
import scalaz.concurrent.Task
/**
* This `Applicative[Task]` runs tasks in parallel, by defining
* `ap` and `apply2` in terms of `mapBoth`. This differs from the
* default `Applicative[Task]`, where effects are sequenced
* deterministically, in left to right order.
*/
val T = new Applicative[Task] {
@milessabin
milessabin / gist:6166101
Created August 6, 2013 16:26
Encoding records in #Scala as an HList of values tagged with the singleton types of their keys.
scala> import SingletonTypes._ ; import Record._
import SingletonTypes._
import Record._
scala> val r = "name" ->> "foo" :: "age" ->> 1 :: "lastName" ->> "bar" :: HNil
r: shapeless.::[String with Object{type keyType = String("name")},shapeless.::[Int with Object{type keyType = String("age")},shapeless.::[String with Object{type keyType = String("lastName")},shapeless.HNil]]] = foo :: 1 :: bar :: HNil
@travisbrown
travisbrown / needle-in-haystack.scala
Created November 13, 2012 22:57
Digging through arbitrarily nested case classes, tuples, and lists
/**
* Digging through arbitrarily nested case classes, tuples, and lists
* by Travis Brown
*
* In response to this question by Channing Walton on the Shapeless dev list:
*
* https://groups.google.com/d/msg/shapeless-dev/hn7_U21tupI/Zm9h3uNb51gJ
*
* Tested with Scala 2.9.2 and Shapeless 1.2.3. Should work on 1.2.2 with minor edits.
*/