Apologies - typo in copy pasted code - the last line should have been else funAction thing withNewThing :: Init_param1 -> Init_param2 -> (Thing -> IO a) -> IO a withNewThing param1 param2 funAction = bracket (newThing param1 param2) destroyThing (\thing -> do { check_null <- isNullThing thing ; if check_null then do -- SOME FAILURE -- else funAction thing }) 2009/12/1 Stephen Tetley <stephen.tetley@gmail.com>:
withNewThing :: Init_param1 -> Init_param2 -> (Thing -> IO a) -> IO a withNewThing param1 param2 funAction = bracket (newThing param1 param2) destroyThing (\thing -> do { check_null <- isNullThing thing ; if check_null then do -- SOME FAILURE -- else funAction face })