lib: macro-ify type checks

CI, what's the score?