An open API service indexing awesome lists of open source software.

https://github.com/memoizr/typelevel-fizzbuzz

An implementation of the famous exercise done at the type level in Scala.
https://github.com/memoizr/typelevel-fizzbuzz

Last synced: 3 months ago
JSON representation

An implementation of the famous exercise done at the type level in Scala.

Awesome Lists containing this project

README

        

# typelevel-fizzbuzz

You have your series you know and love:
1, 2, Fizz, 4, Buzz, ...

Now let's ask the compiler to build it for us in the form of the type of a shapeless `HList`, so we have:

_1 :: _2 :: Fizz :: _4 :: Buzz :: Fizz :: _7 ....

Credit to Miles (who else?) for implementing it as an example in shapeless. This is a variation that uses a typelevel range which is then mapped with a poly function to the desired series. Particular focus was put into making the typelevel code as expressive as possible. As with anything of this ilk, don't do this at home! This is just for entertainment purposes.

Enjoy.