1Types::TypeTiny(3) User Contributed Perl Documentation Types::TypeTiny(3)
2
3
4
6 Types::TypeTiny - type constraints used internally by Type::Tiny
7
9 This module is covered by the Type-Tiny stability policy.
10
12 Dogfooding.
13
14 This isn't a real Type::Library-based type library; that would involve
15 too much circularity. But it exports some type constraints which, while
16 designed for use within Type::Tiny, may be more generally useful.
17
18 Types
19 • StringLike
20
21 Accepts strings and objects overloading stringification.
22
23 • HashLike[`a]
24
25 Accepts hashrefs and objects overloading hashification.
26
27 Since Types::TypeTiny 1.012, may be parameterized with another type
28 constraint like HashLike[Int].
29
30 • ArrayLike[`a]
31
32 Accepts arrayrefs and objects overloading arrayfication.
33
34 Since Types::TypeTiny 1.012, may be parameterized with another type
35 constraint like ArrayLike[Int].
36
37 • CodeLike
38
39 Accepts coderefs and objects overloading codification.
40
41 • TypeTiny
42
43 Accepts blessed Type::Tiny objects.
44
45 • _ForeignTypeConstraint
46
47 Any reference which to_TypeTiny recognizes as something that can be
48 coerced to a Type::Tiny object.
49
50 Yes, the underscore is included.
51
52 Coercion Functions
53 "to_TypeTiny($constraint)"
54 Promotes (or "demotes" if you prefer) a Moose::Meta::TypeConstraint
55 object to a Type::Tiny object.
56
57 Can also handle Validation::Class objects. Type constraints built
58 from Validation::Class objects deliberately ignore field filters
59 when they do constraint checking (and go to great lengths to do
60 so); using filters for coercion only. (The behaviour of "coerce" if
61 we don't do that is just too weird!)
62
63 Can also handle any object providing "check" and "get_message"
64 methods. (This includes Mouse::Meta::TypeConstraint objects.) If
65 the object also provides "has_coercion" and "coerce" methods, these
66 will be used too.
67
68 Can also handle coderefs (but not blessed coderefs or objects
69 overloading "&{}"). Coderefs are expected to return true iff $_
70 passes the constraint. If $_ fails the type constraint, they may
71 either return false, or die with a helpful error message.
72
73 Methods
74 These are implemented so that "Types::TypeTiny->meta->get_type($foo)"
75 works, for rough compatibility with a real Type::Library type library.
76
77 "meta"
78 "type_names"
79 "get_type($name)"
80 "has_type($name)"
81 "coercion_names"
82 "get_coercion($name)"
83 "has_coercion($name)"
84
86 Please report any bugs to
87 <https://github.com/tobyink/p5-type-tiny/issues>.
88
90 Type::Tiny.
91
93 Toby Inkster <tobyink@cpan.org>.
94
96 This software is copyright (c) 2013-2014, 2017-2021 by Toby Inkster.
97
98 This is free software; you can redistribute it and/or modify it under
99 the same terms as the Perl 5 programming language system itself.
100
102 THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
103 WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
104 MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
105
106
107
108perl v5.34.0 2021-09-13 Types::TypeTiny(3)