Chadtech/elm-bool-extra/1.2.0

NOTE: this package is not compatible with Elm 0.19.1

Bool.Extra

Convenience functions for working with Bools

Basics

all : List Bool -> Bool

All the bools are true.

all [ True, True ] == True
all [ True, False ] == False
all [ False, False ] == False
none : List Bool -> Bool

None of the bools are true.

none [ True, True ] == False
none [ True, False ] == False
none [ False, False ] == True
any : List Bool -> Bool

At least one of the bools is true.

any [ True, True ] == True
any [ True, False ] == True
any [ False, False ] == False
notAll : List Bool -> Bool

Not all of them are true

notAll [ True, True ] == False
notAll [ True, False ] == True
notAll [ False, False ] == True

Util

ternary : a -> a -> Bool -> a

A substitue for the "if" statement that can be used in one line, much like the conditional operator in Javascript

columnStyle : Maybe Int -> Int -> List (Attribute Msg)
columnStyle selectedColumn thisColumn =
    selectedColumn
        |> Maybe.map ((==) thisColumn)
        |> Maybe.withDefault False
        |> ternary column.focus NoFocus
        |> focusStyle


focusStyle : Column.Focus -> List (Attribute Msg)
focusStyle focus =
    case focus of
        NoFocus ->
            []


        People ->
            [ class "people-focused" ]


        Prices ->
            [ class "prices-focused" ]

Predicate

allPass : List (a -> Bool) -> a -> Bool

Determine if all predicates are satisfied by the value.

allPass [(>) 20, (<) 10] 11 == True
allPass [(>) 20, (<) 10] 21 == False
allPass [(>) 20, (<) 10] 4 == False
allPass [] 21 == True
anyPass : List (a -> Bool) -> a -> Bool

Determine if any predicate is satisfied by the value.

anyPass [(>) 20, (<) 10] 100 == True
anyPass [(>) 20, (==) 10] 21 == False
anyPass [] 21 == False