Skip to content

Instantly share code, notes, and snippets.

@tobyink
Created April 15, 2013 15:09
Show Gist options
  • Select an option

  • Save tobyink/5388802 to your computer and use it in GitHub Desktop.

Select an option

Save tobyink/5388802 to your computer and use it in GitHub Desktop.
use Data::Dumper;
use Types::Standard qw(-types slurpy);
use Type::Utils;
use Type::Check qw(check); # not sure what this module will really be called
my $RoundedInt = declare as Int;
coerce $RoundedInt, from Int, via q{ int($_) };
sub foo {
state $sig = check[ Str, $RoundedInt, slurpy ArrayRef[$RoundedInt] ];
my ($name, $age, $favourite_numbers) = $sig->check(\@_);
print Dumper {
name => $name,
age => $age,
nums => $favourite_numbers,
};
}
foo("Bob", 32.5, 1.1, 2.2, 3.3);
__END__
$VAR1 = {
name => "Bob",
age => 32,
nums => [1, 2, 3],
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment