Skip to content

Instantly share code, notes, and snippets.

@paulp
Last active August 29, 2015 13:56
Show Gist options
  • Save paulp/8883303 to your computer and use it in GitHub Desktop.
Save paulp/8883303 to your computer and use it in GitHub Desktop.
object Nats {
sealed trait Nat {
type Prev <: Nat { type Succ = Nat.this.type }
type Succ <: Nat { type Prev = Nat.this.type }
}
object Zero extends Nat
type _0 = Zero.type
type _1 = _0#Succ
type _2 = _1#Succ
type _3 = _2#Succ
type _4 = _3#Succ
type _5 = _4#Succ
type _6 = _5#Succ
type _7 = _6#Succ
type _8 = _7#Succ
type _9 = _8#Succ
}
// Largest source alias is _6
// Largest existential created is _3220.type
// 3.555 real, 7.164 user, 0.202 sys
//
// Largest source alias is _7
// Largest existential created is _22432.type
// 6.056 real, 11.557 user, 0.416 sys
//
// Largest source alias is _8
// Largest existential created is _156892.type
// 20.183 real, 29.146 user, 1.645 sys
//
// Largest source alias is _9
// Largest existential created is _1098088.type
// 869.508 real, 902.972 user, 16.297 sys
@paulp
Copy link
Author

paulp commented Feb 8, 2014

scala 2.11.0-M8, looks like it might be less pathological in 2.10.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment