I Hate IO

Marcin 'Qrczak' Kowalczyk qrczak@knm.org.pl
13 Aug 2001 15:29:58 GMT

Fri, 10 Aug 2001 18:31:24 -0700, Ashley Yakeley <ashley@semantic.org> pisze:

> I can only tell you what's useful for me as an API user. Since there are 
> peculiar little differences between different kinds of sockets, my ideal 
> would be every type of socket to have its own API functions, and then 
> common patterns brought together with classes.

It makes harder to program polymorphically. In particular having
a heterogeneous datastructure requires wrapping different types
in either function closures or existential types, thus awkwardly
emulating the current interface.

Items which are used interchangeably shouldn't have different types
in a language like Haskell which doesn't provide subtyping. Too bad
that one can't make his own object with type Handle and arbitrary
behavior. It means that even Handle is a type too much tied to the

> But at the very least, separate out files from sockets. I'm really
> not sure why files have a "file pointer" stream-based API at all.

Because it's convenient. Files are usually read sequentially.

Would you separate terminals from these? Terminals are sequential by
nature and they are used interchangeably with files. How would you
express this in your interface?

    f <- if filename == "-" then return stdin
                            else openFile filename ReadMode

 __("<  Marcin Kowalczyk * qrczak@knm.org.pl http://qrczak.ids.net.pl/
  ^^                      SYGNATURA ZASTĘPCZA