Subject: | Question: recursive container types |
Date: | Tue, 4 Feb 2020 14:54:04 +0100 |
To: | bug-Type-Tiny [...] rt.cpan.org |
From: | BP Jonsson <bpjonsson [...] gmail.com> |
This is a question rather than a bug, but I guess it could also be
construed as a feature request. Apologies if this could/should go over IRC,
but IRC is difficult because of my cerebral palsy; I keep hitting the wrong
keys at the wrong time...
I have a bit of a problem. I want to check for a hashref which may contain
scalars, arrayrefs or further hashrefs basically to any depth, but where
non-hashref, non-arrayref values must be strings or objects with overloaded
stringification, so I guess that I would need to define type constraints
for such arrays and hashes which nest themselves, presumably as weak
references. Is that at all possible with Type::Tiny? I suppose not, so is
there anything I can do short of traversing the whole data structure
"manually" at every turn?
As I said this should probably *not* be taken as a feature request although
I suppose that in principle you could check for recursive inclusions in
nested types like HashRef and make references weak as needed, but no need
to actually implement that at this time; I'm rather looking for good
alternative strategies.