Added a foldM1 function to the Utils module
This commit is contained in:
parent
009cf8cc8b
commit
d2fb80c516
|
@ -393,3 +393,8 @@ liftWrapStateT wrap m
|
|||
(x, st') <- lift $ wrap (runStateT m st)
|
||||
put st'
|
||||
return x
|
||||
|
||||
-- The foldM equivalent of foldl1:
|
||||
foldM1 :: Monad m => (a -> a -> m a) -> [a] -> m a
|
||||
foldM1 f (x:xs) = foldM f x xs
|
||||
foldM1 _ [] = fail "Empty list in foldM1"
|
||||
|
|
Loading…
Reference in New Issue
Block a user