On Fri, Feb 04, 2005 at 06:04:52PM +0800, Autrijus Tang wrote:
>     my @array of Array;
>     my @array is Array of (Any is Array of (Any is Scalar))
>
> If so, may I consider it as equivalent to this Haskell code?
> 
>     class TArray  baseVtype elemVtype where {- ... -} -- Array Trait
>     class TScalar baseVtype           where {- ... -} -- Scalar Trait
> 
>     myArray :: (TArray t1 t2, TArray t2 t3, TScalar t3) => t1

Hmm, it's actually more subtle than that, because Perl6's Array
does not require that each element have the same value type, so a
closer approximation is via existential types -- i.e. for each
element in an array of value type 't3', there must exist an instance
of "TScalar t3", but each element's value-type may differ from
each other; I think that's what the "Any" above means.

However, I wonder how to talk about an array that can contain elements
of any value type, but all the elements must have the same type.
Is Perl6 capable of expressing such a restraint?

Thanks,
/Autrijus/

Attachment: pgpv8Wn4uEuA8.pgp
Description: PGP signature

Reply via email to