Update hindex.hs

Making the code more readable by breaking down in the code into smaller functions, giving variables more descriptive names, and adding more comments.