support user-defined types as base_type

includes new ranged class and more examples and tests.