Evgenii Akentev
·
2023-01-27
WeatherProvider.hs
1{-# LANGUAGE DataKinds #-}
2{-# LANGUAGE OverloadedStrings #-}
3{-# LANGUAGE TypeOperators #-}
4{-# LANGUAGE TypeApplications #-}
5
6module WeatherProvider where
7
8import Data.Vinyl.TypeLevel
9import HandleRec
10import qualified WindProvider as W
11import qualified TemperatureProvider as T
12import QueryTypes
13
14data WeatherData = WeatherData { temperature :: T.Temperature, wind :: W.WindSpeed }
15
16-- We union the methods of providers and extend it with a common method.
17type Methods = '[ '("getWeatherData", (Location -> Day -> IO WeatherData))
18 ] ++ W.Methods ++ T.Methods
19
20type Handle = HandleRec Methods
21
22getWeatherData :: Handle -> Location -> Day -> IO WeatherData
23getWeatherData = getMethod @"getWeatherData"