Subject: | Coercion Hierarchies |
I've defined the following (test code is attached)
class_type Vector, { class => 'Vector' };
declare VecArray,
as Tuple [ ( Num ) x 4 ];
coerce VecArray,
from Tuple [ ( Num ) x 3 ],
via {
[ @{$_}, 1 ]
};
coerce Vector,
from VecArray, via {
Vector->new( $_ );
};
These work:
# coerce Tuple[ (Num) x 3] to VecArray
validate( [ [1,2,3] ], VecArray );
# coerce Tuple[ (Num) x 4] (VecArray) to Vector
validate( [ [1,2,3,1] ], Vector );
But this doesn't:
# coerce Tuple[ (Num) x 3] to VecArray to Vector
validate( [ [1,2,3] ], Vector );
It fails the find the first coercion. Is there a limit to how deep Type::Tiny looks for coercions?
Thanks,
Diab
Subject: | ttype |
Message body not shown because it is not plain text.