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/Property.hs') 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.3-2-g0d8e From 5e06e4d7f2e1442285060ba820df418f3508a449 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Sun, 19 Jun 2016 19:54:27 +0900 Subject: fix build on old GHC by importing Data.Foldable --- src/Propellor/Property.hs | 1 + 1 file changed, 1 insertion(+) (limited to 'src/Propellor/Property.hs') diff --git a/src/Propellor/Property.hs b/src/Propellor/Property.hs index 3fff9e04..c68dc882 100644 --- a/src/Propellor/Property.hs +++ b/src/Propellor/Property.hs @@ -54,6 +54,7 @@ import System.Posix.Files import qualified Data.Hash.MD5 as MD5 import Data.List import Control.Applicative +import Data.Foldable hiding (elem) import Prelude import Propellor.Types -- cgit v1.3-2-g0d8e From 9482099c688dbc90b60d0f12cb55a5705e5e74d5 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Sun, 19 Jun 2016 20:02:49 +0900 Subject: clean build on GHC 7.10 --- src/Propellor/Property.hs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/Propellor/Property.hs') diff --git a/src/Propellor/Property.hs b/src/Propellor/Property.hs index c68dc882..fe314941 100644 --- a/src/Propellor/Property.hs +++ b/src/Propellor/Property.hs @@ -54,8 +54,8 @@ import System.Posix.Files import qualified Data.Hash.MD5 as MD5 import Data.List import Control.Applicative -import Data.Foldable hiding (elem) -import Prelude +import Data.Foldable (Foldable, foldr1) +import Prelude hiding (Foldable) import Propellor.Types import Propellor.Types.Core @@ -349,7 +349,7 @@ applyToList => (b -> p) -> t b -> p -prop `applyToList` xs = foldr1 before $ prop <$> xs +prop `applyToList` xs = Data.Foldable.foldr1 before $ prop <$> xs makeChange :: IO () -> Propellor Result makeChange a = liftIO a >> return MadeChange -- cgit v1.3-2-g0d8e