I create many temporary variables in Haskell:
main = do let nums'' = [1..10] let nums' = a . bunch . of_ . functions $ nums'' let nums = another . bunch . of_ . functions $ nums' print nums
That is, I do not want to write a long chain of such functions:
let nums = another . bunch . of_ . functions . a . bunch . of_ . functions $ [1..10]
Because it becomes unreadable to me, so I try to group functions according to what they do. In this process, I create a bunch of ugly temporary variables like nums''
and nums'
(I could give them more meaningful names, but the dot still stands ... every new line means a new variable). This is the case where a shaded variable will lead to cleaner code. I would like to do something like:
let nums = [1..10] nums = a . bunch . of_ . functions $ nums nums = another . bunch . of_ . functions $ nums
those. exactly the same as above, but without temporary variables. Is there a way to do this in Haskell? Perhaps all of this can be wrapped in a "transaction":
atomically $ do (...this code...) return nums
Something that would let Haskell know that the code in this section contains shaded variables, and he should only worry about the end result. Is it possible?
source share