]> Git — Sourcephile - haskell/symantic.git/blob - symantic/Language/Symantic/Typing/Show.hs
Use symantic-document to write docType.
[haskell/symantic.git] / symantic / Language / Symantic / Typing / Show.hs
1 {-# LANGUAGE PolyKinds #-}
2 {-# OPTIONS_GHC -fno-warn-orphans #-}
3 module Language.Symantic.Typing.Show where
4
5 import Data.Semigroup ((<>))
6 import qualified Data.Text.Lazy as TL
7 import qualified Data.Text.Lazy.Builder as TLB
8
9 import qualified Language.Symantic.Document as D
10 import Language.Symantic.Grammar
11 import Language.Symantic.Typing.Type
12 import Language.Symantic.Typing.Document
13
14 showType :: Config_Doc_Type -> Type src vs t -> String
15 showType conf ty = TL.unpack $ TLB.toLazyText $ D.plain $ docType conf 0 ty
16
17 showTypeS :: Config_Doc_Type -> Precedence -> Type src vs t -> ShowS
18 showTypeS conf pr ty s = s <> TL.unpack (TLB.toLazyText $ D.plain $ docType conf pr ty)
19
20 showTypes :: Config_Doc_Type -> Types src vs ts -> String
21 showTypes conf tys = TL.unpack (TLB.toLazyText $ D.plain $ docTypes conf tys)
22
23 showTypesS :: Config_Doc_Type -> Types src vs ts -> ShowS
24 showTypesS conf tys s = s <> TL.unpack (TLB.toLazyText $ D.plain $ docTypes conf tys)
25
26 instance Source src => Show (Type src vs t) where
27 showsPrec = showTypeS config_doc_type
28 instance Source src => Show (TypeK src vs kt) where
29 showsPrec p (TypeK t) = showsPrec p t
30 instance Source src => Show (TypeVT src) where
31 showsPrec p (TypeVT t) = showsPrec p t
32 instance Source src => Show (TypeT src vs) where
33 showsPrec p (TypeT t) = showsPrec p t
34 instance Source src => Show (Types src vs ts) where
35 showsPrec _ = showTypesS config_doc_type