class RakuAST::Type::Simple { }

The RakuAST::Type::Simple class represents a simple Raku type without any additional features, such as coercion or definedness.

Object introspection§

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.

is-native§

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.

is-coercive§

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.

name§

say $type.name;  # RakuAST::Name.from-identifier("foo")

Returns the L<RakuAST::Name>|/type/RakuAST::Name object of this RakuAST::Type::Simple object.

Object creation§

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.

new§

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.

from-identifier§

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).

from-identifier-parts§

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).