{-# LANGUAGE ScopedTypeVariables #-}
module Htcc.Utils.Bool (
lor,
land,
sop,
sopText
) where
import qualified Data.Text as T
import Prelude hiding (toInteger)
lor :: [a -> Bool] -> a -> Bool
lor :: [a -> Bool] -> a -> Bool
lor [] _ = Bool
False
lor (f :: a -> Bool
f:fs :: [a -> Bool]
fs) x :: a
x | a -> Bool
f a
x = Bool
True | Bool
otherwise = [a -> Bool] -> a -> Bool
forall a. [a -> Bool] -> a -> Bool
lor [a -> Bool]
fs a
x
land :: [a -> Bool] -> a -> Bool
land :: [a -> Bool] -> a -> Bool
land [] _ = Bool
False
land (f :: a -> Bool
f:fs :: [a -> Bool]
fs) x :: a
x = ((a -> Bool) -> Bool -> Bool) -> Bool -> [a -> Bool] -> Bool
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr (Bool -> Bool -> Bool
(&&) (Bool -> Bool -> Bool)
-> ((a -> Bool) -> Bool) -> (a -> Bool) -> Bool -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((a -> Bool) -> a -> Bool) -> a -> (a -> Bool) -> Bool
forall a b c. (a -> b -> c) -> b -> a -> c
flip (a -> Bool) -> a -> Bool
forall a. a -> a
id a
x) (a -> Bool
f a
x) [a -> Bool]
fs
sop :: [a -> Bool] -> [a] -> Bool
sop :: [a -> Bool] -> [a] -> Bool
sop = (a -> Bool) -> [a] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
all ((a -> Bool) -> [a] -> Bool)
-> ([a -> Bool] -> a -> Bool) -> [a -> Bool] -> [a] -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [a -> Bool] -> a -> Bool
forall a. [a -> Bool] -> a -> Bool
lor
sopText :: [Char -> Bool] -> T.Text -> Bool
sopText :: [Char -> Bool] -> Text -> Bool
sopText = (Char -> Bool) -> Text -> Bool
T.all ((Char -> Bool) -> Text -> Bool)
-> ([Char -> Bool] -> Char -> Bool)
-> [Char -> Bool]
-> Text
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Char -> Bool] -> Char -> Bool
forall a. [a -> Bool] -> a -> Bool
lor