diff --git a/Ganeti/HTools/Container.hs b/Ganeti/HTools/Container.hs index 09ab37ffc165ede373efcd8710927797390c8e53..079bc41a849c1c683951423086c5d5de56e7e3b7 100644 --- a/Ganeti/HTools/Container.hs +++ b/Ganeti/HTools/Container.hs @@ -9,6 +9,7 @@ module Ganeti.HTools.Container ( -- * Types Container + , Key -- * Creation , empty , fromAssocList diff --git a/Ganeti/HTools/Types.hs b/Ganeti/HTools/Types.hs index 8bae7c3d038c8e444f880a85ef743a427c1e2b7b..2dc1a05173824155d4fde111c9bf83881ae67195 100644 --- a/Ganeti/HTools/Types.hs +++ b/Ganeti/HTools/Types.hs @@ -60,3 +60,11 @@ instance Element Instance.Instance where idx = Instance.idx setName = Instance.setName setIdx = Instance.setIdx + +-- | Compute the name of an element in a container +cNameOf :: (Element a) => Container.Container a -> Container.Key -> String +cNameOf c k = name $ Container.find k c + +-- | Compute the maximum name length in an Element Container +cMaxNamelen :: (Element a) => Container.Container a -> Int +cMaxNamelen = maximum . map (length . name) . Container.elems