summaryrefslogtreecommitdiff
path: root/src/Propellor/Types/Container.hs
diff options
context:
space:
mode:
authorJoey Hess2015-06-01 23:16:25 -0400
committerJoey Hess2015-06-01 23:16:25 -0400
commit765367dab9b61a512e07268c921f950677af4f27 (patch)
treee721bcd464c0b9dbe619304b6995c40e1dfeb2f6 /src/Propellor/Types/Container.hs
parent6241a16772649d3b918085ec4f113665fcf53459 (diff)
add Bound
Diffstat (limited to 'src/Propellor/Types/Container.hs')
-rw-r--r--src/Propellor/Types/Container.hs30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/Propellor/Types/Container.hs b/src/Propellor/Types/Container.hs
new file mode 100644
index 00000000..d21bada7
--- /dev/null
+++ b/src/Propellor/Types/Container.hs
@@ -0,0 +1,30 @@
+{-# LANGUAGE TypeFamilies #-}
+
+module Propellor.Types.Container where
+
+-- | A value that can be bound between the host and a container.
+--
+-- For example, a Bound Port is a Port on the container that is bound to
+-- a Port on the host.
+data Bound v = Bound
+ { hostSide :: v
+ , containerSide :: v
+ }
+
+-- | Create a Bound value, from two different values for the host and
+-- container.
+--
+-- For example, @Port 8080 -<- Port 80@ means that port 8080 on the host
+-- is bound to port 80 from the container.
+(-<-) :: (hostv ~ v, containerv ~ v) => hostv -> containerv -> Bound v
+(-<-) hostv containerv = Bound hostv containerv
+
+-- | Flipped version of -<- with the container value first and host value
+-- second.
+(->-) :: (containerv ~ v, hostv ~ v) => hostv -> containerv -> Bound v
+(->-) containerv hostv = Bound hostv containerv
+
+-- | Create a Bound value, that is the same on both the host and container.
+same :: v -> Bound v
+same v = Bound v v
+