How to perform unknown functions on list of lists in Haskell with foldl/foldr/recursion?

92 Views Asked by At

I want to write something using foldl/foldr or recursion, what performs tasks one after another in the previously performed "state" with the next Job's function. It needs to work with any type of given variable/function. The time is irrelevant now, that's why I used hole instead of it. I can do it with recursion, but for some reason "++" changes it's type, so I get an error.

I tried this one so far:

data Time = Time Int Int
data Job a = Job Time (a -> a) 


perform :: a -> [Job a] -> a
perform s [] = s  
perform s ((Job _ f):xs) = foldl (\x -> f s) s xs
--perform startingpoint [] = s
--perform startingpoint ((Job _ function) : xs) = foldl (\x -> function startingpoint) (function startingpoint) xs

What's the problem? How could I fix this?

0

There are 0 best solutions below