summaryrefslogtreecommitdiff
path: root/src/Propellor/Property.hs
diff options
context:
space:
mode:
authorJoey Hess2016-03-07 21:51:25 -0400
committerJoey Hess2016-03-07 21:54:22 -0400
commite7c7adc0c4cdc838eada045334b038c7f01dcc56 (patch)
tree85969e8f9bdc8b0d61279956cf5793f493a54ccb /src/Propellor/Property.hs
parent6d50ff845e5180a88e7c82c309a483f0a564eb26 (diff)
add unsupportedOS
Diffstat (limited to 'src/Propellor/Property.hs')
-rw-r--r--src/Propellor/Property.hs11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/Propellor/Property.hs b/src/Propellor/Property.hs
index fe99a3fd..b6b8dc0d 100644
--- a/src/Propellor/Property.hs
+++ b/src/Propellor/Property.hs
@@ -20,6 +20,7 @@ module Propellor.Property (
, property
, ensureProperty
, withOS
+ , unsupportedOS
, makeChange
, noChange
, doNothing
@@ -256,10 +257,18 @@ isNewerThan x y = do
-- > myproperty = withOS "foo installed" $ \o -> case o of
-- > (Just (System (Debian suite) arch)) -> ...
-- > (Just (System (Buntish release) arch)) -> ...
--- > Nothing -> ...
+-- > Nothing -> unsupportedOS
withOS :: Desc -> (Maybe System -> Propellor Result) -> Property NoInfo
withOS desc a = property desc $ a =<< getOS
+-- | Throws an error, for use in `withOS` when a property is lacking
+-- support for an OS.
+unsupportedOS :: Propellor a
+unsupportedOS = go =<< getOS
+ where
+ go Nothing = error "Unknown host OS is not supported by this property."
+ go (Just o) = error $ "This property is not implemented for " ++ show o
+
-- | Undoes the effect of a RevertableProperty.
revert :: RevertableProperty i -> RevertableProperty i
revert (RevertableProperty p1 p2) = RevertableProperty p2 p1