On Fri, May 09, 2014 at 04:46:20PM +0200, 'Petr Pudlak' via ganeti-devel wrote: > .. and the corresponding functions for reading/modifying them. > > The modification functions are somewhat more complex, because they need > to support that the modification function uses ConfigData and can > possibly fail (when the configuration is inconsistent). > > Signed-off-by: Petr Pudlak <[email protected]> > --- > src/Ganeti/WConfd/Monad.hs | 45 ++++++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 44 insertions(+), 1 deletion(-)
> +-- | Atomically modifies an 'IORef' using a function that can possibly fail. > +-- If it fails, the value of the 'IORef' is preserved. > +atomicModifyIORefErr :: (MonadBase IO m) > + => IORef a -> (a -> GenericResult e (a, b)) > + -> ResultT e m b > +atomicModifyIORefErr ref f = > + let f' x = genericResult ((,) x . Bad) (fmap Ok) (f x) > + in ResultT $ atomicModifyIORef ref f' Again, consider moving this function to a genric Util module. In either case: LGTM. -- Klaus Aehlig Google Germany GmbH, Dienerstr. 12, 80331 Muenchen Registergericht und -nummer: Hamburg, HRB 86891 Sitz der Gesellschaft: Hamburg Geschaeftsfuehrer: Graham Law, Christine Elizabeth Flores
