Last active
June 11, 2017 20:59
-
-
Save janekdb/27b861a37f8088ba8171f6565eef4ef8 to your computer and use it in GitHub Desktop.
Scala Type Level Programming: The Natural Numbers: First Assertions
This file contains 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
// 1 = O + 1 | |
implicitly[MsbOne =:= MsbZero#inc] | |
// 2 = O + 1 + 1 | |
implicitly[B0[MsbOne] =:= MsbZero#inc#inc] | |
// 3 = O + 1 + 1 + 1 | |
implicitly[B1[MsbOne] =:= MsbZero#inc#inc#inc] | |
// 4 = O + 1 + 1 + 1 + | |
implicitly[B0[B0[MsbOne]] =:= MsbZero#inc#inc#inc#inc] | |
// etc | |
implicitly[B1[B0[MsbOne]] =:= MsbZero#inc#inc#inc#inc#inc] | |
implicitly[B0[B1[MsbOne]] =:= MsbZero#inc#inc#inc#inc#inc#inc] | |
implicitly[B1[B1[MsbOne]] =:= MsbZero#inc#inc#inc#inc#inc#inc#inc] | |
implicitly[B0[B0[B0[MsbOne]]] =:= MsbZero#inc#inc#inc#inc#inc#inc#inc#inc] | |
implicitly[B1[B0[B0[MsbOne]]] =:= MsbZero#inc#inc#inc#inc#inc#inc#inc#inc#inc] | |
// 0 = 0 * 2 | |
implicitly[MsbZero =:= MsbZero#dbl] | |
// 2 = 1 * 2 | |
implicitly[B0[MsbOne] =:= MsbOne#dbl] | |
// 4 = 2 * 2 | |
implicitly[B0[B0[MsbOne]] =:= B0[MsbOne]#dbl] | |
// 6 = 3 * 2 | |
implicitly[B0[B1[MsbOne]] =:= B1[MsbOne]#dbl] | |
type T0 = MsbZero | |
type T1 = T0#inc | |
type T2 = T1#inc | |
type T3 = T2#inc | |
type T4 = T3#inc | |
type T5 = T4#inc | |
type T6 = T5#inc | |
type T7 = T6#inc | |
type T8 = T7#inc | |
type T9 = T8#inc | |
type T10 = T9#inc | |
type T11 = T10#inc | |
type T12 = T11#inc | |
type T13 = T12#inc | |
type T14 = T13#inc | |
type T15 = T14#inc | |
type T16 = T15#inc | |
type T17 = T16#inc | |
implicitly[T17 =:= MsbZero#inc#inc#inc#inc#inc#inc#inc#inc#inc#inc#inc#inc#inc#inc#inc#inc#inc] | |
// 17 = 1 * 2 * 2 * 2 * 1 + 1 | |
implicitly[T17 =:= MsbOne#dbl#dbl#dbl#dbl#inc] | |
type T20 = T10#add[T10] | |
type T27 = T20#add[T7] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment