Specio::Constraint::Structurable(3) User Contributed Perl Documentation Specio::Constraint::Structurable(3)

# [SYNOPSIS](#SYNOPSIS)

```
    my $tuple = t('Tuple');
    my $tuple_of_str_int = $tuple->parameterize( of => [ t('Str'), t('Int') ] );
```

# [DESCRIPTION](#DESCRIPTION)

This class implements the API for structurable types like "Dict", "Map"&lt; and "Tuple".

# [API](#API)

This class implements the same API as Specio::Constraint::Simple, with a few additions.

## [Specio::Constraint::Structurable-&gt;new(...)](#Specio::Constraint::Structurable)

This class's constructor accepts two additional parameters:

- parameterization\_args\_builder
  
  This is a subroutine that takes the values passed to "of" and returns a hash of named arguments. These arguments will then be passed into the "structured\_constraint\_generator" or "structured\_inline\_generator".
  
  This should also do argument checking to make sure that the argument passed are valid. For example, the "Tuple" type turns the arrayref passed to "of" into a hash, along the way checking that the caller did not do things like interleave optional and required elements or mix optional and slurpy together in the definition.
  
  This parameter is required.
- name\_builder
  
  This is a subroutine that is called to generate a name for the structured type when it is created. This will be called as a method on the "Specio::Constraint::Structurable" object. It will be passed the hash of arguments returned by the "parameterization\_args\_builder".
  
  This parameter is required.
- structured\_constraint\_generator
  
  This is a subroutine that generates a new constraint subroutine when the type is structured.
  
  It will be called as a method on the type and will be passed the hash of arguments returned by the "parameterization\_args\_builder".
  
  This parameter is mutually exclusive with the "structured\_inline\_generator" parameter.
  
  This parameter or the "structured\_inline\_generator" parameter is required.
- structured\_inline\_generator
  
  This is a subroutine that generates a new inline generator subroutine when the type is structured.
  
  It will be called as a method on the Specio::Constraint::Structured object when that object needs to generate an inline constraint. It will receive the type parameter as the first argument and the variable name as a string as the second.
  
  The remaining arguments will be the parameter hash returned by the "parameterization\_args\_builder".
  
  This probably seems fairly confusing, so looking at the examples in the Specio::Library::Structured::* code may be helpful.
  
  This parameter is mutually exclusive with the "structured\_constraint\_generator" parameter.
  
  This parameter or the "structured\_constraint\_generator" parameter is required.

## [$type-&gt;parameterize(...)](#$type)

This method takes two arguments. The "of" argument should be an object which does the Specio::Constraint::Role::Interface role, and is required.

The other argument, "declared\_at", is optional. If it is not given, then a new Specio::DeclaredAt object is creating using a call stack depth of 1.

This method returns a new Specio::Constraint::Structured object.

2026-10-26 perl v5.44.0

---

Document: Specio::Constraint::Structurable(3pm) from perl-specio 0.53-r7 (Chainguard OS)
Source: https://github.com/houseabsolute/Specio
