I don't think this should be part of PrimitiveState. It should be part of the implementation in RegexState. The idea of a PrimitiveState is that it represents an opaque function for determining whether a particular input string matches this state. Your code change makes it non-opaque here, which is an undesirable design change.