Enable to define type

I really like this adea! cool. And I wanna enable user to define type.

But this PR is just kind of refactoring. I'm not sure the best interface so far.