Huh? The getChar function does yield a value of type (IO Char), exactly as the type signature says. If you want access to the Char you must use a >>=, just like in any other monad.
2009/2/9 Gregg Reynolds <d...@mobileink.com>: > On Mon, Feb 9, 2009 at 4:38 AM, Tony Morris <tmor...@tmorris.net> wrote: >> >> -----BEGIN PGP SIGNED MESSAGE----- >> Hash: SHA1 >> >> I also agree it is a value. >> The original post was attempting to make a distinction that does not >> exist. I deliberately avoided that topic. >> >> "A thing cannot be both a value and a function, but e,g, getChar" >> >> My original intent was to hope the poster reconsidered the whole post. >> You've blown my cover :) > > My bad, I restate: a value cannot be both static and dynamic. Or an object > and a morphism. Or an element and a function. Sure, you can treat a > morphism as an object, but only by moving to a higher (or different) level > of abstraction. That doesn't erase the difference between object and > morphism. If you do erase that difference you end up with mush. getChar > /looks/ like an object, but semantically it must be a morphism. But it > can't be a function, since it is non-deterministic. So actually the > logical contradiction comes from the nature of the beast. > > Another reason it's confusing to newcomers: it's typed as "IO Char", which > looks like a type constructor. One would expect getChar to yield a value of > type IO Char, no? But it delivers a Char instead. This is way confusing. > So I take "type IO foo" to mean "type foo, after a side effect". In a sense > "getChar :: IO Char" isn't even a true type signature. > > In any case, many thanks to all who have contributed to the thread. It's > sharpened my thinking revealed weaknesses in my terminology, and I expect > I'll make my inevitable contribution to the infinite Haskell tutorial on the > topic before too long. > > -gregg > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe