IMO, there's no justification for having IORefs etc in the IO monad.
They should be in a separate monad. There could then be an operation
to lift that monad to the IO monad, if you so wish.
But wait, we already have that, it's the ST monad! (So there is no
justification.)
-- Lennart
On Wed, Aug 27, 2008 at 10:50 PM, Jonathan Cast
<jonathanccast at fastmail.fm> wrote:
> On Thu, 2008-08-28 at 01:23 +0400, Bulat Ziganshin wrote:
>> Hello Jonathan,
>>>> Thursday, August 28, 2008, 1:11:35 AM, you wrote:
>> >> IORefs got their names because they are implemented in IO monad :)
>>>> > But why are they implemented in the IO monad?
>>>> because they need its features. but i/o may be implemented w/o IORefs.
>> so sequence was: searching for a was to make i/o in Haskell (you can
>> read about this in "History of Haskell"), finding monads as general
>> approach to implement side-effects,
>> Note that this was true even in Haskell 1.0: the Haskell report included
> example code with definitions of (>>=) and return in the context of I/O,
> but without the explicit recognition of the connection to monads.
>>> naming one of monads used to
>> interact with external world as IO, adding "variables" support to list
>> of operations of this monad
>> Do you really think I'm unaware of the history? I know what happened,
> what I don't understand is, looking at the matter from a language-design
> perspective circa 2008, IORefs would go in the same monad as Handles.
> What is the theoretical justification for this, independent of GHC's
> current implementation of these and their requisite monad(s)?
>> jcc
>>> _______________________________________________
> Haskell-Cafe mailing list
>Haskell-Cafe at haskell.org>http://www.haskell.org/mailman/listinfo/haskell-cafe>