Search code examples
functionhaskellinputcomposition

Feeding the output of two functions to another function Haskell


I have three functions.

function1 :: [Person] -> [String]

function2 :: String -> [Person] -> [(String, Int)]

function3 :: [String] -> [(String, Int)] -> [String]

I want the output of function1 and function2 to be passed to function3. E.g function3(function1 function2)

But function1 and function2 both have their own parameters so it'd look something like:

function3(function1([Person]) function2(String [Person]))

I've looked at function composition but that's when you feed the output of one function to another. In this case, I want to feed the output of two separate functions to another.

Thank you.


Solution

  • You don't need parentheses on your function calls. f (g h) means f applied to a single argument which is g h. You probably want function3 (function1 ...) (function2 ...) where ... is the arguments to each function.