Type::Parser(3)
β¨ Type::Parser β¨
okay so this is the User Contributed Perl Documentation page for Type::Parser(3) and bestie, we're about to parse some type constraint strings together π
πΈ NAME πΈ
Type::Parser β parse type constraint strings π
π¦ SYNOPSIS π¦
use v5.10;
use strict;
use warnings;
use Type::Parser qw( eval_type );
use Type::Registry;
my $reg = Type::Registry->for_me;
$reg->add_types("Types::Standard");
my $type = eval_type("Int | ArrayRef[Int]", $reg);
$type->check(10); # true
$type->check([1..4]); # true
$type->check({foo=>1}); # false
like... look at her go π three checks, three answers, no cap.
π STATUS π
This module is covered by the Type-Tiny stability policy. periodt π
π DESCRIPTION π
ngl bestie, generally speaking, you probably do NOT want to be using this module directly π instead, use the "lookup" method from Type::Registry β that one wraps it for you. it's giving "don't talk to the module directly, talk to the module's friend." iykyk β¨
π Functions π
parse($string)β parses the type constraint string into something like an AST π§ and if you call it in list context, it also hands you back any"tail"that was chillin' on the original string. two-for-one, we love to see it π"extract_type($string, $registry)"β compiles a type constraint string into aType::Tinyobject π₯ and yep, list context again? you get the"tail"from the original string too π"eval_type($string, $registry)"β also compiles a type constraint string into aType::Tinyobject β¨ but here's the thing: it throws an error if the"tail"contains any non-whitespace character. so no sneaky extra characters, she will clock it π
π Constants π
these constants correspond to the values returned by "$token->type" πΈ
"TYPE""QUOTELIKE""STRING""HEXNUM""CLASS""L_BRACKET""R_BRACKET""COMMA""SLURPY""UNION""INTERSECT""SLASH""NOT""L_PAREN""R_PAREN""MYSTERY"
π BUGS π
found a bug? pls report it, we're not gatekeeping:
https://github.com/tobyink/p5-type-tiny/issues
π SEE ALSO π
Type::Registryπ
π«Ά AUTHOR π«Ά
Toby Inkster <tobyink@cpan.org> π
π COPYRIGHT AND LICENCE π
This software is copyright (c) 2013-2014, 2017-2025 by Toby Inkster.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. slay β¨
β οΈ DISCLAIMER OF WARRANTIES β οΈ
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
no promises bestie, she said what she said π
and that's the whole page, mwah π this was rendered by perl v5.42.0 and dated 2026-01-17, so if you're reading this from the future β hi, love you, bye ππ¦β¨
π¦ where this page comes from
- fedora 44: perl-Type-Tiny 2.010001-2.fc44 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms