[racket] member et al.

From: Sam Tobin-Hochstadt (samth at ccs.neu.edu)
Date: Thu Nov 11 08:07:02 EST 2010

On Thu, Nov 11, 2010 at 12:21 AM, Mark Engelberg
<mark.engelberg at gmail.com> wrote:
> I could loosen the types of these Booleans to be Any, but then I'm not
> really reflecting the "predicate intent" of these functions.

This seems to be your primary issue.  But I don't see why it's a
problem.  In particular, you were happy with the semantics of `member'
in Racket before, but now that you want to write types or contracts,
you're unhappy.  What were you writing down for the specification of
these functions before?  For example:

;; Any -> ???
(define (one-two-or-three? n)
 (member n '(1 2 3)))

What should we write for ??? here?  I think that's the central
question, not anything for types or contracts.  Maybe you wrote Any
here - then you should be fine with writing Any as a contract or a
type.  Maybe you wrote TruthValue, or something like that - then you
can do exactly the same with types or contracts; see `truth/c' in the

Maybe you were writing 'Boolean' here before, and trusting that
nothing bad would happen, even though your specification was
incorrect. Now using contracts or types forces you to correct your
specification, and you'd prefer to change your semantics instead.
That's a reasonable argument to have, although I disagree.  But it
isn't about types or contracts, it's about what the semantics of
`member' should be.
sam th
samth at ccs.neu.edu

Posted on the users mailing list.