Compile-time constraints for strings in F#, similar to Units of Measure - is it possible?
问题 I'm developing a Web application using F#. Thinking of protecting user input strings from SQL, XSS, and other vulnerabilities. In two words, I need some compile-time constraints that would allow me discriminate plain strings from those representing SQL, URL, XSS, XHTML, etc. Many languages have it, e.g. Ruby’s native string-interpolation feature #{...} . With F#, it seems that Units of Measure do very well, but they are only available for numeric types. There are several solutions employing