mirror of
https://github.com/GaloisInc/cryptol.git
synced 2024-09-21 19:08:51 +03:00
Add pretty printing instances for parameters.
This is mostly for debugging.
This commit is contained in:
parent
b66d990343
commit
8de5a7921f
@ -453,3 +453,10 @@ instance PP n => PP (WithNames (ModuleG n)) where
|
||||
-- XXX: Print abstarct types/functions
|
||||
vcat (map (ppWithNames (addTNames mps nm)) mDecls)
|
||||
where mps = map mtpParam (Map.elems mParamTypes)
|
||||
|
||||
instance PP (WithNames TCTopEntity) where
|
||||
ppPrec _ (WithNames ent nm) =
|
||||
case ent of
|
||||
TCTopModule m -> ppWithNames nm m
|
||||
TCTopSignature n ps ->
|
||||
hang ("interface module" <+> pp n <+> "where") 2 (ppWithNames nm ps)
|
||||
|
@ -25,7 +25,7 @@ import qualified Data.Set as Set
|
||||
import Data.Text (Text)
|
||||
|
||||
import Cryptol.Parser.Selector
|
||||
import Cryptol.Parser.Position(Located,Range,emptyRange)
|
||||
import Cryptol.Parser.Position(Located,thing,Range,emptyRange)
|
||||
import Cryptol.Parser.AST(ImpName(..))
|
||||
import Cryptol.ModuleSystem.Name
|
||||
import Cryptol.Utils.Ident (Ident, isInfixIdent, exprModName, ogModule)
|
||||
@ -1285,3 +1285,25 @@ instance PP TypeSource where
|
||||
GeneratorOfListComp -> "generator in a list comprehension"
|
||||
FunApp -> "function call"
|
||||
TypeErrorPlaceHolder -> "type error place-holder"
|
||||
|
||||
instance PP (WithNames ModParamNames) where
|
||||
ppPrec _ (WithNames ps ns) =
|
||||
let tps = Map.elems (mpnTypes ps)
|
||||
in
|
||||
vcat $ map pp tps ++
|
||||
if null (mpnConstraints ps) then [] else
|
||||
[ "type constraint" <+>
|
||||
parens (commaSep (map (ppWithNames ns . thing)
|
||||
(mpnConstraints ps)))
|
||||
] ++
|
||||
map (ppWithNames ns) (Map.elems (mpnFuns ps))
|
||||
|
||||
instance PP ModTParam where
|
||||
ppPrec _ p =
|
||||
"type" <+> pp (mtpName p) <+> ":" <+> pp (mtpKind p)
|
||||
|
||||
instance PP (WithNames ModVParam) where
|
||||
ppPrec _ (WithNames p ns) =
|
||||
pp (mvpName p) <+> ":" <+> ppWithNames ns (mvpType p)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user