Fri, 29 Sep 2000 12:26:42 -0300, [EMAIL PROTECTED] <[EMAIL PROTECTED]> pisze:

> instance Ix ix => Foo (MutableByteArray s ix) where
> 
>           foo x = runST(unsafeFreezeByteArray x)

Mutable objects in the ST world, parametrized by those s type
variables, must be created and used "locally" in an ST computation.

Functions operating on them (like readSTArray) tie the type variable
of these objects with the type variable of the ST computation. If
this type variable is also bound outside (like here in the instance
declaration), the argument of runST is no longer fully polymorphic
wrt. s, as required by the type of runST. runST can be applied only
to a computation which does not return nor refer to a mutable value
from outside.

Conversion between mutable and immutable arrays cannot be expressed
as a pure function because the effect would depend on when its result
is evaluated. They can be converted only by ST actions (which share
the type variable s with the mutable object). Your function is not
just unimplementable, but it would lead to an unsound semantics if
it existed.

-- 
 __("<  Marcin Kowalczyk * [EMAIL PROTECTED] http://qrczak.ids.net.pl/
 \__/
  ^^                      SYGNATURA ZASTĘPCZA
QRCZAK



Reply via email to