dry-types 0.13.2 → 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +763 -233
  3. data/LICENSE +17 -17
  4. data/README.md +15 -13
  5. data/dry-types.gemspec +28 -28
  6. data/lib/dry-types.rb +3 -1
  7. data/lib/dry/types.rb +156 -76
  8. data/lib/dry/types/any.rb +32 -12
  9. data/lib/dry/types/array.rb +19 -6
  10. data/lib/dry/types/array/constructor.rb +32 -0
  11. data/lib/dry/types/array/member.rb +75 -16
  12. data/lib/dry/types/builder.rb +131 -15
  13. data/lib/dry/types/builder_methods.rb +49 -20
  14. data/lib/dry/types/coercions.rb +76 -22
  15. data/lib/dry/types/coercions/json.rb +43 -7
  16. data/lib/dry/types/coercions/params.rb +118 -31
  17. data/lib/dry/types/compat.rb +0 -2
  18. data/lib/dry/types/compiler.rb +56 -41
  19. data/lib/dry/types/constrained.rb +81 -32
  20. data/lib/dry/types/constrained/coercible.rb +36 -6
  21. data/lib/dry/types/constraints.rb +18 -4
  22. data/lib/dry/types/constructor.rb +127 -54
  23. data/lib/dry/types/constructor/function.rb +216 -0
  24. data/lib/dry/types/constructor/wrapper.rb +94 -0
  25. data/lib/dry/types/container.rb +7 -0
  26. data/lib/dry/types/core.rb +54 -21
  27. data/lib/dry/types/decorator.rb +38 -17
  28. data/lib/dry/types/default.rb +61 -16
  29. data/lib/dry/types/enum.rb +43 -20
  30. data/lib/dry/types/errors.rb +75 -9
  31. data/lib/dry/types/extensions.rb +7 -1
  32. data/lib/dry/types/extensions/maybe.rb +74 -16
  33. data/lib/dry/types/extensions/monads.rb +29 -0
  34. data/lib/dry/types/fn_container.rb +6 -1
  35. data/lib/dry/types/hash.rb +86 -67
  36. data/lib/dry/types/hash/constructor.rb +33 -0
  37. data/lib/dry/types/inflector.rb +3 -1
  38. data/lib/dry/types/json.rb +18 -16
  39. data/lib/dry/types/lax.rb +75 -0
  40. data/lib/dry/types/map.rb +76 -33
  41. data/lib/dry/types/meta.rb +51 -0
  42. data/lib/dry/types/module.rb +120 -0
  43. data/lib/dry/types/nominal.rb +210 -0
  44. data/lib/dry/types/options.rb +13 -26
  45. data/lib/dry/types/params.rb +39 -25
  46. data/lib/dry/types/predicate_inferrer.rb +238 -0
  47. data/lib/dry/types/predicate_registry.rb +34 -0
  48. data/lib/dry/types/primitive_inferrer.rb +97 -0
  49. data/lib/dry/types/printable.rb +16 -0
  50. data/lib/dry/types/printer.rb +315 -0
  51. data/lib/dry/types/result.rb +29 -3
  52. data/lib/dry/types/schema.rb +408 -0
  53. data/lib/dry/types/schema/key.rb +156 -0
  54. data/lib/dry/types/spec/types.rb +103 -33
  55. data/lib/dry/types/sum.rb +84 -35
  56. data/lib/dry/types/type.rb +49 -0
  57. data/lib/dry/types/version.rb +3 -1
  58. metadata +68 -79
  59. data/.gitignore +0 -10
  60. data/.rspec +0 -2
  61. data/.travis.yml +0 -29
  62. data/.yardopts +0 -5
  63. data/CONTRIBUTING.md +0 -29
  64. data/Gemfile +0 -24
  65. data/Rakefile +0 -20
  66. data/benchmarks/hash_schemas.rb +0 -51
  67. data/lib/dry/types/compat/form_types.rb +0 -27
  68. data/lib/dry/types/compat/int.rb +0 -14
  69. data/lib/dry/types/definition.rb +0 -113
  70. data/lib/dry/types/hash/schema.rb +0 -199
  71. data/lib/dry/types/hash/schema_builder.rb +0 -75
  72. data/lib/dry/types/safe.rb +0 -59
data/LICENSE CHANGED
@@ -1,20 +1,20 @@
1
- Copyright (c) 2013-2014 Piotr Solnica
1
+ The MIT License (MIT)
2
2
 
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
3
+ Copyright (c) 2015-2021 dry-rb team
10
4
 
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
13
11
 
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,27 +1,29 @@
1
1
  [gem]: https://rubygems.org/gems/dry-types
