On Wed, Dec 1, 2010 at 14:47, Iustin Pop <[email protected]> wrote:
> The type alias NameAssoc has been introduced a long time ago, but there
> are some few not-yet-converted cases. In preparation for changes to that
> type, let's make sure we use it consistently.
> ---
> Ganeti/HTools/Loader.hs | 6 +++---
> Ganeti/HTools/Luxi.hs | 2 +-
> Ganeti/HTools/Rapi.hs | 4 ++--
> Ganeti/HTools/Text.hs | 4 ++--
> 4 files changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/Ganeti/HTools/Loader.hs b/Ganeti/HTools/Loader.hs
> index a0db67a..30a2614 100644
> --- a/Ganeti/HTools/Loader.hs
> +++ b/Ganeti/HTools/Loader.hs
> @@ -7,7 +7,7 @@ has been loaded from external sources.
>
> {-
>
> -Copyright (C) 2009 Google Inc.
> +Copyright (C) 2009, 2010 Google Inc.
>
> This program is free software; you can redistribute it and/or modify
> it under the terms of the GNU General Public License as published by
> @@ -76,14 +76,14 @@ data Request = Request RqType Node.List Instance.List
> [String]
> -- * Functions
>
> -- | Lookups a node into an assoc list.
> -lookupNode :: (Monad m) => [(String, Ndx)] -> String -> String -> m Ndx
> +lookupNode :: (Monad m) => NameAssoc -> String -> String -> m Ndx
> lookupNode ktn inst node =
> case lookup node ktn of
> Nothing -> fail $ "Unknown node '" ++ node ++ "' for instance " ++
> inst
> Just idx -> return idx
>
> -- | Lookups an instance into an assoc list.
> -lookupInstance :: (Monad m) => [(String, Idx)] -> String -> m Idx
> +lookupInstance :: (Monad m) => NameAssoc -> String -> m Idx
> lookupInstance kti inst =
> case lookup inst kti of
> Nothing -> fail $ "Unknown instance '" ++ inst ++ "'"
> diff --git a/Ganeti/HTools/Luxi.hs b/Ganeti/HTools/Luxi.hs
> index d17fcab..24441b3 100644
> --- a/Ganeti/HTools/Luxi.hs
> +++ b/Ganeti/HTools/Luxi.hs
> @@ -85,7 +85,7 @@ getInstances :: NameAssoc
> getInstances ktn arr = toArray arr >>= mapM (parseInstance ktn)
>
> -- | Construct an instance from a JSON object.
> -parseInstance :: [(String, Ndx)]
> +parseInstance :: NameAssoc
> -> JSValue
> -> Result (String, Instance.Instance)
> parseInstance ktn (JSArray [ name, disk, mem, vcpus
> diff --git a/Ganeti/HTools/Rapi.hs b/Ganeti/HTools/Rapi.hs
> index 84332f6..37ac578 100644
> --- a/Ganeti/HTools/Rapi.hs
> +++ b/Ganeti/HTools/Rapi.hs
> @@ -4,7 +4,7 @@
>
> {-
>
> -Copyright (C) 2009 Google Inc.
> +Copyright (C) 2009, 2010 Google Inc.
>
> This program is free software; you can redistribute it and/or modify
> it under the terms of the GNU General Public License as published by
> @@ -75,7 +75,7 @@ getNodes body = loadJSArray "Parsing node data" body >>=
> mapM (parseNode . fromJSObject)
>
> -- | Construct an instance from a JSON object.
> -parseInstance :: [(String, Ndx)]
> +parseInstance :: NameAssoc
> -> [(String, JSValue)]
> -> Result (String, Instance.Instance)
> parseInstance ktn a = do
> diff --git a/Ganeti/HTools/Text.hs b/Ganeti/HTools/Text.hs
> index e61014d..242620e 100644
> --- a/Ganeti/HTools/Text.hs
> +++ b/Ganeti/HTools/Text.hs
> @@ -113,7 +113,7 @@ loadNode s = fail $ "Invalid/incomplete node data: '"
> ++ show s ++ "'"
>
> -- | Load an instance from a field list.
> loadInst :: (Monad m) =>
> - [(String, Ndx)] -> [String] -> m (String, Instance.Instance)
> + NameAssoc -> [String] -> m (String, Instance.Instance)
> loadInst ktn [name, mem, dsk, vcpus, status, pnode, snode, tags] = do
> pidx <- lookupNode ktn name pnode
> sidx <- (if null snode then return Node.noSecondary
> @@ -135,7 +135,7 @@ loadInst _ s = fail $ "Invalid/incomplete instance
> data: '" ++ show s ++ "'"
> -- a supplied conversion function.
> loadTabular :: (Monad m, Element a) =>
> [String] -> ([String] -> m (String, a))
> - -> m ([(String, Int)], [(Int, a)])
> + -> m (NameAssoc, [(Int, a)])
> loadTabular lines_data convert_fn = do
> let rows = map (sepSplit '|') lines_data
> kerows <- mapM convert_fn rows
> --
> 1.7.2.3
>
>
LGTM