Last active
December 13, 2015 21:48
-
-
Save fthomas/4979797 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
// see http://stackoverflow.com/questions/14924707/how-to-write-a-scalaz-isempty-parameter-for-generic-types | |
import scalaz._ | |
import Scalaz._ | |
object Test { | |
def asOption[C](c: C)(implicit ev: IsEmpty[({type F[_] = C})#F]): Option[C] = | |
if (ev.isEmpty(c)) None else Some(c) | |
implicit def detailedIsEmpty[A, C[_]](implicit ev: IsEmpty[C]) = | |
ev.asInstanceOf[IsEmpty[({type F[_] = C[A]})#F]] | |
implicit def detailedIsEmptyMap[K, V](implicit ev: IsEmpty[({type F[V] = Map[K, V]})#F]) = | |
ev.asInstanceOf[IsEmpty[({type F[_] = Map[K, V]})#F]] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment