[m-rev.] for review: improvementstopprintinterface
Mark Brown
dougl at cs.mu.OZ.AU
Thu May 9 17:14:20 AEST 2002
These changes are fine; you can go ahead and commit them.
On 09-May-2002, Ralph Becket <rafe at cs.mu.OZ.AU> wrote:
> Mark Brown, Thursday, 9 May 2002:
> > - Is there an expectation that users would usually add all the
> > types they wish to print as instances of the typeclass? This
> > would be good, because they could then write a function that
> > converts, say, map(K, V) into doc where K and V are constrained
> > by doc, without necessarily resorting to the generic to_doc
> > function. You could then make map/2 an instance of doc. If
> > this is the expectation, then I suggest adding examples of this
> > to the documentation.
>
> Unfortunately, until we can check at run-time whether a type is an
> instance of a particular type class, to_doc will still have to do
> dynamic type casts on the set of special cases (maps, arrays, lists
> etc.)
I agree that, for this problem, dynamic casts are a better solution.
>
> This also means that the special case conversions have to call the
> generic to_doc on their arguments.
>
There is still the alternative approach that the user could make _all_
the types appearing in their data structures instances of the typeclass
(even library types such as pair and list). Many of these instances
would just use the generic to_doc/2 as the instance method. Then dynamic
casts would not be required, since the compiler should be able to prove
typeclass membership statically. Of course, creating all those instances
may be an unreasonable burden on the programmer.
So the answer to my original question is no, you do not have that
expectation. Therefore, I have no further comments on the change.
Cheers,
Mark.
--------------------------------------------------------------------------
mercury-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list