Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save janekdb/c07c4f5cec7e4e08bef80ec192325469 to your computer and use it in GitHub Desktop.
Save janekdb/c07c4f5cec7e4e08bef80ec192325469 to your computer and use it in GitHub Desktop.
Scala Type Level Programming: The Natural Numbers: Exponentiation Assertions
// 1^0
implicitly[T1#exp[T0] =:= T1]
// 1^1
implicitly[T1#exp[T1] =:= T1]
// 1^2
implicitly[T1#exp[T2] =:= T1]
// 1^3
implicitly[T1#exp[T3] =:= T1]
// 2^0
implicitly[T2#exp[T0] =:= T1]
// 2^1
implicitly[T2#exp[T1] =:= T2]
// 2^2
implicitly[T2#exp[T2] =:= T4]
// 2^3
implicitly[T2#exp[T3] =:= T8]
// 3^0
implicitly[T3#exp[T0] =:= T1]
// 3^1
implicitly[T3#exp[T1] =:= T3]
// 3^2
implicitly[T3#exp[T2] =:= T9]
// 3^3
implicitly[T3#exp[T3] =:= T27]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment