The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Type::Constraint::Parameterizable - A class which represents parameterizable constraints

VERSION

version 0.05

SYNOPSIS

  my $arrayref = t('ArrayRef');

  my $arrayref_of_int = $arrayref->parameterize( of => t('Int') );

DESCRIPTION

This class implements the API for parameterizable types like ArrayRef and Maybe.

API

This class implements the same API as Type::Constraint::Simple, with a few additions.

Type::Constraint::Parameterizable->new(...)

This class's constructor accepts two additional parameters:

  • parameterized_constraint_generator

    This is a subroutine that generates a new constraint subroutine when the type is parameterized.

    It will be called as a method on the type and will be passed a single argument, the type object for the type parameter.

    This parameter is mutually exclusive with the parameterized_inline_generator parameter.

  • parameterized_inline_generator

    This is a subroutine that generates a new inline generator subroutine when the type is parameterized.

    It will be called as a method on the Type::Constraint::Parameterized object when that object needs to generate inline constraint. It will receive the type parameter as the first argument and the variable name as a string as the second.

    This probably seems fairly confusing, so looking at the examples in the Type::Library::Builtins code may be helpful.

    This parameter is mutually exclusive with the parameterized_inline_generator parameter.

$type->parameterize(...)

This method takes two arguments. The of argument should be an object which does the Type::Constraint::Role::Interface role, and is required.

The other argument, declared_at, is optional. If it is not given, then a new Type::DeclaredAt object is creating using a call stack depth of 1.

This method returns a new Type::Constraint::Parameterized object.

AUTHOR

Dave Rolsky <autarch@urth.org>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2012 by Dave Rolsky.

This is free software, licensed under:

  The Artistic License 2.0 (GPL Compatible)