{
    "content": [
        {
            "type": "text",
            "text": "# Type::Registry (perldoc)\n\n## NAME\n\nType::Registry - a glorified hashref for looking up type constraints\n\n## SYNOPSIS\n\npackage Foo::Bar;\nuse Type::Registry;\nmy $reg = \"Type::Registry\"->forme;  # a registry for Foo::Bar\n# Register all types from Types::Standard\n$reg->addtypes(-Standard);\n# Register just one type from Types::XSD\n$reg->addtypes(-XSD => [\"NonNegativeInteger\"]);\n# Register all types from MyApp::Types\n$reg->addtypes(\"MyApp::Types\");\n# Create a type alias\n$reg->aliastype(\"NonNegativeInteger\" => \"Count\");\n# Look up a type constraint\nmy $type = $reg->lookup(\"ArrayRef[Count]\");\n$type->check([1, 2, 3.14159]);  # croaks\nAlternatively:\npackage Foo::Bar;\nuse Type::Registry qw( t );\n# Register all types from Types::Standard\nt->addtypes(-Standard);\n# Register just one type from Types::XSD\nt->addtypes(-XSD => [\"NonNegativeInteger\"]);\n# Register all types from MyApp::Types\nt->addtypes(\"MyApp::Types\");\n# Create a type alias\nt->aliastype(\"NonNegativeInteger\" => \"Count\");\n# Look up a type constraint\nmy $type = t(\"ArrayRef[Count]\");\n$type->check([1, 2, 3.14159]);  # croaks\n\n## DESCRIPTION\n\nA type registry is basically just a hashref mapping type names to type constraint objects.\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **STATUS**\n- **DESCRIPTION** (3 subsections)\n- **BUGS**\n- **SEE ALSO**\n- **AUTHOR**\n- **COPYRIGHT AND LICENCE**\n- **DISCLAIMER OF WARRANTIES**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "Type::Registry",
        "section": "",
        "mode": "perldoc",
        "summary": "Type::Registry - a glorified hashref for looking up type constraints",
        "synopsis": "package Foo::Bar;\nuse Type::Registry;\nmy $reg = \"Type::Registry\"->forme;  # a registry for Foo::Bar\n# Register all types from Types::Standard\n$reg->addtypes(-Standard);\n# Register just one type from Types::XSD\n$reg->addtypes(-XSD => [\"NonNegativeInteger\"]);\n# Register all types from MyApp::Types\n$reg->addtypes(\"MyApp::Types\");\n# Create a type alias\n$reg->aliastype(\"NonNegativeInteger\" => \"Count\");\n# Look up a type constraint\nmy $type = $reg->lookup(\"ArrayRef[Count]\");\n$type->check([1, 2, 3.14159]);  # croaks\nAlternatively:\npackage Foo::Bar;\nuse Type::Registry qw( t );\n# Register all types from Types::Standard\nt->addtypes(-Standard);\n# Register just one type from Types::XSD\nt->addtypes(-XSD => [\"NonNegativeInteger\"]);\n# Register all types from MyApp::Types\nt->addtypes(\"MyApp::Types\");\n# Create a type alias\nt->aliastype(\"NonNegativeInteger\" => \"Count\");\n# Look up a type constraint\nmy $type = t(\"ArrayRef[Count]\");\n$type->check([1, 2, 3.14159]);  # croaks",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 46,
                "subsections": []
            },
            {
                "name": "STATUS",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 2,
                "subsections": [
                    {
                        "name": "Constructors",
                        "lines": 12
                    },
                    {
                        "name": "Methods",
                        "lines": 72
                    },
                    {
                        "name": "Functions",
                        "lines": 3
                    }
                ]
            },
            {
                "name": "BUGS",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "AUTHOR",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "COPYRIGHT AND LICENCE",
                "lines": 5,
                "subsections": []
            },
            {
                "name": "DISCLAIMER OF WARRANTIES",
                "lines": 4,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "Type::Registry - a glorified hashref for looking up type constraints\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "package Foo::Bar;\n\nuse Type::Registry;\n\nmy $reg = \"Type::Registry\"->forme;  # a registry for Foo::Bar\n\n# Register all types from Types::Standard\n$reg->addtypes(-Standard);\n\n# Register just one type from Types::XSD\n$reg->addtypes(-XSD => [\"NonNegativeInteger\"]);\n\n# Register all types from MyApp::Types\n$reg->addtypes(\"MyApp::Types\");\n\n# Create a type alias\n$reg->aliastype(\"NonNegativeInteger\" => \"Count\");\n\n# Look up a type constraint\nmy $type = $reg->lookup(\"ArrayRef[Count]\");\n\n$type->check([1, 2, 3.14159]);  # croaks\n\nAlternatively:\n\npackage Foo::Bar;\n\nuse Type::Registry qw( t );\n\n# Register all types from Types::Standard\nt->addtypes(-Standard);\n\n# Register just one type from Types::XSD\nt->addtypes(-XSD => [\"NonNegativeInteger\"]);\n\n# Register all types from MyApp::Types\nt->addtypes(\"MyApp::Types\");\n\n# Create a type alias\nt->aliastype(\"NonNegativeInteger\" => \"Count\");\n\n# Look up a type constraint\nmy $type = t(\"ArrayRef[Count]\");\n\n$type->check([1, 2, 3.14159]);  # croaks\n",
                "subsections": []
            },
            "STATUS": {
                "content": "This module is covered by the Type-Tiny stability policy.\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "A type registry is basically just a hashref mapping type names to type constraint objects.\n",
                "subsections": [
                    {
                        "name": "Constructors",
                        "content": "\"new\"\nCreate a new glorified hashref.\n\n\"forclass($class)\"\nCreate or return the existing glorified hashref associated with the given class.\n\nNote that any type constraint you have imported from Type::Library-based type libraries will\nbe automatically available in your class' registry.\n\n\"forme\"\nCreate or return the existing glorified hashref associated with the caller.\n"
                    },
                    {
                        "name": "Methods",
                        "content": "\"addtypes(@libraries)\"\nThe libraries list is treated as an \"optlist\" (a la Data::OptList).\n\nStrings are the names of type libraries; if the first character is a hyphen, it is expanded\nto the \"Types::\" prefix. If followed by an arrayref, this is the list of types to import\nfrom that library. Otherwise, imports all types from the library.\n\nuse Type::Registry qw(t);\n\nt->addtypes(-Standard);  # OR: t->addtypes(\"Types::Standard\");\n\nt->addtypes(\n-TypeTiny => ['HashLike'],\n-Standard => ['HashRef' => { -as => 'RealHash' }],\n);\n\nMooseX::Types (and experimentally, MouseX::Types) libraries can also be added this way, but\n*cannot be followed by an arrayref of types to import*.\n\n\"addtype($type, $name)\"\nThe long-awaited singular form of \"addtypes\". Given a type constraint object, adds it to\nthe registry with a given name. The name may be omitted, in which case \"$type->name\" is\ncalled, and Type::Registry will throw an error if $type is anonymous. If a name is\nexplicitly given, Type::Registry cares not one wit whether the type constraint is anonymous.\n\nThis method can even add MooseX::Types and MouseX::Types type constraints; indeed anything\nthat can be handled by Types::TypeTiny's \"toTypeTiny\" function. (Bear in mind that\ntoTypeTiny *always* results in an anonymous type constraint, so $name will be required.)\n\n\"aliastype($oldname, $newname)\"\nCreate an alias for an existing type.\n\n\"simplelookup($name)\"\nLook up a type in the registry by name.\n\nReturns undef if not found.\n\n\"foreignlookup($name)\"\nLike \"simplelookup\", but if the type name contains \"::\", will attempt to load it from a\ntype library. (And will attempt to load that module.)\n\n\"lookup($name)\"\nLook up by name, with a DSL.\n\nt->lookup(\"Int|ArrayRef[Int]\")\n\nThe DSL can be summed up as:\n\nX               type from this registry\nMy::Lib::X      type from a type library\n~X              complementary type\nX | Y           union\nX & Y           intersection\nX[...]          parameterized type\nslurpy X        slurpy type\nFoo::Bar::      class type\n\nCroaks if not found.\n\n\"makeunion(@constraints)\", \"makeintersection(@constraints)\", \"makeclasstype($class)\",\n\"makeroletype($role)\"\nConvenience methods for creating certain common type constraints.\n\n\"AUTOLOAD\"\nOverloaded to call \"lookup\".\n\n$registry->Str;  # like $registry->lookup(\"Str\")\n\n\"getparent\", \"setparent($reg)\", \"clearparent\", \"hasparent\"\nAdvanced stuff. Allows a registry to have a \"parent\" registry which it inherits type\nconstraints from.\n"
                    },
                    {
                        "name": "Functions",
                        "content": "\"t\" This class can export a function \"t\" which acts like\n\"\"Type::Registry\"->forclass($importingclass)\".\n"
                    }
                ]
            },
            "BUGS": {
                "content": "Please report any bugs to <https://github.com/tobyink/p5-type-tiny/issues>.\n",
                "subsections": []
            },
            "SEE ALSO": {
                "content": "Type::Library.\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": []
            }
        }
    }
}