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

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Tue Dec 4 19:49:18 EST 2012

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.

Robby

On Tuesday, December 4, 2012, Harry Spier wrote:

> Dear list members,
>
>  I'm a little confused about the difference between the definition of a
>  predicate and the definition of a flat contract.  If someone could
>  clear that up I'd appreciate it.
>
>  1) AT ALL PLACES in the documentation where it uses the term
>  "predicate" does that mean a procedure that takes a single value and
>  returns a boolean?  I inferred that from:
>
> http://docs.racket-lang.org/reference/function-contracts.html#(def._((lib._racket/contract/base..rkt)._predicate/c))
>
>  But from the section of the Racket Guide "Rolling your own contracts"
> http://docs.racket-lang.org/guide/contract-func.html#(part._contracts-own)
>  I inferred that a procedure that takes a value and returns a boolean
>  can be used as a contract, so is a predicate always a flat-function?
>  If thats so, then what does (flat-contract predicate)  do?
>
> http://docs.racket-lang.org/reference/data-structure-contracts.html#(def._((lib._racket/contract/private/misc..rkt)._flat-contract))
>
>  Thanks,
>  Harry Spier
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20121204/02c2c4cc/attachment.html>

Posted on the users mailing list.