Last active
July 1, 2016 04:07
-
-
Save mankyKitty/ef2267fbf6ef9ab5538a06c59e9bfafe to your computer and use it in GitHub Desktop.
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 HasAString[A] { | |
def getTheString( a: A ): String | |
} | |
// This shenanigan has been pulled from Scalaz Functor definition | |
object HasAString { | |
@inline def apply[A](implicit a:HasAString[A]): HasAString[A] = a | |
} | |
object Zuh { | |
implicit val wutHasAString: HasAString[Wut] = new HasAString[Wut] { | |
def getTheString( a:Wut ): String = | |
a.totes.has.string | |
} | |
def zooms[A: HasAString]( xs: List[A] ): List[A] = | |
xs.foldr(List.empty[A])( (x,acc) => { | |
val s = HasAString[A].getTheString(x) | |
fugfug(x, s) :: acc | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment