Hacker News new | past | comments | ask | show | jobs | submit login

I've been very curious about Perl6's gradual typing[1] which, as I understand it, draws a lot from Haskell's type system but in an optional manner.

    subset NonNegativeInt of Int where * >= 0;
    
    sub fib(NonNegativeInt $nth) {
      given $nth {
        when 0  { 0 }
        when 1  { 1 }
        default { fib($nth-1) + fib($nth-2) }
      }
    }
[1] http://blogs.perl.org/users/ovid/2015/02/avoid-a-common-soft...



Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: