Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/patrickt/fastsum
A fast open-union type, suitable for 100+ contained alternatives.
https://github.com/patrickt/fastsum
Last synced: 4 days ago
JSON representation
A fast open-union type, suitable for 100+ contained alternatives.
- Host: GitHub
- URL: https://github.com/patrickt/fastsum
- Owner: patrickt
- License: other
- Created: 2018-05-02T19:16:00.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-04-28T22:24:10.000Z (8 months ago)
- Last Synced: 2024-12-24T12:30:16.761Z (5 days ago)
- Language: Haskell
- Homepage:
- Size: 56.6 KB
- Stars: 97
- Watchers: 8
- Forks: 7
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Changelog: ChangeLog.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# fastsum
This package provides `Data.Sum`, an open-union type, similar to the `Union` type that powers the implementation of [Oleg Kiselyov's extensible-effects library](http://okmij.org/ftp/Haskell/extensible/).
Unlike most open-union implementations, this type is very fast to compile, even when the type-level list of alternatives contains hundreds of entries. Membership queries are constant-time, compiling to a single type-level natural lookup in a closed type family, unlike the traditional encoding of `Union`, which relies on recursive typeclass lookups. As such, this type lends itself to representing abstract syntax trees or other rich data structures.
GHC 8's support for custom type errors provides readable type errors should membership constraints not be satisfied.
In order to achieve speed, this package makes fewer guarantees about what can be proven given a `Member` instance. If you require a richer vocabulary to describe the implications of membership, you should use the traditional implementation of open-unions.
# Credits
This library is built on the work of Oleg Kiselyov, which was then modified by Allele Dev. It was extracted from Josh Vera's [effects](https://github.com/joshvera/effects/) library. Rob Rix implemented the `ElemIndex` type family and the `Apply` typeclass.