"interact" behaves oddly if used interactively
Olaf Chitil
olaf at cs.york.ac.uk
Wed Oct 1 13:32:13 EDT 2003
Christian Maeder wrote:
>
> Malcolm Wallace wrote:
> [...]
> > Surely the name suggests that "interactive" behaviour is required, i.e.
> > exactly some interleaving of input and output. The chunk-size of the
> > interleaving should depend only on the strictness of the argument to
> > "interact".
>
> I'm not happy that interleaving depends on the strictness. Lazy or
> strict evaluation should only change the behaviour of overall
> termination (lazy evaluation should terminate more often).
I disagree with your point of view. Non-strictness is an essential
feature of Haskell that any Haskell programmer should learn about soon.
The use of an interleaving function interact helps to understand
non-strictness. Also it shows that Haskell doesn't need a set of
additinal primitives to deal with IO (the IO monad), but that
non-strictness can provide the basis for IO. You only need as single
primitive function, interact, that connects your non-strict IO function
to the external world. I do not claim that this IO model is the best for
programming in the large, but you can learn a lot from it.
> Surely also something is needed for endless character resources as
> Tom pointed out.
An "interactive" interact is fine for that.
Olaf
--
OLAF CHITIL,
Dept. of Computer Science, The University of York, York YO10 5DD, UK.
URL: http://www.cs.york.ac.uk/~olaf/
Tel: +44 1904 434756; Fax: +44 1904 432767
More information about the Haskell
mailing list