Created
March 5, 2015 20:42
-
-
Save ceedubs/119f5fc72c4acd22e52a to your computer and use it in GitHub Desktop.
Weird implicit search failure with Shapeless At and Nat._0
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
package shapeless.examples | |
import shapeless._ | |
import nat._ | |
import ops.hlist._ | |
object TableExample { | |
final case class Row[L <: HList](cells: L) | |
final case class Table[L <: HList](rows: L) { | |
def row[R <: HList](rowNumber: Nat)(implicit atR: At.Aux[L, rowNumber.N, Row[R]]): Row[R] = | |
atR(rows) | |
} | |
val test = Table( | |
Row(1 :: 2 :: 3 :: HNil) :: | |
Row(4 :: 5 :: 6 :: HNil) :: | |
Row(7 :: 8 :: 9 :: HNil) :: | |
HNil) | |
test.row(1) // Row(4 :: 5 :: 6 :: HNil) | |
test.row(2) // Row(7 :: 8 :: 9 :: HNil) | |
// all of these below fail to compile with errors like: | |
// could not find implicit value for parameter atR: shapeless.ops.hlist.At.Aux[shapeless.::[shapeless.examples.TableExample.Row[shapeless.::[Int,shapeless.::[Int,shapeless.::[Int,shapeless.HNil]]]],shapeless.::[shapeless.examples.TableExample.Row[shapeless.::[Int,shapeless.::[Int,shapeless.::[Int,shapeless.HNil]]]],shapeless.::[shapeless.examples.TableExample.Row[shapeless.::[Int,shapeless.::[Int,shapeless.::[Int,shapeless.HNil]]]],shapeless.HNil]]],nat_$macro$3.N,shapeless.examples.TableExample.Row[R]] | |
//test.row(0) | |
//test.row(Nat(0)) | |
//test.row(Nat._0) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It looks like it works if I change
row
to:But this doesn't work when I need to go through a chain of ops with
At
being the first one.