]> Git — Sourcephile - haskell/symantic.git/blob - symantic/Language/Symantic/Typing/Show.hs
Update to lastest symantic-document
[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 qualified Data.Text.Lazy as TL
6 import qualified Data.Text.Lazy.Builder as TLB
7
8 import qualified Symantic.Document as Doc
9 import Language.Symantic.Grammar
10 import Language.Symantic.Typing.Type
11 import Language.Symantic.Typing.Module
12 import Language.Symantic.Typing.Document
13
14 stringDocTerm :: Doc.Plain TLB.Builder -> String
15 stringDocTerm =
16 TL.unpack .
17 TLB.toLazyText .
18 Doc.runPlain
19
20 showType :: Config_Doc_Type -> Type src vs t -> String
21 showType conf ty = stringDocTerm $ docType conf 0 ty
22
23 showTypeS :: Config_Doc_Type -> Precedence -> Type src vs t -> ShowS
24 showTypeS conf pr ty = showString $ stringDocTerm $ docType conf pr ty
25
26 showTypes :: Config_Doc_Type -> Types src vs ts -> String
27 showTypes conf tys = stringDocTerm $ docTypes conf tys
28
29 showTypesS :: Config_Doc_Type -> Types src vs ts -> ShowS
30 showTypesS conf tys = showString $ stringDocTerm $ docTypes conf tys
31
32 instance NameTyOf c => Show (Const src c) where
33 showsPrec _p = showString . stringDocTerm . docConst mempty
34
35 instance Source src => Show (Type src vs t) where
36 showsPrec = showTypeS config_Doc_Type
37 instance Source src => Show (TypeK src vs kt) where
38 showsPrec p (TypeK t) = showsPrec p t
39 instance Source src => Show (TypeVT src) where
40 showsPrec p (TypeVT t) = showsPrec p t
41 instance Source src => Show (TypeT src vs) where
42 showsPrec p (TypeT t) = showsPrec p t
43 instance Source src => Show (Types src vs ts) where
44 showsPrec _ = showTypesS config_Doc_Type