From 31aaefbc8c86e9fff93fa4fbeaec3302c4679282 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Wed, 7 Apr 2010 14:15:22 +0200 Subject: [PATCH] Add allM and anyM functions. --- "c\316\273ash/CLasH/Utils.hs" | 6 ++++++ 1 file changed, 6 insertions(+) diff --git "a/c\316\273ash/CLasH/Utils.hs" "b/c\316\273ash/CLasH/Utils.hs" index 41d7bee..2966757 100644 --- "a/c\316\273ash/CLasH/Utils.hs" +++ "b/c\316\273ash/CLasH/Utils.hs" @@ -48,6 +48,12 @@ andM, orM :: (Monad m) => m [Bool] -> m Bool andM = Monad.liftM and orM = Monad.liftM or +-- | Monadic versions of any and all. We reimplement them, since there +-- is no ready-made lifting function for them. +allM, anyM :: (Monad m) => (a -> m Bool) -> [a] -> m Bool +allM f = andM . (mapM f) +anyM f = orM . (mapM f) + mapAccumLM :: (Monad m) => (acc -> x -> m (acc, y)) -> acc -> [x] -> m (acc, [y]) mapAccumLM _ s [] = return (s, []) mapAccumLM f s (x:xs) = do -- 2.30.2