user
This draft task needs a purpose, a description and some way to tell whether examples satisfy or do not satisfy it.

Task

Show a function/procedure that processes a block of text by printing it.

The function takes one parameter (ideally) that describes the text.

Demonstrate by calling the function twice, each time passing in a different type.

This can be done with pattern matching, multi-methods, dynamic type detection, structure(s) with a tag, etc.

The objective is write a [e.g. library] function that processes text from multiple sources (such as a string/char \*, socket, file, etc).

If not practical, show how the caller would coerce a type that can be passed to the library function.
assistant
(formerly Perl 6)

**Works with**: Rakudo version 2020.08.1

Raku is a dynamic language that has gradual, duck typing. It provides introspection methods through its comprehensive MOP (Meta Object Protocol) making it easy to do type detection, subroutine signatures and multi-dispatch. Raku types have two general flavors: content types and container types. Different container types have varying restrictions on what sort of content they can contain and in return provide specialized methods to operate on those contents. Content types give the compiler hints on how to best handle the information, what storage requirements it may have, what operators will work with it, etc.

This is really a very broad and kind of hand-wavey overview of Raku types. For much more in-depth coverage see: https://docs.raku.org/type.html

```
sub type ($t) { say $t.raku, "\tis type: ", $t.WHAT }

# some content types
.&type for 1, 2.0, 3e0, 4i, π, Inf, NaN, 'String';

# some primitive container types
.&type for $, [ ], @, { }, %, (5 .. 7), (8 ... 10), /0/, {;}, sub {}, ( );

# undefined things
.&type for Any, Nil;

# user defined types
class my-type { };

my my-type $object;

$object.&type;

```

Output:

```
1	is type: (Int)
2.0	is type: (Rat)
3e0	is type: (Num)
<0+4i>	is type: (Complex)
3.14159265358979e0	is type: (Num)
Inf	is type: (Num)
NaN	is type: (Num)
"String"	is type: (Str)
Any	is type: (Any)
$[]	is type: (Array)
$[]	is type: (Array)
{}	is type: (Hash)
{}	is type: (Hash)
5..7	is type: (Range)
(8, 9, 10).Seq	is type: (Seq)
/0/	is type: (Regex)
-> ;; $_? is raw { #`(Block|61385680) ... }	is type: (Block)
sub () { #`(Sub|62948936) ... }	is type: (Sub)
$()	is type: (List)
Any	is type: (Any)
Nil	is type: Nil
my-type	is type: (my-type)
```