News aggregator

Error handling in acid-state

Haskell on Reddit - Mon, 01/05/2015 - 3:46am

Using Exceptions as a general error handling strategy within an acid-state update/query won't work, read the point about stateNestedError1 here.

Until now I have been using the following pattern for error handling:

type MyUpdate st e a = StateT st (Either e) a runMyUpdate :: MyUpdate st e a -> Update st (Either e a) runMyUpdate act = do s <- get case runStateT act s of Left e -> return $ Left e Right (x,s') -> do put s' return $ Right x setVal' :: Int -> MyUpdate Int String () setVal' 5 = throwError "wrong number" setVal' x = put x setVal :: Int -> Update Int (Either String ()) setVal = runMyUpdate . setVal' makeAcidic ''Int ['setVal]

But I realize that this will still write the failing update to the event log, so you will have a lot of transactions in the log that don't modify the state. An alternative would be for runMyUpdate to throw an Exception instead (this will be ok since the exception is not nested).

What error handling strategies are other acid-state users using?

submitted by ttfh
[link] [5 comments]
Categories: Incoming News

www.jdon.com

del.icio.us/haskell - Sun, 01/04/2015 - 1:02am
Categories: Offsite Blogs

New gtk2hs 0.12.4 release

gtk2hs - Wed, 11/21/2012 - 12:56pm

Thanks to John Lato and Duncan Coutts for the latest bugfix release! The latest packages should be buildable on GHC 7.6, and the cairo package should behave a bit nicer in ghci on Windows. Thanks to all!

~d

Categories: Incoming News