data-has: Simple extensible product

This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.

[maintain] [Publish]


Simple extensible product

[Skip to Readme]


Change log CHANGELOG
Dependencies base (>=4.8 && <5) [details]
License BSD-3-Clause
Author winterland1989
Category Data
Home page
Source repo head: git clone git://
Uploaded by winterland at 2020-12-01T05:40:30Z


[Index] [Quick Jump]


Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Readme for data-has-

[back to package description]


Hackage Build Status

A simple extensible product system, a typical usage is to free you from considering how to layer your monad stack, because your can now extend your monad in one layer:

 {-# LANGUAGE FlexibleContexts #-}

 -- in some library code
 logInAnyReaderHasLogger :: (Has Logger r, MonadReader r m) => LogString -> m ()
 logInAnyReaderHasLogger s = asks getter >>= logWithLogger s

 queryInAnyReaderHasSQL :: (Has SqlBackEnd r, MonadReader r m) => Query -> m a
 queryInAnyReaderHasSQL q = asks getter >>= queryWithSQL q

 -- now you want to use these effects together
 logger <- initLogger  ...
 sql <- initSqlBackEnd ...

 (`runReader` (logger, sql)) $ do
       logInAnyReaderHasLogger ...
       x <- queryInAnyReaderHasSQL ...