Created
May 23, 2013 17:43
-
-
Save milessabin/5637928 to your computer and use it in GitHub Desktop.
Mapping get over an HList of Maps.
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._ | |
trait Name | |
case class VarName(nme: String) extends Name | |
case class ParamName(nme: String) extends Name | |
def lookup(nme: String): Option[Name] :: Option[Name] :: HNil = { | |
object get extends Poly1 { | |
implicit def default[T <: Name] = at[Map[String, T]](_.get(nme)) | |
} | |
val finalMap = Map("foo" -> VarName("foo")) :: Map("bar" -> ParamName("bar")) :: HNil | |
finalMap.map(get) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment