Beware that "%identity" is an unsafe feature that breaks all safety guarantees if used badly.

If you were, for example, to change your definition of "foo" (in a way not always representable as integers, such as adding a constructor with parameters), int_of_foo would become incorrect. The compiler wouldn't warn you, and you could get pretty bad failures (segfaults). You're on your own.