Skip to content

Instantly share code, notes, and snippets.

View juanpavergara's full-sized avatar

Juan Pablo Vergara juanpavergara

View GitHub Profile
// http://underscore.io/blog/posts/2015/04/14/free-monads-are-simple.html
// updated version for scalaz 7.2.x where Free automatically applies the
// Coyoneda transform
import scalaz.{Free, ~>, Id}
import scalaz.std.list._
import scalaz.syntax.traverse._
type UserId = Int
type UserName = String
@igstan
igstan / poly-return.scala
Last active June 15, 2017 22:50
Polymorphic return types in Scala using implicit parameters
trait Factory[T] {
def create: T
}
object Factory {
implicit def stringFactory: Factory[String] = new Factory[String] {
def create = "foo"
}
implicit def intFactory: Factory[Int] = new Factory[Int] {