Since the function returns only 0 or 1 result, I'd slightly prefer to return `Maybe JobId` (just as toMetaOpCode in the next patch), even if it means adding maybeToList at other places. But if you prefer to use lists, we can leave it as it is.
Otherwise LGTM On Thu, Apr 10, 2014 at 11:57 AM, Klaus Aehlig <[email protected]> wrote: > Add a function that extracts the job id, if given in absolute > form, from a job dependency. > > Signed-off-by: Klaus Aehlig <[email protected]> > --- > src/Ganeti/Types.hs | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/src/Ganeti/Types.hs b/src/Ganeti/Types.hs > index 6fe1fff..9bac047 100644 > --- a/src/Ganeti/Types.hs > +++ b/src/Ganeti/Types.hs > @@ -111,6 +111,7 @@ module Ganeti.Types > , JobIdDep(..) > , JobDependency(..) > , absoluteJobDependency > + , getJobIdFromDependency > , OpSubmitPriority(..) > , opSubmitPriorityToRaw > , parseSubmitPriority > @@ -706,6 +707,12 @@ absoluteJobDependency :: (Monad m) => JobDependency > -> JobId -> m JobDependency > absoluteJobDependency (JobDependency jdep fstats) jid = > liftM (flip JobDependency fstats) $ absoluteJobIdDep jdep jid > > +-- | From a job dependency get the absolute job id it depends on, > +-- if given absolutely. > +getJobIdFromDependency :: JobDependency -> [JobId] > +getJobIdFromDependency (JobDependency (JobDepAbsolute jid) _) = [jid] > +getJobIdFromDependency _ = [] > + > -- | Valid opcode priorities for submit. > $(THH.declareIADT "OpSubmitPriority" > [ ("OpPrioLow", 'ConstantUtils.priorityLow) > -- > 1.9.1.423.g4596e3a > >
