Hi
Whoops! Only just spotted this. Many apologies.
On 10 Jul 2007, at 20:35, Creighton Hogg wrote:
Me:
> No, an
> operating system is supposed to remain responsive. And that's what
> total coprograms do.
I'm sorry, but can you expand a little further on this? I guess I
don't understand how a corecursion => responsive to input but not
terminating. Where does the idea of waiting for input fit into
corecursion?
You'll be needing a bit of higher-order corecursion for that.
Here's a coprogram for haskell-cafe:
> data{-codata-} Punter = Speak String (String -> Punter)
A Punter is guaranteed to ask a question, and whatever answer you give
them, they've always got another question, forever! Meanwhile, a
String -> Punter is a good-natured soul, always up for answering
questions.
Hence haskell-cafe is a productive coprogram(*) producing a stream of
questions
and answers!
> data{-codata-} Stream x = x :> (Stream x)
> cafe :: Punter -> (String -> Punter) -> Stream (String, String)
> cafe (Speak question learn) guru =
> let Speak answer guru' = guru question
> in (question, answer) :> (cafe (learn answer) guru')
All the best
Conor
(*) and yes, I know what that means in Greek...
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe