[racket] TR Keyword Args (Lil Help)

From: Eric Dobson (eric.n.dobson at gmail.com)
Date: Fri Aug 10 03:12:24 EDT 2012

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
>

Posted on the users mailing list.