[commit: packages/base] master: Add Data.Bool.bool (fixes #8302) (f404697)

git at git.haskell.org git at git.haskell.org
Mon Sep 16 17:19:33 CEST 2013


Repository : ssh://git@git.haskell.org/base

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/f404697486b1db27711be134fd65c6c5e60d7604/base

>---------------------------------------------------------------

commit f404697486b1db27711be134fd65c6c5e60d7604
Author: Oliver Charles <ollie at ocharles.org.uk>
Date:   Sun Sep 15 01:23:56 2013 +0100

    Add Data.Bool.bool (fixes #8302)


>---------------------------------------------------------------

f404697486b1db27711be134fd65c6c5e60d7604
 Data/Bool.hs |    7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/Data/Bool.hs b/Data/Bool.hs
index 2f80c97..9f6ce04 100644
--- a/Data/Bool.hs
+++ b/Data/Bool.hs
@@ -23,9 +23,16 @@ module Data.Bool (
    (||),
    not,
    otherwise,
+   bool,
   ) where
 
 #ifdef __GLASGOW_HASKELL__
 import GHC.Base
 #endif
 
+-- | Case analysis for the 'Bool' type.
+-- @bool a b p@ evaluates to @a@ when @p@ is @False@, and evaluates to @b@
+-- when @p@ is @True at .
+bool :: a -> a -> Bool -> a
+bool f _ False = f
+bool _ t True  = t




More information about the ghc-commits mailing list