Skip to content

Instantly share code, notes, and snippets.

@LLFourn
Created June 22, 2016 08:50
Show Gist options
  • Save LLFourn/17eed8f486e7b79471c12ad21174f6a0 to your computer and use it in GitHub Desktop.
Save LLFourn/17eed8f486e7b79471c12ad21174f6a0 to your computer and use it in GitHub Desktop.
use nqp;
my package EXPORTHOW {
package SUPERSEDE {
class subset is Metamodel::SubsetHOW {
has @!ss-params;
method parameterize($obj,*@params) {
@!ss-params = @params;
$obj;
}
method accepts_type($obj,$checkee) {
nqp::p6bool(
nqp::istype($checkee, $.refinee($obj)) &&
nqp::istrue($.refinement($obj).($checkee,|@!ss-params))
)
}
}
}
}
perl6 -Ilib -e '
use Type::Tiny;
subset IntsGreaterThan of Int where { $^a > $^b };
say 1 ~~ IntsGreaterThan[2]; say 3 ~~ IntsGreaterThan[2]'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment