    {-# LANGUAGE DeriveDataTypeable #-}

    module Propellor.Types.Docker where

    import Propellor.Types
    import Propellor.Types.Empty
    import Propellor.Types.Info

    import qualified Data.Semigroup as Sem
    import qualified Data.Map as M
    import Data.Monoid
    import Prelude

    data DockerInfo = DockerInfo
    	{ DockerInfo -> [DockerRunParam]
    _dockerRunParams :: [DockerRunParam]
    	, DockerInfo -> Map String Host
    _dockerContainers :: M.Map String Host
    	}
    	deriving (Int -> DockerInfo -> ShowS
    [DockerInfo] -> ShowS
    DockerInfo -> String
    (Int -> DockerInfo -> ShowS)
    -> (DockerInfo -> String)
    -> ([DockerInfo] -> ShowS)
    -> Show DockerInfo
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    showList :: [DockerInfo] -> ShowS
    $cshowList :: [DockerInfo] -> ShowS
    show :: DockerInfo -> String
    $cshow :: DockerInfo -> String
    showsPrec :: Int -> DockerInfo -> ShowS
    $cshowsPrec :: Int -> DockerInfo -> ShowS
    Show, Typeable)

    instance IsInfo DockerInfo where
    	propagateInfo :: DockerInfo -> PropagateInfo
    propagateInfo _ = Bool -> PropagateInfo
    PropagateInfo Bool
    False

    instance Sem.Semigroup DockerInfo where
    	old :: DockerInfo
    old <> :: DockerInfo -> DockerInfo -> DockerInfo
    <> new :: DockerInfo
    new = DockerInfo :: [DockerRunParam] -> Map String Host -> DockerInfo
    DockerInfo
    		{ _dockerRunParams :: [DockerRunParam]
    _dockerRunParams = DockerInfo -> [DockerRunParam]
    _dockerRunParams DockerInfo
    old [DockerRunParam] -> [DockerRunParam] -> [DockerRunParam]
    forall a. Semigroup a => a -> a -> a
    <> DockerInfo -> [DockerRunParam]
    _dockerRunParams DockerInfo
    new
    		, _dockerContainers :: Map String Host
    _dockerContainers = Map String Host -> Map String Host -> Map String Host
    forall k a. Ord k => Map k a -> Map k a -> Map k a
    M.union (DockerInfo -> Map String Host
    _dockerContainers DockerInfo
    old) (DockerInfo -> Map String Host
    _dockerContainers DockerInfo
    new)
    		}

    instance Monoid DockerInfo where
    	mempty :: DockerInfo
    mempty = [DockerRunParam] -> Map String Host -> DockerInfo
    DockerInfo [DockerRunParam]
    forall a. Monoid a => a
    mempty Map String Host
    forall a. Monoid a => a
    mempty
    	mappend :: DockerInfo -> DockerInfo -> DockerInfo
    mappend = DockerInfo -> DockerInfo -> DockerInfo
    forall a. Semigroup a => a -> a -> a
    (Sem.<>)

    instance Empty DockerInfo where
    	isEmpty :: DockerInfo -> Bool
    isEmpty i :: DockerInfo
    i = [Bool] -> Bool
    forall (t :: * -> *). Foldable t => t Bool -> Bool
    and
    		[ [DockerRunParam] -> Bool
    forall t. Empty t => t -> Bool
    isEmpty (DockerInfo -> [DockerRunParam]
    _dockerRunParams DockerInfo
    i)
    		, Map String Host -> Bool
    forall t. Empty t => t -> Bool
    isEmpty (DockerInfo -> Map String Host
    _dockerContainers DockerInfo
    i)
    		]

    newtype DockerRunParam = DockerRunParam (HostName -> String)

    instance Show DockerRunParam where
    	show :: DockerRunParam -> String
    show (DockerRunParam a :: ShowS
    a) = ShowS
    a ""