[（b：qs）：qss | （qs：qss）< - separate bs] ，您只需将
The problem is that with
[(b:qs):qss | (qs:qss) <- separate bs], you only prepend
b to the first subset of each of the
bs partitions. You want to prepend it to every subset.
separate (b:bs) = [[b]:s | s <- separate bs] ++ (singleModifies (b:) =<< separate bs) -- | All possibilities of applying a function to exactly one element in the list. singleModifies :: (a->a) -> [a] -> [[a]] singleModifies _  =  singleModifies f (x:xs) = (f x:xs) : map (x:) (singleModifies f xs)
In case you don't understand what the
=<< operator does: it “flattens” the nesting of lists.
separate bs already generates a list of partitions; for each of these we get another list from
singleModifies, but in the end we're not interested in which list came from where, so we just join (aka concat) them together. Another way for writing this would be
separate (b:bs) = [[b]:s | s <- separate bs] ++ concat [singleModifies (b:) bp | bp <- separate bs]