Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/raehik/type-level-show
Utilities for writing Show-like type families
https://github.com/raehik/type-level-show
Last synced: about 2 months ago
JSON representation
Utilities for writing Show-like type families
- Host: GitHub
- URL: https://github.com/raehik/type-level-show
- Owner: raehik
- License: mit
- Created: 2024-05-04T22:58:36.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2024-06-01T15:14:30.000Z (7 months ago)
- Last Synced: 2024-06-11T18:32:41.035Z (7 months ago)
- Language: Haskell
- Size: 34.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# type-level-show
Utilities for writing `Show`-like type families i.e. instead of `showsPrec
:: Int -> a -> ShowS`, we have `ShowsPrec :: Natural -> k -> Symbol`.Requires at least GHC 9.6 for the builtin `SChar` etc. singletons.
## Why?
[refined-hackage]: https://hackage.haskell.org/package/refined
[rerefined-hackage]: https://hackage.haskell.org/package/rerefined[refined][refined-hackage] fills out error messages using `TypeRep`s. My rewrite
[rerefined][rerefined-hackage] allows you to use `Typeable` to fill out a
predicate name, or you can do it yourself. But `TypeRep` is a pain to use, and
it seems strange to do runtime work on type representations. Why can't we just
do it on the type level?We _could_, but the problem is nice formatting. `Show` instances handle
precedence, and the base library provides a bunch of handy utilities such as
`showParen :: Bool -> ShowS -> ShowS`. Worse, I couldn't find a `ShowNat ::
Natural -> Symbol` type family on Hoogle, which is a very simple type family
that should certainly be lying around.This library intends to provide such utilities, so that rerefined can avoid
`Typeable` altogether.Unsure if I'll provide a `ShowType`. Lower priority than the plain utilities.
## License
Provided under the MIT license. See `LICENSE` for license text.