This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Inspired by the writings of Edward Kmett, Edward Yang and Gabriel Gonzalez | |
-- concerning free monads and the codensity transformation. | |
-- | |
-- http://comonad.com/reader/2011/free-monads-for-less/ | |
-- http://blog.ezyang.com/2012/01/problem-set-the-codensity-transformation/ | |
-- http://www.haskellforall.com/2012/06/you-could-have-invented-free-monads.html | |
-- | |
{-# LANGUAGE RankNTypes #-} | |
{-# LANGUAGE MultiParamTypeClasses #-} | |
{-# LANGUAGE FlexibleInstances #-} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
svn co http://svn.apache.org/repos/asf/hadoop/common/trunk hadoop-trunk -r 1178440 | |
cd hadoop-trunk/ | |
mvn clean install package -Dtar -Pdist -DskipTests -P-cbuild | |
cd hadoop-mapreduce-project/ | |
mvn clean install package -Dtar -Pdist -DskipTests -P-cbuild assembly:assembly | |
mkdir ~/HADOOP_MAPREDUCE | |
cp ./../../hadoop-trunk/hadoop-common-project/hadoop-common/target/hadoop-common-0.24.0-SNAPSHOT.tar.gz ~/HADOOP_MAPREDUCE/. | |
cp ./../../hadoop-trunk/hadoop-mapreduce-project/target/hadoop-mapreduce-0.24.0-SNAPSHOT-all.tar.gz ~/HADOOP_MAPREDUCE/. | |
cd ~/HADOOP_MAPREDUCE | |
tar xvfz hadoop-common-0.24.0-SNAPSHOT.tar.gz ; mv hadoop-common-0.24.0-SNAPSHOT common |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
---------------------------------------------------------------- | |
-- Free Monad example agaist RWH 15.8 | |
-- | |
-- Original code: http://ideone.com/F49k71 | |
import Control.Applicative | |
import Control.Monad.Free | |
import System.IO (Handle, IOMode(..), stdout) | |
import qualified System.IO as IO | |
import System.IO.Unsafe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Based on the second part of the talk "Dead-Simple Dependency Injection in Scala" by @runarorama at NEScala 2012 | |
http://marakana.com/s/dependency_injection_in_scala,1108/index.html | |
*/ | |
sealed trait KVS[A] | |
case class Put[A](key: String, value: String, a: A) extends KVS[A] | |
case class Get[A](key: String, h: String => A) extends KVS[A] | |
case class Delete[A](key: String, a: A) extends KVS[A] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// At the external API level, use TypeTag | |
def extract[T: TypeTag](jsv: JsValue): T = | |
extractImpl[T](jsv, typeOf[T]) | |
// But use Type for everything else | |
def extractImpl[T](jsv: JsValue, tpe: Type): T = { | |
// no need for m | |
val ex = jsv match { | |
case JsNumber(n) => n | |
case JsString(s) => s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.reflect.runtime.universe._ | |
import scala.reflect.api.{TypeCreator, Universe} | |
object Test extends App { | |
def foo[T: TypeTag] = TypeTag(typeTag[T].mirror, new TypeCreator { | |
override def apply[U <: Universe with Singleton](m: scala.reflect.api.Mirror[U]): U # Type = { | |
typeTag[T].in(m).tpe match { | |
case TypeRef(_, _, argHead :: Nil) => argHead.asInstanceOf[U#Type] | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14:26 ~/Projects/210x (2.10.x)$ scala | |
Welcome to Scala version 2.10.1-20130204-105326-3d318be51f (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_37). | |
Type in expressions to have them evaluated. | |
Type :help for more information. | |
scala> case class Shop(store: String, item: String, cost: Int) { def this() = this(null, null, 0) } | |
defined class Shop | |
scala> val t = typeOf[Shop] | |
t: reflect.runtime.universe.Type = Shop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import concurrent.{ExecutionContext, Future => SFuture, Promise} | |
import util.Try | |
import _root_.scalaz.\/ | |
import _root_.scalaz.concurrent.{Task => ZTask} | |
object Task { | |
def fromScala[A] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#WARNING: Use at your own risk. No warranties expressed or implied. YMMV. Drive responsibly. Eat healthy. | |
#First, `cd` into the parent dir for all of your `sbt`/`maven` projects (I assume you have one of those) | |
find "$(cd ..; pwd)" -type d -name "target" -exec sudo tmutil addexclusion -p {} + |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scalaVersion := "2.11.8" | |
scalaOrganization := "org.typelevel" | |
libraryDependencies ++= Seq( | |
"org.typelevel" %% "cats" % "0.9.0", | |
"org.atnos" %% "eff" % "4.0.0" | |
) | |
addCompilerPlugin("org.spire-math" %% "kind-projector" % "0.9.3") |
OlderNewer