Skip to content

Instantly share code, notes, and snippets.

@pedrofurla
Created April 1, 2014 15:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pedrofurla/9917123 to your computer and use it in GitHub Desktop.
Save pedrofurla/9917123 to your computer and use it in GitHub Desktop.
HList map doesn't like defaults...
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