build-type: Simple
extra-source-files: CHANGELOG.md
-library domain
+library domain-provider
hs-source-dirs: domain
signatures: WeatherProvider
default-language: Haskell2010
hs-source-dirs: domain
signatures: WeatherReporter
default-language: Haskell2010
- build-depends: base, domain
+ build-depends: base, domain-provider
-library impl
+library impl-provider
hs-source-dirs: impl
exposed-modules: SuperWeatherProvider
- , SuperWeatherReporter
- reexported-modules: SuperWeatherProvider as WeatherProvider,
- SuperWeatherReporter as WeatherReporter
+ reexported-modules: SuperWeatherProvider as WeatherProvider
default-language: Haskell2010
build-depends: base
-library test-impl
+library impl-reporter
+ hs-source-dirs: impl
+ exposed-modules: SuperWeatherReporter
+ reexported-modules: SuperWeatherReporter as WeatherReporter
+ default-language: Haskell2010
+ build-depends: base, domain-provider
+
+library test-provider
hs-source-dirs: test-impl
exposed-modules: TestWeatherProvider
reexported-modules: TestWeatherProvider as WeatherProvider
executable main
main-is: Main.hs
build-depends: base >=4.13 && <4.14
- , impl
- , domain
+ , impl-provider
+ , impl-reporter
+ , domain-reporter
+ , domain-provider
default-language: Haskell2010
test-suite spec
build-depends: base >= 4.7 && < 5
, QuickCheck
, hspec
- , domain
- , test-impl
- , impl
- mixins:
- impl (WeatherProvider as UnusedWeatherProvider, WeatherReporter)
+ , domain-reporter
+ , domain-provider
+ , test-provider
+ , impl-reporter
module SuperWeatherReporter where
-import qualified SuperWeatherProvider
+import qualified WeatherProvider
type WeatherReport = String
-type WeatherProviderHandle = SuperWeatherProvider.Handle
+type WeatherProviderHandle = WeatherProvider.Handle
-- | We hide dependencies in the handle
-data Handle = Handle { weatherProvider :: SuperWeatherProvider.Handle }
+data Handle = Handle { weatherProvider :: WeatherProvider.Handle }
-- | Constructor for Handle
-new :: SuperWeatherProvider.Handle -> Handle
+new :: WeatherProvider.Handle -> Handle
new = Handle
-- | Domain logic. Usually some pure code that might use mtl, free monads, etc.
-createWeatherReport :: SuperWeatherProvider.WeatherData -> WeatherReport
-createWeatherReport (SuperWeatherProvider.WeatherData temp) =
+createWeatherReport :: WeatherProvider.WeatherData -> WeatherReport
+createWeatherReport (WeatherProvider.WeatherData temp) =
"The current temperature in London is " ++ (show temp)
-- | Domain logic that uses external dependency to get data and process it.
getCurrentWeatherReportInLondon :: Handle -> IO WeatherReport
getCurrentWeatherReportInLondon (Handle wph) = do
- weatherData <- SuperWeatherProvider.getWeatherData wph "London" "now"
+ weatherData <- WeatherProvider.getWeatherData wph "London" "now"
return $ createWeatherReport weatherData