new_type
ErrorsCollection

new_type

Synthesised documentation from type/Metamodel/PackageHOW type/Metamodel/ClassHOW type/Metamodel/EnumHOW type/Metamodel/DefiniteHOW

From type/Metamodel/PackageHOW

See Original text in context

method new_type(:$name = '<anon>':$repr:$ver:$auth)

Creates a new package, with optional representation, version and auth field.

From type/Metamodel/ClassHOW

See Original text in context

method (:$name:$repr = 'P6opaque':$ver:$auth)

Creates a new type from the metamodel, which we can proceed to build

my $type = Metamodel::ClassHOW.new_type(name => "NewType",
                                        ver => v0.0.1,
                                        auth => 'github:perl6' );
$type.HOW.add_method($type,"hey"method { say "Hey" });
$type.hey;     # OUTPUT: «Hey␤» 
$type.HOW.compose($type);
my $instance = $type.new;
$instance.hey# OUTPUT: «Hey␤»

We add a single method by using Higher Order Workings methods, and then we can use that method directly as class method; we can then compose the type, following which we can create already an instance, which will behave in the exact same way.

From type/Metamodel/EnumHOW

See Original text in context

method new_type(:$name!:$base_type?:$repr = 'P6opaque':$is_mixin)

Creates a new type object for an enum. $name is the enum name, $base_type is the type given when the enum is declared using a scoped declaration (if any), and $repr is the type representation passed to the enum using the repr trait. $is_mixin is unused.

From type/Metamodel/DefiniteHOW

See Original text in context

method new_type(:$base_type!:$definite!)

Creates a new definite type given a base type and definiteness. $definite should either be 1 for :D types or 0 for :U types.