Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/raehik/generic-type-asserts
Structural assertions on generic data representations
https://github.com/raehik/generic-type-asserts
Last synced: 12 days ago
JSON representation
Structural assertions on generic data representations
- Host: GitHub
- URL: https://github.com/raehik/generic-type-asserts
- Owner: raehik
- License: mit
- Created: 2024-04-04T02:51:03.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-04-13T00:56:36.000Z (10 months ago)
- Last Synced: 2024-12-14T11:06:03.959Z (about 1 month ago)
- Language: Haskell
- Size: 14.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
[gdf-hackage]: https://hackage.haskell.org/package/generic-data-functions
# generic-type-asserts
Structural assertions on generic type representations (`GHC.Generic.Rep a`).Sometimes, we want to write generics that only work on certain data types with a
certain shape e.g. non-sum types (single constructor). Achieving this is fairly
straightforward if we add a `TypeError` constraint on the relevant generic
representation unwrapping instance (here, the `(:+:)` constructor sum type).This library effectively pulls those checks out of generic code and runs them by
separately. This way, we can simplify our generics, and make them more flexible
(e.g. a user may choose whether to permit void types at compile time or not).This began as a minor feature in my [generic-data-functions][gdf-hackage]
library.## License
Provided under the MIT license. See `LICENSE` for license text.