Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Message from discussion Offering abstract data structures (with simple and efficient implementation)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Albert Lai  
View profile  
 More options Dec 14 2003, 6:50 pm
Newsgroups: comp.lang.functional
From: Albert Lai <tre...@vex.net>
Date: 14 Dec 2003 18:21:11 -0500
Local: Sun, Dec 14 2003 6:21 pm
Subject: Re: Offering abstract data structures (with simple and efficient implementation)

Joachim Durchholz <joachim.durchh...@web.de> writes:
> On your treatment of Maps: they don't just share properties with Sets,
> they /are/ sets (in a "is a proper subtype" sense), namely (please
> forgive my rusty Haskell)
>    Map a b = Set (Pair a b)
> (the set of pairs from a domain and a codomain, aka the set of
> key-value pairs). This implies multi-parameter type classes.

Map "is a subtype" of set, in the exact same sense that pair "is a
subtype" of set:

  Pair a b = Set (Either a (Set (Either a b)))
  mkpair a b :: a -> b -> Pair a b
  mkpair x y = {left a, right {left a, right b}}

These "is-a" relations simply give one way of implementing maps and
pairs in a seldom-used programming language called ZF, and they are
not very helpful in conveying and understanding what maps and pairs
are about.  If maps and pairs are thought of as abstract data types,
an abstract specification is called for, and chances are it is more
enlightening, e.g.,

  (x,y)=(a,b) iff x=a and y=b

is infinitely more readable, useful, and to the point than any
set-theoretic encoding.

Furthermore, sets are not always more primitive, and maps are not
always derived from sets in implementations.  In PalmOS, maps or
relations are primitive, and if you want a set, you ought to derive
one from relations.

A specification for maps, whether in the form of a bunch of axioms
concerning lookups, or as an equation with a certain set, must be
judged on its merit as a specification (is it understandable, does it
help reasoning about programs using it), not on how faithfully it
copies from the foundations of mathematics.  No one specifies the
integer data type as equivalence classes of pairs of natural numbers
under the relation (m,n)~(j,k) iff m+k=n+j.  (On the other hand, when
specifying stacks, I still find it easier to encourage the audience to
imagine consing and tailing a cons list.)

The reason explained below may or may not be a good reason to say maps
are special sets; I don't know, because I don't understand it:

> Here's why I advocate this model:
> The alternative model that one would come up with was used in the
> abstract Eiffel class TABLE (equivalent to your Map): a set of "keys",
> with additional functions for mapping these keys to associated values.
> This approach, while untuitive, has very unfortunate consequences for
> equality.

What are the unfortunate consequences for equality?

Are they general shortcomings of all abstract axiomatizations of
lookups, or just a failing of the particular Eiffel specification?


    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2010 Google