Tagged monads

So, I finally found some time for a Template Metaranting follow-up post. This time let's get down to business as this one contains a fair amount of code.

Sadly, I won't rant as much but instead I'll try to show how awesome D's templates really are. We'll write a piece of code, based on this Scheme implementation, that is, a simple monad) that we'll use to build a binary tree, with uniquely numbered nodes containing their height, without any global state (therefore purely) entirely at compile time.

Quick Reader, grab my code!

ADVENTURE!

Continue reading