Created
April 1, 2014 15:59
-
-
Save pedrofurla/9917123 to your computer and use it in GitHub Desktop.
HList map doesn't like defaults...
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
scala> val sample = "A" :: 1 :: 2L :: HNil | |
sample: shapeless.::[String,shapeless.::[Int,shapeless.::[Long,shapeless.HNil]]] = A :: 1 :: 2 :: HNil | |
scala> object bleh4 extends Poly1 { | |
| implicit val caseInt = at[Int](_.toString); | |
| implicit val caseLong = at[Long](_.toString); | |
| implicit val caseStr = at[String](_.toString); | |
| } | |
defined module bleh4 | |
scala> object bleh5 extends Poly1 { | |
| implicit val caseInt = at[Int](_.toString); | |
| implicit val caseLong = at[Long](_.toString); | |
| implicit val caseStr = at[String](_.toString); | |
| implicit def default[T]=at[T](identity) | |
| } | |
defined module bleh5 | |
scala> sample map bleh4 | |
res11: shapeless.::[bleh4.caseStr.Result,shapeless.::[bleh4.caseInt.Result,shapeless.::[bleh4.caseLong.Result,shapeless.HNil]]] = A :: 1 :: 2 :: HNil | |
scala> sample map bleh5 | |
<console>:35: error: could not find implicit value for parameter mapper: shapeless.ops.hlist.Mapper[bleh5.type,shapeless.::[String,shapeless.::[Int,shapeless.::[Long,shapeless.HNil]]]] | |
sample map bleh5 | |
^ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment