Fwd: [Haskell-cafe] What's the deal with Clean?

Artyom.
I know what uniqueness means. What I meant is that the context in which
uniqueness is used, for imperative sequences:
(y, s')= proc1 s x
(z, s'')= proc2 s' y
.....
is essentially the same sequence as if we rewrite an state monad to make the
state explicit. When the state is the "world" state, then it is similar to
the IO monad.
An state monad forces a single use of the implicit state variable too
(unless you pass it trough the next step without changes. That can be done
in Clean too.
2009/11/4 Artyom Shalkhakov
The code executed by uniqueness types is somehow similar to the internal code executed in a state monad (or in the case of IO, the IO monad). The main difference is that the pairs of results (state, value) are explicitly written in Clean by the programmer and the type sytem assures that the order of executions makes sense at compile time, whereas in the case of
2009/11/4 Alberto G. Corona
: the state monad the sequence of instructions is lazily assembled at runtime in the first step and executed in a second step. So there is a little more overhead in haskell but the code is higher level. Am I right?
I would rather say: code with uniqueness types allows for safe destructive updates.
In Clean, a variable of unique type is ensured to have only one reference to it, at any time (that's why it's called "uniqueness typing"). So you can't write the code like this
f(x) + f(x)
where f : *a -> int (x is of unique type), because x is clearly referenced two times here. What to do? Let f yield another reference to x! That also means that the old reference is not usable any more, since you have new one. f becomes:
f : *a -> (int, *a)
and the code looks very familiar:
let (a, x') = f(x) (b, x'') = f(x') in a + b
The function f can use destructive updates under the hood though it doesn't violate referential transparency. I bet you can you see why.
I'd say that call-by-need is orthogonal to uniqueness typing.
Cheers, Artyom Shalkhakov.

On 4 Nov 2009, at 13:36, Alberto G. Corona wrote:
Artyom.
I know what uniqueness means. What I meant is that the context in which uniqueness is used, for imperative sequences:
(y, s')= proc1 s x (z, s'')= proc2 s' y .....
is essentially the same sequence as if we rewrite an state monad to make the state explicit. When the state is the "world" state, then it is similar to the IO monad.
Yes, as long as there is a single thing that is being updated there's little difference between the state monad and a unique type. But uniqueness typing is more general. For instance, a function which updates two arrays f (arr1, arr2) = (update arr1 0 'x', update arr2 0 'y') is easily written in functional style in Clean, whereas in Haskell we need to sequentialize the two updates: f (arr1, arr2) = do writeArray arr1 0 'x' writeArray arr2 0 'y' You can find a more detailed comparison in my thesis (https://www.cs.tcd.ie/Edsko.de.Vries/pub/MakingUniquenessTypingLessUnique-sc... , Section 2.8.7). -Edsko

On Wed, Nov 4, 2009 at 7:11 AM, Edsko de Vries
On 4 Nov 2009, at 13:36, Alberto G. Corona wrote:
Artyom.
I know what uniqueness means. What I meant is that the context in which uniqueness is used, for imperative sequences:
(y, s')= proc1 s x (z, s'')= proc2 s' y .....
is essentially the same sequence as if we rewrite an state monad to make the state explicit. When the state is the "world" state, then it is similar to the IO monad.
Yes, as long as there is a single thing that is being updated there's little difference between the state monad and a unique type. But uniqueness typing is more general. For instance, a function which updates two arrays
f (arr1, arr2) = (update arr1 0 'x', update arr2 0 'y')
is easily written in functional style in Clean, whereas in Haskell we need to sequentialize the two updates:
f (arr1, arr2) = do writeArray arr1 0 'x' writeArray arr2 0 'y'
Those sequential updates can be run concurrently on both, just with different syntax though right?
You can find a more detailed comparison in my thesis ( https://www.cs.tcd.ie/Edsko.de.Vries/pub/MakingUniquenessTypingLessUnique-sc..., Section 2.8.7).
-Edsko
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

I'm not sure I follow you? The compiler can't reorder the two updates or do them in parallel (IO is not a commutative monad). You might tell the compiler this explicitly, but then are you writing lower and lower level code, further removed from the functional paradigm. Edsko On 4 Nov 2009, at 15:27, David Leimbach wrote:
On Wed, Nov 4, 2009 at 7:11 AM, Edsko de Vries
wrote: On 4 Nov 2009, at 13:36, Alberto G. Corona wrote:
Artyom.
I know what uniqueness means. What I meant is that the context in which uniqueness is used, for imperative sequences:
(y, s')= proc1 s x (z, s'')= proc2 s' y .....
is essentially the same sequence as if we rewrite an state monad to make the state explicit. When the state is the "world" state, then it is similar to the IO monad.
Yes, as long as there is a single thing that is being updated there's little difference between the state monad and a unique type. But uniqueness typing is more general. For instance, a function which updates two arrays
f (arr1, arr2) = (update arr1 0 'x', update arr2 0 'y')
is easily written in functional style in Clean, whereas in Haskell we need to sequentialize the two updates:
f (arr1, arr2) = do writeArray arr1 0 'x' writeArray arr2 0 'y'
Those sequential updates can be run concurrently on both, just with different syntax though right?
You can find a more detailed comparison in my thesis (https://www.cs.tcd.ie/Edsko.de.Vries/pub/MakingUniquenessTypingLessUnique-sc... , Section 2.8.7).
-Edsko
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
participants (3)
-
Alberto G. Corona
-
David Leimbach
-
Edsko de Vries