[bitc-dev] Confusion: multiparameter type classes
Jonathan S. Shapiro
shap at eros-os.org
Tue Jul 26 09:51:20 EDT 2005
On Mon, 2005-07-25 at 11:54 -0700, Iavor Diatchki wrote:
> This is just a minor point here that perhaps is clear to everyone, but
> had me confused while I was reading the posts, so I though I should
> clarify it.
> We cannot think of a multi-parameter class as single paramter class
> that is always instantiated to a tuple type, but rather it would be
> instantiated to a tuple of types.
Note, however, that there is an bijective, total function between a
tuple of types and the type consisting of that tuple of types. This
means that in a strange way we might consider *any* type class
(regardless of arity) to be instantiated to a *constrained* tuple type
'a that is known to be of the form (tuple 'b 'c ... 'z) for some arity.
The existence of a 1:1 and total function between the type of the tuple
of types and the tuple of types itself would, in principle, allow us to
build the foundations of the constraint type in a different way than
> Notice that a tuple-type (just like
> a sum-type) is a single type, even though it is paramaterized. A
> tuple of types on the other hand would be a collection of types.
Thank you for pointing this out. In my original note, I should have
written "tuple of types" throughout.
Oh! There is something we discussed yesterday here that may be relevant.
I don't know if this applies to Haskell, but in SML the tuple type is
very very weird. Based on the syntax, one would conclude that SML
permits tuples of arity zero, and tuples of arity >= 2, but not tuples
of arity 1. It is asserted that the SML tuple is a product type, but if
so it is a rather odd definition of product, because the product
operators is not associative:
(('a, 'b) , 'c) != ('a, 'b, 'c)
The arity strangeness is partially explained by noting that the UNIT
is of type "Unit", which (despite the lexical oddity) is *not* a tuple
of arity zero. Thus, SML tuples must be of arity >= 2. This is at least
more consistent, but still a bit weird.
Tuples in BitC are not the same as tuples in SML. The forms
(tuple) ; tuple of arity 0
(tuple 'a) ; tuple of arity 1
are both legal, and note that
(tuple 'a) != 'a
in the type system.
More information about the bitc-dev