Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kleidukos/cache-effectful
Bindings to the `cache` library for the Effectful ecosystem
https://github.com/kleidukos/cache-effectful
effect-system effectful
Last synced: 19 days ago
JSON representation
Bindings to the `cache` library for the Effectful ecosystem
- Host: GitHub
- URL: https://github.com/kleidukos/cache-effectful
- Owner: Kleidukos
- License: mit
- Created: 2022-02-12T17:59:40.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-04-02T21:56:56.000Z (9 months ago)
- Last Synced: 2024-11-30T17:55:31.789Z (23 days ago)
- Topics: effect-system, effectful
- Language: Haskell
- Homepage:
- Size: 10.7 KB
- Stars: 8
- Watchers: 1
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# effectful-cache [![CI-badge][CI-badge]][CI-url]
A `Cache` effect for the [`effectful`][effectful] ecosystem.
## How to use
This library exposes the following elements:
* `Cache` — The type-level effect that you can declare in your type signatures.
```
populateIntCache :: (Cache Int Int :> es) => Eff es ()
```* `insert`, `lookup`, `keys`, `delete`, `filterWithKey` – Operations on `Cache`. They should always be used with Type Applications when using literals:
```Haskell
insertAndLookup :: (Cache Int Int :> es) => Eff es (Maybe Int)
insertAndLookup = do
insert @Int @Int 3 12
lookup @Int 3listKeys :: (Cache Int Int :> es) => Eff es [Int]
listKeys = do
populateIntCache
keys @Int @Int
```* An IO Runner
```
runCacheIO (cache :: Data.Cache Int Int)
```See the [tests][tests] to see an example use.
[effectful]: https://github.com/haskell-effectful/effectful
[tests]: https://github.com/haskell-effectful/effectful-cache/blob/main/effectful-cache/test/Main.hs
[CI-badge]: https://img.shields.io/github/workflow/status/haskell-effectful/effectful-cache/CI?style=flat-square
[CI-url]: https://github.com/haskell-effectful/effectful-cache/actions