[project @ 2002-04-24 16:31:37 by simonmar]
[ghc-base.git] / Data / Either.hs
1 {-# OPTIONS -fno-implicit-prelude #-}
2 -----------------------------------------------------------------------------
3 -- |
4 -- Module      :  Data.Either
5 -- Copyright   :  (c) The University of Glasgow 2001
6 -- License     :  BSD-style (see the file libraries/core/LICENSE)
7 -- 
8 -- Maintainer  :  libraries@haskell.org
9 -- Stability   :  experimental
10 -- Portability :  portable
11 --
12 -- $Id: Either.hs,v 1.4 2002/04/24 16:31:39 simonmar Exp $
13 --
14 -- The Either type, and associated operations.
15 --
16 -----------------------------------------------------------------------------
17
18 module Data.Either (
19    Either(..),
20    either       -- :: (a -> c) -> (b -> c) -> Either a b -> c
21  ) where
22
23 #ifdef __GLASGOW_HASKELL__
24 import GHC.Base
25 #endif
26
27 data  Either a b  =  Left a | Right b   deriving (Eq, Ord )
28
29 either                  :: (a -> c) -> (b -> c) -> Either a b -> c
30 either f _ (Left x)     =  f x
31 either _ g (Right y)    =  g y