diff --git a/src/Database/Esqueleto/Utils.hs b/src/Database/Esqueleto/Utils.hs index b2e077453..bac61ff27 100644 --- a/src/Database/Esqueleto/Utils.hs +++ b/src/Database/Esqueleto/Utils.hs @@ -80,7 +80,7 @@ import qualified Data.Text.Lazy.Builder as Text.Builder import Data.Monoid (Last(..)) import Utils (commaSeparatedText) -import Utils.Set (concatMapSet) +-- import Utils.Set (concatMapSet) {-# ANN any ("HLint: ignore Use any" :: String) #-} @@ -335,7 +335,7 @@ mkContainsFilterWith cast lenslike row criterias | otherwise = any (hasInfix $ lenslike row) (E.val . cast <$> Set.toList criterias) -- | like `mkContainsFilterWith` but allows conversion to produce multiple needles -mkContainsFilterWithSet :: (E.SqlString b, Ord b) +mkContainsFilterWithSet :: (E.SqlString b, Ord b, Ord a) => (a -> Set.Set b) -> (t -> E.SqlExpr (E.Value b)) -- ^ getter from query to searched element -> t -- ^ query row @@ -343,7 +343,7 @@ mkContainsFilterWithSet :: (E.SqlString b, Ord b) -> E.SqlExpr (E.Value Bool) mkContainsFilterWithSet cast lenslike row criterias | Set.null criterias = true - | otherwise = any (hasInfix $ lenslike row) (E.val <$> Set.toList (concatMapSet cast criterias)) + | otherwise = any (hasInfix $ lenslike row) (E.val <$> Set.toList (foldMap cast criterias)) -- | like `mkContainsFilterWithSet` but fixed to comma separated Texts mkContainsFilterWithComma :: (E.SqlString b, Ord b) @@ -352,7 +352,7 @@ mkContainsFilterWithComma :: (E.SqlString b, Ord b) -> t -- ^ query row -> Set.Set Text -- ^ needle collection -> E.SqlExpr (E.Value Bool) -mkContainsFilterWithComma cast lenslike row (concatMapSet commaSeparatedText -> criterias) +mkContainsFilterWithComma cast lenslike row (foldMap commaSeparatedText -> criterias) | Set.null criterias = true | otherwise = any (hasInfix $ lenslike row) (E.val . cast <$> Set.toList criterias) @@ -363,7 +363,7 @@ mkContainsFilterWithCommaPlus :: (E.SqlString b, Ord b) -> t -- ^ query row -> Set.Set Text -- ^ needle collection -> E.SqlExpr (E.Value Bool) -mkContainsFilterWithCommaPlus cast lenslike row (concatMapSet commaSeparatedText -> criterias) +mkContainsFilterWithCommaPlus cast lenslike row (foldMap commaSeparatedText -> criterias) | Set.null criterias = true | Set.null compulsories = cond_optional | Set.null alternatives = cond_compulsory diff --git a/src/Utils/Set.hs b/src/Utils/Set.hs index 7fb14cdfa..7ef167280 100644 --- a/src/Utils/Set.hs +++ b/src/Utils/Set.hs @@ -58,7 +58,7 @@ setMapMaybe f = Set.fromList . mapMaybe f . Set.toList concatMapSet :: Ord b => (a -> Set b) -> Set a -> Set b concatMapSet f = Set.foldl ((. f) . (<>)) mempty --- concatMapSet f = foldMap f --- requires Ord a as well +-- concatMapSet f = foldMap f --- requires Ord a as well, which we ought to have anyway -- | Symmetric difference of two sets. setSymmDiff :: Ord a => Set a -> Set a -> Set a