From 42da8445470a6e4950873fc5d6bea88646ec2b63 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 26 Mar 2016 18:54:18 -0400 Subject: got rid of the undefined in privdata addInfoProperty' is like addInfoProperty but for when the input property is already known to HasInfo. --- src/Propellor/PrivData.hs | 6 +----- src/Propellor/Types.hs | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/Propellor/PrivData.hs b/src/Propellor/PrivData.hs index 5e6e0869..77c7133f 100644 --- a/src/Propellor/PrivData.hs +++ b/src/Propellor/PrivData.hs @@ -127,11 +127,7 @@ withPrivData' feed srclist c mkprop = addinfo $ mkprop $ \a -> "Fix this by running:" : showSet (map (\s -> (privDataField s, Context cname, describePrivDataSource s)) srclist) return FailedChange - addinfo p = Property undefined -- FIXME: should use sing here - (propertyDesc p) - (getSatisfy p) - (propertyInfo p `addInfo` privset) - (propertyChildren p) + addinfo p = p `addInfoProperty'` (toInfo privset) privset = PrivInfo $ S.fromList $ map (\s -> (privDataField s, describePrivDataSource s, hc)) srclist fieldnames = map show fieldlist diff --git a/src/Propellor/Types.hs b/src/Propellor/Types.hs index 4b3f665a..ccbfd3e0 100644 --- a/src/Propellor/Types.hs +++ b/src/Propellor/Types.hs @@ -25,6 +25,8 @@ module Propellor.Types , HasInfo , type (+) , addInfoProperty + , addInfoProperty' + , addChildrenProperty , adjustPropertySatisfy , propertyInfo , propertyDesc @@ -159,6 +161,19 @@ addInfoProperty addInfoProperty (Property _ d a oldi c) newi = Property sing d a (oldi <> newi) c +-- | Adds more info to a Property that already HasInfo. +addInfoProperty' + :: (IncludesInfo metatypes ~ 'True) + => Property metatypes + -> Info + -> Property metatypes +addInfoProperty' (Property t d a oldi c) newi = + Property t d a (oldi <> newi) c + +-- | Adds children to a Property. +addChildrenProperty :: Property metatypes -> [ChildProperty] -> Property metatypes +addChildrenProperty (Property t s a i cs) cs' = Property t s a i (cs ++ cs') + -- | Changes the action that is performed to satisfy a property. adjustPropertySatisfy :: Property metatypes -> (Propellor Result -> Propellor Result) -> Property metatypes adjustPropertySatisfy (Property t d s i c) f = Property t d (f s) i c -- cgit v1.3-2-g0d8e