repos / handle-examples.hs.git


handle-examples.hs.git / backpack-handle / test-impl
Evgenii Akentev  ·  2021-01-05

TestWeatherProvider.hs

 1module TestWeatherProvider where
 2
 3type Temperature = Int
 4data WeatherData = WeatherData { temperature :: Temperature }
 5
 6type Location = String
 7type Day = String
 8
 9-- | This is a configuration that allows to setup the provider for tests.
10data Config = Config
11  { initTemperature :: Temperature
12  }
13
14data Handle = Handle
15  { config :: Config
16  }
17
18new :: Config -> Handle
19new = Handle
20
21-- | This is an implementation `WeatherProvider` interface for tests
22getWeatherData :: Handle -> Location -> Day -> IO WeatherData
23getWeatherData (Handle conf) _ _ = return $ WeatherData $ initTemperature conf