On Sun, Mar 1, 2009 at 11:59 AM, Will Ness <will_n48@yahoo.com> wrote:
The IO-action is not the I/O operation in the real world, but an action of
recording a promise to perform it.
Any IO primitive can be seen as latching this hidden promise onto its explicit
return value, thus creating a monadic value (:: IO a), carrying along this
hidden promise. IO bind combines these promises into a combined record, or log,
of promises to perform actual I/O activity, if called upon by the system.
That recording of a promise is the IO-action that IO monad is about, from pure
Haskell standpoint.
Another monad will have another meaning for its actions, latching another
hidden data on their results, but they still can be seen as actions, in context
of being sequenced and combined by that monad's bind.
> Correction: special name for IO "functions" (actually "IO terms" would beWhy? They are just fuctions, of type (Monad m => a -> m b). What I'm saying,
better).
they are of special type, chainable by the M monad, so it seems logical to have
a special name for such M-chainable functions, e.g. "M-action functions"
(whatever the M).
>> This was a big problem for me; I find termsWhy? A function of type (a -> M b) is a function that returns a value, (:: M
like "action", "computation", "function" completely misleading for IO
terms/values.
b), tagged with some monadic hidden data. In case of IO, it is a promise to
perform some actual I/O that's passed around, hidden. But the M-action function
itself is just a regular Haskell function. It can be defined elsewhere,
anywhere.