> This can be used to call into C code expecting pointer input or output > types to great effect: > > wrapperAroundForeignCode :: InputType -> IO OutputType > wrapperAroundForeignCode in = > alloca $ \inPtr -> > alloca $ outPtr -> do > poke inPtr in > c_call inPtr outPtr > peek outPtr
There is also 'with' (:: Storable a => a -> (Ptr a -> IO b) -> IO b), which is exactly the combination of 'alloca' and 'poke' you use on 'in'. Erik _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe