]> Git — Sourcephile - haskell/symantic.git/blob - symantic/Language/Symantic/Typing/Show.hs
Remove need for space after infix operator.
[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 Language.Symantic.Document as D
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 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 = showString $ 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 = showString $ TL.unpack (TLB.toLazyText $ D.plain $ docTypes conf tys)
25
26 instance NameTyOf c => Show (Const src c) where
27 showsPrec _p = showString . TL.unpack . TLB.toLazyText . D.plain . docConst mempty
28
29 instance Source src => Show (Type src vs t) where
30 showsPrec = showTypeS config_Doc_Type
31 instance Source src => Show (TypeK src vs kt) where
32 showsPrec p (TypeK t) = showsPrec p t
33 instance Source src => Show (TypeVT src) where
34 showsPrec p (TypeVT t) = showsPrec p t
35 instance Source src => Show (TypeT src vs) where
36 showsPrec p (TypeT t) = showsPrec p t
37 instance Source src => Show (Types src vs ts) where
38 showsPrec _ = showTypesS config_Doc_Type