[Haskell-beginners] Tips for a FFI-wrapped C library?

Stephen Tetley stephen.tetley at gmail.com
Tue Dec 1 04:50:12 EST 2009


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 at 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 })


More information about the Beginners mailing list