How to fix this error? I know that testDatabase have an additional [ ] but how to remove the [ ] without triggering error? I am stuck for a few days...
* Couldn't match expected type `Spa -> [Spa]'
with actual type `[Spa]'
* In the second argument of `(.)', namely `testDatabase'
In the second argument of `(.)', namely
`averageRating . testDatabase'
In the first argument of `filter', namely
`((>= 8) . averageRating . testDatabase)'
My code below
data Spa = Spa SpaID Brand Area Stars [(Service, LevelRating)]
deriving (Eq, Show, Read)
type spaID = String
type Brand = String
type Area = String
type Stars = Int
type Service = String
type LevelRating = Int
testDatabase :: [Spa]
-- spa service level rating
getServiceLevelRating :: Spa -> [(Service, LevelRating)]
getServiceLevelRating (Spa _ _ _ _ s) = s
--making spa average level rating
averagelvRating :: [(String,Int)] -> Float
averagelvRating [] = 0
averagelvRating avglvrating = (fromIntegral(sum $ map snd avglvrating)) / (fromIntegral(length avglvrating))
--making spa average list
averageRating :: [Spa] -> [Float]
averageRating = (<$>) (averagelvRating . getServiceLevelRating)
--filtering
spaLevelRating :: Float -> [Spa] -> [Spa]
spaLevelRating levelRating = filter ((>=8) . averageRating . testDatabase)