repos / handle-examples.hs.git


commit
5f12fd0
parent
13b140f
author
Evgenii Akentev
date
2023-01-27 23:54:42 +0400 +04
Fix build and use composite implementation for WeatherProvider
3 files changed,  +10, -9
M vinyl-handle/domain/WeatherProvider.hs
+0, -3
1@@ -21,6 +21,3 @@ type Handle = HandleRec Methods
2 
3 getWeatherData :: Handle -> Location -> Day -> IO WeatherData
4 getWeatherData = getMethod @"getWeatherData"
5-
6-getWindData :: Handle -> Location -> Day -> IO W.WindSpeed
7-getWindData = getMethod @"getWindData"
M vinyl-handle/impl/SuperWeatherProvider.hs
+8, -4
 1@@ -1,3 +1,5 @@
 2+{-# LANGUAGE RecordWildCards #-}
 3+
 4 module SuperWeatherProvider where
 5 
 6 import Data.Vinyl
 7@@ -7,9 +9,11 @@ import qualified WindProvider
 8 import QueryTypes
 9 
10 new :: WindProvider.Handle -> TemperatureProvider.Handle -> Handle
11-new wp tp = Field getSuperWeatherData
12-  :& RNil <+> wp <+> tp
13+new wp tp = Field (getSuperWeatherData wp tp) :& RNil <+> wp <+> tp
14 
15 -- | This is some concrete implementation `WeatherProvider` interface
16-getSuperWeatherData :: Location -> Day -> IO WeatherData
17-getSuperWeatherData _ _ = return $ WeatherData 30 10
18+getSuperWeatherData :: WindProvider.Handle -> TemperatureProvider.Handle -> Location -> Day -> IO WeatherData
19+getSuperWeatherData wp tp loc day = do
20+  temperature <- TemperatureProvider.getTemperatureData tp loc day
21+  wind <- WindProvider.getWindData wp loc day
22+  return $ WeatherData{..}
M vinyl-handle/vinyl-handle.cabal
+2, -2
 1@@ -1,4 +1,4 @@
 2-cabal-version:       >=2
 3+cabal-version:       >=2.0
 4 name:                vinyl-handle
 5 version:             0.1.0.0
 6 license-file:        LICENSE
 7@@ -34,7 +34,7 @@ library test-impl
 8 
 9 executable main
10   main-is:             Main.hs
11-  build-depends:       base >=4.13 && <4.14
12+  build-depends:       base >=4.13 && <5
13                      , domain
14                      , impl
15   default-language:    Haskell2010