| Safe Haskell | Safe-Inferred |
|---|---|
| Language | GHC2021 |
TypeLevelShow.Doc
Contents
Synopsis
- data Doc s
- renderDoc :: Doc String -> String
- type PDoc = Doc Symbol
- type family RenderPDoc doc where ...
- type family ErrorPDoc doc where ...
- data SDoc (doc :: PDoc) where
- class SingDoc (doc :: PDoc) where
- demoteDoc :: SDoc doc -> Doc String
- reifyDoc :: forall (doc :: PDoc). SingDoc doc => Doc String
- errorPDoc :: forall (doc :: PDoc) a. SingDoc doc => a
Term level
Simple pretty document ADT.
Designed to work on both type level (as a limited ErrorMessage) and term
level (as a boring ADT).
Note that ShowType is magical (see
compilerGHCCore/Type.hs#L1309), so we need to remove it for term level.
singletons-base defines a version of this, but retains the ShowType
constructor and is in the singletons ecosystem.
Constructors
| Text s | plain ol' text |
| (Doc s) :<>: (Doc s) | append docs next to each other |
| (Doc s) :$$: (Doc s) | stack docs on top of each other (newline) |
Type level
type family RenderPDoc doc where ... Source #
Render a PDoc as an ErrorMessage, for type-level error messages.
PDoc is a subset of ErrorMessage, so this is very boring.
Equations
| RenderPDoc (Text s) = Text s | |
| RenderPDoc (l :<>: r) = RenderPDoc l :<>: RenderPDoc r | |
| RenderPDoc (l :$$: r) = RenderPDoc l :$$: RenderPDoc r |
type family ErrorPDoc doc where ... Source #
Render a PDoc as an ErrorMessage, and wrap it in a TypeError.
Note that this must be a type family, or the PDoc won't actually get
rendered.
Equations
| ErrorPDoc doc = TypeError (RenderPDoc doc) |
Singleton
data SDoc (doc :: PDoc) where Source #
Singleton Doc.
class SingDoc (doc :: PDoc) where Source #
Produce the singleton for the given promoted Doc.