[commit: ghc] master: Add IsString Outputable.SDoc instance (402bbe6)
git at git.haskell.org
git at git.haskell.org
Mon Dec 14 19:54:48 UTC 2015
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/402bbe6e2dddb96326e29b247adc40d9081ab224/ghc
>---------------------------------------------------------------
commit 402bbe6e2dddb96326e29b247adc40d9081ab224
Author: Herbert Valerio Riedel <hvr at gnu.org>
Date: Mon Dec 14 20:55:08 2015 +0100
Add IsString Outputable.SDoc instance
This allows to conveniently interpret string literals as `text`
when `-XOverloadedStrings` is in effect.
For what it's worth, `Text.PrettyPrint.Doc` also possesses such
an instance.
This is a spin-off from D1240
Reviewed By: bgamari
Differential Revision: https://phabricator.haskell.org/D1618
>---------------------------------------------------------------
402bbe6e2dddb96326e29b247adc40d9081ab224
compiler/utils/Outputable.hs | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/compiler/utils/Outputable.hs b/compiler/utils/Outputable.hs
index b539fa6..cda7475 100644
--- a/compiler/utils/Outputable.hs
+++ b/compiler/utils/Outputable.hs
@@ -103,6 +103,7 @@ import Data.Int
import qualified Data.IntMap as IM
import Data.Set (Set)
import qualified Data.Set as Set
+import Data.String
import Data.Word
import System.IO ( Handle )
import System.FilePath
@@ -286,6 +287,9 @@ data SDocContext = SDC
, sdocDynFlags :: !DynFlags
}
+instance IsString SDoc where
+ fromString = text
+
initSDocContext :: DynFlags -> PprStyle -> SDocContext
initSDocContext dflags sty = SDC
{ sdocStyle = sty
More information about the ghc-commits
mailing list