The problem is that you don't really split up the tail
, the two comparisons aren't complemental. It becomes obvious when we write the first one as a lambda, too:
first ( (\x -> qs. . filter (x<))
&&& (\x -> (x:) . qs . filter (>=x)) )
when what you want is obviously
first ( (\x -> qs. . filter (<x))
&&& (\x -> (x:) . qs . filter (>=x)) )
or
first ( (qs.) . filter . (>)
&&& (\x -> (x:) . qs . filter (x<=)) )
BTW, I'd prefer app
over uncurry id
.