Hacker News new | ask | show | jobs
by emmanueloga_ 1015 days ago
One possible application: If an input to a function parameter must match a certain regex, and the output of a function produces results matching another regex, we can know if the functions are compatible: if the intersection of regular expressions is empty, then you cannot connect one function to the other.

Combined with the fact the regular expressions can be used not only on strings but more generally (e.g. for JSON schema validation [1]), this could be a possible implementation of static checks, similar to "design by contract".

--

1: https://www.balisage.net/Proceedings/vol23/html/Holstege01/B...