Does this do what you need?

(define/contract (foo bar)
  (-> (or/c 1 #t "bar" (listof string?) (listof (or/c 'a 'b))) boolean?)
  #t)

(foo 1)
(foo #t)
(foo "bar")
(foo '("should work"))
(foo '(a))
(foo '(b))
(foo '(b a b a a a))
(foo "should fail")

Output:

#t
#t
#t
#t
#t
#t
#t
foo: contract violation
  expected: (or/c 1 #t "bar" (listof string?) (listof (or/c (quote a)
(quote b))))
  given: "should fail"
  in: the 1st argument of
      (->
       (or/c
        1
        #t
        "bar"
        (listof string?)
    (listof (or/c 'a 'b)))
       boolean?)
  contract from: (function foo)

On Mon, Nov 28, 2016 at 11:25 AM, Alexis King <lexi.lam...@gmail.com> wrote:

> That sounds promising, yes. Not being familiar with the guts of
> parameters, is there any way to implement this as a derived concept
> using the existing support in chaperone-procedure? As far as I can
> tell, parameters do not expose the continuation marks they use, and
> they also create thread cells, which I’m not sure that
> chaperone-procedure’s existing API would support. Would this require
> modification of procedure chaperones to support parameters directly,
> or is there some way to implement it separately?
>
> > On Nov 23, 2016, at 10:51 AM, Scott Moore <sdmo...@fas.harvard.edu>
> wrote:
> >
> > Yes, we worked with Matthew to implement the necessary hooks in
> procedure chaperones (see the 'mark options that were added to the return
> value of wrapper-proc). For the contracts we were writing, we ended up
> using these continuation marks directly.
> >
> > To implement what you're looking for, a little extra work is required to
> link up the implementation of parameters with this mechanism to get at the
> appropriate continuation marks. One question there will be whether to
> integrate it with either the existing
> > arrow contracts (carefully protecting access to the internals of the
> parameter implementation), or to just provide a standalone combinator. I
> would need to refresh my memory to see what exactly would need to be done
> for either.
> >
> > Cheers,
> > Scott
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to