red-g/filter/2.0.2

NOTE: the latest version is 2.0.3

Filter

Useful ways to combine filters (also known as predicates)!

type Filter a

A Filter takes a value a and determines whether it should pass or fail.

type Status
= Pass
| Fail

The result of a filter.

all : List (Filter a) -> Filter a

Pass if all filters pass.

and : Filter a -> Filter a -> Filter a

Pass if both filters pass.

any : List (Filter a) -> Filter a

Pass if at least one filter passes.

array : Filter a -> Array a -> Array a

Keep items that pass the filter.

by : (a -> b) -> Filter b -> Filter a

Filter a value by a derived property, like its height.

bob =
    { height = 5 }


isTall =
    by .height <| gt 6


test isTall bob
-- Fail
custom : (a -> Status) -> Filter a

Sometimes the building blocks in this library aren't enough!

eq : a -> Filter a

Test whether a value is equal to ref.

A filter that always fails.

gt : Int -> Filter Int

Test whether a value is greater than num.

list : Filter a -> List a -> List a

Keep items that pass the filter.

lt : Int -> Filter Int

Test whether a value is less than num.

not : Filter a -> Filter a

Flip the outcome of a filter; if it fails it passes, and if it passes it fails.

or : Filter a -> Filter a -> Filter a

Pass if at least one filter passes.

A filter that always passes.

test : Filter a -> a -> Status

Run an item through a given filter.

gte : Int -> Filter Int

Test whether a value is greater than or equal to num.

lte : Int -> Filter Int

Test whether a value is less than or equal to num.

neq : a -> Filter a

Test whether a value is not equal to ref.