[racket] Whats the difference between a predicate and a flat contract?

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Tue Dec 4 21:41:21 EST 2012

It does that for symbols, but not everything.

This is the place you should be looking, I think.

http://docs.racket-lang.org/reference/contracts.html

Robby

On Tue, Dec 4, 2012 at 8:38 PM, Harry Spier <vasishtha.spier at gmail.com> wrote:
> OK I see the docs to flat-contract? but not flat-contract
> http://docs.racket-lang.org/reference/contract-utilities.html#(def._((lib._racket/contract/private/misc..rkt)._flat-contract~3f))
> mention that flat-contracts are more than predicates.  Those docs
> don't mention it, but it appears from experimentation that
> (flat-contract something) produces a procedure such that
> ((flat-contract something) x) is #t if something eq? x .
>
> Harry Spier
>
> On Tue, Dec 4, 2012 at 8:57 PM, Robby Findler
> <robby at eecs.northwestern.edu> wrote:
>> On Tue, Dec 4, 2012 at 7:28 PM, Carl Eastlund <cce at ccs.neu.edu> wrote:
>>> On Tue, Dec 4, 2012 at 7:49 PM, Robby Findler <robby at eecs.northwestern.edu>
>>> wrote:
>>>>
>>>> Flat contracts includes more things than contracts. For example:
>>>>
>>>> [robby at yanpu] ~/git/plt/collects/scribblings/reference$ racket
>>>> Welcome to Racket v5.3.1.9.
>>>> > (flat-contract? 'x)
>>>> #t
>>>> > (procedure? 'x)
>>>> #f
>>>>
>>>> The flat-contract function is a holdover from the days when flat contracts
>>>> weren't able to be used directly as predicate functions.
>>>>
>>>>
>>>> I'll push a clarification to the docs for flat-contract.
>>>
>>>
>>> Isn't that the wrong way around?  The flat-contract function lets you use a
>>> predicate as a contract, not a contract as a predicate.  Presumably it's
>>> from before predicates could be used as contracts, although I hadn't
>>> realized there was such a time.
>>
>> There was a time when you had to call 'flat-contract' to turn a
>> predicate into a contract, yep. There was a housecleaning (anyone
>> remember the days when there were multiple suffixes (not just "/c") on
>> the combinators?) and I probably should have gotten rid of it at that
>> time, but I didn't.
>>
>> (Oh and I mean "contracts" where I wrote "preducate functions" above. Oops.)
>>
>> Robby

Posted on the users mailing list.