data-has: Simple extensible product

[ bsd3, data, library ] [ Propose Tags ]

Simple extensible product


[Skip to Readme]

Modules

[Index]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.1.0.0, 0.2.0.0, 0.2.1.0, 0.3.0.0, 0.4.0.0
Change log CHANGELOG
Dependencies base (<5) [details]
License BSD-3-Clause
Author winterland1989
Maintainer winterland1989@gmail.com
Category Data
Home page https://github.com/winterland1989/data-has
Source repo head: git clone git://github.com/winterland1989/data-has.git
Uploaded by winterland at 2016-11-24T07:41:13Z
Distributions LTSHaskell:0.4.0.0, NixOS:0.4.0.0, Stackage:0.4.0.0
Reverse Dependencies 8 direct, 5 indirect [details]
Downloads 6448 total (45 in the last 30 days)
Rating 2.0 (votes: 1) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for data-has-0.2.0.0

[back to package description]

data-has

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