NAME

registry

ABSTRACT

Register Type Libraries with Namespaces

SYNOPSIS

  package main;

  use strict;
  use warnings;
  use registry;

  $registry;

  # $registry->('main')
  # 'main' Type::Registry object

  # or ...
  # return registry object based on caller
  # registry::access('main')

  # and ...
  # resolve type expressions based on caller
  # registry::lookup('ClassName')

DESCRIPTION

This pragma is used to associate the calling package with Type::Tiny type libraries. A $registry variable is made available to the caller to be used to access registry objects. The variable is a callback (i.e. coderef) which should be called with a single argument, the namespace whose registry object you want, otherwise the argument defaults to main.

  package main;

  use strict;
  use warnings;

  use registry 'Types::Standard';
  use registry 'Types::Common::Numeric';
  use registry 'Types::Common::String';

  $registry;

  # resolve type expression using exported variable
  # my $constraint = $registry->('main')->lookup('StrLength[10]')

  # resolve type expression using registry function
  # my $constraint = registry::lookup('StrLength[10]', 'main')

You can configure the calling package to be associated with multiple distinct type libraries. The exported $registry object can be used to reify type constraints and resolve type expressions.

AUTHOR

Al Newkirk, awncorp@cpan.org

LICENSE

Copyright (C) 2011-2019, Al Newkirk, et al.

This is free software; you can redistribute it and/or modify it under the terms of the The Apache License, Version 2.0, as elucidated in the "license file".

PROJECT

Wiki

Project

Initiatives

Milestones

Contributing

Issues