Really fix the basics recipe 4 code to remove unneeded code, and update the narrative...
[gitmo/Moose.git] / lib / Moose / Manual / Types.pod
index a18605c..e6cbce9 100644 (file)
@@ -39,9 +39,9 @@ The basic Moose type hierarchy looks like this
       Undef
       Defined
           Value
-              Num
-                Int
               Str
+                Num
+                    Int
                 ClassName
                 RoleName
           Ref
@@ -53,14 +53,28 @@ The basic Moose type hierarchy looks like this
               GlobRef
                 FileHandle
               Object
-                Role
 
 In practice, the only difference between C<Any> and C<Item> is
 conceptual. C<Item> is used as the top-level type in the hierarchy.
 
-The rest of these types correspond to existing Perl concepts. For
-example, a C<Num> is anything that Perl thinks looks like a number, an
-C<Object> is a blessed reference, etc.
+The rest of these types correspond to existing Perl concepts.
+In particular:
+
+=over 4
+
+=item C<Bool> accepts C<1> for true, and any value that perl treats as false for false.
+
+=item C<Maybe[`a]> accepts either C<`a> or C<undef>.
+
+=item C<Num> accepts anything that perl thinks looks like a number (see L<Scalar::Util/looks_like_number>).
+
+=item C<ClassName> and C<RoleName> accept strings that are either the name of a class or the name of a role. The class/role must be loaded beforehand for this to succeed.
+
+=item C<FileHandle> accepts either an object of type L<IO::Handle> or a builtin perl filehandle (see L<Scalar::Util/openhandle>).
+
+=item C<Object> accepts any blessed reference.
+
+=back
 
 The types followed by "[`a]" can be parameterized. So instead of just
 plain C<ArrayRef> we can say that we want C<ArrayRef[Int]> instead. We
@@ -194,7 +208,7 @@ rather than needing to fully qualify them everywhere. It also allows
 
   has 'counts' => (is => 'ro', isa => HashRef[PositiveInt]);
 
-and similarly for the union and other syntaxes discussed below, which
+and similarly for the union and other syntax discussed below, which
 will compile time check your use of names and is generally more robust
 than the string type parsing for complex cases.
 
@@ -364,7 +378,7 @@ type, or as the value for an attribute's C<isa> option:
 
   has 'size' => (
       is => 'ro',
-      isa => subtype 'Int' => where { $_ > 0 },
+      isa => subtype('Int' => where { $_ > 0 }),
   );
 
 This is handy when you want to create a one-off type and don't want to