[Haskell] Re: ANN: HDBC (Haskell Database Connectivity)

Krasimir Angelov kr.angelov at gmail.com
Tue Jan 10 03:16:09 EST 2006

2006/1/10, oleg at pobox.com <oleg at pobox.com>:
> It seems using types to enforce the policy that a data base handle
> cannot ever `leak' out might be a better idea, in Haskell. It is quite
> straight-forward to do so: cf. the design of the ST monad guarantees
> that an STRef cannot `leak' out in the result of runST. Monadic
> Regions (implemented in Haskell) generalize the idea to multiple
> nested regions: a pointer (or any other resource, e.g., a database
> cursor) allocated in one region can be used in nested regions but
> cannot leak outside of the region that created it (Or, to be more
> precise, cannot be used outside -- and so, can be safely deallocated
> when the region is exited).

This might be a good idea.

> Incidentally, the difficulty with finalizers was precisely the
> argument for using enumerators rather than cursors in database
> APIs. Takusen has implemented that idea; takusen currently supports
> Sqlite, PostgreSQL and Oracle, has a test suite. Its performance test
> shows that takusen can retrieve 2 million rows from a table without
> running out of memory.

Can you explain how do you manage the lifetime of handles in Takusen?
It isn't clear to me where are the advantages of enumerators.


More information about the Haskell mailing list