2
- [travis]: https://travis-ci.org/dry-rb/dry-types
3
- [codeclimate]: https://codeclimate.com/github/dry-rb/dry-types
4
- [coveralls]: https://coveralls.io/r/dry-rb/dry-types
2
+ [actions]: https://github.com/dry-rb/dry-types/actions
3
+ [codacy]: https://www.codacy.com/gh/dry-rb/dry-types
4
+ [chat]: https://dry-rb.zulipchat.com
5
5
  [inchpages]: http://inch-ci.org/github/dry-rb/dry-types
6
6
 
7
- # dry-types [![Join the chat at https://gitter.im/dry-rb/chat](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/dry-rb/chat)
7
+ # dry-types [![Join the chat at https://dry-rb.zulipchat.com](https://img.shields.io/badge/dry--rb-join%20chat-%23346b7a.svg)][chat]
8
8
 
9
9
  [![Gem Version](https://badge.fury.io/rb/dry-types.svg)][gem]
10
- [![Build Status](https://travis-ci.org/dry-rb/dry-types.svg?branch=master)][travis]
11
- [![Code Climate](https://codeclimate.com/github/dry-rb/dry-types/badges/gpa.svg)][codeclimate]
12
- [![Test Coverage](https://codeclimate.com/github/dry-rb/dry-types/badges/coverage.svg)][codeclimate]
10
+ [![CI Status](https://github.com/dry-rb/dry-types/workflows/ci/badge.svg)][actions]
11
+ [![Codacy Badge](https://api.codacy.com/project/badge/Grade/f2d71613195f4da993acb9ac9d6ea336)][codacy]
12
+ [![Codacy Badge](https://api.codacy.com/project/badge/Coverage/f2d71613195f4da993acb9ac9d6ea336)][codacy]
13
13
  [![Inline docs](http://inch-ci.org/github/dry-rb/dry-types.svg?branch=master)][inchpages]
14
14
 
15
15
  ## Links
16
16
 
17
- * [Documentation](http://dry-rb.org/gems/dry-types)
17
+ * [User documentation](http://dry-rb.org/gems/dry-types)
18
+ * [API documentation](http://rubydoc.info/gems/dry-types)
18
19
 
19
- ## Development
20
+ ## Supported Ruby versions
20
21
 
21
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `bundle exec rake run_specs` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
22
+ This library officially supports the following Ruby versions:
22
23
 
23
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
24
+ * MRI >= `2.5`
25
+ * jruby >= `9.2`
24
26
 
25
- ## Contributing
27
+ ## License
26
28
 
27
- Bug reports and pull requests are welcome on GitHub at https://github.com/dry-rb/dry-types.
29
+ See `LICENSE` file.
data/dry-types.gemspec CHANGED
@@ -1,42 +1,42 @@
1
- lib = File.expand_path('../lib', __FILE__)
1
+ # frozen_string_literal: true
2
+ # this file is managed by dry-rb/devtools project
3
+
4
+ lib = File.expand_path('lib', __dir__)
2
5
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
6
  require 'dry/types/version'
4
7
 
5
8
  Gem::Specification.new do |spec|
6
- spec.name = "dry-types"
7
- spec.version = Dry::Types::VERSION.dup
9
+ spec.name = 'dry-types'
8
10
  spec.authors = ["Piotr Solnica"]
9
11
  spec.email = ["piotr.solnica@gmail.com"]
10
12
  spec.license = 'MIT'
13
+ spec.version = Dry::Types::VERSION.dup
11
14
 
12
- spec.summary = 'Type system for Ruby supporting coercions, constraints and complex types like structs, value objects, enums etc.'
15
+ spec.summary = "Type system for Ruby supporting coercions, constraints and complex types like structs, value objects, enums etc"
13
16
  spec.description = spec.summary
14
- spec.homepage = "https://github.com/dry-rb/dry-types"
17
+ spec.homepage = 'https://dry-rb.org/gems/dry-types'
18
+ spec.files = Dir["CHANGELOG.md", "LICENSE", "README.md", "dry-types.gemspec", "lib/**/*"]
19
+ spec.bindir = 'bin'
20
+ spec.executables = []
21
+ spec.require_paths = ['lib']
15
22
 
16
- # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
17
- # delete this section to allow pushing this gem to any host.
18
- if spec.respond_to?(:metadata)
19
- spec.metadata['allowed_push_host'] = "https://rubygems.org"
20
- else
21
- raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
22
- end
23
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
24
+ spec.metadata['changelog_uri'] = 'https://github.com/dry-rb/dry-types/blob/master/CHANGELOG.md'
25
+ spec.metadata['source_code_uri'] = 'https://github.com/dry-rb/dry-types'
26
+ spec.metadata['bug_tracker_uri'] = 'https://github.com/dry-rb/dry-types/issues'
23
27
 
24
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } - ['bin/console', 'bin/setup']
25
- spec.bindir = "exe"
26
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
- spec.require_paths = ["lib"]
28
- spec.required_ruby_version = ">= 2.2.0"
28
+ spec.required_ruby_version = ">= 2.5.0"
29
29
 
30
- spec.add_runtime_dependency 'concurrent-ruby', '~> 1.0'
31
- spec.add_runtime_dependency 'dry-core', '~> 0.4', '>= 0.4.4'
32
- spec.add_runtime_dependency 'dry-inflector', '~> 0.1', '>= 0.1.2'
33
- spec.add_runtime_dependency 'dry-container', '~> 0.3'
34
- spec.add_runtime_dependency 'dry-equalizer', '~> 0.2'
35
- spec.add_runtime_dependency 'dry-logic', '~> 0.4', '>= 0.4.2'
30
+ # to update dependencies edit project.yml
31
+ spec.add_runtime_dependency "concurrent-ruby", "~> 1.0"
32
+ spec.add_runtime_dependency "dry-container", "~> 0.3"
33
+ spec.add_runtime_dependency "dry-core", "~> 0.5", ">= 0.5"
34
+ spec.add_runtime_dependency "dry-inflector", "~> 0.1", ">= 0.1.2"
35
+ spec.add_runtime_dependency "dry-logic", "~> 1.0", ">= 1.0.2"
36
36
 
37
- spec.add_development_dependency "bundler", "~> 1.6"
38
- spec.add_development_dependency "rake", "~> 11.0"
39
- spec.add_development_dependency "rspec", "~> 3.3"
40
- spec.add_development_dependency 'dry-monads', '~> 0.2'
41
- spec.add_development_dependency 'yard', '~> 0.9.5'
37
+ spec.add_development_dependency "bundler"
38
+ spec.add_development_dependency "dry-monads", "~> 1.0"
39
+ spec.add_development_dependency "rake"
40
+ spec.add_development_dependency "rspec"
41
+ spec.add_development_dependency "yard"
42
42
  end
data/lib/dry-types.rb CHANGED
@@ -1 +1,3 @@
1
- require 'dry/types'
1
+ # frozen_string_literal: true
2
+
3
+ require "dry/types"
data/lib/dry/types.rb CHANGED
@@ -1,81 +1,94 @@
1
- require 'bigdecimal'
2
- require 'date'
3
- require 'set'
1
+ # frozen_string_literal: true
4
2
 
5
- require 'concurrent'
3
+ require "bigdecimal"
4
+ require "date"
5
+ require "set"
6
6
 
7
- require 'dry-container'
8
- require 'dry-equalizer'
9
- require 'dry/core/extensions'
10
- require 'dry/core/constants'
11
- require 'dry/core/class_attributes'
7
+ require "concurrent/map"
12
8
 
13
- require 'dry/types/version'
14
- require 'dry/types/container'
15
- require 'dry/types/inflector'
16
- require 'dry/types/type'
17
- require 'dry/types/definition'
18
- require 'dry/types/constructor'
19
- require 'dry/types/builder_methods'
9
+ require "dry/container"
10
+ require "dry/core/extensions"
11
+ require "dry/core/constants"
12
+ require "dry/core/class_attributes"
20
13
 
21
- require 'dry/types/errors'
14
+ require "dry/types/version"
15
+ require "dry/types/container"
16
+ require "dry/types/inflector"
17
+ require "dry/types/type"
18
+ require "dry/types/printable"
19
+ require "dry/types/nominal"
20
+ require "dry/types/constructor"
21
+ require "dry/types/module"
22
+
23
+ require "dry/types/errors"
22
24
 
23
25
  module Dry
26
+ # Main library namespace
27
+ #
28
+ # @api public
24
29
  module Types
25
30
  extend Dry::Core::Extensions
26
31
  extend Dry::Core::ClassAttributes
32
+ extend Dry::Core::Deprecations[:'dry-types']
27
33
  include Dry::Core::Constants
28
34
 
29
- # @!attribute [r] namespace
30
- # @return [Container{String => Definition}]
31
- defines :namespace
32
-
33
- namespace self
34
-
35
- TYPE_SPEC_REGEX = %r[(.+)<(.+)>].freeze
35
+ TYPE_SPEC_REGEX = /(.+)<(.+)>/.freeze
36
36
 
37
- # @return [Module]
38
- def self.module
39
- namespace = Module.new
40
- define_constants(namespace, type_keys)
41
- namespace.extend(BuilderMethods)
42
- namespace
37
+ # @see Dry.Types
38
+ def self.module(*namespaces, default: :nominal, **aliases)
39
+ ::Module.new(container, *namespaces, default: default, **aliases)
43
40
  end
41
+ deprecate_class_method :module, message: <<~DEPRECATION
42
+ Use Dry.Types() instead. Beware, it exports strict types by default, for old behavior use Dry.Types(default: :nominal). See more options in the changelog
43
+ DEPRECATION
44
44
 
45
- # @deprecated Include {Dry::Types.module} instead
46
- def self.finalize
47
- warn 'Dry::Types.finalize and configuring namespace is deprecated. Just'\
48
- ' do `include Dry::Types.module` in places where you want to have access'\
49
- ' to built-in types'
50
-
51
- define_constants(self.namespace, type_keys)
45
+ # @api private
46
+ def self.included(*)
47
+ raise "Import Dry.Types, not Dry::Types"
52
48
  end
53
49
 
54
- # @return [Container{String => Definition}]
50
+ # Return container with registered built-in type objects
51
+ #
52
+ # @return [Container{String => Nominal}]
53
+ #
54
+ # @api private
55
55
  def self.container
56
56
  @container ||= Container.new
57
57
  end
58
58
 
59
+ # Check if a give type is registered
60
+ #
61
+ # @return [Boolean]
62
+ #
59
63
  # @api private
60
64
  def self.registered?(class_or_identifier)
61
65
  container.key?(identifier(class_or_identifier))
62
66
  end
63
67
 
68
+ # Register a new built-in type
69
+ #
64
70
  # @param [String] name
65
71
  # @param [Type] type
66
72
  # @param [#call,nil] block
67
- # @return [Container{String => Definition}]
73
+ #
74
+ # @return [Container{String => Nominal}]
75
+ #
68
76
  # @api private
69
77
  def self.register(name, type = nil, &block)
70
78
  container.register(name, type || block.call)
71
79
  end
72
80
 
81
+ # Get a built-in type by its name
82
+ #
73
83
  # @param [String,Class] name
84
+ #
74
85
  # @return [Type,Class]
86
+ #
87
+ # @api public
75
88
  def self.[](name)
76
89
  type_map.fetch_or_store(name) do
77
90
  case name
78
- when String
91
+ when ::String
79
92
  result = name.match(TYPE_SPEC_REGEX)
80
93
 
81
94
  if result
@@ -84,7 +97,12 @@ module Dry
84
97
  else
85
98
  container[name]
86
99
  end
87
- when Class
100
+ when ::Class
101
+ warn(<<~DEPRECATION)
102
+ Using Dry::Types.[] with a class is deprecated, please use string identifiers: Dry::Types[Integer] -> Dry::Types['integer'].
103
+ If you're using dry-struct this means changing `attribute :counter, Integer` to `attribute :counter, Dry::Types['integer']` or to `attribute :counter, 'integer'`.
104
+ DEPRECATION
105
+
88
106
  type_name = identifier(name)
89
107
 
90
108
  if container.key?(type_name)
@@ -96,58 +114,120 @@ module Dry
96
114
  end
97
115
  end
98
116
 
99
- # @param [Module] namespace
100
- # @param [<String>] identifiers
101
- # @return [<Definition>]
102
- def self.define_constants(namespace, identifiers)
103
- names = identifiers.map do |id|
104
- parts = id.split('.')
105
- [Inflector.camelize(parts.pop), parts.map(&Inflector.method(:camelize))]
106
- end
107
-
108
- names.map do |(klass, parts)|
109
- mod = parts.reduce(namespace) do |a, e|
110
- a.constants.include?(e.to_sym) ? a.const_get(e) : a.const_set(e, Module.new)
111
- end
112
-
113
- mod.const_set(klass, self[identifier((parts + [klass]).join('::'))])
114
- end
115
- end
116
-
117
+ # Infer a type identifier from the provided class
118
+ #
117
119
  # @param [#to_s] klass
120
+ #
118
121
  # @return [String]
119
122
  def self.identifier(klass)
120
- Inflector.underscore(klass).tr('/', '.')
123
+ Inflector.underscore(klass).tr("/", ".")
121
124
  end
122
125
 
126
+ # Cached type map
127
+ #
123
128
  # @return [Concurrent::Map]
129
+ #
130
+ # @api private
124
131
  def self.type_map
125
- @type_map ||= Concurrent::Map.new
132
+ @type_map ||= ::Concurrent::Map.new
126
133
  end
127
134
 
128
- # List of type keys defined in {Dry::Types.container}
129
- # @return [<String>]
130
- def self.type_keys
131
- container.keys
132
- end
133
-
134
- private
135
-
136
135
  # @api private
137
136
  def self.const_missing(const)
138
137
  underscored = Inflector.underscore(const)
139
138
 
140
- if type_keys.any? { |key| key.split('.')[0] == underscored }
141
- raise NameError,
142
- 'dry-types does not define constants for default types. '\
143
- 'You can access the predefined types with [], e.g. Dry::Types["strict.integer"] '\
144
- 'or generate a module with types using Dry::Types.module'
139
+ if container.keys.any? { |key| key.split(".")[0] == underscored }
140
+ raise ::NameError,
141
+ "dry-types does not define constants for default types. "\
142
+ 'You can access the predefined types with [], e.g. Dry::Types["integer"] '\
143
+ "or generate a module with types using Dry.Types()"
145
144
  else
146
145
  super
147
146
  end
148
147
  end
148
+
149
+ # Add a new type builder method. This is a public API for defining custom
150
+ # type constructors
151
+ #
152
+ # @example simple custom type constructor
153
+ # Dry::Types.define_builder(:or_nil) do |type|
154
+ # type.optional.fallback(nil)
155
+ # end
156
+ #
157
+ # Dry::Types["integer"].or_nil.("foo") # => nil
158
+ #
159
+ # @example fallback alias
160
+ # Dry::Types.define_builder(:or) do |type, fallback|
161
+ # type.fallback(fallback)
162
+ # end
163
+ #
164
+ # Dry::Types["integer"].or(100).("foo") # => 100
165
+ #
166
+ # @param [Symbol] method
167
+ # @param [#call] block
168
+ #
169
+ # @api public
170
+ def self.define_builder(method, &block)
171
+ Builder.define_method(method) do |*args|
172
+ block.(self, *args)
173
+ end
174
+ end
175
+ end
176
+
177
+ # Export registered types as a module with constants
178
+ #
179
+ # @example no options
180
+ #
181
+ # module Types
182
+ # # imports all types as constants, uses modules for namespaces
183
+ # include Dry::Types()
184
+ # end
185
+ # # strict types are exported by default
186
+ # Types::Integer
187
+ # # => #<Dry::Types[Constrained<Nominal<Integer> rule=[type?(Integer)]>]>
188
+ # Types::Nominal::Integer
189
+ # # => #<Dry::Types[Nominal<Integer>]>
190
+ #
191
+ # @example changing default types
192
+ #
193
+ # module Types
194
+ # include Dry::Types(default: :nominal)
195
+ # end
196
+ # Types::Integer
197
+ # # => #<Dry::Types[Nominal<Integer>]>
198
+ #
199
+ # @example cherry-picking namespaces
200
+ #
201
+ # module Types
202
+ # include Dry::Types(:strict, :coercible)
203
+ # end
204
+ # # cherry-picking discards default types,
205
+ # # provide the :default option along with the list of
206
+ # # namespaces if you want the to be exported
207
+ # Types.constants # => [:Coercible, :Strict]
208
+ #
209
+ # @example custom names
210
+ # module Types
211
+ # include Dry::Types(coercible: :Kernel)
212
+ # end
213
+ # Types::Kernel::Integer
214
+ # # => #<Dry::Types[Constructor<Nominal<Integer> fn=Kernel.Integer>]>
215
+ #
216
+ # @param [Array<Symbol>] namespaces List of type namespaces to export
217
+ # @param [Symbol] default Default namespace to export
218
+ # @param [Hash{Symbol => Symbol}] aliases Optional renamings, like strict: :Draconian
219
+ #
220
+ # @return [Dry::Types::Module]
221
+ #
222
+ # @see Dry::Types::Module
223
+ #
224
+ # @api public
225
+ #
226
+ def self.Types(*namespaces, default: Types::Undefined, **aliases)
227
+ Types::Module.new(Types.container, *namespaces, default: default, **aliases)
149
228
  end
150
229
  end
151
230
 
152
- require 'dry/types/core' # load built-in types
153
- require 'dry/types/extensions'
231
+ require "dry/types/core" # load built-in types
232
+ require "dry/types/extensions"
233
+ require "dry/types/printer"