Add type_check callback

Fixes #196.