perms :: [a] -> [[a]] perms [] = [[]] perms (x:xs) = [take i perm ++ [x] ++ drop i perm | perm <- perms xs, i <- [0..length perm]]