comonads, io
Andrew J Bromage
ajb@spamcop.net
Fri, 3 Jan 2003 09:56:41 +1100
G'day all.
On Wed, Jan 01, 2003 at 01:15:09PM +0100, Nicolas.Oury wrote:
> From this, I think the safety become intuitive.
Maybe.
Using the OI module from Richard Kieburtz' paper, I can write
this:
-- Bootstrap into the OI comonad
main :: IO ()
main = return $! comain stdOI
-- The following are the OI functions which we use.
-- stdGetChar :: OI () -> Char
-- stdPutStrLn :: OI String -> ()
comain :: OI a -> ()
comain w
= coeval (w .>> show (a,b) =>> stdPutStrLn)
where
a = coeval (w .>> () =>> stdGetChar)
b = coeval (w .>> () =>> stdGetChar)
Even though a and b are identical, they return different values. I see
two possibilities: Either my intuition is way off, or the OI comonad
breaks referential transparency.
It's possible that it's a fault in the implementation. It was clearly
intended as an example only, after all.
Cheers,
Andrew Bromage