bracket
:: IO a -- ^ computation to run first (\"acquire resource\")
-> (a -> IO b) -- ^ computation to run last (\"release resource\")
-> (a -> IO c) -- ^ computation to run in-between
-> IO c -- returns the value from the in-between computation
bracket before after thing =
mask $ \restore -> do
a <- before
r <- restore (thing a) `onException` after a
_ <- after a
return r这是否与某些API设计模式或约定有关?为什么不使用签名的以下部分?
-> (a -> IO ()) -- ^ computation to run last (empty result)或
-> (a -> IO a) -- ^ computation to run last (`a` cannot be ignored)https://stackoverflow.com/questions/38421682
复制相似问题