| Copyright | (c) The University of Glasgow 2001 |
|---|---|
| License | BSD-style (see the file libraries/base/LICENSE) |
| Maintainer | libraries@haskell.org |
| Stability | experimental |
| Portability | portable |
| Safe Haskell | Trustworthy |
| Language | Haskell2010 |
Data.Bool
Contents
Description
The Bool type and related functions.
Booleans
Instances
| Bounded Bool # | Since: base-2.1 |
| Enum Bool # | Since: base-2.1 |
| Eq Bool | |
| Data Bool # | Since: base-4.0.0.0 |
Defined in Data.Data Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Bool -> c Bool # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Bool # dataTypeOf :: Bool -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Bool) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Bool) # gmapT :: (forall b. Data b => b -> b) -> Bool -> Bool # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Bool -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Bool -> r # gmapQ :: (forall d. Data d => d -> u) -> Bool -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Bool -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Bool -> m Bool # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Bool -> m Bool # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Bool -> m Bool # | |
| Ord Bool | |
| Read Bool # | Since: base-2.1 |
| Show Bool # | Since: base-2.1 |
| Ix Bool # | Since: base-2.1 |
| Generic Bool # | |
| FiniteBits Bool # | Since: base-4.7.0.0 |
Defined in Data.Bits Methods finiteBitSize :: Bool -> Int # countLeadingZeros :: Bool -> Int # countTrailingZeros :: Bool -> Int # | |
| Bits Bool # | Interpret Since: base-4.7.0.0 |
Defined in Data.Bits Methods (.&.) :: Bool -> Bool -> Bool # (.|.) :: Bool -> Bool -> Bool # complement :: Bool -> Bool # shift :: Bool -> Int -> Bool # rotate :: Bool -> Int -> Bool # setBit :: Bool -> Int -> Bool # clearBit :: Bool -> Int -> Bool # complementBit :: Bool -> Int -> Bool # testBit :: Bool -> Int -> Bool # bitSizeMaybe :: Bool -> Maybe Int # shiftL :: Bool -> Int -> Bool # unsafeShiftL :: Bool -> Int -> Bool # shiftR :: Bool -> Int -> Bool # unsafeShiftR :: Bool -> Int -> Bool # rotateL :: Bool -> Int -> Bool # | |
| Storable Bool # | Since: base-2.1 |
Defined in Foreign.Storable | |
| type Rep Bool # | Since: base-4.6.0.0 |
Operations
Case analysis for the Bool type. evaluates to bool x y px
when p is False, and evaluates to y when p is True.
This is equivalent to if p then y else x; that is, one can
think of it as an if-then-else construct with its arguments
reordered.
Examples
Basic usage:
>>>bool "foo" "bar" True"bar">>>bool "foo" "bar" False"foo"
Confirm that and bool x y pif p then y else x are
equivalent:
>>>let p = True; x = "bar"; y = "foo">>>bool x y p == if p then y else xTrue>>>let p = False>>>bool x y p == if p then y else xTrue
Since: base-4.7.0.0