Better type checking for first-class functions
Perl6
Latest commit 58e7fce Oct 27, 2016 @zoffixznet zoffixznet committed with moritz Add mandatory "perl" META field
The `perl` field specifies the minimal perl version for which this distribution can be installed and is a mandatory field. The value of `"6.*"` indicates any version suffices.

It is recommended to use [Test::META](https://modules.perl6.org/repo/Test::META) module as an author test, to catch any issues with the META file.

README

SYNOPSIS

    use Typed::Subroutines;

    # create a subtype from Sub
    subset TwoArgSub         of Sub where typed_sub(Any, Any);
    subset TakesIntAndString of Sub where typed_sub(Int, Str);

    my TwoArgSub         $a;
    my TakesIntAndString $b;

    $a = sub ($a, $b) { ... }; # lives
    $a = sub ($a)     { ... }; # dies

    $b = sub (Int $a, Str $b) { ... }; # lives
    $b = sub (Int $a,     $b) { ... }; # dies

    # validate subroutines passed to your subroutines (dawg)
    sub doStuff(Int $a, Str $b, &operation where typed_sub(Int, Str)}) {
        ...
    }

    doStuff(99, "bottles of beer", -> Int $a, Str $b { ... }) # lives
    doStuff(99, "bottles of beer", -> Rat $a, Num $b { ... }) # dies

DESCRIPTION

Typed::Subroutines let you specify subroutine types verifying the parameter list so you can have better type checking for first-class functions.

I'll write more docs when I'm less tired.