data Pipe a = On a | Off | Pass deriving Show
instance (Ord a) => Semigroup (Pipe a) where
_ <> Off = Off
Off <> _ = Off
Pass <> x = x
x <> Pass = x
(On x) <> (On y) = On (min x y) -- possibly an error
instance (Ord a) => Monoid (Pipe a) where
mempty = Pass
mappend (On x) (On y) = On (min x y)
mappend Pass x = x
mappend x Pass = x
mappend _ _ = Off
k = mconcat [On 2, On 3, Pass]