
On 07/11/11 11:41, Felipe Almeida Lessa wrote:
Yes, there's a documentation problem. But you can guess by the types =).
IO a: opens a new resource a. a -> IO (): disposes the given resource. Int: maximum number of open resources. Pool a -> m b: the action you want to execute; after it executes, the pool is destroyed. a -> IO Bool: check if the resource is still alive. m b: the result of running your given action with a new pool.
The key to understanding all of this is looking backwards from the result.
1) The result is m b. Where did this come from? 2) Well, there's a 'Pool a -> m b'. So it runs the action for me. So this is like a 'withFile :: FilePath -> (Handle -> IO a) -> IO a' function. 3) So if it is a 'Pool a', then the resource is of type 'a'. 4) The only function returning 'a' is 'IO a', so this creates the resource. 5) By the same reason, 'a -> IO ()' disposes it. 6) 'a -> IO Bool' is confusing, but there's a doc for that. 7) 'Int' is also confusing, but since this is a pool, this must be the maximum number of open resources.
Magic, got it =)