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
{ | |
"metadata": { | |
"name": "" | |
}, | |
"nbformat": 3, | |
"nbformat_minor": 0, | |
"worksheets": [ | |
{ | |
"cells": [ | |
{ |
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
trait MeasureTypeClass[A]{ | |
def measure(a: A) : Int | |
} | |
object TypeClassExample{ | |
def genericMeasure[A : MeasureTypeClass](value: A): Int = { | |
val measurer = implicitly[MeasureTypeClass[A]] | |
measurer.measure(value) | |
} | |
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 scalaz.contrib.std.FutureInstances // Dependency: scalaz-contrib | |
import scalaz.{ Monad , OptionT } // Dependency: scalaz | |
import scala.concurrent.ExecutionContext.Implicits.global | |
import scala.concurrent.Future | |
class FutureAndOptionComposition[A, B, C, D] | |
extends FutureInstances | |
// The FutureInstances trait has a method which creates a Monad instance | |
// for Future which is used implicitly by the OptionT | |
{ |
NewerOlder