summaryrefslogtreecommitdiff
path: root/src/Propellor/Types
diff options
context:
space:
mode:
authorJoey Hess2016-03-16 14:12:41 -0400
committerJoey Hess2016-03-16 14:12:41 -0400
commit199d10fe18d69f7eac1b2acbc0133d35c42ff2b8 (patch)
tree4ce83ebda5b26e6d965f0def31b478000926386c /src/Propellor/Types
parent83359452a84ffcc71cf755168c064f6c5a5c6dd8 (diff)
wip
Diffstat (limited to 'src/Propellor/Types')
-rw-r--r--src/Propellor/Types/Target.hs23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/Propellor/Types/Target.hs b/src/Propellor/Types/Target.hs
index 9e78a03a..228aae70 100644
--- a/src/Propellor/Types/Target.hs
+++ b/src/Propellor/Types/Target.hs
@@ -33,6 +33,22 @@ target
=> Targeting newtarget -> Property (Targeting oldtarget) -> Property (Targeting newtarget')
target newtarget (Property oldtarget a) = Property (intersectTarget oldtarget newtarget) a
+-- | Makes a property that uses either of the two input properties,
+-- depending on the targeted OS.
+--
+-- If both input properties support the targeted OS, then the first will be
+-- used.
+orProperty
+ :: Property (Targeting a)
+ -> Property (Targeting b)
+ -> Property (Targeting (UnionTarget a b))
+orProperty a@(Property ta ioa) b@(Property tb iob) =
+ Property (unionTarget ta tb) io
+ where
+ -- TODO pick with of ioa or iob to use based on final OS of
+ -- system being run on.
+ io = undefined
+
----- DEMO ----------
-- Intentionally a type error! :)
--foo :: Property (Targeting '[OSDebian, OSFreeBSD])
@@ -40,6 +56,13 @@ target newtarget (Property oldtarget a) = Property (intersectTarget oldtarget ne
-- ensureProperty supportedos jail
-- where supportedos = includeTarget debian freeBSD
+--bar :: Property (Targeting '[OSDebian, OSFreeBSD])
+bar = aptinstall `orProperty` jail
+
+aptinstall :: Property DebianOnly
+aptinstall = target debian $ mkProperty $ do
+ return ()
+
jail :: Property FreeBSDOnly
jail = target freeBSD $ mkProperty $ do
return ()