I was just playing around with using a "subset" to restrict a
string to a set of allowed values:
subset Monster of Str where * eq any( << godzilla mothera blob
tingler grendel minotaur >> );
my Monster $thingie;
$thingie = 'grendel'; # accepts this as expected
$thingie = 'nada'; # fails as expected, with message:
# Type check failed in assignment to $thingie; expected Monster but
got Str ("nada")
I was wondering if there's some way to replace that error message
with a better one. If there's only a half dozen allowed values
I'd want to tell the user something like
"The string nada is note one of the allowed values
godzilla mothera blob tingler grendel minotaur"
I keep thinking there should be a form of where with a CATCH that
should work, but I don't see how to do it.