From c01a362a8cf718ff2ed317846022a3e8fa26c420 Mon Sep 17 00:00:00 2001 From: "lennart@augustsson.net" Date: Thu, 21 Dec 2006 21:05:32 +0000 Subject: [PATCH] Add IsString class for overloaded string literals. --- Foreign/Marshal/Pool.hs | 2 +- GHC/Base.lhs | 8 ++++++++ Prelude.hs | 3 +++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Foreign/Marshal/Pool.hs b/Foreign/Marshal/Pool.hs index a2a73ac..3f7e2d5 100644 --- a/Foreign/Marshal/Pool.hs +++ b/Foreign/Marshal/Pool.hs @@ -45,7 +45,7 @@ module Foreign.Marshal.Pool ( ) where #ifdef __GLASGOW_HASKELL__ -import GHC.Base ( Int, Monad(..), (.), not ) +import GHC.Base ( Int, Monad(..), IsString(..), (.), not ) import GHC.Err ( undefined ) import GHC.Exception ( block, unblock, throw, catchException ) import GHC.IOBase ( IO, IORef, newIORef, readIORef, writeIORef, ) diff --git a/GHC/Base.lhs b/GHC/Base.lhs index 4fc09a6..5522e23 100644 --- a/GHC/Base.lhs +++ b/GHC/Base.lhs @@ -496,6 +496,14 @@ otherwise :: Bool otherwise = True \end{code} +\begin{code} +class IsString a where + fromString :: String -> a + +instance IsString [Char] where + fromString xs = xs +\end{code} + %********************************************************* %* * diff --git a/Prelude.hs b/Prelude.hs index 840c2ca..cae9c25 100644 --- a/Prelude.hs +++ b/Prelude.hs @@ -80,6 +80,9 @@ module Prelude ( Functor(fmap), mapM, mapM_, sequence, sequence_, (=<<), + -- ** String class + IsString(fromString), + -- ** Miscellaneous functions id, const, (.), flip, ($), until, asTypeOf, error, undefined, -- 1.7.10.4