repos / handle-examples.hs.git


handle-examples.hs.git / simple / domain
Evgenii Akentev  ·  2021-01-07

WeatherReporter.hs

 1module WeatherReporter where
 2
 3import qualified WeatherProvider
 4
 5type WeatherReport = String
 6
 7-- | Domain logic. Usually some pure code that might use mtl, free monads, etc.
 8createWeatherReport :: WeatherProvider.WeatherData -> WeatherReport
 9createWeatherReport (WeatherProvider.WeatherData temp) =
10  "The current temperature in London is " ++ (show temp)
11
12-- | Domain logic that uses external dependency to get data and process it.
13getCurrentWeatherReportInLondon :: IO WeatherReport
14getCurrentWeatherReportInLondon = do
15  weatherData <- WeatherProvider.getWeatherData "London" "now"
16  return $ createWeatherReport weatherData