@hackage type-level-show0.3.0
Utilities for writing Show-like type families
Categories
License
MIT
Maintainer
Ben Orchard <thefirstmuffinman@gmail.com>
Links
Versions
Installation
Dependencies (3)
- base >=4.18 && <5
- defun-core >=0.1 && <0.2
- singleraeh >=0.4.0 && <0.5 Show all…
Dependents (3)
@hackage/binrep, @hackage/symparsec, @hackage/rerefined
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 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.