-{- | A custom Term printer to handle some types that
- we may not want to show, such as Data.Typeable.TypeRep -}
-cPprTermExtended :: Monad m => Session -> IO (CustomTermPrinter m)
-cPprTermExtended session = liftM22 (++) (return cPprTermBase) extended
- where
- extended = do
- [typerep_name] <- parseName session "Data.Typeable.TypeRep"
- Just (ATyCon typerep) <- lookupName session typerep_name
-
- return (\_y ->
- [ ifType (isTyCon typerep) (\_val _prec -> return (text "<typerep>")) ])
-
- ifType pred f prec ty _ val _tt
- | pred ty = Just `liftM` f prec val
- | otherwise = return Nothing
- isTyCon a_tc ty = fromMaybe False $ do
- (tc,_) <- splitTyConApp_maybe ty
- return (a_tc == tc)
- liftM22 f x y = do x' <- x; y' <- y
- return$ do x'' <- x';y'' <- y';return (f x'' y'')
-