2012/10/5 Iustin Pop <[email protected]>: > … and also use it to simplify 'needsLiveData'. Additionally, add an > explicit export list to Ganeti.Query.Types, since otherwise we'd > (re)export all imported symbols. > --- > htools/Ganeti/Query/Query.hs | 4 +--- > htools/Ganeti/Query/Types.hs | 13 ++++++++++++- > 2 files changed, 13 insertions(+), 4 deletions(-) > > diff --git a/htools/Ganeti/Query/Query.hs b/htools/Ganeti/Query/Query.hs > index 9dfcfa4..9edbb4d 100644 > --- a/htools/Ganeti/Query/Query.hs > +++ b/htools/Ganeti/Query/Query.hs > @@ -116,9 +116,7 @@ maybeCollectLiveData True cfg nodes = do > > -- | Check whether list of queried fields contains live fields. > needsLiveData :: [FieldGetter a b] -> Bool > -needsLiveData = any (\getter -> case getter of > - FieldRuntime _ -> True > - _ -> False) > +needsLiveData = any isRuntimeField > > -- | Checks whether we have requested exactly some names. This is a > -- simple wrapper over 'requestedNames' and 'nameField'. > diff --git a/htools/Ganeti/Query/Types.hs b/htools/Ganeti/Query/Types.hs > index 175dfa5..42300b2 100644 > --- a/htools/Ganeti/Query/Types.hs > +++ b/htools/Ganeti/Query/Types.hs > @@ -26,7 +26,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, > MA > > -} > > -module Ganeti.Query.Types where > +module Ganeti.Query.Types > + ( FieldGetter(..) > + , FieldData > + , FieldList > + , FieldMap > + , isRuntimeField > + ) where > > import qualified Data.Map as Map > > @@ -52,3 +58,8 @@ type FieldList a b = [FieldData a b] > > -- | Alias for field maps. > type FieldMap a b = Map.Map String (FieldData a b) > + > +-- | Helper function to check if a getter is a runtime one. > +isRuntimeField :: FieldGetter a b -> Bool > +isRuntimeField (FieldRuntime _) = True > +isRuntimeField _ = False > -- > 1.7.10.4 >
LGTM
