From 472759eef32534fd1f1e14bb05f5cb97b18de760 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 15 Mar 2017 15:36:29 -0400 Subject: Added Monoid instances for Property and RevertableProperty. * Added Monoid instances for Property and RevertableProperty. * Removed applyToList. Instead, use mconcat. (API change) Eg, if you had: applyToList accountFor [User "joey", User "root"] use instead: mconcat (map accountFor [User "joey", User "root"]) mappend x y is basically the same as x `before` y. In particular, if x fails to be ensured, it won't ensure y. This seems to make sense, since applyToList had that behavior, and so does the Monoid for Propellor Result. The alternative would be to try to ensure both and combine the results. However, I don't see any reason to do it that way. It would be nice if the description of both properties were displayed when ensuring the combination. But then, it would need to display eg: ensuring x..ok ensuring y..failed ensuring x and ensuring y..failed Without a way to get rid of that redundant last line, I don't want to do that. Note that the haddocks for the Monoid instances need a really wide screen to display! This is IMHO an infelicity in haddock, and I can't do anything about it really. This commit was sponsored by Fernando Jimenez on Patreon. --- src/Propellor/Property.hs | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) (limited to 'src/Propellor/Property.hs') diff --git a/src/Propellor/Property.hs b/src/Propellor/Property.hs index 1a40bb75..706e684b 100644 --- a/src/Propellor/Property.hs +++ b/src/Propellor/Property.hs @@ -16,7 +16,6 @@ module Propellor.Property ( , check , fallback , revert - , applyToList -- * Property descriptions , describe , (==>) @@ -54,7 +53,6 @@ import System.Posix.Files import qualified Data.Hash.MD5 as MD5 import Data.List import Control.Applicative -import Data.Foldable hiding (and, elem) import Prelude import Propellor.Types @@ -353,14 +351,6 @@ 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, Combines p p, p ~ CombinedType p p) - => (b -> p) - -> t b - -> p -prop `applyToList` xs = Data.Foldable.foldr1 before $ prop <$> xs - makeChange :: IO () -> Propellor Result makeChange a = liftIO a >> return MadeChange @@ -368,7 +358,7 @@ noChange :: Propellor Result noChange = return NoChange doNothing :: SingI t => Property (MetaTypes t) -doNothing = property'' "noop property" Nothing +doNothing = mempty -- | Registers an action that should be run at the very end, after -- propellor has checks all the properties of a host. -- cgit v1.2.3