/* * Copyright 2022 Magnus Madsen, Stephen Tetley * * Use of this source code is governed by the Apache 2.0 license * that can be found in the LICENSE.md file. */////// Trait for types that support filtering, and its functions.///pubmod Filterable {////// Trait for types that support filtering.///pubtraitFilterable[m: Type -> Type] withFunctor[m], Foldable[m] {////// Applies the partial function `f` to every element in `x` collecting the results.///pubdeffilterMap(f: a -> Option[b] \ ef, t: m[a]): m[b] \ (ef + Foldable.Aef[m])////// Applies `f` to every element in `x`. Keeps every element that satisfies `f`.///pubdeffilter(f: a -> Bool \ ef, t: m[a]): m[a] \ (ef + Foldable.Aef[m]) =Filterable.filterMap(x -> if (f(x)) Some(x) else None, t) }}