You cannot do this with a simple list, but you can create your own list type, as shown below:
{-
Then you can do these CascadingList as follows:
addOnePositive :: CascadingList Int Bool addOnePositive = Cascade (>0) $ Cascade (+1) $ Id
You can collapse lists:
collapse :: CascadingList ab -> a -> b collapse Id = id collapse (Cascade fc) = f . collapse c
Then you will have
collapse addOnePositive 0 == True
Please note that this does not take into account the types of intermediate functions, so this may not be what you are looking for.
I just realized that this is closer to something like [c β d, b β c, a β b]. This is an easy change to bring it closer to your intentions; I could edit it, but I think you get the point.
source share