]> Git — Sourcephile - haskell/symantic.git/blob - symantic/Language/Symantic/Typing/Show.hs
Sync symantic with 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
7 import qualified Language.Symantic.Document.Term as Doc
8 import Language.Symantic.Grammar
9 import Language.Symantic.Typing.Type
10 import Language.Symantic.Typing.Module
11 import Language.Symantic.Typing.Document
12
13 stringDocTerm :: Doc.Term -> String
14 stringDocTerm =
15 TL.unpack .
16 Doc.textTerm .
17 Doc.withColorable False .
18 Doc.withDecorable False
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