Kavorka is a function signatures module, along the lines of Function::Parameters, Method::Signatures, and MooseX::Method::Signatures.
Its features include:
- Named, positional and slurpy parameters
- Required and optional parameters
- Defaults for optional parameters
- Type constraints and value constraints
- Type coercions
- Return types
- Method modifiers
- Multi subs and multi methods
- Lexical (private) methods
- An introspection API that can integrate with Moose’s MOP
- Speed
It probably has every feature you want from in a function signatures module, unless you want minimalism.
Here’s how you might write a function with type checks on the incoming parameters and also the returned value:
fun maxnum (Num @numbers → Num) { my $max = shift @numbers; for (@numbers) { $max = $_ if $max < $_; } return $max; }
Kavorka is still not especially stable, but seems to work pretty well (except in some cases defining closures over variables outside the sub).
Feedback welcome.