moo-nad: Invocation helpers for the ReaderT-record-of-functions style.
Using a record-of-functions as the environment of some reader-like monad is a common way of structuring Haskell applications, somewhat resembling dependency injection in OOP.
We often want our program logic to be polymorphic over both the
concrete monad and the environment. One common solution is to
abstract the monad using MonadReader
, and abstract the environment
using HasX
-style typeclasses.
One minor annoyance though is that invoking the function in the environment is often a bit cumbersome: you have to ask the environment for the function, and then lift the result of the function back into the reader-like monad.
This library supports a special twist on ReaderT
-record-of-functions
style: instead of depending only on typeclasses for abstraction,
we also use a module signature. This comes with different tradeoffs.
One benefit is that we support a simpler way of invoking functions from the environment, using a helper that takes care of both asking the environment and lifting function results, and which works uniformly for functions of any arity.
[Skip to Readme]
library moo-nad
library moo-nad:example-impl
library moo-nad:example-logic-that-logs
Downloads
- moo-nad-0.1.0.2.tar.gz [browse] (Cabal source package)
- Package description (as included in the package)
Maintainer's Corner
For package maintainers and hackage trustees
Candidates
- No Candidates
Versions [RSS] | 0.1.0.1, 0.1.0.2 |
---|---|
Change log | CHANGELOG.md |
Dependencies | base (>=4.11.0.0 && <5), dep-t (>=0.4.4 && <0.5), moo-nad, mtl (>=2.2 && <2.3), transformers (>=0.5 && <0.6) [details] |
License | BSD-3-Clause |
Author | Daniel Diaz Carrete |
Maintainer | diaz_carrete@yahoo.com |
Category | Control |
Source repo | head: git clone https://github.com/danidiaz/moo-nad.git |
Uploaded | by DanielDiazCarrete at 2021-05-23T13:47:53Z |
Distributions | |
Downloads | 262 total (2 in the last 30 days) |
Rating | (no votes yet) [estimated by Bayesian average] |
Your Rating | |
Status | Docs uploaded by user [build log] Last success reported on 2021-05-23 [all 1 reports] |