Strict tuples
Simon Marlow
simonmar at microsoft.com
Mon Mar 20 08:26:56 EST 2006
On 20 March 2006 12:26, Bulat Ziganshin wrote:
> 2) to allow "changing" of strictness inside existing ADTs, i propose
> to "copy" strictness annotations on type arguments to the type
> declaration bodies:
>
> data List a = Nil | Cons (List a) a
> type StrictElements a = List !a
>
> is equal to the:
>
> data StrictElements a = Nil | Cons (List a) !a
So, in fact StrictElements is not compatible with the List type at all
(that is, you can't pass a value of type (StrictElements Int) to a
function expecting (List Int)). I can envisage that this might be a
sound extension, and imlementable, but is it what you mean? I don't
think so.
I imagine you want a lot of automatic conversion back and forth bewteen
strict and lazy types. This is where it gets a *lot* trickier, starting
with the type system.
> i.e. it's the same list but each element is strict. using strictness
> annotation on type constructor itself should mean strictifying of all
> other (non-type-variable) fields:
>
> type StrictList a = !List a
> =>
> data StrictList a = !Nil | !Cons !(List a) a
I don't know what !Nil or !Cons mean.
> of course, i don't mean introducing new incompatible types - that is a
> compiler responsibility (sorry, Simon :)
Well, you haven't told me what type system I need to implement, so it's
not just an implementation issue. And it seems to me that you *are*
introducing incompatible types.
Cheers,
Simon
More information about the Haskell-prime
mailing list