On Thu, Feb 03, 2005 at 03:59:06PM -0800, Brent 'Dax' Royal-Gordon wrote:
> Autrijus Tang <[EMAIL PROTECTED]> wrote:
> > However, I'd still like to know whether my understanding on punning
> > (same class 'Array' used as both Implementation Type and Value Type)
> > and the validity of matching on "$var is TraitName" in subroutine
> > signatures is correct.  That, and types of hash keys. :)
> 
> Either that, or the Ref value type is designed to wrap an
> implementation type.

Can you elaborate?  Do you mean the two below are equivalent?

    # Something that agrees with the Perl5 model
    my @array of Array;
    my @array is Array of (Ref of (Any is Array) is Scalar)

> I'm not sure which is the case.

Another possible interpretation is that "of TraitName" automatically
exapnds to "of (Any is TraitName)", which will alleviate the need of a
separate "Ref" above:

    # Something that does not quite agree with the Perl5 model
    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

That is, "myArray" matches any value type (t1) that is an instance of
the TArray type-class interface, with its elemVtype (t2) is also an
interface of TArray, and t2's elemVtype (t3) must be an instance of
the TScalar type-class.  Which means this equivalency should hold:

    Perl6 Trait         <===>   Haskell TypeClass
    Perl6 ValueType     <===>   Haskell Type

Please let me know whether this interpretation is valid. :)

Thanks,
/Autrijus/

Attachment: pgpFr8L2yNMBS.pgp
Description: PGP signature

Reply via email to