1Type::Tiny::Union(3) User Contributed Perl Documentation Type::Tiny::Union(3)
2
3
4
6 Type::Tiny::Union - union type constraints
7
9 This module is covered by the Type-Tiny stability policy.
10
12 Union type constraints.
13
14 This package inherits from Type::Tiny; see that for most documentation.
15 Major differences are listed below:
16
17 Constructor
18 The "new" constructor from Type::Tiny still works, of course. But there
19 is also:
20
21 "new_by_overload(%attributes)"
22 Like the "new" constructor, but will sometimes return another type
23 constraint which is not strictly an instance of Type::Tiny::Union,
24 but still encapsulates the same meaning. This constructor is used
25 by Type::Tiny's overloading of the "|" operator.
26
27 Attributes
28 "type_constraints"
29 Arrayref of type constraints.
30
31 When passed to the constructor, if any of the type constraints in
32 the union is itself a union type constraint, this is "exploded"
33 into the new union.
34
35 "constraint"
36 Unlike Type::Tiny, you cannot pass a constraint coderef to the
37 constructor. Instead rely on the default.
38
39 "inlined"
40 Unlike Type::Tiny, you cannot pass an inlining coderef to the
41 constructor. Instead rely on the default.
42
43 "parent"
44 Unlike Type::Tiny, you cannot pass an inlining coderef to the
45 constructor. A parent will instead be automatically calculated.
46
47 "coercion"
48 You probably do not pass this to the constructor. (It's not
49 currently disallowed, as there may be a use for it that I haven't
50 thought of.)
51
52 The auto-generated default will be a Type::Coercion::Union object.
53
54 Methods
55 "find_type_for($value)"
56 Returns the first individual type constraint in the union which
57 $value passes.
58
59 "stringifies_to($constraint)"
60 See Type::Tiny::ConstrainedObject.
61
62 "numifies_to($constraint)"
63 See Type::Tiny::ConstrainedObject.
64
65 "with_attribute_values($attr1 => $constraint1, ...)"
66 See Type::Tiny::ConstrainedObject.
67
68 Overloading
69 • Arrayrefification calls "type_constraints".
70
72 Please report any bugs to
73 <https://github.com/tobyink/p5-type-tiny/issues>.
74
76 Type::Tiny::Manual.
77
78 Type::Tiny.
79
81 Toby Inkster <tobyink@cpan.org>.
82
84 This software is copyright (c) 2013-2014, 2017-2023 by Toby Inkster.
85
86 This is free software; you can redistribute it and/or modify it under
87 the same terms as the Perl 5 programming language system itself.
88
90 THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
91 WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
92 MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
93
94
95
96perl v5.36.0 2023-01-04 Type::Tiny::Union(3)