data-has: Simple extensible product

[ benchmark, bsd3, data, library ] [ Propose Tags ]
Change log CHANGELOG
Dependencies base (<5), base‑compat (>=0.9), transformers [details]
License BSD-3-Clause
Author winterland1989
Category Data
Home page
Source repo head: git clone git://
Uploaded by winterland at Thu Aug 17 10:47:56 UTC 2017
Distributions LTSHaskell:, NixOS:, Stackage:, openSUSE:
Downloads 798 total (14 in the last 30 days)
Rating (no votes yet) [estimated by rule of succession]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2017-08-17 [all 1 reports]
Hackage Matrix CI

Simple extensible product

[Skip to Readme]




Maintainer's Corner

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 ...