https://github.com/zenhack/haskell-quota
Haskell library for tracking quota usage
https://github.com/zenhack/haskell-quota
Last synced: about 1 year ago
JSON representation
Haskell library for tracking quota usage
- Host: GitHub
- URL: https://github.com/zenhack/haskell-quota
- Owner: zenhack
- License: apache-2.0
- Created: 2016-11-08T22:44:12.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2018-10-04T19:46:42.000Z (over 7 years ago)
- Last Synced: 2025-02-03T13:45:04.024Z (about 1 year ago)
- Language: Haskell
- Size: 26.4 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: ChangeLog.md
- License: LICENSE
Awesome Lists containing this project
README
**Unmaintained**. This package was originally written for use with [haskell-capnp][1],
but the relevant functionality [has been folded into that package][2], so this is no
longer used.
Haskell library to track quota usage.
# Why
Sometimes you need to process untrusted inputs in a way which if done
naively could consume unacceptably large amounts of resources. In this
case, you need a way to track and limit the resource usage.
# What
The core of the library is a type class, `MonadQuota`:
```haskell
class MonadQuota m where
invoice :: Int -> m ()
````
...and a monad transformer `QuotaT`, which implements MonadQuota on
top of MonadThrow.
The QuotaT keeps track of a quota, calling `throwM QuotaError` if it is
expended. `invoice` deducts its argument from the quota.
This was originally developed for use with [haskell-capnp][1], which
needs to deal with inputs where naive traversal could cause a DoS
vulnerability.
# License
Apache 2.0
[1]: https://github.com/zenhack/haskell-capnp
[2]: http://hackage.haskell.org/package/capnp-0.3.0.0/docs/Data-Capnp-TraversalLimit.html