有没有办法链接功能withCString?我的意思是任何看起来像的功能f :: Foo -> (CFoo -> IO a) -> IO a.
例如,假设有一个功能 cFunc :: CString -> CFoo -> CBar -> IO ()
Usualy,我会做类似的事情:
haskellFunc string foo bar =
withCString string $ \ cString ->
withCFoo foo $ \ cFoo ->
withCBar bar $ \ cBar ->
cFunc cString cFoo cBar
Run Code Online (Sandbox Code Playgroud)
但我想做的事情如下:
haskellFunc = (withCString |.| withCFoo |.| withCBar) cFunc
Run Code Online (Sandbox Code Playgroud)
与一些合适的组合操作员|.|.
我正在编写带有大量C绑定的库,这个样板经常出现.难道我做错了什么?
continuations haskell function-composition continuation-passing