From 2fa8431a83031128428caa8f833a3396de34536f Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Sun, 21 Jun 2009 20:43:46 +0200 Subject: [PATCH] Add pprString convenience method. This method can convert any Outputable to a string. --- Pretty.hs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Pretty.hs b/Pretty.hs index b2ac91d..7896372 100644 --- a/Pretty.hs +++ b/Pretty.hs @@ -1,4 +1,4 @@ -module Pretty (prettyShow) where +module Pretty (prettyShow, pprString) where import qualified Data.Map as Map @@ -151,3 +151,7 @@ instance (Pretty k, Pretty v) => Pretty (Map.Map k v) where where ppentry (k, v) = pPrint k <> text " : " $$ nest 15 (pPrint v) + +-- Convenience method for turning an Outputable into a string +pprString :: (Outputable x) => x -> String +pprString = showSDoc . ppr -- 2.30.2