As you may already know when you use map it takes a function and applies that function to every element of a list
map f xs is the list obtained by applying f to each element of xs, i.e.,
But in my case I have a list of functions that need to be applied in order to an specific value. These are the types, to give a better idea:
data Auto = Auto {plate :: String, currentTank :: Int, tanqSize :: Int} deriving (Show, Eq)
type Services = Car -> Car
service :: Car -> [Services] -> Car
As I explained before [Services] will be a list of functions that take in Car
and return Car
. I need to apply in order those functions to the Car
that takes service
and return it with all the modifications done.
Here are some examples of functions that may appear on the list:
emptyTank :: Services
reFuel :: Int -> Services
changePlate :: String -> Services
upgradeTank :: Int -> Services
Does anyone know a way to solve this? In case you know a more appropriate function to use instead of map, tell me and I'll look into it.