[Haskell] line-based interactive program

Olaf Chitil O.Chitil at kent.ac.uk
Fri Jul 8 10:16:00 EDT 2005


Christian Maeder wrote:

>Colin Runciman wrote:
>> buffer xs = foldl const xs xs
>  
>
>
>I don't find it this easy nor a good programming practise.
>
>My interaction depends on the (subtle order of) evaluation of a pure and
>total function?
>  
>
I would not think so much about the operational evaluation order, but 
about the denotational value of functions. In a non-strict language 
functions always also accept partially defined arguments (including 
bottom _|_). What a function returns for partially defined arguments 
tells you how it can be used in an interactive program.

So:
buffer _|_ = _|_
buffer (a1:_|_) = _|_
buffer (a1:a2:_|_) = _|_
...
buffer (a1:a2:...:an:[]) = a1:a2:...:an:[]

Ciao,
Olaf


More information about the Haskell mailing list