Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/winterland1989/data-has
Simple extensible product
https://github.com/winterland1989/data-has
Last synced: 9 days ago
JSON representation
Simple extensible product
- Host: GitHub
- URL: https://github.com/winterland1989/data-has
- Owner: winterland1989
- License: bsd-3-clause
- Created: 2016-11-23T04:02:10.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2020-12-01T05:39:56.000Z (almost 4 years ago)
- Last Synced: 2024-04-26T05:44:52.239Z (6 months ago)
- Language: Haskell
- Size: 10.7 KB
- Stars: 38
- Watchers: 5
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG
- License: LICENSE
Awesome Lists containing this project
README
data-has
========[![Hackage](https://img.shields.io/hackage/v/data-has.svg?style=flat)](http://hackage.haskell.org/package/data-has)
[![Build Status](https://travis-ci.org/winterland1989/data-has.svg)](https://travis-ci.org/winterland1989/data-has)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:
```haskell
{-# LANGUAGE FlexibleContexts #-}-- in some library code
...
logInAnyReaderHasLogger :: (Has Logger r, MonadReader r m) => LogString -> m ()
logInAnyReaderHasLogger s = asks getter >>= logWithLogger squeryInAnyReaderHasSQL :: (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 ...
...
...
```