Type class trickery to eliminate the FFI boilerplate.