import qualified TemperatureProvider
import QueryTypes
-data WeatherData = WeatherData { temperature :: T.Temperature, wind :: W.WindSpeed }
+data WeatherData = WeatherData { temperature :: TemperatureProvider.Temperature, wind :: WindProvider.WindSpeed }
-- We union the methods of providers and extend it with a common method.
type Methods = ("getWeatherData" .== (Location -> Day -> IO WeatherData))
getWeatherData :: Handle -> Location -> Day -> IO WeatherData
getWeatherData = getMethod @"getWeatherData"
-getWindData :: Handle -> Location -> Day -> IO W.WindSpeed
+getWindData :: Handle -> Location -> Day -> IO WindProvider.WindSpeed
getWindData = getMethod @"getWindData"
+{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE OverloadedLabels #-}
+
module SuperWeatherProvider where
import Data.Row
import QueryTypes
new :: WindProvider.Handle -> TemperatureProvider.Handle -> Handle
-new wp tp = #getWeatherData .== getSuperWeatherData .+ wp .+ tp
+new wp tp = #getWeatherData .== (getSuperWeatherData wp tp) .+ wp .+ tp
-- | This is some concrete implementation `WeatherProvider` interface
-getSuperWeatherData :: Location -> Day -> IO WeatherData
-getSuperWeatherData _ _ = return $ WeatherData 30 10
+getSuperWeatherData :: WindProvider.Handle -> TemperatureProvider.Handle -> Location -> Day -> IO WeatherData
+getSuperWeatherData wp tp loc day = do
+ temperature <- TemperatureProvider.getTemperatureData tp loc day
+ wind <- WindProvider.getWindData wp loc day
+ return $ WeatherData{..}