Here is my solution:
import Control.Arrow select :: [a] -> [(a, [a])] select [] = [] select (x:xs) = (x, xs) : map (second (x:)) (select xs) perms :: Int -> [a] -> [[a]] perms 0 _ = [[]] perms n xs = do (y, ys) <- select xs fmap (y:) (perms (n - 1) ys)
He is very lazy and even works for endless lists, although the output there is not very useful. I did not bother to realize diagonalization or something like that. For leaf lists, this is great.
source share