[racket] TR Keyword Args (Lil Help)

From: Ray Racine (ray.racine at gmail.com)
Date: Fri Aug 10 10:21:53 EDT 2012

Removal of the extra case, shifts the bug.  It now type checks fine, but
when you instantiate (run) the module it blows up with a bountiful error
message.

If I again comment out the kw args all is well.
To summarize:
1) case-> + kw => type checking fails.
2) Remove case, leave kws => RUNning the module fails.
3) Remove kws and add back case-> => everything works.

Ray



function: broke its contract
 promised a procedure that accepts 3 arguments and arbitrarily more and the
optional keywords #:alpha #:color #:label #:samples #:style #:width #:y-max
#:y-min
 produced: #<procedure:function>
 in: (recursive-contract
... for ~300 lines





On Fri, Aug 10, 2012 at 3:12 AM, Eric Dobson <eric.n.dobson at gmail.com>wrote:

> It looks like there is an issue with turning case lambdas with
> keywords into a contract. If you drop the one argument case for
> function, it should work.
>
>
>
> On Thu, Aug 9, 2012 at 4:01 PM, Ray Racine <ray.racine at gmail.com> wrote:
> > The following sample works well enough that I can do something similar
> for
> > each of my current situational plotting needs  However, I can't seem to
> get
> > any of the keyword typings to work.
> >
> > No keyword typing support for require/typed at this time, bug, or I'm
> flat
> > out doing it wrong?
> >
> > Thanks,
> >
> > Ray
> >
> > #lang typed/racket/base
> >
> > (require
> >  (only-in racket/math
> >           sqr))
> >
> > (define-type Color% (Class () () ()))
> >
> > (define-type Plot-Pen-Style (U Integer
> >                                (U 'transparent 'solid
> >                                   'bdiagnol-hatch 'fdiagonal-hatch
> >                                   'horizontal-hath 'veritcal-hatch
> >                                   'crossdisg-hatch 'cross-hath)))
> >
> > (define-type Plot-Color (U Integer (List Real Real Real)
> >                            String Symbol Color%))
> >
> > (define-type Image-Snip% (Class () () ()))
> >
> > (require/typed plot/utils
> >                [opaque Renderer2d renderer2d?]
> >                [linear-seq (Real Real Exact-Nonnegative-Integer ->
> (Listof
> > Real))])
> >
> > (require/typed plot/main
> >    [plot (Any -> Any)]
> >    [function (case-> ((Real -> Real)
> >                       (Option Exact-Rational)
> >                       (Option Exact-Rational)
> >                       ;[#:y-min   Exact-Rational]
> >                       ;              [#:y-max   Exact-Rational]
> >                       ;              [#:samples Integer]
> >                       ;              [#:color   Plot-Color]
> >                       ;              [#:width   Natural]
> >                       ;              [#:style   Plot-Pen-Style]
> >                       ;              [#:alpha   Real]
> >                       ;              [#:label  (Option String)]
> >                       -> Renderer2d)
> >                      ((Real -> Real) -> Renderer2d))]
> >
> >    [area-histogram
> >     ((Real -> Real) (Listof Real) -> Renderer2d)])
> >
> > (define (test)
> >   (: f (Real -> Real))
> >   (define (f x) (exp (* -1/2 (sqr x))))
> >   (plot (list (area-histogram f (linear-seq -4 4 10))
> >               (function f -4 4))))
> >
> > ____________________
> >   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/20120810/f43ede65/attachment.html>

Posted on the users mailing list.