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       "SLASH"
68       "NOT"
69       "L_PAREN"
70       "R_PAREN"
71       "MYSTERY"
72

BUGS

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

SEE ALSO

78       Type::Registry.
79

AUTHOR

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

DISCLAIMER OF WARRANTIES

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.38.0                      2023-07-21                   Type::Parser(3)
Impressum