I am a beginner to Haskell. This is an example from my lectures, where we define our function permu which should produce all permutations of a list.
permu :: [a] -> [[a]]
permu [] = [[]]
permu (x:xs) = concatMap (insertAll x) $ permu xs
insertAll :: a -> [a] -> [[a]]
insertAll = undefined
I'll leave insertAll as undefined for now, as it is not the part that I need help with.
My problem is this: concatMap has the type Foldable t => (a -> [b]) -> t a -> [b] and should thus take two parameters. However, insertAll should also take two parameters.
As far as I can tell concatMap takes insertAll x as first parameter and permu xs as the second. This all is good. But it looks to me like insertAll only takes the argument x.
Is it possible that both concatMap and insertAll takes permu xs as their second parameter, or am I missing something??
Thank you!
insertAll xis curried: it's equivallent to\arg -> insertAll x arg.f arg1 arg2we actually callfwitharg1, get the resulting function, and call that witharg2. Indeed,f arg1 arg2is equivalent to(f arg1) arg2and tolet resultFun = f arg1 in resultFun arg2.