PrintAs.hs revision a0e24c863b78669b05797ff8ce635995a9bede44
fae04f4a69922eb1ddf0f46b34fa15a5a080b693Felix Gabriel ManceModule : $Header$
fae04f4a69922eb1ddf0f46b34fa15a5a080b693Felix Gabriel ManceCopyright : (c) Christian Maeder and Uni Bremen 2003
fae04f4a69922eb1ddf0f46b34fa15a5a080b693Felix Gabriel ManceLicense : similar to LGPL, see HetCATS/LICENSE.txt or LIZENZ.txt
fae04f4a69922eb1ddf0f46b34fa15a5a080b693Felix Gabriel ManceMaintainer : maeder@tzi.de
fae04f4a69922eb1ddf0f46b34fa15a5a080b693Felix Gabriel ManceStability : experimental
fae04f4a69922eb1ddf0f46b34fa15a5a080b693Felix Gabriel MancePortability : portable
ae2e84ab0a53874417f01b792cbc6907ee6d09f6Felix Gabriel Manceprinting data types of the abstract syntax
ae2e84ab0a53874417f01b792cbc6907ee6d09f6Felix Gabriel Manceimport Data.List (groupBy)
ae2e84ab0a53874417f01b792cbc6907ee6d09f6Felix Gabriel Mance-- | short cut for: if b then empty else d
ae2e84ab0a53874417f01b792cbc6907ee6d09f6Felix Gabriel MancenoPrint :: Bool -> Doc -> Doc
ae2e84ab0a53874417f01b792cbc6907ee6d09f6Felix Gabriel MancenoPrint b d = if b then empty else d
ae2e84ab0a53874417f01b792cbc6907ee6d09f6Felix Gabriel MancenoNullPrint :: [a] -> Doc -> Doc
ae2e84ab0a53874417f01b792cbc6907ee6d09f6Felix Gabriel MancenoNullPrint = noPrint . null
ae2e84ab0a53874417f01b792cbc6907ee6d09f6Felix Gabriel MancesemiDs :: Pretty a => [a] -> Doc
ae2e84ab0a53874417f01b792cbc6907ee6d09f6Felix Gabriel MancesemiDs = fsep . punctuate semi . map pretty
ae2e84ab0a53874417f01b792cbc6907ee6d09f6Felix Gabriel MancesemiAnnoted :: Pretty a => [Annoted a] -> Doc
ae2e84ab0a53874417f01b792cbc6907ee6d09f6Felix Gabriel MancesemiAnnoted = vcat . map (printSemiAnno pretty True)
808e2693447ecc5a311a2b9de6b81ca07f193778Felix Gabriel Manceinstance Pretty Variance where
808e2693447ecc5a311a2b9de6b81ca07f193778Felix Gabriel Mance pretty = sidDoc . mkSimpleId . show
808e2693447ecc5a311a2b9de6b81ca07f193778Felix Gabriel Manceinstance Pretty a => Pretty (AnyKind a) where
808e2693447ecc5a311a2b9de6b81ca07f193778Felix Gabriel Mance pretty knd = case knd of
ae2e84ab0a53874417f01b792cbc6907ee6d09f6Felix Gabriel Mance ClassKind ci -> pretty ci
ae2e84ab0a53874417f01b792cbc6907ee6d09f6Felix Gabriel Mance FunKind v k1 k2 _ -> fsep [pretty v <>
ae2e84ab0a53874417f01b792cbc6907ee6d09f6Felix Gabriel Mance FunKind _ _ _ _ -> parens
ae2e84ab0a53874417f01b792cbc6907ee6d09f6Felix Gabriel Mance _ -> id) (pretty k1)
ae2e84ab0a53874417f01b792cbc6907ee6d09f6Felix Gabriel MancevarOfTypeArg :: TypeArg -> Id
ae2e84ab0a53874417f01b792cbc6907ee6d09f6Felix Gabriel MancevarOfTypeArg (TypeArg i _ _ _ _ _ _) = i
ae2e84ab0a53874417f01b792cbc6907ee6d09f6Felix Gabriel Manceinstance Pretty TypePattern where
ae2e84ab0a53874417f01b792cbc6907ee6d09f6Felix Gabriel Mance pretty tp = case tp of
ae2e84ab0a53874417f01b792cbc6907ee6d09f6Felix Gabriel Mance TypePattern name args _ -> pretty name
ae2e84ab0a53874417f01b792cbc6907ee6d09f6Felix Gabriel Mance <+> fsep (map (pretty . varOfTypeArg) args)
ae2e84ab0a53874417f01b792cbc6907ee6d09f6Felix Gabriel Mance TypePatternToken t -> pretty t
ae2e84ab0a53874417f01b792cbc6907ee6d09f6Felix Gabriel Mance MixfixTypePattern ts -> fsep $ map pretty ts
ae2e84ab0a53874417f01b792cbc6907ee6d09f6Felix Gabriel Mance BracketTypePattern k l _ -> bracket k $ ppWithCommas l
ae2e84ab0a53874417f01b792cbc6907ee6d09f6Felix Gabriel Mance TypePatternArg t _ -> parens $ pretty t
ae2e84ab0a53874417f01b792cbc6907ee6d09f6Felix Gabriel Mance-- | put proper brackets around a document
ae2e84ab0a53874417f01b792cbc6907ee6d09f6Felix Gabriel Mancebracket :: BracketKind -> Doc -> Doc
ae2e84ab0a53874417f01b792cbc6907ee6d09f6Felix Gabriel Mancebracket b = case b of
ae2e84ab0a53874417f01b792cbc6907ee6d09f6Felix Gabriel Mance Parens -> parens
ae2e84ab0a53874417f01b792cbc6907ee6d09f6Felix Gabriel Mance Squares -> brackets
ae2e84ab0a53874417f01b792cbc6907ee6d09f6Felix Gabriel Mance Braces -> specBraces
ae2e84ab0a53874417f01b792cbc6907ee6d09f6Felix Gabriel Mance NoBrackets -> id
ae2e84ab0a53874417f01b792cbc6907ee6d09f6Felix Gabriel Mance-- | print a 'Kind' plus a preceding colon (or nothing)
ae2e84ab0a53874417f01b792cbc6907ee6d09f6Felix Gabriel ManceprintKind :: Kind -> Doc
ae2e84ab0a53874417f01b792cbc6907ee6d09f6Felix Gabriel ManceprintKind k = noPrint (k == universe) $ printVarKind InVar (VarKind k)
ae2e84ab0a53874417f01b792cbc6907ee6d09f6Felix Gabriel Mance-- | print the kind of a variable with its variance and a preceding colon
ae2e84ab0a53874417f01b792cbc6907ee6d09f6Felix Gabriel ManceprintVarKind :: Variance -> VarKind -> Doc
ae2e84ab0a53874417f01b792cbc6907ee6d09f6Felix Gabriel ManceprintVarKind e vk = case vk of
ae2e84ab0a53874417f01b792cbc6907ee6d09f6Felix Gabriel Mance space <> less <+> pretty t
ae2e84ab0a53874417f01b792cbc6907ee6d09f6Felix Gabriel Mance VarKind k -> space <> colon <+>
ae2e84ab0a53874417f01b792cbc6907ee6d09f6Felix Gabriel Mance pretty e <> pretty k
ae2e84ab0a53874417f01b792cbc6907ee6d09f6Felix Gabriel Mance MissingKind -> empty
ae2e84ab0a53874417f01b792cbc6907ee6d09f6Felix Gabriel Mancedata TypePrec = Outfix | Prefix | ProdInfix | FunInfix deriving (Eq, Ord)
ae2e84ab0a53874417f01b792cbc6907ee6d09f6Felix Gabriel ManceparenPrec :: TypePrec -> (TypePrec, Doc) -> Doc
ae2e84ab0a53874417f01b792cbc6907ee6d09f6Felix Gabriel ManceparenPrec p1 (p2, d) = if p2 < p1 then d else parens d
ae2e84ab0a53874417f01b792cbc6907ee6d09f6Felix Gabriel ManceprintTypeToken :: Token -> Doc
ae2e84ab0a53874417f01b792cbc6907ee6d09f6Felix Gabriel ManceprintTypeToken t = let
ae2e84ab0a53874417f01b792cbc6907ee6d09f6Felix Gabriel Mance l = ("*", cross) : map ( \ (a, d) -> (show a, d) )
ae2e84ab0a53874417f01b792cbc6907ee6d09f6Felix Gabriel Mance [ (FunArr, funArrow)
ae2e84ab0a53874417f01b792cbc6907ee6d09f6Felix Gabriel Mance , (PFunArr, pfun)
808e2693447ecc5a311a2b9de6b81ca07f193778Felix Gabriel Mance , (ContFunArr, cfun)
ae2e84ab0a53874417f01b792cbc6907ee6d09f6Felix Gabriel Mance , (PContFunArr, pcfun) ]
ae2e84ab0a53874417f01b792cbc6907ee6d09f6Felix Gabriel Mance in case lookup (tokStr t) l of
4440f5c4ab1cb6dfd445da97f87a72d87d24c25aFelix Gabriel MancetoMixType :: Type -> (TypePrec, Doc)
ce5d83770556362fe2c8b567975c2a3758888358Felix Gabriel MancetoMixType typ = case typ of
ce5d83770556362fe2c8b567975c2a3758888358Felix Gabriel Mance ExpandedType t1 _ -> toMixType t1
808e2693447ecc5a311a2b9de6b81ca07f193778Felix Gabriel Mance BracketType k l _ -> (Outfix, bracket k $ sepByCommas $ map
c92573b85930868b709024284c0f13dbcaec9554Felix Gabriel Mance (snd . toMixType) l)
ce5d83770556362fe2c8b567975c2a3758888358Felix Gabriel Mance KindedType t kind _ -> (Prefix,
c92573b85930868b709024284c0f13dbcaec9554Felix Gabriel Mance fsep [parenPrec Prefix $ toMixType t, colon, pretty kind])
c92573b85930868b709024284c0f13dbcaec9554Felix Gabriel Mance MixfixType ts -> (Prefix, fsep $ map (snd . toMixType) ts)
c92573b85930868b709024284c0f13dbcaec9554Felix Gabriel Mance _ -> let (topTy, tyArgs) = getTypeAppl typ in
ae2e84ab0a53874417f01b792cbc6907ee6d09f6Felix Gabriel Mance TypeName name@(Id ts cs _) _k _i -> let topDoc = pretty name in
ce5d83770556362fe2c8b567975c2a3758888358Felix Gabriel Mance case tyArgs of
ae2e84ab0a53874417f01b792cbc6907ee6d09f6Felix Gabriel Mance [] -> (Outfix, pretty name)
ae2e84ab0a53874417f01b792cbc6907ee6d09f6Felix Gabriel Mance [arg] -> let dArg = toMixType arg in
ce5d83770556362fe2c8b567975c2a3758888358Felix Gabriel Mance [e1, e2, e3] | not (isPlace e1) && isPlace e2
ce5d83770556362fe2c8b567975c2a3758888358Felix Gabriel Mance && not (isPlace e3) && null cs ->
ce5d83770556362fe2c8b567975c2a3758888358Felix Gabriel Mance (Outfix, fsep [pretty e1, snd dArg, pretty e3])
ce5d83770556362fe2c8b567975c2a3758888358Felix Gabriel Mance _ -> (Prefix, fsep [topDoc, parenPrec Prefix dArg])
ce5d83770556362fe2c8b567975c2a3758888358Felix Gabriel Mance [arg1, arg2] -> let dArg1 = toMixType arg1
ce5d83770556362fe2c8b567975c2a3758888358Felix Gabriel Mance dArg2 = toMixType arg2 in
ce5d83770556362fe2c8b567975c2a3758888358Felix Gabriel Mance [e1, e2, e3] | isPlace e1 && not (isPlace e2)
ce5d83770556362fe2c8b567975c2a3758888358Felix Gabriel Mance && isPlace e3 && null cs ->
ce5d83770556362fe2c8b567975c2a3758888358Felix Gabriel Mance if tokStr e2 == prodS then
ce5d83770556362fe2c8b567975c2a3758888358Felix Gabriel Mance (ProdInfix, fsep [
ce5d83770556362fe2c8b567975c2a3758888358Felix Gabriel Mance parenPrec ProdInfix dArg1, cross,
ce5d83770556362fe2c8b567975c2a3758888358Felix Gabriel Mance parenPrec ProdInfix dArg2])
ce5d83770556362fe2c8b567975c2a3758888358Felix Gabriel Mance else -- assume fun type
ce5d83770556362fe2c8b567975c2a3758888358Felix Gabriel Mance (FunInfix, fsep [
ce5d83770556362fe2c8b567975c2a3758888358Felix Gabriel Mance parenPrec FunInfix dArg1, printTypeToken e2, snd dArg2])
ce5d83770556362fe2c8b567975c2a3758888358Felix Gabriel Mance _ -> (Prefix, fsep [topDoc, parenPrec Prefix dArg1,
ce5d83770556362fe2c8b567975c2a3758888358Felix Gabriel Mance parenPrec Prefix dArg2])
ce5d83770556362fe2c8b567975c2a3758888358Felix Gabriel Mance _ -> if name == productId (length tyArgs) then
ce5d83770556362fe2c8b567975c2a3758888358Felix Gabriel Mance (ProdInfix, fsep $ punctuate (space <> cross) $
ce5d83770556362fe2c8b567975c2a3758888358Felix Gabriel Mance map (parenPrec ProdInfix . toMixType) tyArgs)
ce5d83770556362fe2c8b567975c2a3758888358Felix Gabriel Mance else (Prefix, fsep $ topDoc :
ce5d83770556362fe2c8b567975c2a3758888358Felix Gabriel Mance map (parenPrec Prefix . toMixType) tyArgs)
ce5d83770556362fe2c8b567975c2a3758888358Felix Gabriel Mance _ | null tyArgs -> (Outfix, printType topTy)
ce5d83770556362fe2c8b567975c2a3758888358Felix Gabriel Mance _ -> (Prefix, fsep $ parenPrec ProdInfix (toMixType topTy)
ce5d83770556362fe2c8b567975c2a3758888358Felix Gabriel Mance : map (parenPrec Prefix . toMixType) tyArgs)
ce5d83770556362fe2c8b567975c2a3758888358Felix Gabriel ManceprintType :: Type -> Doc
ce5d83770556362fe2c8b567975c2a3758888358Felix Gabriel ManceprintType ty = case ty of
c92573b85930868b709024284c0f13dbcaec9554Felix Gabriel Mance TypeName name _ _ -> pretty name
808e2693447ecc5a311a2b9de6b81ca07f193778Felix Gabriel Mance TypeAppl t1 t2 -> fcat [parens (printType t1),
808e2693447ecc5a311a2b9de6b81ca07f193778Felix Gabriel Mance parens (printType t2)]
808e2693447ecc5a311a2b9de6b81ca07f193778Felix Gabriel Mance ExpandedType t1 t2 -> fcat [printType t1, text asP, printType t2]
808e2693447ecc5a311a2b9de6b81ca07f193778Felix Gabriel Mance TypeToken t -> printTypeToken t
808e2693447ecc5a311a2b9de6b81ca07f193778Felix Gabriel Mance BracketType k l _ -> bracket k $ sepByCommas $ map (printType) l
808e2693447ecc5a311a2b9de6b81ca07f193778Felix Gabriel Mance KindedType t kind _ -> sep [printType t, colon <+> pretty kind]
808e2693447ecc5a311a2b9de6b81ca07f193778Felix Gabriel Mance MixfixType ts -> fsep $ map printType ts
4440f5c4ab1cb6dfd445da97f87a72d87d24c25aFelix Gabriel Manceinstance Pretty Type where
4440f5c4ab1cb6dfd445da97f87a72d87d24c25aFelix Gabriel Mance pretty = snd . toMixType
808e2693447ecc5a311a2b9de6b81ca07f193778Felix Gabriel Mance-- no curried notation for bound variables
808e2693447ecc5a311a2b9de6b81ca07f193778Felix Gabriel Manceinstance Pretty TypeScheme where
808e2693447ecc5a311a2b9de6b81ca07f193778Felix Gabriel Mance pretty (TypeScheme vs t _) = let tdoc = pretty t in
808e2693447ecc5a311a2b9de6b81ca07f193778Felix Gabriel Mance if null vs then tdoc else
808e2693447ecc5a311a2b9de6b81ca07f193778Felix Gabriel Mance fsep [forallDoc, semiDs vs, bullet <+> tdoc]
4440f5c4ab1cb6dfd445da97f87a72d87d24c25aFelix Gabriel Manceinstance Pretty Partiality where
4440f5c4ab1cb6dfd445da97f87a72d87d24c25aFelix Gabriel Mance pretty p = case p of
4440f5c4ab1cb6dfd445da97f87a72d87d24c25aFelix Gabriel Mance Partial -> quMarkD
4440f5c4ab1cb6dfd445da97f87a72d87d24c25aFelix Gabriel Mance Total -> empty
4440f5c4ab1cb6dfd445da97f87a72d87d24c25aFelix Gabriel Manceinstance Pretty Quantifier where
4440f5c4ab1cb6dfd445da97f87a72d87d24c25aFelix Gabriel Mance pretty q = case q of
4440f5c4ab1cb6dfd445da97f87a72d87d24c25aFelix Gabriel Mance Universal -> forallDoc
4440f5c4ab1cb6dfd445da97f87a72d87d24c25aFelix Gabriel Mance Existential -> exists
4440f5c4ab1cb6dfd445da97f87a72d87d24c25aFelix Gabriel Mance Unique -> unique
4440f5c4ab1cb6dfd445da97f87a72d87d24c25aFelix Gabriel Manceinstance Pretty TypeQual where
4440f5c4ab1cb6dfd445da97f87a72d87d24c25aFelix Gabriel Mance pretty q = case q of
4440f5c4ab1cb6dfd445da97f87a72d87d24c25aFelix Gabriel Mance OfType -> colon
4440f5c4ab1cb6dfd445da97f87a72d87d24c25aFelix Gabriel Mance AsType -> text asS
4440f5c4ab1cb6dfd445da97f87a72d87d24c25aFelix Gabriel Mance InType -> inDoc
4440f5c4ab1cb6dfd445da97f87a72d87d24c25aFelix Gabriel Mance Inferred -> colon
ae2e84ab0a53874417f01b792cbc6907ee6d09f6Felix Gabriel Manceinstance Pretty Term where
4440f5c4ab1cb6dfd445da97f87a72d87d24c25aFelix Gabriel Mance pretty = printTerm . rmSomeTypes
fae04f4a69922eb1ddf0f46b34fa15a5a080b693Felix Gabriel ManceisSimpleTerm :: Term -> Bool
fae04f4a69922eb1ddf0f46b34fa15a5a080b693Felix Gabriel ManceisSimpleTerm trm = case trm of
fae04f4a69922eb1ddf0f46b34fa15a5a080b693Felix Gabriel Mance QualVar _ -> True
fae04f4a69922eb1ddf0f46b34fa15a5a080b693Felix Gabriel Mance QualOp _ _ _ _ -> True
fae04f4a69922eb1ddf0f46b34fa15a5a080b693Felix Gabriel Mance ResolvedMixTerm _ _ _ -> True
4440f5c4ab1cb6dfd445da97f87a72d87d24c25aFelix Gabriel Mance ApplTerm _ _ _ -> True
4440f5c4ab1cb6dfd445da97f87a72d87d24c25aFelix Gabriel Mance TupleTerm _ _ -> True
fae04f4a69922eb1ddf0f46b34fa15a5a080b693Felix Gabriel Mance TermToken _ -> True
fae04f4a69922eb1ddf0f46b34fa15a5a080b693Felix Gabriel Mance BracketTerm _ _ _ -> True
fae04f4a69922eb1ddf0f46b34fa15a5a080b693Felix Gabriel Mance-- | used only to produce CASL applications
fae04f4a69922eb1ddf0f46b34fa15a5a080b693Felix Gabriel ManceisSimpleArgTerm :: Term -> Bool
fae04f4a69922eb1ddf0f46b34fa15a5a080b693Felix Gabriel ManceisSimpleArgTerm trm = case trm of
fae04f4a69922eb1ddf0f46b34fa15a5a080b693Felix Gabriel Mance QualVar vd -> not (isPatVarDecl vd)
fae04f4a69922eb1ddf0f46b34fa15a5a080b693Felix Gabriel Mance QualOp _ _ _ _ -> True
fae04f4a69922eb1ddf0f46b34fa15a5a080b693Felix Gabriel Mance ResolvedMixTerm n l _ -> placeCount n /= 0 || not (null l)
fae04f4a69922eb1ddf0f46b34fa15a5a080b693Felix Gabriel Mance TupleTerm _ _ -> True
fae04f4a69922eb1ddf0f46b34fa15a5a080b693Felix Gabriel Mance BracketTerm _ _ _ -> True
fae04f4a69922eb1ddf0f46b34fa15a5a080b693Felix Gabriel MancehasRightQuant :: Term -> Bool
fae04f4a69922eb1ddf0f46b34fa15a5a080b693Felix Gabriel MancehasRightQuant t = case t of
fae04f4a69922eb1ddf0f46b34fa15a5a080b693Felix Gabriel Mance QuantifiedTerm {} -> True
fae04f4a69922eb1ddf0f46b34fa15a5a080b693Felix Gabriel Mance LambdaTerm {} -> True
fae04f4a69922eb1ddf0f46b34fa15a5a080b693Felix Gabriel Mance CaseTerm {} -> True
fae04f4a69922eb1ddf0f46b34fa15a5a080b693Felix Gabriel Mance LetTerm Let _ _ _ -> True
fae04f4a69922eb1ddf0f46b34fa15a5a080b693Felix Gabriel Mance ResolvedMixTerm n ts _ | endPlace n && placeCount n == length ts
fae04f4a69922eb1ddf0f46b34fa15a5a080b693Felix Gabriel Mance -> hasRightQuant (last ts)
fae04f4a69922eb1ddf0f46b34fa15a5a080b693Felix Gabriel Mance ApplTerm (ResolvedMixTerm n [] _) t2 _ | endPlace n ->
fae04f4a69922eb1ddf0f46b34fa15a5a080b693Felix Gabriel Mance TupleTerm ts _ | placeCount n == length ts -> hasRightQuant (last ts)
fae04f4a69922eb1ddf0f46b34fa15a5a080b693Felix Gabriel Mance _ -> hasRightQuant t2
fae04f4a69922eb1ddf0f46b34fa15a5a080b693Felix Gabriel Mance ApplTerm _ t2 _ -> hasRightQuant t2
fae04f4a69922eb1ddf0f46b34fa15a5a080b693Felix Gabriel MancezipArgs :: Id -> [Term] -> [Doc] -> [Doc]
fae04f4a69922eb1ddf0f46b34fa15a5a080b693Felix Gabriel MancezipArgs n ts ds = case (ts, ds) of
fae04f4a69922eb1ddf0f46b34fa15a5a080b693Felix Gabriel Mance (t : r, d : s) -> let
fae04f4a69922eb1ddf0f46b34fa15a5a080b693Felix Gabriel Mance p = parenTermDoc t d
fae04f4a69922eb1ddf0f46b34fa15a5a080b693Felix Gabriel Mance e = if hasRightQuant t then parens d else p
fae04f4a69922eb1ddf0f46b34fa15a5a080b693Felix Gabriel Mance in if null r && null s && endPlace n then
fae04f4a69922eb1ddf0f46b34fa15a5a080b693Felix Gabriel Mance [if hasRightQuant t then d else p]
fae04f4a69922eb1ddf0f46b34fa15a5a080b693Felix Gabriel Mance else e : zipArgs n r s
fae04f4a69922eb1ddf0f46b34fa15a5a080b693Felix Gabriel ManceisPatVarDecl :: VarDecl -> Bool
fae04f4a69922eb1ddf0f46b34fa15a5a080b693Felix Gabriel ManceisPatVarDecl (VarDecl v ty _ _) = case ty of
fae04f4a69922eb1ddf0f46b34fa15a5a080b693Felix Gabriel Mance TypeName t _ _ -> isSimpleId v && take 2 (show t) == "_v"
fae04f4a69922eb1ddf0f46b34fa15a5a080b693Felix Gabriel ManceparenTermDoc :: Term -> Doc -> Doc
fae04f4a69922eb1ddf0f46b34fa15a5a080b693Felix Gabriel ManceparenTermDoc trm = if isSimpleTerm trm then id else parens
fae04f4a69922eb1ddf0f46b34fa15a5a080b693Felix Gabriel ManceprintTermRec :: FoldRec Doc (Doc, Doc)
fae04f4a69922eb1ddf0f46b34fa15a5a080b693Felix Gabriel ManceprintTermRec = FoldRec
fae04f4a69922eb1ddf0f46b34fa15a5a080b693Felix Gabriel Mance { foldQualVar = \ _ vd@(VarDecl v _ _ _) ->
fae04f4a69922eb1ddf0f46b34fa15a5a080b693Felix Gabriel Mance if isPatVarDecl vd then pretty v
fae04f4a69922eb1ddf0f46b34fa15a5a080b693Felix Gabriel Mance else parens $ keyword varS <+> pretty vd
fae04f4a69922eb1ddf0f46b34fa15a5a080b693Felix Gabriel Mance , foldQualOp = \ _ br n t _ ->
fae04f4a69922eb1ddf0f46b34fa15a5a080b693Felix Gabriel Mance parens $ fsep [pretty br, pretty n, colon, pretty $
808e2693447ecc5a311a2b9de6b81ca07f193778Felix Gabriel Mance if isPred br then unPredTypeScheme t else t]
fae04f4a69922eb1ddf0f46b34fa15a5a080b693Felix Gabriel Mance , foldResolvedMixTerm = \ (ResolvedMixTerm _ os _) n ts _ ->
fae04f4a69922eb1ddf0f46b34fa15a5a080b693Felix Gabriel Mance if placeCount n == length ts || null ts then
fae04f4a69922eb1ddf0f46b34fa15a5a080b693Felix Gabriel Mance idApplDoc n $ zipArgs n os ts
fae04f4a69922eb1ddf0f46b34fa15a5a080b693Felix Gabriel Mance else idApplDoc applId [idDoc n, parens $ sepByCommas ts]
fae04f4a69922eb1ddf0f46b34fa15a5a080b693Felix Gabriel Mance , foldApplTerm = \ (ApplTerm o1 o2 _) t1 t2 _ ->
fae04f4a69922eb1ddf0f46b34fa15a5a080b693Felix Gabriel Mance case (o1, o2) of
fae04f4a69922eb1ddf0f46b34fa15a5a080b693Felix Gabriel Mance -- comment out the following two guards for CASL applications