Skip to content

Instantly share code, notes, and snippets.

@tpolecat
Last active December 20, 2015 22:58
Show Gist options
  • Save tpolecat/6208565 to your computer and use it in GitHub Desktop.
Save tpolecat/6208565 to your computer and use it in GitHub Desktop.
Playing around with Nat literals and I'm finding cases (as below) where everything goes kind of sideways. Any clues?
// Scala 2.10.2 and Shapeless 2.0.0-SNAPSHOT
import shapeless._
import shapeless.nat._
sealed trait Month {
type ND <: Nat
def apply(n: Nat)(implicit ev: LTEq[n.N, ND]) = "foo"
}
def mkMonth(len: Nat) =
new Month {
type ND = len.N
}
val Jan = mkMonth(31)
Jan(30) // compiles ok
Jan(31) // spins the compiler; never returns
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment