data-has

Simple extensible product https://github.com/winterland1989/data-has

Version on this page:0.2.1.0
LTS Haskell 9.18:0.2.1.0
Stackage Nightly 2017-12-16:0.3.0.0
Latest on Hackage:0.3.0.0
BSD3 licensed by winterland1989
Maintained by winterland1989@gmail.com

Module documentation for 0.2.1.0

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

Changes

# v0.3.0.0

* Add `hasLens`, thanks @pavelkogan!

# v0.2.1.0

* Fix benchmarks.

# v0.2.0.0

* Change `get/modify` to `getter/modifier` to reduce naming collision, namely `get/modify` would collide with `MonadState`.

* Add tuple instances up to 12 elements.
Depends on 1 package:
Used by 1 package:
comments powered byDisqus