From 2e317d707ce3512be60ada74a22119cd0a054ca1 Mon Sep 17 00:00:00 2001 From: Ian Lynagh Date: Tue, 30 Jan 2007 13:48:41 +0000 Subject: [PATCH] Add Data.String, containing IsString(fromString); trac proposal #1126 This is used by the overloaded strings extension (-foverloaded-strings in GHC). --- Data/String.hs | 31 +++++++++++++++++++++++++++++++ Foreign/Marshal/Pool.hs | 2 +- GHC/Base.lhs | 9 --------- base.cabal | 1 + package.conf.in | 1 + 5 files changed, 34 insertions(+), 10 deletions(-) create mode 100644 Data/String.hs diff --git a/Data/String.hs b/Data/String.hs new file mode 100644 index 0000000..f1a65cd --- /dev/null +++ b/Data/String.hs @@ -0,0 +1,31 @@ +{-# OPTIONS_GHC -fno-implicit-prelude #-} +----------------------------------------------------------------------------- +-- | +-- Module : Data.String +-- Copyright : (c) The University of Glasgow 2007 +-- License : BSD-style (see the file libraries/base/LICENSE) +-- +-- Maintainer : libraries@haskell.org +-- Stability : experimental +-- Portability : portable +-- +-- Things related to the String type. +-- +----------------------------------------------------------------------------- + +module Data.String ( + IsString(..) + ) where + +#ifdef __GLASGOW_HASKELL__ +import GHC.Base +#endif + +-- | Class for string-like datastructures; used by the overloaded string +-- extension (-foverloaded-strings in GHC). +class IsString a where + fromString :: String -> a + +instance IsString [Char] where + fromString xs = xs + diff --git a/Foreign/Marshal/Pool.hs b/Foreign/Marshal/Pool.hs index 3f7e2d5..a2a73ac 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(..), IsString(..), (.), not ) +import GHC.Base ( Int, Monad(..), (.), 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 5522e23..c590366 100644 --- a/GHC/Base.lhs +++ b/GHC/Base.lhs @@ -496,15 +496,6 @@ otherwise :: Bool otherwise = True \end{code} -\begin{code} -class IsString a where - fromString :: String -> a - -instance IsString [Char] where - fromString xs = xs -\end{code} - - %********************************************************* %* * \subsection{The @()@ type} diff --git a/base.cabal b/base.cabal index 071e81e..aacd081 100644 --- a/base.cabal +++ b/base.cabal @@ -77,6 +77,7 @@ exposed-modules: Data.STRef.Strict, Data.Sequence, Data.Set, + Data.String, Data.Tree, Data.Traversable, Data.Tuple, diff --git a/package.conf.in b/package.conf.in index d9b23d4..e6374dd 100644 --- a/package.conf.in +++ b/package.conf.in @@ -75,6 +75,7 @@ exposed-modules: Data.STRef.Strict, Data.Sequence, Data.Set, + Data.String, Data.Traversable, Data.Tree, Data.Tuple, -- 1.7.10.4