Created
April 15, 2013 15:09
-
-
Save tobyink/5388802 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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