Have you tried reformulating as separate functions rather than "trying to be smart on the first go" with the embedded lambda expression? When I'm doing Haskell it helps to identify problem areas.