ppTermF' pp lcls p (Pi name tp rhs) = ppPi <$> lhs <*> pp lcls' PrecLambda rhs
  where ppPi lhs' rhs' = ppParens (p > PrecLambda) $ lhs' <<$>> text "->" <+> rhs'
        lhs | name == "_" = (align . group . nest 2) <$> pp lcls PrecApp tp
            | otherwise = (\tp' -> parens (text name' <+> doublecolon <+> align (group (nest 2 tp'))))
                            <$> pp lcls PrecLambda tp
        name' = freshVariant (docUsedMap lcls) name
        lcls' = consBinding lcls name'
ppTermF' pp lcls p (Pi name tp rhs) = ppPi <$> lhs <*> pp lcls' PrecLambda rhs
  where ppPi lhs' rhs' = ppParens (p > PrecLambda) $ lhs' <<$>> text "->" <+> rhs'
        lhs | name == "_" = (align . group . nest 2) <$> pp lcls PrecApp tp
            | otherwise = (\tp' -> parens (text name' <+> doublecolon <+> align (group (nest 2 tp'))))
                            <$> pp lcls PrecLambda tp
        name' = freshVariant (docUsedMap lcls) name
        lcls' = consBinding lcls name'
ppTermF' pp lcls p (Pi name tp rhs) = ppPi <$> lhs <*> pp lcls' PrecLambda rhs
  where ppPi lhs' rhs' = ppParens (p > PrecLambda) $ lhs' <<$>> text "->" <+> rhs'
        lhs | name == "_" = (align . group . nest 2) <$> pp lcls PrecApp tp
            | otherwise = (\tp' -> parens (text name' <+> doublecolon <+> align (group (nest 2 tp'))))
                            <$> pp lcls PrecLambda tp
        name' = freshVariant (docUsedMap lcls) name
        lcls' = consBinding lcls name'