type-level-show: Utilities for writing Show-like type families

[ data, library, mit, types ] [ Propose Tags ] [ Report a vulnerability ]

Please see README.md.


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0, 0.1.1, 0.2.0, 0.2.1, 0.3.0
Change log CHANGELOG.md
Dependencies base (>=4.16 && <5), defun-core (>=0.1 && <0.2) [details]
Tested with ghc ==9.8, ghc ==9.6, ghc ==9.4, ghc ==9.2
License MIT
Author Ben Orchard
Maintainer Ben Orchard <thefirstmuffinman@gmail.com>
Category Types, Data
Home page https://github.com/raehik/type-level-show#readme
Bug tracker https://github.com/raehik/type-level-show/issues
Source repo head: git clone https://github.com/raehik/type-level-show
Uploaded by raehik at 2024-05-07T19:24:37Z
Distributions LTSHaskell:0.3.0, NixOS:0.3.0
Reverse Dependencies 3 direct, 3 indirect [details]
Downloads 185 total (9 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for type-level-show-0.1.0

[back to package description]

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.2 for the type-level Symbol manipulation.

Why?

refined fills out error messages using TypeReps. My rewrite rerefined 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.