From 0e452bb50b4718829b904af4ee26c8a4d77abea1 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Thu, 16 Jun 2016 21:17:21 +0900 Subject: applyToList combinator I think Joey wrote this at some point .. though it's possible I did --- src/Propellor/Property.hs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/Propellor') diff --git a/src/Propellor/Property.hs b/src/Propellor/Property.hs index af36ed58..3fff9e04 100644 --- a/src/Propellor/Property.hs +++ b/src/Propellor/Property.hs @@ -16,6 +16,7 @@ module Propellor.Property ( , check , fallback , revert + , applyToList -- * Property descriptions , describe , (==>) @@ -341,6 +342,14 @@ unsupportedOS' = go =<< getOS revert :: RevertableProperty setup undo -> RevertableProperty undo setup revert (RevertableProperty p1 p2) = RevertableProperty p2 p1 +-- | Apply a property to each element of a list. +applyToList + :: (Foldable t, Functor t, IsProp p, Combines p p, p ~ CombinedType p p) + => (b -> p) + -> t b + -> p +prop `applyToList` xs = foldr1 before $ prop <$> xs + makeChange :: IO () -> Propellor Result makeChange a = liftIO a >> return MadeChange -- cgit v1.2.3