On Fri, Oct 05, 2012 at 09:46:48AM +0200, Agata Murawska wrote:
> 2012/10/5 Iustin Pop <[email protected]>:
> > The disk free/total values are optional ones, wrapped in a Maybe, so
> > we shouldn't directly serialise them. In order to simplify the
> > embedded extraction, we add a small helper function.
> >
> > Signed-off-by: Iustin Pop <[email protected]>
> > ---
> >  htools/Ganeti/Query/Node.hs |    9 +++++++--
> >  1 file changed, 7 insertions(+), 2 deletions(-)
> >
> > diff --git a/htools/Ganeti/Query/Node.hs b/htools/Ganeti/Query/Node.hs
> > index 0630754..01d0a89 100644
> > --- a/htools/Ganeti/Query/Node.hs
> > +++ b/htools/Ganeti/Query/Node.hs
> > @@ -68,6 +68,11 @@ nodeLiveFieldsDefs =
> >       "Total amount of memory of physical machine")
> >    ]
> >
> > +-- | Helper for extracting Maybe values from a possibly empty list.
> > +getMaybeJsonHead :: (J.JSON b) => [a] -> (a -> Maybe b) -> J.JSValue
> > +getMaybeJsonHead [] _ = J.JSNull
> > +getMaybeJsonHead (x:_) f = maybe J.JSNull J.showJSON (f x)
> I think this should be in JSON.hs, just in case we'd ever need that again

Thanks, make sense. Will send interdiff.

iustin

Reply via email to