precursor-0.1.0.0: src/Precursor/Data/Bool.hs
{-# LANGUAGE NoImplicitPrelude #-}
module Precursor.Data.Bool
( -- * Booleans
Bool(..)
-- ** Operations
, (&&)
, (||)
, not
, otherwise
, bool
, ifThenElse
) where
import Data.Bool hiding (bool)
-- | Used for desugaring @if@ expressions.
--
-- >>> ifThenElse True 1 0
-- 1
-- >>> ifThenElse False 1 0
-- 0
ifThenElse :: Bool -> a -> a -> a
ifThenElse True t _ = t
ifThenElse False _ f = f
-- | Fold over a 'Bool'.
--
-- >>> bool 1 0 True
-- 1
-- >>> bool 1 0 False
-- 0
bool :: a -> a -> Bool -> a
bool t _ True = t
bool _ f False = f