Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kowainik/idris-patricia
🌋 Idris implementation of patricia tree
https://github.com/kowainik/idris-patricia
algorithm containers data-structure idris persistence
Last synced: 3 days ago
JSON representation
🌋 Idris implementation of patricia tree
- Host: GitHub
- URL: https://github.com/kowainik/idris-patricia
- Owner: kowainik
- License: mit
- Created: 2017-10-12T14:35:18.000Z (about 7 years ago)
- Default Branch: main
- Last Pushed: 2020-11-06T17:55:51.000Z (about 4 years ago)
- Last Synced: 2024-08-02T13:33:04.616Z (3 months ago)
- Topics: algorithm, containers, data-structure, idris, persistence
- Language: Idris
- Homepage: https://kowainik.github.io/projects/idris-patricia
- Size: 15.6 KB
- Stars: 22
- Watchers: 5
- Forks: 1
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Codeowners: CODEOWNERS
Awesome Lists containing this project
README
# idris-patricia
[![Build status](https://secure.travis-ci.org/kowainik/idris-patricia.svg)](http://travis-ci.org/kowainik/idris-patricia)
[![MIT license](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)This package implements map from integer key to values. Data structure can be used as persistent array. Implementation is based on article about patricia trees and on [existing Haskell implementation](https://hackage.haskell.org/package/containers-0.5.10.2/docs/Data-IntMap-Lazy.html) from [`containers`](http://hackage.haskell.org/package/containers) package. Dependent types can help to ensure some invariants for data structure.
## REPL examples
```idris
λΠ> the (Int32Map String) $ insert 3 "a" Empty
Leaf (MkBits 3) "a" : IntBitMap 32 StringλΠ> the (Int32Map String) $ delete 3 $ insert 3 "a" Empty
Empty : IntBitMap 32 StringλΠ> the (Int32Map String) $ insert 2 "c" $ insert 4 "b" $ insert 3 "a" Empty
Bin (MkBits 3)
(FS (FS FZ))
(Bin (MkBits 2) FZ (Leaf (MkBits 2) "c") (Leaf (MkBits 3) "a"))
(Leaf (MkBits 4) "b") : IntBitMap 32 StringλΠ> toList $ the (IntBitMap 32 String) $ insert 2 "c" $ insert 4 "b" $ insert 3 "a" Empty
["c", "a", "b"] : List String
```## How to build
### Nix
Just run this command to build project and run tests.
```bash
nix-shell -A idris-patricia --command "bash install-dependencies.sh && idris --testpkg patricia-nix.ipkg --idrispath dependencies/specdris/src"
```### No-Nix
1. Install [`specdris`](https://github.com/pheymann/specdris) following instructions from repository.
2. Run `idris --testpkg patricia.ipkg`.