# Transparently use native ruby types

**URL:** <https://discourse.dry-rb.org/t/transparently-use-native-ruby-types/762>\
**Category:** dry-types\
**Created:** [April 26, 2019, 7:10am UTC](https://discourse.dry-rb.org/t/transparently-use-native-ruby-types/762 "2019-04-26T07:10:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![waiting-for-dev](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.dry-rb.org/waiting-for-dev/32/71_2.png) [@waiting-for-dev](https://discourse.dry-rb.org/u/waiting-for-dev)\
**Post date:** [April 26, 2019, 7:10am UTC](https://discourse.dry-rb.org/t/transparently-use-native-ruby-types/762/1 "2019-04-26T07:10:12Z")

</div>

A ruby class is already a type. However, to specify it within a `dry-types` declaration we must wrap it in `Types.Instance()`. For example:

```ruby
Types::Strict::Array.of(Object)["a"]
# => NoMethodError: undefined method `call_unsafe' for Object:Class
Types::Strict::Array.of(Types.Instance(Object))["a"]
# => ["a"]

```

Would it be too difficult to transparently swallow ruby native types? And what are your thoughts about it?

---

<div class="post-metadata">

**Author:** ![solnic](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.dry-rb.org/solnic/32/779_2.png) [@solnic](https://discourse.dry-rb.org/u/solnic)\
**Post date:** [April 29, 2019, 7:54am UTC](https://discourse.dry-rb.org/t/transparently-use-native-ruby-types/762/2 "2019-04-29T07:54:40Z")

</div>

We must wrap it so that it’s not ambiguous. Inferring type from a core primitive could be tricky and it could even lead to subtle bugs; furthermore, I would not like to see code like this:

```ruby
attribute :foo, Float
attribute :bar, Types::Integer.constrained(gt: 0)

```

I understand where you’re coming from with this, but if it really bothers you, it should be trivial to add your own helper method that would cover your specific use cases.

---

<div class="post-metadata">

**Author:** ![waiting-for-dev](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.dry-rb.org/waiting-for-dev/32/71_2.png) [@waiting-for-dev](https://discourse.dry-rb.org/u/waiting-for-dev)\
**Post date:** [April 29, 2019, 9:54am UTC](https://discourse.dry-rb.org/t/transparently-use-native-ruby-types/762/3 "2019-04-29T09:54:55Z")

</div>

Yep, your point is very fair. I had contradictory feelings with it anyway. Thanks!
