This file contains hidden or 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
object Manage { | |
sealed trait SubCmd | |
case class DeployCmd(deployUser: String, deployDir: String, noPack: Boolean) extends SubCmd | |
case class RestartCmd(restartUser: String) extends SubCmd | |
case object LogCmd extends SubCmd | |
case object ConsoleCmd extends SubCmd | |
case class ManageCmd( | |
verbose: Boolean = false, | |
quiet: Boolean = false, |
This file contains hidden or 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
package main | |
import scala.annotation.implicitNotFound | |
object DemoWithNaiveSupertype extends App { | |
trait Addable { | |
def +(other: Addable): Addable | |
} | |
case class Foo(x: Int) extends Addable { |
This file contains hidden or 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
val httpService = new RhoService { | |
GET / "hello" / 'world +? param[Int]('fav) |>> { params => | |
Ok(s"Received ${params('fav)}, ${params('world)}") | |
} | |
} |
This file contains hidden or 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
~$ ls /Library/Java/JavaVirtualMachines/jdk1.7.0_*.jdk/Contents/Home/jre | |
/Library/Java/JavaVirtualMachines/jdk1.7.0_25.jdk/Contents/Home/jre: | |
COPYRIGHT README THIRDPARTYLICENSEREADME.txt bin | |
LICENSE THIRDPARTYLICENSEREADME-JAVAFX.txt Welcome.html lib | |
/Library/Java/JavaVirtualMachines/jdk1.7.0_40.jdk/Contents/Home/jre: | |
COPYRIGHT README THIRDPARTYLICENSEREADME.txt bin | |
LICENSE THIRDPARTYLICENSEREADME-JAVAFX.txt Welcome.html lib | |
/Library/Java/JavaVirtualMachines/jdk1.7.0_60.jdk/Contents/Home/jre: |
This file contains hidden or 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.language.higherKinds | |
def optKleisli[M[_]: Applicative, A, B](fn: Kleisli[M, A, B]) = Kleisli[M, Option[A], Option[B]] { | |
case Some(t) => fn(t).map(_.some) | |
case None => Applicative[M].point(none[B]) | |
} |
This file contains hidden or 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
/** | |
* Copyright (c) 2014 Erik Allik | |
* | |
* All rights reserved. | |
* | |
* Redistribution and use in source and binary forms, with or without | |
* modification, are permitted provided that the following conditions are met: | |
* | |
* 1. Redistributions of source code must retain the above copyright notice, this | |
* list of conditions and the following disclaimer. |
This file contains hidden or 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
type Va[A] = Validation[String, A] | |
type VaNel[A] = ValidationNel[String, A] | |
import shapeless._, contrib.scalaz._, syntax.std.tuple._ | |
import syntax.std.function._, ops.function._ | |
import shapeless.ops.hlist._ | |
// for Kleisli and its >=> | |
implicit val vaBinding = new Bind[Va] { | |
def map[A, B](fa: Va[A])(f: A => B): Va[B] = fa.map(f) |
This file contains hidden or 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
// libraryDependencies ++= Seq( | |
// "org.scalaz" %% "scalaz-core" % "7.1.0", | |
// "com.chuusai" %% "shapeless" % "2.0.0", | |
// "org.typelevel" %% "shapeless-scalacheck" % "0.3", | |
// "org.typelevel" %% "shapeless-spire" % "0.3", | |
// "org.typelevel" %% "shapeless-scalaz" % "0.3" | |
// ) | |
import shapeless._, contrib.scalaz._, syntax.std.tuple._ |
This file contains hidden or 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
[error] found : scalaz.syntax.ApplicativeBuilder[[X]scalaz.Validation[scalaz.NonEmptyList[String],X],String,String] | |
[error] required: scalaz.ValidationNel[String,String] | |
[error] (which expands to) scalaz.Validation[scalaz.NonEmptyList[String],String] | |
[error] params.map(_.toValidationNel).reduce(_ |@| _) { (code, countryCode3) => | |
[error] ^ |
This file contains hidden or 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 shapeless._ | |
import poly._ | |
import syntax.std.tuple._ | |
type Va[+A] = Validation[String, A] | |
type Vali[+A, -B] = Kleisli[Va, A, B] | |
def Vali[A, B](fn: A => Va[B]): Vali[A, B] = Kleisli[Va, A, B](fn) | |
implicit val vaBinding = new Bind[Va] { | |
def map[A, B](fa: Va[A])(f: A => B): Va[B] = fa.map(f) |