Remove unused imports from base
[ghc-base.git] / Data / Data.hs
index 2a32997..646249e 100644 (file)
@@ -114,7 +114,6 @@ import Data.Maybe
 import Control.Monad
 
 -- Imports for the instances
-import Data.Typeable
 import Data.Int              -- So we can give Data instance for Int8, ...
 import Data.Word             -- So we can give Data instance for Word8, ...
 #ifdef __GLASGOW_HASKELL__
@@ -501,11 +500,9 @@ instance Eq Constr where
 
 
 -- | Public representation of datatypes
-{-# DEPRECATED StringRep "Use CharRep instead" #-}
 data DataRep = AlgRep [Constr]
              | IntRep
              | FloatRep
-             | StringRep -- ^ Deprecated. Please use 'CharRep' instead.
              | CharRep
              | NoRep
 
@@ -514,11 +511,9 @@ data DataRep = AlgRep [Constr]
 
 
 -- | Public representation of constructors
-{-# DEPRECATED StringConstr "Use CharConstr instead" #-}
 data ConstrRep = AlgConstr    ConIndex
                | IntConstr    Integer
                | FloatConstr  Rational
-               | StringConstr String -- ^ Deprecated. Please use 'CharConstr' instead.
                | CharConstr   Char
 
                deriving (Eq,Show)
@@ -571,7 +566,6 @@ repConstr dt cr =
         (AlgRep cs, AlgConstr i)      -> cs !! (i-1)
         (IntRep,    IntConstr i)      -> mkIntConstr dt i
         (FloatRep,  FloatConstr f)    -> mkRealConstr dt f
-        (StringRep, StringConstr str) -> mkStringConstr dt str
         (CharRep,   CharConstr c)     -> mkCharConstr dt c
         _ -> error "repConstr"
 
@@ -645,8 +639,7 @@ readConstr dt str =
       case dataTypeRep dt of
         AlgRep cons -> idx cons
         IntRep      -> mkReadCon (\i -> (mkPrimCon dt str (IntConstr i)))
-        FloatRep    -> mkReadCon (\f -> (mkPrimCon dt str (FloatConstr f)))
-        StringRep   -> Just (mkStringConstr dt str)
+        FloatRep    -> mkReadCon ffloat
         CharRep     -> mkReadCon (\c -> (mkPrimCon dt str (CharConstr c)))
         NoRep       -> Nothing
   where
@@ -664,6 +657,8 @@ readConstr dt str =
                      then Nothing
                      else Just (head fit)
 
+    ffloat :: Double -> Constr
+    ffloat =  mkPrimCon dt str . FloatConstr . toRational
 
 ------------------------------------------------------------------------------
 --
@@ -721,7 +716,7 @@ mkFloatType = mkPrimType FloatRep
 -- | This function is now deprecated. Please use 'mkCharType' instead.
 {-# DEPRECATED mkStringType "Use mkCharType instead" #-}
 mkStringType :: String -> DataType
-mkStringType = mkPrimType StringRep
+mkStringType = mkCharType
 
 -- | Constructs the 'Char' type
 mkCharType :: String -> DataType
@@ -769,9 +764,12 @@ mkRealConstr dt f = case datarep dt of
 -- | This function is now deprecated. Please use 'mkCharConstr' instead.
 {-# DEPRECATED mkStringConstr "Use mkCharConstr instead" #-}
 mkStringConstr :: DataType -> String -> Constr
-mkStringConstr dt str = case datarep dt of
-                       StringRep -> mkPrimCon dt str (StringConstr str)
-                       _ -> error "mkStringConstr"
+mkStringConstr dt str =
+  case datarep dt of
+    CharRep -> case str of
+      [c] -> mkPrimCon dt (show c) (CharConstr c)
+      _ -> error "mkStringConstr: input String must contain a single character"
+    _ -> error "mkStringConstr"
 
 -- | Makes a constructor for 'Char'.
 mkCharConstr :: DataType -> Char -> Constr