Last active
December 20, 2015 22:58
-
-
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?
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 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