Generic I/O

Simon Marlow simonmar at
Fri Oct 22 11:41:27 EDT 2004

On 22 October 2004 14:32, John Goerzen wrote:

> I'm not quite sure how to describe this concept in Haskell, so let me
> first start by describing a feature of Python I find very useful.
> In Python, a file handle is just another object.  It has certain
> methods that Python programmers expect to find: read(), readlines(),
> write(), writelines(), seek(), tell(), etc.  This is useful because
> even things do not correspond to OS-level file descriptors can be
> accessed as files. In Python, this is used so that a file-like
> interface is available for gzip/gunzip interfaces, strings, SSL
> connections, bzip2, files from FTP, etc.  That means that almost any
> function designed to work with an on-disk file could also work
> transparently read from a gzipped file, a string, etc.
> I think it would be useful to have this sort of abstraction in
> Haskell. However, I can't really see any way to tie into the Handle
> system; from what I can tell, it seems to be hooked in with the
> underlying OS at a fairly low level.

The Stream API can provide this kind of abstraction.  This is a
partly-baked proposal for a replacement IO library for Haskell, which
grew out of some discussion on this list last year.  There's a partial
implementation here:

The idea was to provide an extensible stream abstraction, as well as
provide proper support for text encodings (i18n).

Work on this library is currently stalled.  If you'd like to pick it up,
you're entirely welcome.


More information about the Libraries mailing list