[project @ 1997-11-24 17:49:28 by simonm]
authorsimonm <unknown>
Mon, 24 Nov 1997 17:50:10 +0000 (17:50 +0000)
committersimonm <unknown>
Mon, 24 Nov 1997 17:50:10 +0000 (17:50 +0000)
Pull Maybe and Either out of PrelBase into separate modules in an attempt
to make PrelBase a little smaller.

12 files changed:
ghc/lib/ghc/IOBase.lhs
ghc/lib/ghc/IOHandle.lhs
ghc/lib/ghc/PrelBase.lhs
ghc/lib/ghc/PrelEither.lhs [new file with mode: 0644]
ghc/lib/ghc/PrelList.lhs
ghc/lib/ghc/PrelMaybe.lhs [new file with mode: 0644]
ghc/lib/ghc/PrelNum.lhs
ghc/lib/ghc/PrelRead.lhs
ghc/lib/required/IO.lhs
ghc/lib/required/Maybe.lhs
ghc/lib/required/Numeric.lhs
ghc/lib/required/Prelude.lhs

index d6253db..c920cc8 100644 (file)
@@ -16,6 +16,7 @@ module IOBase where
 import {-# SOURCE #-} Error
 import STBase
 import PrelTup
+import PrelMaybe
 import Addr
 import PackBase        ( unpackCString )
 import PrelBase
index 0d1a9fb..b0c3c81 100644 (file)
@@ -23,6 +23,7 @@ import Ix
 import IOBase
 import Unsafe   ( unsafePerformIO )
 import PrelTup
+import PrelMaybe
 import PrelBase
 import GHC
 import Addr
index 86c9a58..7e780c9 100644 (file)
@@ -309,41 +309,6 @@ otherwise          =  True
 
 %*********************************************************
 %*                                                     *
-\subsection{Type @Maybe@}
-%*                                                     *
-%*********************************************************
-
-\begin{code}
-data  Maybe a  =  Nothing | Just a     deriving (Eq, Ord, Show {- Read -})
-
-maybe :: b -> (a -> b) -> Maybe a -> b
-maybe n f Nothing  = n
-maybe n f (Just x) = f x
-
-instance  Functor Maybe  where
-    map f Nothing       = Nothing
-    map f (Just a)      = Just (f a)
-
-instance  Monad Maybe  where
-    (Just x) >>= k      = k x
-    Nothing  >>= k      = Nothing
-
-    (Just x) >>  k      = k
-    Nothing  >>  k      = Nothing
-
-    return              = Just
-
-instance  MonadZero Maybe  where
-    zero                = Nothing
-
-instance  MonadPlus Maybe  where
-    Nothing ++ ys       = ys
-    xs      ++ ys       = xs
-\end{code}
-
-
-%*********************************************************
-%*                                                     *
 \subsection{The @()@ type}
 %*                                                     *
 %*********************************************************
@@ -391,21 +356,6 @@ instance  Show ()  where
 
 %*********************************************************
 %*                                                     *
-\subsection{Type @Either@}
-%*                                                     *
-%*********************************************************
-
-\begin{code}
-data  Either a b  =  Left a | Right b  deriving (Eq, Ord, Show {- Read -} )
-
-either                  :: (a -> c) -> (b -> c) -> Either a b -> c
-either f g (Left x)     =  f x
-either f g (Right y)    =  g y
-\end{code}
-
-
-%*********************************************************
-%*                                                     *
 \subsection{Type @Ordering@}
 %*                                                     *
 %*********************************************************
diff --git a/ghc/lib/ghc/PrelEither.lhs b/ghc/lib/ghc/PrelEither.lhs
new file mode 100644 (file)
index 0000000..71969aa
--- /dev/null
@@ -0,0 +1,20 @@
+%
+% (c) The GRASP/AQUA Project, Glasgow University, 1992-1997
+%
+\section[PrelEither]{Module @PrelEither@}
+
+The @Either@ Type.
+
+\begin{code}
+{-# OPTIONS -fno-implicit-prelude #-}
+
+module PrelEither where
+
+import PrelBase
+
+data  Either a b  =  Left a | Right b  deriving (Eq, Ord, Show {- Read -} )
+
+either                  :: (a -> c) -> (b -> c) -> Either a b -> c
+either f g (Left x)     =  f x
+either f g (Right y)    =  g y
+\end{code}
index 26be5ae..4ed206b 100644 (file)
@@ -24,6 +24,7 @@ module PrelList (
 
 import {-# SOURCE #-} Error ( error )
 import PrelTup
+import PrelMaybe
 import PrelBase
 
 infix  4 `elem`, `notElem`
diff --git a/ghc/lib/ghc/PrelMaybe.lhs b/ghc/lib/ghc/PrelMaybe.lhs
new file mode 100644 (file)
index 0000000..974e5de
--- /dev/null
@@ -0,0 +1,44 @@
+%
+% (c) The GRASP/AQUA Project, Glasgow University, 1992-1996
+%
+\section[PrelMaybe]{Module @PrelMaybe@}
+
+The @Maybe@ type.
+
+\begin{code}
+{-# OPTIONS -fno-implicit-prelude #-}
+
+module PrelMaybe where
+
+import PrelBase
+
+data  Maybe a  =  Nothing | Just a     deriving (Eq, Ord, Show {- Read -})
+
+maybe :: b -> (a -> b) -> Maybe a -> b
+maybe n f Nothing  = n
+maybe n f (Just x) = f x
+
+instance  Functor Maybe  where
+    map f Nothing       = Nothing
+    map f (Just a)      = Just (f a)
+
+instance  Monad Maybe  where
+    (Just x) >>= k      = k x
+    Nothing  >>= k      = Nothing
+
+    (Just x) >>  k      = k
+    Nothing  >>  k      = Nothing
+
+    return              = Just
+
+instance  MonadZero Maybe  where
+    zero                = Nothing
+
+instance  MonadPlus Maybe  where
+    Nothing ++ ys       = ys
+    xs      ++ ys       = xs
+\end{code}
+
+
+
+
index 72e6d4a..041214d 100644 (file)
@@ -23,6 +23,7 @@ import PrelBase
 import GHC
 import {-# SOURCE #-} Error ( error )
 import PrelList
+import PrelMaybe
 
 import ArrBase ( Array, array, (!) )
 import Unsafe   ( unsafePerformIO )
@@ -1185,7 +1186,6 @@ integerLogBase b i =
        in  doDiv (i `div` (b^l)) l
 \end{code}
 
-
 %*********************************************************
 %*                                                     *
 \subsection{Numeric primops}
index f3a064f..60917b3 100644 (file)
@@ -15,6 +15,8 @@ import {-# SOURCE #-} Error ( error )
 import PrelNum
 import PrelList
 import PrelTup
+import PrelMaybe
+import PrelEither
 import PrelBase
 \end{code}
 
index abf28ec..4e058d3 100644 (file)
@@ -40,6 +40,8 @@ import ArrBase                ( MutableByteArray(..), newCharArray )
 import IOHandle                -- much of the real stuff is in here
 import PackBase                ( unpackNBytesST )
 import PrelBase
+import PrelMaybe
+import PrelEither
 import GHC
 import Addr
 
index 2c663aa..40b130f 100644 (file)
@@ -23,6 +23,7 @@ module Maybe
 import Error   ( error )
 import Monad   ( filter )
 import PrelList
+import PrelMaybe
 import PrelBase
 \end{code}
 
index 34b26d1..2dd49a3 100644 (file)
@@ -32,6 +32,7 @@ module Numeric
        ) where
 
 import PrelBase
+import PrelMaybe
 import ArrBase
 import PrelNum
 import PrelRead
index 088bc2b..92d173f 100644 (file)
@@ -67,6 +67,8 @@ import PrelIO
 import PrelRead
 import PrelNum
 import PrelTup
+import PrelMaybe
+import PrelEither
 import Monad
 import Maybe
 import Error   ( error )