Represent a type without any additional features
class RakuAST::Type::Simple { }
The RakuAST::Type::Simple class represents a simple Raku type without any additional features, such as coercion or definedness.
RakuAST::Type::Simple object is typically created when parsing Raku Programming Language code. So most developers will only need to know how to introspect the objects created.
say $type.is-native; # True or False
The is-native method returns True if the canonical name of the type consists of only lowercase letters. Else it returns False.
say $type.is-coercive; # True or False
The is-coercive method returns True if the resolved type is known to be coercive. Else it returns False.
say $type.name; # RakuAST::Name.from-identifier("foo")
Returns the L<RakuAST::Name>|/type/RakuAST::Name object of this RakuAST::Type::Simple object.
There are several ways to create a RakuAST::Type::Simple object. For simple identifiers it is recommended to use the alternate .from-identifier and .from-identifier-parts methods to create a RakuAST::Type::Simple object. Otherwise one can use the standard .new method.
my $type = RakuAST::Type::Simple.new(
RakuAST::Name.new(
RakuAST::Name::Part::Simple.new("Foo"),
colonpairs => (
RakuAST::ColonPair::Value.new(
key => "ver",
value => RakuAST::StrLiteral.new("1.1")
),
)
)
);
dd $type; # Foo:ver("1.1")
Creates a RakuAST::Type::Simple object from the given RakuAST::Name object.
my $type = RakuAST::Type::Simple.from-identifier('foo');
dd $type; # foo
Creates a RakuAST::Type::Simple object from the given simple identifier string (which may not contain any :: separators).
my $type = RakuAST::Type::Simple.from-identifier-parts('IO','Path');
dd $type; # IO::Path
Creates a RakuAST::Type::Simple object from the given simple identifier string parts (which may not contain any :: separators).