module Data.Bool.HT.Private where
import Data.List as List (find, )
import Data.Maybe as Maybe (fromMaybe, )
{-# INLINE if' #-}
if' :: Bool -> a -> a -> a
if' True x _ = x
if' False _ y = y
{-# INLINE ifThenElse #-}
ifThenElse :: Bool -> a -> a -> a
ifThenElse = if'
{-# INLINE select #-}
select, select0, select1 :: a -> [(Bool, a)] -> a
select def = maybe def snd . find fst
select0 def = fromMaybe def . lookup True
select1 = foldr (uncurry if')
zipIf :: [Bool] -> [a] -> [a] -> [a]
zipIf = zipWith3 if'
infixr 1 ?:
{-# INLINE (?:) #-}
(?:) :: Bool -> (a,a) -> a
(?:) = uncurry . if'
infixr 1 `implies`
{-# INLINE implies #-}
implies :: Bool -> Bool -> Bool
implies prerequisite conclusion =
not prerequisite || conclusion