From: Evgenii Akentev Date: Fri, 27 Jan 2023 19:54:42 +0000 (+0300) Subject: Fix build and use composite implementation for WeatherProvider X-Git-Url: https://git.ak3n.com/?a=commitdiff_plain;h=5f12fd0f62072dd3938bbd60925b250fcf54310c;p=handle-examples.git Fix build and use composite implementation for WeatherProvider --- diff --git a/vinyl-handle/domain/WeatherProvider.hs b/vinyl-handle/domain/WeatherProvider.hs index 6dd7245..5596d95 100644 --- a/vinyl-handle/domain/WeatherProvider.hs +++ b/vinyl-handle/domain/WeatherProvider.hs @@ -21,6 +21,3 @@ type Handle = HandleRec Methods getWeatherData :: Handle -> Location -> Day -> IO WeatherData getWeatherData = getMethod @"getWeatherData" - -getWindData :: Handle -> Location -> Day -> IO W.WindSpeed -getWindData = getMethod @"getWindData" diff --git a/vinyl-handle/impl/SuperWeatherProvider.hs b/vinyl-handle/impl/SuperWeatherProvider.hs index 4333fa6..099facc 100644 --- a/vinyl-handle/impl/SuperWeatherProvider.hs +++ b/vinyl-handle/impl/SuperWeatherProvider.hs @@ -1,3 +1,5 @@ +{-# LANGUAGE RecordWildCards #-} + module SuperWeatherProvider where import Data.Vinyl @@ -7,9 +9,11 @@ import qualified WindProvider import QueryTypes new :: WindProvider.Handle -> TemperatureProvider.Handle -> Handle -new wp tp = Field getSuperWeatherData - :& RNil <+> wp <+> tp +new wp tp = Field (getSuperWeatherData wp tp) :& RNil <+> 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{..} diff --git a/vinyl-handle/vinyl-handle.cabal b/vinyl-handle/vinyl-handle.cabal index 4d9b821..a351134 100644 --- a/vinyl-handle/vinyl-handle.cabal +++ b/vinyl-handle/vinyl-handle.cabal @@ -1,4 +1,4 @@ -cabal-version: >=2 +cabal-version: >=2.0 name: vinyl-handle version: 0.1.0.0 license-file: LICENSE @@ -34,7 +34,7 @@ library test-impl executable main main-is: Main.hs - build-depends: base >=4.13 && <4.14 + build-depends: base >=4.13 && <5 , domain , impl default-language: Haskell2010