From 19a0a53469ad5288fa6688f5e140994a3be63f8e Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 11 Nov 2017 21:33:26 -0400 Subject: Added Propellor.Property.impossible --- debian/changelog | 1 + src/Propellor/Property.hs | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/debian/changelog b/debian/changelog index 06a333be..177dde38 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,6 +2,7 @@ propellor (4.9.1) UNRELEASED; urgency=medium * Add Typeable instance to OriginUrl, fixing build with old versions of ghc. + * Added Propellor.Property.impossible -- Joey Hess Thu, 02 Nov 2017 10:28:44 -0400 diff --git a/src/Propellor/Property.hs b/src/Propellor/Property.hs index 55e688ab..884ee683 100644 --- a/src/Propellor/Property.hs +++ b/src/Propellor/Property.hs @@ -32,6 +32,7 @@ module Propellor.Property ( , makeChange , noChange , doNothing + , impossible , endAction -- * Property result checking , UncheckedProperty @@ -62,6 +63,7 @@ import Propellor.Types.ResultCheck import Propellor.Types.MetaTypes import Propellor.Types.Singletons import Propellor.Info +import Propellor.Message import Propellor.EnsureProperty import Utility.Exception import Utility.Monad @@ -364,6 +366,12 @@ noChange = return NoChange doNothing :: SingI t => Property (MetaTypes t) doNothing = mempty +-- | In situations where it's not possible to provide a property that +-- works, this can be used to make a property that always fails with an +-- error message you provide. +impossible :: SingI t => String -> Property (MetaTypes t) +impossible msg = property "impossible" $ errorMessage msg + -- | Registers an action that should be run at the very end, after -- propellor has checks all the properties of a host. endAction :: Desc -> (Result -> Propellor Result) -> Propellor () -- cgit v1.2.3