summaryrefslogtreecommitdiff
path: root/src/Propellor/Property/Versioned.hs
diff options
context:
space:
mode:
authorJoey Hess2017-07-17 16:51:22 -0400
committerJoey Hess2017-07-17 16:51:22 -0400
commit940a2a58204a376cc15c6cd0bcd76d975ec8562e (patch)
tree588b3929ad9d45cf02ba6d78b6cac7950a88503a /src/Propellor/Property/Versioned.hs
parente388963b85cb94a21f22ee90bcc2228953dac2d3 (diff)
Generate a better description for versioned properties.
Diffstat (limited to 'src/Propellor/Property/Versioned.hs')
-rw-r--r--src/Propellor/Property/Versioned.hs24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/Propellor/Property/Versioned.hs b/src/Propellor/Property/Versioned.hs
index 58d3e8d5..87673c64 100644
--- a/src/Propellor/Property/Versioned.hs
+++ b/src/Propellor/Property/Versioned.hs
@@ -55,6 +55,9 @@
module Propellor.Property.Versioned (Versioned, version, (-->), (<|>)) where
import Propellor
+import Propellor.Types.Core
+
+import Data.List
-- | Something that has multiple versions of type `v`.
type Versioned v t = VersionedBy v -> t
@@ -89,12 +92,21 @@ processVerSpec
=> v
-> VerSpec v metatypes
-> RevertableProperty metatypes metatypes
-processVerSpec v (Base (c, p))
- | c v = p
- | otherwise = revert p
-processVerSpec v (More (c, p) vs)
- | c v = processVerSpec v vs `before` p
- | otherwise = revert p `before` processVerSpec v vs
+processVerSpec v s = combinedp s
+ `describe` intercalate " and " (combineddesc s [])
+ where
+ combinedp (Base (c, p))
+ | c v = p
+ | otherwise = revert p
+ combinedp (More (c, p) vs)
+ | c v = combinedp vs `before` p
+ | otherwise = revert p `before` combinedp vs
+ combineddesc (Base (c, p)) l
+ | c v = getDesc p : l
+ | otherwise = getDesc (revert p) : l
+ combineddesc (More (c, p) vs) l
+ | c v = getDesc p : combineddesc vs l
+ | otherwise = getDesc (revert p) : combineddesc vs l
-- | Specify a function that checks the version, and what
-- `RevertableProperty` to use if the version matches.