Last active
December 10, 2016 03:22
-
-
Save trane/ff512d6d1c7254264b81bbb2d613f156 to your computer and use it in GitHub Desktop.
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.util.Try | |
object ImplementedClient { | |
def getStuff[A](url: String): Try[A] = | |
Try(url.asInstanceOf[A]) | |
} | |
trait Client[F[_], G[_]] { | |
def transform[A](f: F[A]): G[A] | |
def get[A](url: String): G[A] | |
} | |
trait BaseClient[G[_]] extends Client[Try, G] { | |
def transform[A](f: Try[A]): G[A] | |
def get[A](url: String): G[A] = transform(ImplementedClient.getStuff[A](url)) | |
} | |
val optionClient = new BaseClient[Option] { def transform[A](f: Try[A]): Option[A] = f.toOption } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment