
1 Dec
2009
1 Dec
'09
9:46 a.m.
Hi Patrick One thing you can do is use `bracket` to manage the lifetime of objects created on the C side: 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 }) -- newThing destroyThing isNullThing are defined somewhere. This might be appropriate for the Context, Language etc. objects in your library. For the documentation on bracket see Control.Exception.Base. Best wishes Stephen