From 4333a88752255bdc89b193d0ef683b5dcafb984f Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Sun, 24 May 2009 00:11:19 +0100 Subject: [PATCH] Add some utility functions for kt deprecation These will be used to remove even more uses of ktn/kti in non-critical paths. --- Ganeti/HTools/Container.hs | 1 + Ganeti/HTools/Types.hs | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/Ganeti/HTools/Container.hs b/Ganeti/HTools/Container.hs index 09ab37ffc..079bc41a8 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 8bae7c3d0..2dc1a0517 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 -- GitLab