SHA1 compile time checked literals: F# vs Nemerle vs D
![Image](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-p0D6bPaaFLctyqSmwtYDeADvZ_MtLzL9BixOIYGIl9CCMgcbkyYui0AuLIisEJL_8miIOHbdNlS47-4Gyows8axO_SK9imfQ2cLi-AGh9F3AYJ7u4Ivnzl8_JGNYDDQ6cfY7iV3iqyqC/s1600/sha1_fsharp_tp_error1.png)
I've always been interested in metaprogramming. Sooner or later, I'm starting to feel constrained within a language without it. F# is a really nice language, but I'm afraid I'd have got bored with it if it'd not have Type Providers, for example. Why metaprogramming is so important? Because it allows changing a language without cracking the compiler. It allows making things which seemed to be impossible to implement. I'm dealing with cryptography hashes a lot at work, nothing rocket since, just MD5, SHA-1 and so on. And I write tons of tests where such hashes are used in form of string literals, like this: The problem with this code is that the compiler cannot guarantee that the hex string in the last line represents a valid SHA-1. If it does not, the test will fail at runtime for a reason it's not intended to. OK, now we can formulate our task: provide a language construct to enforce a string literal being a valid SHA-1 hexadecimal, at compile t