+pprTermM1 _ = panic "pprTermM1"
+
+pprNewtypeWrap y p NewtypeWrap{ty=ty, wrapped_term=t}
+ | Just (tc,_) <- splitNewTyConApp_maybe ty
+ , ASSERT(isNewTyCon tc) True
+ , Just new_dc <- maybeTyConSingleCon tc = do
+ real_term <- y 10 t
+ return$ cparen (p >= app_prec) (ppr new_dc <+> real_term)
+pprNewtypeWrap _ _ _ = panic "pprNewtypeWrap"
+
+-------------------------------------------------------
+-- Custom Term Pretty Printers
+-------------------------------------------------------
+
+-- We can want to customize the representation of a
+-- term depending on its type.
+-- However, note that custom printers have to work with
+-- type representations, instead of directly with types.
+-- We cannot use type classes here, unless we employ some
+-- typerep trickery (e.g. Weirich's RepLib tricks),
+-- which I didn't. Therefore, this code replicates a lot
+-- of what type classes provide for free.
+
+-- Concretely a custom term printer takes an explicit
+-- recursion knot, and produces a list of Term Processors,
+-- which additionally need a precedence value to
+-- either produce a SDoc or fail (and they do this in some monad m).
+
+type Precedence = Int
+type RecursionKnot m = Precedence -> Term -> m SDoc
+type CustomTermPrinter m = RecursionKnot m
+ -> [Precedence -> Term -> (m (Maybe SDoc))]