W_t = M_t[i] if 0 <= t <= 15 W_t = ROTL_1(W_(t-3) XOR W_(t-8) XOR W_(t-14) XOR W_(t-16)) if 16 <= t <= 79
This is from SHA-1 standards. In haskell, what you would trivially do is write a recursive function to do this, but to make it more efficient, I would like to expand all the recursion. The attachment will not work, as this can lead to exponential bloating of the code. I mean write TH to create the constant W_0 , W_1 , W_2 , etc. Until W_79 .
Another example is the unfolding of a loop in the case of
For t=0 to 79: { T = ROTL_5(a) + f_t(b, c, d ) + e + K_t + W_t e = d d = c c = ROTL_30(b) b = a a = T }
I would also like to expand this loop to avoid recursive function calls (and I don't think ghc will do such optimizations).
So, before I go and write TH for this, I wanted to ask if there is a better way to do this. Just to say that optimization is very important here.
source share