PrintAs.hs revision 024621f43239cfe9629e35d35a8669fad7acbba2
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann{- HetCATS/HasCASL/PrintAs.hs
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann $Id$
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann Authors: Christian Maeder
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann Year: 2002
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printing As data types
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann-}
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmannmodule PrintAs where
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmannimport As
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmannimport Keywords
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmannimport HToken
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmannimport Pretty
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmannimport PrettyPrint
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmannimport GlobalAnnotations(GlobalAnnos)
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmannimport Print_AS_Annotation
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmanncommas, semis :: PrettyPrint a => GlobalAnnos -> [a] -> Doc
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmanncommas ga l = fcat $ punctuate comma (map (printText0 ga) l)
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmannsemis ga l = sep $ punctuate semi (map (printText0 ga) l)
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmanninstance PrettyPrint TypePattern where
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (TypePattern name args _) = printText0 ga name
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <> fcat (map (parens . printText0 ga) args)
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (TypePatternToken t) = printText0 ga t
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (MixfixTypePattern ts) = fsep (map (printText0 ga) ts)
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (BracketTypePattern k l _) = bracket k $ commas ga l
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (TypePatternArgs l) = semis ga l
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmannbracket :: BracketKind -> Doc -> Doc
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmannbracket Parens t = parens t
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmannbracket Squares t = Pretty.brackets t
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmannbracket Braces t = braces t
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann
304d15b2ffa9376d78bddcfc63569824381714abDaniel HausmannprintKind :: GlobalAnnos -> Kind -> Doc
304d15b2ffa9376d78bddcfc63569824381714abDaniel HausmannprintKind ga kind = case kind of
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann Kind [] (Intersection [] _) _ -> empty
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann _ -> space <> colon <> printText0 ga kind
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmanninstance PrettyPrint Type where
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (TypeConstrAppl name kind args _) = printText0 ga name
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <> printKind ga kind
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <> if null args then empty
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann else parens (commas ga args)
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (TypeVar name kind i _) = printText0 ga name
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <> printKind ga kind
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <> if i == 0 then empty
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann else parens (ptext (show i))
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (TypeToken t) = printText0 ga t
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (BracketType k l _) = bracket k $ commas ga l
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (KindedType t kind _) = printText0 ga t
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <> printKind ga kind
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (MixfixType ts) = fsep (map (printText0 ga) ts)
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (TupleType args _) = parens $ commas ga args
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (LazyType t _) = text quMark <+> printText0 ga (t)
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (ProductType ts _) = fsep (punctuate (space <> text timesS)
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann (map (printText0 ga) ts))
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (FunType t1 arr t2 _) = printText0 ga t1
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <+> printText0 ga arr
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <+> printText0 ga t2
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmanninstance PrettyPrint Pred where
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (IsIn c ts) = if null ts then printText0 ga c
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann else if null $ tail ts then
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (head ts) <+>
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann colon <+> printText0 ga c
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann else printText0 ga c <+>
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann fsep (punctuate space
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann (map (printText0 ga) ts))
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmanninstance PrettyPrint t => PrettyPrint (Qual t) where
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (ps :=> t) = (if null ps then empty
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann else parens $ commas ga ps <+>
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann ptext implS <+> space) <>
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga t
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann-- no curried notation for bound variables
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmanninstance PrettyPrint TypeScheme where
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (SimpleTypeScheme t) = printText0 ga t
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (TypeScheme vs t _) = text forallS
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <+> semis ga vs
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <+> text dotS
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <+> printText0 ga t
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmanninstance PrettyPrint Partiality where
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 _ Partial = text quMark
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 _ Total = text exMark
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmanninstance PrettyPrint Arrow where
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 _ FunArr = text funS
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 _ PFunArr = text pFun
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 _ ContFunArr = text contFun
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 _ PContFunArr = text pContFun
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmanninstance PrettyPrint Quantifier where
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 _ Universal = text forallS
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 _ Existential = text existsS
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 _ Unique = text $ existsS ++ exMark
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmanninstance PrettyPrint TypeQual where
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 _ OfType = colon
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 _ AsType = text asS
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 _ InType = text inS
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmanninstance PrettyPrint LogOp where
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 _ NotOp = text notS
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 _ AndOp = text lAnd
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 _ OrOp = text lOr
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 _ ImplOp = text implS
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 _ EquivOp = text equivS
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmanninstance PrettyPrint EqOp where
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 _ EqualOp = text equalS
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 _ ExEqualOp = text exEqual
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmanninstance PrettyPrint Formula where
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (TermFormula t) = printText0 ga t
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (ConnectFormula o fs _) = parens $
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann fsep (punctuate (space <> printText0 ga o) (map (printText0 ga) fs))
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (EqFormula o t1 t2 _) = printText0 ga t1
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <+> printText0 ga o
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <+> printText0 ga t2
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (DefFormula t _) = text defS <+> printText0 ga t
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (QuantifiedFormula q vs f _) =
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga q <+> semis ga vs <+> text dotS <+> printText0 ga f
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (PolyFormula ts f _) =
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann text forallS <+> semis ga ts <+> text dotS <+> printText0 ga f
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmanninstance PrettyPrint Term where
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (CondTerm t1 f t2 _) = printText0 ga t1
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <+> text whenS
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <+> printText0 ga f
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <+> text elseS
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <+> printText0 ga t2
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (QualVar v t _) = parens $ text varS
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <+> printText0 ga v
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <+> colon
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <+> printText0 ga t
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (QualOp n t _) = parens $
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann text opS
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <+> printText0 ga n
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <+> colon
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <+> printText0 ga t
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (ApplTerm t1 t2 _) = printText0 ga t1
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <+> parens (printText0 ga t2)
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (TupleTerm ts _) = parens $ commas ga ts
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (TypedTerm term q typ _) = printText0 ga term
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <+> printText0 ga q
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <+> printText0 ga typ
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (QuantifiedTerm q vs t _) = printText0 ga q
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <+> semis ga vs
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <+> text dotS
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <+> printText0 ga t
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (LambdaTerm ps q t _) = text lamS
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <+> (if length ps == 1 then
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga $ head ps
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann else fcat $ map
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann (parens.printText0 ga) ps)
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <+> (case q of
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann Partial -> text dotS
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann Total -> text $ dotS ++ exMark)
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <+> printText0 ga t
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (CaseTerm t es _ ) = text caseS
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <+> printText0 ga t
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <+> text ofS
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <+> vcat (punctuate (text " | ")
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann (map (printEq0 ga funS) es))
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (LetTerm es t _) = text letS
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <+> vcat (punctuate semi
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann (map (printEq0 ga equalS) es))
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <+> text inS
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <+> printText0 ga t
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (TermToken t) = printText0 ga t
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (MixfixTerm ts) = fsep $ map (printText0 ga) ts
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (BracketTerm k l _) = bracket k $ commas ga l
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmanninstance PrettyPrint Pattern where
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (PatternVars vs _) = semis ga vs
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (PatternConstr n t args _) = printText0 ga n
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <+> colon
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <+> printText0 ga t
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <+> fcat (map (parens.printText0 ga) args)
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (PatternToken t) = printText0 ga t
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (BracketPattern k l _) = bracket k $ commas ga l
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (TuplePattern ps _) = parens $ commas ga ps
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (MixfixPattern ps) = fsep (map (printText0 ga) ps)
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (TypedPattern p t _) = printText0 ga p
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <+> colon
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <+> printText0 ga t
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (AsPattern v p _) = printText0 ga v
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <+> text asP
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <+> printText0 ga p
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann
304d15b2ffa9376d78bddcfc63569824381714abDaniel HausmannprintEq0 :: GlobalAnnos -> String -> ProgEq -> Doc
304d15b2ffa9376d78bddcfc63569824381714abDaniel HausmannprintEq0 ga s (ProgEq p t _) = fsep [printText0 ga p
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann , text s
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann , printText0 ga t]
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmanninstance PrettyPrint VarDecl where
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (VarDecl v t _ _) = printText0 ga v <+> colon
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <+> printText0 ga t
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmanninstance PrettyPrint TypeVarDecl where
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (TypeVarDecl v c _ _) =
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga v <+>
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann case c of
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann Kind [] (Downset t) _ ->
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann text lessS <+> printText0 ga t
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann _ -> colon <+> printText0 ga c
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmanninstance PrettyPrint GenVarDecl where
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (GenVarDecl v) = printText0 ga v
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (GenTypeVarDecl tv) = printText0 ga tv
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmanninstance PrettyPrint TypeArg where
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (TypeArg v c _ _) = printText0 ga v <> colon
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <> printText0 ga c
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmanninstance PrettyPrint Variance where
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 _ CoVar = text plusS
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 _ ContraVar = text minusS
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 _ InVar = empty
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmanninstance PrettyPrint ExtClass where
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (ExtClass c v _) = printText0 ga c <> printText0 ga v
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <> space
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmanninstance PrettyPrint ProdClass where
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (ProdClass l _) = fcat $ punctuate (text timesS)
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann (map (printText0 ga) l)
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmanninstance PrettyPrint Kind where
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (KindAppl k1 k2) = parens (printText0 ga k1)
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <> ptext funS <> printText0 ga k2
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (Kind l c _) = (if null l then empty else
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann (fcat $ punctuate (text funS)
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann (map (printText0 ga) l))
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <> text funS)
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <> printText0 ga c
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmanninstance PrettyPrint Class where
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (Downset t) = braces $ text lessS <+> printText0 ga t
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (Intersection c _) = if null c then ptext "Type"
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann else if null $ tail c then printText0 ga $ head c
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann else parens $ commas ga c
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmanninstance PrettyPrint Types where
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (Types l _) = Pretty.brackets $ commas ga l
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmanninstance PrettyPrint InstOpName where
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (InstOpName n l) = printText0 ga n
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <> fcat(map (printText0 ga) l)
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann------------------------------------------------------------------------
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann-- item stuff
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann------------------------------------------------------------------------
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmanninstance PrettyPrint PseudoType where
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (SimplePseudoType t) = printText0 ga t
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (PseudoType l t _) = text lamS
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <+> fcat(map (printText0 ga) l)
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <+> text dotS <+> printText0 ga t
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmanninstance PrettyPrint TypeArgs where
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (TypeArgs l _) = semis ga l
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmanninstance PrettyPrint TypeVarDecls where
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (TypeVarDecls l _) = Pretty.brackets $ semis ga l
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmanninstance PrettyPrint BasicSpec where
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (BasicSpec l) = vcat (map (printText0 ga) l)
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmanninstance PrettyPrint ProgEq where
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga = printEq0 ga equalS
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmanninstance PrettyPrint BasicItem where
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (SigItems s) = printText0 ga s
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (ProgItems l _) = text programS <+> semis ga l
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (ClassItems i l _) = text classS <+> printText0 ga i
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <+> semis ga l
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (GenVarItems l _) = text varS <+> semis ga l
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (FreeDatatype l _) = text freeS <+> text typeS
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <+> semis ga l
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (GenItems l _) = text generatedS <+> braces (semis ga l)
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (AxiomItems vs fs _) = (if null vs then empty
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann else text forallS <+> semis ga vs)
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann $$ vcat (map
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann (\x -> text dotS <+> printText0 ga x)
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann fs)
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmanninstance PrettyPrint SigItems where
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (TypeItems i l _) = text typeS <+> printText0 ga i
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <+> semis ga l
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (OpItems l _) = text opS <+> semis ga l
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (PredItems l _) = text predS <+> semis ga l
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmanninstance PrettyPrint Instance where
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 _ Instance = text instanceS
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 _ _ = empty
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmanninstance PrettyPrint ClassItem where
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (ClassItem d l _) = printText0 ga d $$
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann if null l then empty
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann else braces (semis ga l)
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmanninstance PrettyPrint ClassDecl where
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (ClassDecl l _) = commas ga l
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (SubclassDecl l s _) = commas ga l <> text lessS
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <> printText0 ga s
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (ClassDefn n c _) = printText0 ga n
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <> text equalS
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <> printText0 ga c
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (DownsetDefn c v t _) = printText0 ga c
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <> text equalS
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <> braces (printText0 ga v
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <> text dotS
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <> printText0 ga v
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <> (text lessS
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <+> printText0 ga t))
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmanninstance PrettyPrint TypeItem where
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (TypeDecl l k _) = commas ga l <>
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printKind ga k
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (SubtypeDecl l t _) = commas ga l <+> text lessS
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <+> printText0 ga t
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (IsoDecl l _) = cat(punctuate (text " = ")
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann (map (printText0 ga) l))
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (SubtypeDefn p v t f _) = printText0 ga p
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <+> text equalS
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <+> braces (printText0 ga v
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <+> colon
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <+> printText0 ga t
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <+> text dotS
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <+> printText0 ga f)
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (AliasType p k t _) = (printText0 ga p <>
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printKind ga k)
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <+> text assignS
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <+> printText0 ga t
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (Datatype t) = printText0 ga t
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmanninstance PrettyPrint OpItem where
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (OpDecl l t as _) = commas ga l <+> colon
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <+> (printText0 ga t
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <> (if null as then empty else comma)
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <> commas ga as)
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (OpDefn n ps s p t _) = (printText0 ga n
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <> fcat (map (printText0 ga) ps))
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <+> (colon <> if p == Partial
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann then text quMark else empty)
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <+> printText0 ga s
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <+> text equalS
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <+> printText0 ga t
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmanninstance PrettyPrint PredItem where
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (PredDecl l t _) = commas ga l <+> colon <+> printText0 ga t
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (PredDefn n ps f _) = (printText0 ga n
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <> fcat (map (printText0 ga) ps))
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <+> text equivS
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <+> printText0 ga f
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmanninstance PrettyPrint BinOpAttr where
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 _ Assoc = text assocS
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 _ Comm = text commS
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 _ Idem = text idemS
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmanninstance PrettyPrint OpAttr where
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (BinOpAttr a _) = printText0 ga a
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (UnitOpAttr t _) = text unitS <+> printText0 ga t
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmanninstance PrettyPrint DatatypeDecl where
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (DatatypeDecl p k as d _) = (printText0 ga p <>
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printKind ga k)
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <+> text defnS
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <+> vcat(punctuate (text " | ")
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann (map (printText0 ga) as))
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <+> case d of { Nothing -> empty
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann ; Just c -> text derivingS
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <+> printText0 ga c
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann }
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmanninstance PrettyPrint Alternative where
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (Constructor n cs p _) = printText0 ga n
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <> fcat (map (printText0 ga) cs)
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <> (case p of {Partial -> text quMark;
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann _ -> empty})
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (Subtype l _) = text typeS <+> commas ga l
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmanninstance PrettyPrint Components where
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (Selector n p t _ _) = printText0 ga n
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <> colon <> (case p of { Partial ->text quMark;
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann _ -> empty }
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <+> printText0 ga t)
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (NoSelector t) = printText0 ga t
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (NestedComponents l _) = parens $ semis ga l
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmanninstance PrettyPrint OpName where
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann printText0 ga (OpName n ts) = printText0 ga n
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann <+> fcat(map (printText0 ga) ts)
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann
304d15b2ffa9376d78bddcfc63569824381714abDaniel Hausmann