Is it possible to manipulate nested function compositions in Haskell, in such a way that some processing be executed to each function before the composition?
Suppose a nested composition like (lines . unlines . words) "Testing Haskell composition"
(it does not make sense; it is just an random example).
I would like to do something before executing lines
,unlines
and words
. Something like this fake code:
performComposition :: [functions] -> returnValue
performComposition [] = ()
performComposition (f:fs) = do something
f (performComposition fs )
Is it possible, even if it is necessary to create a new operator?
EDIT (February 17th, 2016)
I did not mention that i wanted to do something different on the last function. On the example above, the words
function would do something different from the others before executing it.
The solution i have found is detailed below.