1Type::Parser(3)       User Contributed Perl Documentation      Type::Parser(3)
2
3
4

NAME

6       Type::Parser - parse type constraint strings
7

SYNOPSIS

9        use v5.10;
10        use strict;
11        use warnings;
12
13        use Type::Parser qw( eval_type );
14        use Type::Registry;
15
16        my $reg = Type::Registry->for_me;
17        $reg->add_types("Types::Standard");
18
19        my $type = eval_type("Int | ArrayRef[Int]", $reg);
20
21        $type->check(10);        # true
22        $type->check([1..4]);    # true
23        $type->check({foo=>1});  # false
24

STATUS

26       This module is covered by the Type-Tiny stability policy.
27

DESCRIPTION

29       Generally speaking, you probably don't want to be using this module
30       directly.  Instead use the "lookup" method from Type::Registry which
31       wraps it.
32
33   Functions
34       "parse($string)"
35           Parse the type constraint string into something like an AST.
36
37           If called in list context, also returns any "tail" found on the
38           original string.
39
40       "extract_type($string, $registry)"
41           Compile a type constraint string into a Type::Tiny object.
42
43           If called in list context, also returns any "tail" found on the
44           original string.
45
46       "eval_type($string, $registry)"
47           Compile a type constraint string into a Type::Tiny object.
48
49           Throws an error if the "tail" contains any non-whitespace
50           character.
51
52   Constants
53       The following constants correspond to values returned by
54       "$token->type".
55
56       "TYPE"
57       "QUOTELIKE"
58       "STRING"
59       "HEXNUM"
60       "CLASS"
61       "L_BRACKET"
62       "R_BRACKET"
63       "COMMA"
64       "SLURPY"
65       "UNION"
66       "INTERSECT"
67       "NOT"
68       "L_PAREN"
69       "R_PAREN"
70       "MYSTERY"
71

BUGS

73       Please report any bugs to
74       <https://github.com/tobyink/p5-type-tiny/issues>.
75

SEE ALSO

77       Type::Registry.
78

AUTHOR

80       Toby Inkster <tobyink@cpan.org>.
81
83       This software is copyright (c) 2013-2014, 2017-2021 by Toby Inkster.
84
85       This is free software; you can redistribute it and/or modify it under
86       the same terms as the Perl 5 programming language system itself.
87

DISCLAIMER OF WARRANTIES

89       THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
90       WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
91       MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
92
93
94
95perl v5.34.0                      2022-01-21                   Type::Parser(3)
Impressum