From 2b09d1369ead1a675a916a3c928e0b72c169c3fe Mon Sep 17 00:00:00 2001 From: ross Date: Tue, 16 Jul 2002 15:47:26 +0000 Subject: [PATCH] [project @ 2002-07-16 15:47:25 by ross] First stage of making the new libraries work with Hugs: * wrap #ifndef __HUGS__ around stuff that Hugs defines in its monster prelude (because Hugs can't handle recursive imports). * remove non-Haskell 98 export of [](..) from Data.List * make the definitions of tuples in Data.Tuple GHC-only. * make the export of the new Read stuff in Text.Read GHC-only, like its definition is. --- Control/Monad.hs | 2 ++ Data/Either.hs | 2 ++ Data/List.hs | 6 +++--- Data/Maybe.hs | 2 ++ Data/Ratio.hs | 3 ++- Data/Tuple.hs | 17 +++++++++-------- Text/Read.hs | 2 ++ Text/Show.hs | 4 ++-- 8 files changed, 24 insertions(+), 14 deletions(-) diff --git a/Control/Monad.hs b/Control/Monad.hs index 14f33d6..c86ffbb 100644 --- a/Control/Monad.hs +++ b/Control/Monad.hs @@ -51,6 +51,7 @@ import GHC.List import GHC.Base #endif +#ifndef __HUGS__ infixr 1 =<< -- ----------------------------------------------------------------------------- @@ -77,6 +78,7 @@ mapM f as = sequence (map f as) mapM_ :: Monad m => (a -> m b) -> [a] -> m () {-# INLINE mapM_ #-} mapM_ f as = sequence_ (map f as) +#endif /* __HUGS__ */ -- ----------------------------------------------------------------------------- -- Monadic classes: MonadPlus diff --git a/Data/Either.hs b/Data/Either.hs index 9fed2d3..406e7e7 100644 --- a/Data/Either.hs +++ b/Data/Either.hs @@ -22,6 +22,7 @@ module Data.Either ( import GHC.Base #endif +#ifndef __HUGS__ {-| The 'Either' type represents values with two possibilities: a value of @@ -37,3 +38,4 @@ data Either a b = Left a | Right b deriving (Eq, Ord ) either :: (a -> c) -> (b -> c) -> Either a b -> c either f _ (Left x) = f x either _ g (Right y) = g y +#endif /* __HUGS__ */ diff --git a/Data/List.hs b/Data/List.hs index 51c4fda..1531a3e 100644 --- a/Data/List.hs +++ b/Data/List.hs @@ -15,9 +15,7 @@ module Data.List ( - [] (..) - - , elemIndex -- :: (Eq a) => a -> [a] -> Maybe Int + elemIndex -- :: (Eq a) => a -> [a] -> Maybe Int , elemIndices -- :: (Eq a) => a -> [a] -> [Int] , find -- :: (a -> Bool) -> [a] -> Maybe a @@ -597,6 +595,7 @@ foldl' :: (a -> b -> a) -> a -> [b] -> a foldl' f a [] = a foldl' f a (x:xs) = let a' = f a x in a' `seq` foldl' f a' xs +#ifndef __HUGS__ -- ----------------------------------------------------------------------------- -- List sum and product @@ -619,3 +618,4 @@ product l = prod l 1 prod [] a = a prod (x:xs) a = prod xs (a*x) #endif +#endif /* __HUGS__ */ diff --git a/Data/Maybe.hs b/Data/Maybe.hs index 32101b7..1a1467f 100644 --- a/Data/Maybe.hs +++ b/Data/Maybe.hs @@ -35,6 +35,7 @@ import {-# SOURCE #-} GHC.Err ( error ) import GHC.Base #endif +#ifndef __HUGS__ -- --------------------------------------------------------------------------- -- The Maybe type, and instances @@ -71,6 +72,7 @@ instance Monad Maybe where maybe :: b -> (a -> b) -> Maybe a -> b maybe n _ Nothing = n maybe _ f (Just x) = f x +#endif /* __HUGS__ */ isJust :: Maybe a -> Bool isJust Nothing = False diff --git a/Data/Ratio.hs b/Data/Ratio.hs index 5c58cd5..37dd821 100644 --- a/Data/Ratio.hs +++ b/Data/Ratio.hs @@ -39,6 +39,7 @@ import Prelude import GHC.Real -- The basic defns for Ratio #endif +#ifndef __HUGS__ -- ----------------------------------------------------------------------------- -- approxRational @@ -76,4 +77,4 @@ approxRational rat eps = simplest (rat-eps) (rat+eps) nd'' = simplest' d' r' d r n'' = numerator nd'' d'' = denominator nd'' - +#endif /* __HUGS__ */ diff --git a/Data/Tuple.hs b/Data/Tuple.hs index e3c0a43..6c096bb 100644 --- a/Data/Tuple.hs +++ b/Data/Tuple.hs @@ -14,19 +14,18 @@ ----------------------------------------------------------------------------- module Data.Tuple ( - module Data.Tuple - -- tuples 1..37, - -- fst :: (a,b) -> a - -- snd :: (a,b) -> a - -- curry :: ((a, b) -> c) -> a -> b -> c - -- uncurry :: (a -> b -> c) -> ((a, b) -> c) + module Data.Tuple + -- tuples 1..37 + , fst -- :: (a,b) -> a + , snd -- :: (a,b) -> a + , curry -- :: ((a, b) -> c) -> a -> b -> c + , uncurry -- :: (a -> b -> c) -> ((a, b) -> c) ) where #ifdef __GLASGOW_HASKELL__ import GHC.Base default () -- Double isn't available yet -#endif data (,) a b = (,) a b deriving (Eq, Ord) data (,,) a b c = (,,) a b c deriving (Eq, Ord) @@ -213,10 +212,12 @@ data (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, data (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z a_ b_ c_ d_ e_ f_ g_ h_ i_ j_ k_ l_ m_ n_ o_ p_ q_ r_ s_ t_ u_ v_ w_ x_ y_ z_ a__ b__ c__ d__ e__ f__ g__ h__ i__ j__ k__ l__ m__ n__ o__ p__ q__ r__ s__ t__ u__ v__ w__ x__ y__ z__ a___ b___ c___ d___ e___ f___ g___ h___ i___ j___ k___ l___ m___ n___ o___ p___ q___ r___ s___ t___ u___ v___ = (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z a_ b_ c_ d_ e_ f_ g_ h_ i_ j_ k_ l_ m_ n_ o_ p_ q_ r_ s_ t_ u_ v_ w_ x_ y_ z_ a__ b__ c__ d__ e__ f__ g__ h__ i__ j__ k__ l__ m__ n__ o__ p__ q__ r__ s__ t__ u__ v__ w__ x__ y__ z__ a___ b___ c___ d___ e___ f___ g___ h___ i___ j___ k___ l___ m___ n___ o___ p___ q___ r___ s___ t___ u___ v___ -} +#endif /* __GLASGOW_HASKELL__ */ -- --------------------------------------------------------------------------- -- Standard functions over tuples +#ifndef __HUGS__ fst :: (a,b) -> a fst (x,_) = x @@ -230,4 +231,4 @@ curry f x y = f (x, y) uncurry :: (a -> b -> c) -> ((a, b) -> c) uncurry f p = f (fst p) (snd p) - +#endif /* __HUGS__ */ diff --git a/Text/Read.hs b/Text/Read.hs index bf70920..c2fc39b 100644 --- a/Text/Read.hs +++ b/Text/Read.hs @@ -28,12 +28,14 @@ module Text.Read ( readParen, -- :: Bool -> ReadS a -> ReadS a lex, -- :: ReadS String +#ifdef __GLASGOW_HASKELL__ -- * New parsing functions module Text.ParserCombinators.ReadPrec, L.Lexeme(..), lexP, -- :: ReadPrec Lexeme readListDefault, -- :: Read a => ReadS [a] readListPrecDefault, -- :: Read a => ReadPrec [a] +#endif ) where diff --git a/Text/Show.hs b/Text/Show.hs index 3f2e1a7..9c2cabd 100644 --- a/Text/Show.hs +++ b/Text/Show.hs @@ -31,10 +31,10 @@ module Text.Show ( import GHC.Show #endif -#ifdef __GLASGOW_HASKELL__ showListWith :: (a -> ShowS) -> [a] -> ShowS showListWith = showList__ -#else + +#ifndef __GLASGOW_HASKELL__ showList__ :: (a -> ShowS) -> [a] -> ShowS showList__ _ [] s = "[]" ++ s showList__ showx (x:xs) s = '[' : showx x (showl xs) -- 1.7.10.4