Similar to foldl' but takes a function with its arguments flipped.
flipfoldl' (/) 5 [2,3] :: Rational15 % 2
This function can be useful for constructing containers from lists.
:: a typeCtrl KGHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05
Modulerelude-1.2.0.0Haskell2010
SPDX-License-Identifier : MIT Maintainer : Kowainik xrom.xkov@gmail.com Stability : Stable Portability : Portable
Fixes and additions to Foldable. Specifically:
Similar to foldl' but takes a function with its arguments flipped.
flipfoldl' (/) 5 [2,3] :: Rational15 % 2
This function can be useful for constructing containers from lists.
Alternative version of Relude.asum that takes a function to map over.
asumMap (\x -> if x > 2 then Just x else Nothing) [1..4]Just 3
Polymorphic version of the Relude.concatMapA function.
foldMapA @[Int] (Just . replicate 3) [1..3]Just [1,1,1,2,2,2,3,3,3]
Polymorphic version of the Relude.concatMapM function.
foldMapM @[Int] (Just . replicate 3) [1..3]Just [1,1,1,2,2,2,3,3,3]
Stricter version of sum.
sum [1..10]55
Stricter version of product.
product [1..10]3628800
Like elem but doesn't work on Set and HashSet for performance reasons.
elem 'x' ("abc" :: String)Falseelem False (one True :: Set Bool)...... Do not use 'elem' and 'notElem' methods from 'Foldable' on Set Suggestions: Instead of elem :: (Foldable t, Eq a) => a -> t a -> Bool use member :: Ord a => a -> Set a -> Bool... Instead of notElem :: (Foldable t, Eq a) => a -> t a -> Bool use not . member...
Like notElem but doesn't work on Set and HashSet for performance reasons.
notElem 'x' ("abc" :: String)TruenotElem False (one True :: Set Bool)...... Do not use 'elem' and 'notElem' methods from 'Foldable' on Set Suggestions: Instead of elem :: (Foldable t, Eq a) => a -> t a -> Bool use member :: Ord a => a -> Set a -> Bool... Instead of notElem :: (Foldable t, Eq a) => a -> t a -> Bool use not . member...
Monadic version of all.
allM (readMaybe >=> pure . even) ["6", "10"]Just TrueallM (readMaybe >=> pure . even) ["5", "aba"]Just FalseallM (readMaybe >=> pure . even) ["aba", "10"]Nothing
Monadic version of any.
anyM (readMaybe >=> pure . even) ["5", "10"]Just TrueanyM (readMaybe >=> pure . even) ["10", "aba"]Just TrueanyM (readMaybe >=> pure . even) ["aba", "10"]Nothing
Monadic version of and.
andM [Just True, Just False]Just FalseandM [Just True]Just TrueandM [Just True, Just False, Nothing]Just FalseandM [Just True, Nothing]NothingandM [putTextLn "1" >> pure True, putTextLn "2" >> pure False, putTextLn "3" >> pure True]12False
Monadic version of or.
orM [Just True, Just False]Just TrueorM [Just True, Nothing]Just TrueorM [Nothing, Just True]Nothing