Commit 020857d3 authored by simonmar's avatar simonmar
Browse files

[project @ 2001-07-03 14:13:32 by simonmar]

Move generic Maybe and Either definitions from GHC.Maybe to Data.Maybe
and Data.Either, and remove GHC.Maybe.
parent 900b4a14
......@@ -9,7 +9,7 @@
-- Stability : experimental
-- Portability : portable
--
-- $Id: Dynamic.hs,v 1.2 2001/07/03 11:37:49 simonmar Exp $
-- $Id: Dynamic.hs,v 1.3 2001/07/03 14:13:32 simonmar Exp $
--
-- The Dynamic interface provides basic support for dynamic types.
--
......@@ -64,9 +64,11 @@ module Data.Dynamic
) where
import Data.Maybe
import Data.Either
#ifdef __GLASGOW_HASKELL__
import GHC.Base
import GHC.Maybe
import GHC.Show
import GHC.Err
import GHC.Num
......
......@@ -9,7 +9,7 @@
-- Stability : experimental
-- Portability : portable
--
-- $Id: Either.hs,v 1.2 2001/07/03 11:37:49 simonmar Exp $
-- $Id: Either.hs,v 1.3 2001/07/03 14:13:32 simonmar Exp $
--
-- The Either type, and associated operations.
--
......@@ -21,5 +21,11 @@ module Data.Either (
) where
#ifdef __GLASGOW_HASKELL__
import GHC.Maybe
import GHC.Base
#endif
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
......@@ -9,7 +9,7 @@
-- Stability : experimental
-- Portability : portable
--
-- $Id: Maybe.hs,v 1.2 2001/07/03 11:37:50 simonmar Exp $
-- $Id: Maybe.hs,v 1.3 2001/07/03 14:13:32 simonmar Exp $
--
-- The Maybe type, and associated operations.
--
......@@ -33,12 +33,36 @@ module Data.Maybe
) where
#ifdef __GLASGOW_HASKELL__
import GHC.Err ( error )
import GHC.List
import GHC.Maybe
import {-# SOURCE #-} GHC.Err ( error )
import GHC.Base
#endif
-- ---------------------------------------------------------------------------
-- The Maybe type, and instances
data Maybe a = Nothing | Just a deriving (Eq, Ord)
instance Functor Maybe where
fmap _ Nothing = Nothing
fmap f (Just a) = Just (f a)
instance Monad Maybe where
(Just x) >>= k = k x
Nothing >>= _ = Nothing
(Just _) >> k = k
Nothing >> _ = Nothing
return = Just
fail _ = Nothing
-- ---------------------------------------------------------------------------
-- Functions over Maybe
maybe :: b -> (a -> b) -> Maybe a -> b
maybe n _ Nothing = n
maybe _ f (Just x) = f x
isJust :: Maybe a -> Bool
isJust Nothing = False
isJust _ = True
......
% -----------------------------------------------------------------------------
% $Id: Base.lhs,v 1.2 2001/07/03 11:37:50 simonmar Exp $
% $Id: Base.lhs,v 1.3 2001/07/03 14:13:32 simonmar Exp $
%
% (c) The University of Glasgow, 1992-2000
%
......@@ -33,7 +33,7 @@ GHC.Show Class: Show, plus instances for GHC.Base/GHC.Tup types
GHC.Enum Class: Enum, plus instances for GHC.Base/GHC.Tup types
GHC.Maybe Type: Maybe, plus instances for GHC.Base classes
Data.Maybe Type: Maybe, plus instances for GHC.Base classes
GHC.Num Class: Num, plus instances for Int
Type: Integer, plus instances for all classes so far (Eq, Ord, Num, Show)
......
% -----------------------------------------------------------------------------
% $Id: Conc.lhs,v 1.1 2001/06/28 14:15:03 simonmar Exp $
% $Id: Conc.lhs,v 1.2 2001/07/03 14:13:32 simonmar Exp $
%
% (c) The University of Glasgow, 1994-2000
%
......@@ -40,8 +40,9 @@ module GHC.Conc
) where
import Data.Maybe
import GHC.Base
import GHC.Maybe
import GHC.Err ( parError, seqError )
import GHC.IOBase ( IO(..), MVar(..) )
import GHC.Base ( Int(..) )
......
% -----------------------------------------------------------------------------
% $Id: Enum.lhs,v 1.2 2001/07/03 11:37:50 simonmar Exp $
% $Id: Enum.lhs,v 1.3 2001/07/03 14:13:32 simonmar Exp $
%
% (c) The University of Glasgow, 1992-2000
%
......@@ -21,8 +21,6 @@ module GHC.Enum(
import {-# SOURCE #-} GHC.Err ( error )
import GHC.Base
import Data.Tuple () -- To make sure we look for the .hi file
default () -- Double isn't available yet
\end{code}
......
% ------------------------------------------------------------------------------
% $Id: Exception.lhs,v 1.1 2001/06/28 14:15:03 simonmar Exp $
% $Id: Exception.lhs,v 1.2 2001/07/03 14:13:32 simonmar Exp $
%
% (c) The University of Glasgow, 1998-2000
%
......@@ -17,8 +17,9 @@ module GHC.Exception
throw, ioError )
where
import Data.Either
import GHC.Base
import GHC.Maybe
import GHC.IOBase
#endif
......
% ------------------------------------------------------------------------------
% $Id: Float.lhs,v 1.1 2001/06/28 14:15:03 simonmar Exp $
% $Id: Float.lhs,v 1.2 2001/07/03 14:13:32 simonmar Exp $
%
% (c) The University of Glasgow, 1994-2000
%
......@@ -23,6 +23,8 @@ and the classes
module GHC.Float( module GHC.Float, Float#, Double# ) where
import Data.Maybe
import GHC.Base
import GHC.List
import GHC.Enum
......@@ -30,7 +32,6 @@ import GHC.Show
import GHC.Num
import GHC.Real
import GHC.Arr
import GHC.Maybe
infixr 8 **
\end{code}
......
% ------------------------------------------------------------------------------
% $Id: IOBase.lhs,v 1.1 2001/06/28 14:15:03 simonmar Exp $
% $Id: IOBase.lhs,v 1.2 2001/07/03 14:13:32 simonmar Exp $
%
% (c) The University of Glasgow, 1994-2001
%
......@@ -18,7 +18,7 @@ import GHC.STRef
import GHC.Arr
import GHC.Base
import GHC.Num -- To get fromInteger etc, needed because of -fno-implicit-prelude
import GHC.Maybe ( Maybe(..) )
import Data.Maybe ( Maybe(..) )
import GHC.Show
import GHC.List
import GHC.Read
......
% ------------------------------------------------------------------------------
% $Id: List.lhs,v 1.2 2001/07/03 11:37:50 simonmar Exp $
% $Id: List.lhs,v 1.3 2001/07/03 14:13:32 simonmar Exp $
%
% (c) The University of Glasgow, 1994-2000
%
......@@ -37,7 +37,7 @@ module GHC.List (
import {-# SOURCE #-} GHC.Err ( error )
import Data.Tuple
import GHC.Maybe
import Data.Maybe
import GHC.Base
infixl 9 !!
......
% ------------------------------------------------------------------------------
% $Id: Read.lhs,v 1.1 2001/06/28 14:15:03 simonmar Exp $
% $Id: Read.lhs,v 1.2 2001/07/03 14:13:32 simonmar Exp $
%
% (c) The University of Glasgow, 1994-2000
%
......@@ -13,13 +13,15 @@ Instances of the Read class.
module GHC.Read where
import Data.Maybe
import Data.Either
import {-# SOURCE #-} GHC.Err ( error )
import GHC.Enum ( Enum(..), maxBound )
import GHC.Num
import GHC.Real
import GHC.Float
import GHC.List
import GHC.Maybe
import GHC.Show -- isAlpha etc
import GHC.Base
\end{code}
......
% ------------------------------------------------------------------------------
% $Id: Show.lhs,v 1.2 2001/07/03 11:37:50 simonmar Exp $
% $Id: Show.lhs,v 1.3 2001/07/03 14:13:32 simonmar Exp $
%
% (c) The University of Glasgow, 1992-2000
%
......@@ -34,7 +34,8 @@ module GHC.Show
import {-# SOURCE #-} GHC.Err ( error )
import GHC.Base
import GHC.Maybe
import Data.Maybe
import Data.Either
import GHC.List ( (!!), break, dropWhile
#ifdef USE_REPORT_PRELUDE
, concatMap, foldr1
......
% ------------------------------------------------------------------------------
% $Id: Weak.lhs,v 1.1 2001/06/28 14:15:03 simonmar Exp $
% $Id: Weak.lhs,v 1.2 2001/07/03 14:13:32 simonmar Exp $
%
% (c) The University of Glasgow, 1998-2000
%
......@@ -13,7 +13,7 @@ module GHC.Weak where
import GHC.Prim
import GHC.Base
import GHC.Maybe
import Data.Maybe
import GHC.IOBase ( IO(..), unIO )
data Weak v = Weak (Weak# v)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment