Re: [racket] error : Attempted to use a higher-order value passed as `Any` in untyped code:
mailoo <[email protected]>
| Newsgroups | gmane.comp.lang.racket.user,gmane.lisp.scheme.plt |
|---|---|
| Message-ID | <[email protected]> |
Unfortunatly, not. I'm building a framework were the user will send data over the async-channel, so I didn't know the type in advance, and cannot specify more the async-channel... On 04/20/2018 02:50 PM, Sam Tobin-Hochstadt wrote: > Can you give a more specific type to what you send on the channel? That > will allow Typed Racket to generate a contract that works for your values. > > Sam > > On Fri, Apr 20, 2018, 6:14 AM mailoo <[email protected] > <mailto:[email protected]>> wrote: > > Hello, > > I continue my work with Typed/Racket and Racket, and I now have > another problem, with the same error. > > I try to use in untyped racket a typed async-channel of type Any, > and I'm not able to use the higher-order value from this channel. > Here is an example code that show this problem : > > ``` > #lang racket > > ; A higher-order value > (define add (lambda (x) (+ x 1))) > (add 1) > > ; Untyped is working well > (require racket/async-channel) > (define untype-p (make-async-channel 10)) > (async-channel-put untype-p add) > (define new-add (async-channel-get untype-p)) > (display "untype world : ") > (displayln (new-add 2)) > > ; Untype <-> type world doesn't work > (module port typed/racket > (provide build-port (struct-out port)) > > (require typed/racket/async-channel) > > (struct port ([channel : (Async-Channelof Any)])) > > (: build-port (-> port)) > (define (build-port) > (port (make-async-channel 10)))) > > (require 'port) > (define p (build-port)) > > (async-channel-put (port-channel p) add) > (define n-add (async-channel-get (port-channel p))) > > ; Fail : Attempted to use a higher-order value passed as `Any` in > untyped code: #<procedure:add> > (n-add 3) > ``` > > Do you have an idea how I can use my procedure? > I don't know if it's possible, or if it is a limitation of the > untyped <-> typed boundary? > > Thank you in advance, > > Denis Michiels > > > -- > 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+unsubscribe-/[email protected] > <mailto:racket-users%2Bunsubscribe-/[email protected]>. > 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+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected] For more options, visit https://groups.google.com/d/optout.