{
    "mode": "perldoc",
    "parameter": "Type::Tiny::Manual",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Type%3A%3ATiny%3A%3AManual/json",
    "generated": "2026-06-10T16:27:49Z",
    "synopsis": "Type::Tiny is a small Perl <http://www.perl.org/> class for writing type constraints, inspired\nby Moose's type constraint API and MooseX::Types. It has only one non-core dependency (and even\nthat is simply a module that was previously distributed as part of Type::Tiny but has since been\nspun off), and can be used with Moose, Mouse, or Moo (or none of the above).\nType::Tiny is used by over 800 Perl distributions on the CPAN (Comprehensive Perl Archive\nNetwork) and can be considered a stable and mature framework for efficiently and reliably\nenforcing data types.\nType::Tiny is bundled with Type::Library a framework for organizing type constraints into\ncollections. Also bundled is Types::Standard, a Moose-inspired library of useful type\nconstraints. Type::Params is also provided, to allow very fast checking and coercion of function\nand method parameters.\nThe following example gives you an idea of some of the features of these modules. If you don't\nunderstand it all, that's fine; that's what the rest of the manual is for. Although the example\nuses Moo, the \"use Moo\" could be changed to \"use Moose\" or \"use Mouse\" and it would still work.\nuse v5.12;\nuse strict;\nuse warnings;\npackage Horse {\nuse Moo;\nuse Types::Standard qw( Str Int Enum ArrayRef InstanceOf );\nuse Type::Params qw( compile );\nuse namespace::autoclean;\nhas name => (\nis       => 'ro',\nisa      => Str,\nrequired => 1,\n);\nhas gender => (\nis       => 'ro',\nisa      => Enum[qw( f m )],\n);\nhas age => (\nis       => 'rw',\nisa      => Int->where( '$ >= 0' ),\n);\nhas children => (\nis       => 'ro',\nisa      => ArrayRef[ InstanceOf['Horse'] ],\ndefault  => sub { return [] },\n);\nsub addchild {\n# method signature\nstate $check = compile( InstanceOf['Horse'], InstanceOf['Horse'] );\nmy ($self, $child) = $check->(@);   # unpack @\npush @{ $self->children }, $child;\nreturn $self;\n}\n}\npackage main;\nmy $boldruler = Horse->new(\nname    => \"Bold Ruler\",\ngender  => 'm',\nage     => 16,\n);\nmy $secretariat = Horse->new(\nname    => \"Secretariat\",\ngender  => 'm',\nage     => 0,\n);\n$boldruler->addchild( $secretariat );\nuse Types::Standard qw( isObject assertObject );\n# isObject will return a boolean\n#\nif ( isObject($boldruler) ) {\nsay $boldruler->name;\n}\n# assertObject will return $secretariat or die\n#\nsay assertObject($secretariat)->name;",
    "sections": {
        "NAME": {
            "content": "Type::Tiny::Manual - an overview of Type::Tiny\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "Type::Tiny is a small Perl <http://www.perl.org/> class for writing type constraints, inspired\nby Moose's type constraint API and MooseX::Types. It has only one non-core dependency (and even\nthat is simply a module that was previously distributed as part of Type::Tiny but has since been\nspun off), and can be used with Moose, Mouse, or Moo (or none of the above).\n\nType::Tiny is used by over 800 Perl distributions on the CPAN (Comprehensive Perl Archive\nNetwork) and can be considered a stable and mature framework for efficiently and reliably\nenforcing data types.\n\nType::Tiny is bundled with Type::Library a framework for organizing type constraints into\ncollections. Also bundled is Types::Standard, a Moose-inspired library of useful type\nconstraints. Type::Params is also provided, to allow very fast checking and coercion of function\nand method parameters.\n\nThe following example gives you an idea of some of the features of these modules. If you don't\nunderstand it all, that's fine; that's what the rest of the manual is for. Although the example\nuses Moo, the \"use Moo\" could be changed to \"use Moose\" or \"use Mouse\" and it would still work.\n\nuse v5.12;\nuse strict;\nuse warnings;\n\npackage Horse {\nuse Moo;\nuse Types::Standard qw( Str Int Enum ArrayRef InstanceOf );\nuse Type::Params qw( compile );\nuse namespace::autoclean;\n\nhas name => (\nis       => 'ro',\nisa      => Str,\nrequired => 1,\n);\nhas gender => (\nis       => 'ro',\nisa      => Enum[qw( f m )],\n);\nhas age => (\nis       => 'rw',\nisa      => Int->where( '$ >= 0' ),\n);\nhas children => (\nis       => 'ro',\nisa      => ArrayRef[ InstanceOf['Horse'] ],\ndefault  => sub { return [] },\n);\n\nsub addchild {\n# method signature\nstate $check = compile( InstanceOf['Horse'], InstanceOf['Horse'] );\n\nmy ($self, $child) = $check->(@);   # unpack @\npush @{ $self->children }, $child;\n\nreturn $self;\n}\n}\n\npackage main;\n\nmy $boldruler = Horse->new(\nname    => \"Bold Ruler\",\ngender  => 'm',\nage     => 16,\n);\n\nmy $secretariat = Horse->new(\nname    => \"Secretariat\",\ngender  => 'm',\nage     => 0,\n);\n\n$boldruler->addchild( $secretariat );\n\nuse Types::Standard qw( isObject assertObject );\n\n# isObject will return a boolean\n#\nif ( isObject($boldruler) ) {\nsay $boldruler->name;\n}\n\n# assertObject will return $secretariat or die\n#\nsay assertObject($secretariat)->name;\n",
            "subsections": []
        },
        "MANUAL": {
            "content": "Even if you are using Type::Tiny with other object-oriented programming toolkits (such as Moose\nor Mouse), you should start with the Moo sections of the manual. Most of the information is\ndirectly transferrable and the Moose and Mouse sections of the manual list the minor differences\nbetween using Type::Tiny with Moo and with them.\n\nIn general, this manual assumes you use Perl 5.12 or above and may use examples that do not work\non older versions of Perl. Type::Tiny does work on earlier versions of Perl, but not all the\nexamples and features in the manual will run without adjustment. (For instance, you may need to\nreplace \"state\" variables with lexical variables, avoid the \"package NAME { BLOCK }\" syntax,\netc.)\n\n*   Type::Tiny::Manual::Installation\n\nHow to install Type::Tiny. If Type::Tiny is already installed, you can skip this.\n\n*   Type::Tiny::Manual::UsingWithMoo\n\nBasic use of Type::Tiny with Moo, including attribute type constraints, parameterized type\nconstraints, coercions, and method parameter checking.\n\n*   Type::Tiny::Manual::UsingWithMoo2\n\nAdvanced use of Type::Tiny with Moo, including unions and intersections, \"stringifiesto\",\n\"numifiesto\", \"withattributevalues\", and \"where\".\n\n*   Type::Tiny::Manual::UsingWithMoo3\n\nThere's more than one way to do it! Alternative ways of using Type::Tiny, including type\nregistries, exported functions, and \"dwimtype\".\n\n*   Type::Tiny::Manual::Libraries\n\nDefining your own type libraries, including extending existing libraries, defining new\ntypes, adding coercions, defining parameterizable types, and the declarative style.\n\n*   Type::Tiny::Manual::UsingWithMoose\n\nHow to use Type::Tiny with Moose, including the advantages of Type::Tiny over built-in type\nconstraints, and Moose-specific features.\n\n*   Type::Tiny::Manual::UsingWithMouse\n\nHow to use Type::Tiny with Mouse, including the advantages of Type::Tiny over built-in type\nconstraints, and Mouse-specific features.\n\n*   Type::Tiny::Manual::UsingWithClassTiny\n\nIncluding how to Type::Tiny in your object's \"BUILD\" method, and third-party shims between\nType::Tiny and Class::Tiny.\n\n*   Type::Tiny::Manual::UsingWithOther\n\nUsing Type::Tiny with Class::InsideOut, Params::Check, and Object::Accessor.\n\n*   Type::Tiny::Manual::UsingWithTestMore\n\nType::Tiny for test suites.\n\n*   Type::Tiny::Manual::Params\n\nAdvanced information on Type::Params, and using Type::Tiny with other signature modules like\nFunction::Parameters and Kavorka.\n\n*   Type::Tiny::Manual::NonOO\n\nType::Tiny in non-object-oriented code.\n\n*   Type::Tiny::Manual::Optimization\n\nSqueeze the most out of your CPU.\n\n*   Type::Tiny::Manual::Coercions\n\nAdvanced information on coercions.\n\n*   Type::Tiny::Manual::AllTypes\n\nAn alphabetical list of all type constraints bundled with Type::Tiny.\n\n*   Type::Tiny::Manual::Policies\n\nPolicies related to Type::Tiny development.\n\n*   Type::Tiny::Manual::Contributing\n\nContributing to Type::Tiny development.\n",
            "subsections": []
        },
        "BUGS": {
            "content": "Please report any bugs to <https://github.com/tobyink/p5-type-tiny/issues>.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "The Type::Tiny homepage <https://typetiny.toby.ink/>.\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "Toby Inkster <tobyink@cpan.org>.\n",
            "subsections": []
        },
        "COPYRIGHT AND LICENCE": {
            "content": "This software is copyright (c) 2013-2014, 2017-2021 by Toby Inkster.\n\nThis is free software; you can redistribute it and/or modify it under the same terms as the Perl\n5 programming language system itself.\n",
            "subsections": []
        },
        "DISCLAIMER OF WARRANTIES": {
            "content": "THIS PACKAGE IS PROVIDED \"AS IS\" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,\nWITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR\nPURPOSE.\n",
            "subsections": []
        }
    },
    "summary": "Type::Tiny::Manual - an overview of Type::Tiny",
    "flags": [],
    "examples": [],
    "see_also": []
}