mrb: move type check code to mruby