Last active
August 29, 2015 13:57
-
-
Save tixxit/9789854 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
import shapeless._ | |
import shapeless.ops.traversable._ | |
trait ListApply[A] { | |
def apply(xs: List[_]): Option[A] | |
} | |
object ListApply { | |
implicit def genericListApply[A, L <: HList](gen: Generic.Aux[A, L], toHList: FromTraversable[L]) = | |
new ListApply[A] { | |
def apply(xs: List[_]): Option[A] = toHList(xs) map gen.from | |
} | |
def apply[A](xs: List[_])(implicit toA: ListApply[A]): Option[A] = toA(xs) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment