NAME
Type::Tiny::Signatures - Method/Function Signatures w/Type::Tiny Constraints
VERSION
version 0.06
SYNOPSIS
use Type::Tiny;
use Type::Tiny::Signatures;
method hello (Str $greeting, Str $fullname) {
print "$greeting, $fullname\n";
}
DESCRIPTION
This module uses Function::Parameters to extends Perl with keywords that let you define methods and functions with parameter lists which can be validated using Type::Tiny type constraints. The type constraints can be provided by the Type::Tiny standard library, Types::Standard, or any supported user-defined type library which can be a Moose, MooseX::Type, MouseX::Type, or Type::Library library.
use Type::Tiny;
use Type::Tiny::Signatures qw(MyApp::Types);
method identify (Str $name, SSN $number) {
print "identifying $name using SSN $number\n";
}
The method and function signatures can be configured to validate user-defined type constraints by passing the user-defined type library package name as an argument to the Type::Tiny::Signatures usage declaration. The default behavior configures the Function::Parameters pragma using its defaults, i.e. strict-mode disabled. Please note, you can pass all the acceptable Function::Parameters import options to the Type::Tiny::Signatures usage declaration to configure the underlying Function::Parameters pragma to suit your needs.
use Type::Tiny;
use Type::Tiny::Signatures ':strict' => qw(MyApp::Types);
method identify (Str $name, SSN $number) {
print "identifying $name using SSN $number\n";
}
AUTHOR
Al Newkirk anewkirk@ana.io
COPYRIGHT AND LICENSE
This software is copyright (c) 2014 by Al Newkirk.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.