upsiflu / less-ui

Write your views across several screen regions, and hide all Ui state in the Url.
https://package.elm-lang.org/packages/upsiflu/less-ui/latest
BSD 3-Clause "New" or "Revised" License
6 stars 1 forks source link

Defunc `Filter` #55

Open upsiflu opened 10 months ago

upsiflu commented 10 months ago

As it stands (v1), a Filter accepts a function [SearchTerms] -> Ui. A defunctionalized alternative might look like

predicateA ∧ (predicateB ∨ predicateC)

We cannot use the Api of https://package.elm-lang.org/packages/red-g/filter/latest/Filter because it immediately applies the filter, and it checks for a Bool, not for a list.

In Filter, we are working with SearchTerms (Strings) assigned to a given Category.

type alias Filter 
    = List (Predicate, Ui)

type Predicate
    = And Predicate Predicate
    | Or Predicate Predicate
    | IsSimilarTo { deviation : Int, compareTo : String }
    | Contains String
    | Equals String

apply : Filter -> List SearchTerm -> Ui

and : Filter -> Filter -> Filter

or : Filter -> Filter -> Filter