[racket-users] Typed Racket: Polymorphic function `dynamic-wind' could not be applied to arguments

2017-03-04 Thread kay
I have the following simple module that I'm converting to typed/racket. I got a 
type check error that I don't know how to fix. More specifically, it's related 
to the polymorphic function dynamic-wind's arguments. I read from document [1] 
that type inference doesn't work for a lambda that is an argument to a 
polymorphic function. But since here the three arguments are all thunks 
(without input argument), I don't know how to properly annotate them. 

Note that I tried to even annotate the first argument:

  (λ () (ann #f AnyValues))

And the type checker complained:

  Argument 1:
Expected: (-> AnyValues)
Given:(-> AnyValues)

which is really weird.


[1]: 
https://docs.racket-lang.org/ts-guide/more.html#%28part._when-annotations~3f%29



Here's the module:
--

#lang typed/racket

;;(require racket/string racket/list racket/match racket/system racket/port 
racket/function)
(provide execute)

(: execute (-> String * (Values String String)))
(define (execute . args)
  (define cmdln (string-join args))
  (displayln (format "running ~a" cmdln))
  (match (process cmdln)
[(list out in pid err f)

 (define cust (make-custodian))
 (dynamic-wind
  (λ () (ann #f AnyValues))
  
  (thunk 
   (parameterize ([current-custodian cust])
 (define buf_stdout (open-output-string))
 (define buf_stderr (open-output-string))
   
 (thread (λ () (copy-port out buf_stdout (current-output-port
 (thread (λ () (copy-port err buf_stderr (current-error-port

 (displayln (f 'status))
 (f 'wait)
   
 (values (get-output-string buf_stdout) (get-output-string 
buf_stderr
  
  (thunk (custodian-shutdown-all cust)))
 ]))




Here's the type error:
--

. executor.rkt:14:5: Type Checker: Polymorphic function `dynamic-wind' could 
not be applied to arguments:
Argument 1:
  Expected: (-> AnyValues)
  Given:(-> AnyValues)
Argument 2:
  Expected: (-> a)
  Given:(-> (values (String : (Top | Bot)) (String : (Top | Bot
Argument 3:
  Expected: (-> AnyValues)
  Given:(-> Void)

Result type: a
Expected result: (values String String)
 in: (dynamic-wind (λ () (ann #f AnyValues)) (thunk (parameterize 
((current-custodian cust)) (define buf_stdout (open-output-string)) (define 
buf_stderr (open-output-string)) (thread (λ () (copy-port out buf_stdout 
(current-output-port (thread (λ () (copy-port err buf_stderr 
(current-error-port (displayln (f (quote status))) (f (quote wait)) (values 
(get-output-string buf_stdout) (get-output-string buf_stderr (thunk 
(custodian-shutdown-all cust)))

-- 
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.


Re: [racket-users] scribble section as link

2017-03-04 Thread Stephen Chang
Ah, I understand now. I remember trying to do this as well but I'm not
sure it's possible.

I just tried manually playing around a bit with scribble structs but
couldnt figure it out. Best I could do was redirecting a seclink, or
changing the toc contents of an element.

But there doesnt seem to be any way to change the toc contents of a
part (someone correct me if I'm wrong).

Here's my code in case it's helpful.

#lang scribble/manual
@(require scribble/core
  scribble/html-properties
  net/url)
@title{asdf}
@section[#:style (make-style #f (list (make-part-link-redirect
(string->url "http://google.com"; #:tag "a"]{A}
@section{@seclink["a"]{link to sec A (goes to google)}}

@(make-toc-target2-element #f "stuff" '(element "stf")
@hyperlink["http://google.com"]{link to "stuff" (try to redirect to
google but doesnt work)"})

On Sat, Mar 4, 2017 at 2:38 PM, David Van Horn  wrote:
> The latex analogy of what I'd like is something like:
>
> \addcontentsline{toc}{section}{\href{google.com}{The Google}}
>
> On Sat, Mar 4, 2017 at 2:30 PM, David Van Horn  wrote:
>> Thanks, this does make the section heading a link, but in the table of
>> contents or in the left hand navigation bar, the link is to the
>> (empty) section, not the URL.  What I'd like is for the navigation
>> links to go to the URL.
>>
>> David
>>
>>
>> On Sat, Mar 4, 2017 at 2:06 PM, Stephen Chang  wrote:
>>> Does `hyperlink` do what you want?
>>>
>>> eg
>>>
>>> @section{@hyperlink["http://google.com"]{The Google}}
>>>
>>> On Sat, Mar 4, 2017 at 1:49 PM, David Van Horn  wrote:
 I'm using scribble to make a web page and I'd like a section-like
 heading that is just a link to an external URL, but I don't see how to
 do this.  Is it possible?

 David

 --
 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.

-- 
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.


Re: [racket-users] scribble section as link

2017-03-04 Thread David Van Horn
The latex analogy of what I'd like is something like:

\addcontentsline{toc}{section}{\href{google.com}{The Google}}

On Sat, Mar 4, 2017 at 2:30 PM, David Van Horn  wrote:
> Thanks, this does make the section heading a link, but in the table of
> contents or in the left hand navigation bar, the link is to the
> (empty) section, not the URL.  What I'd like is for the navigation
> links to go to the URL.
>
> David
>
>
> On Sat, Mar 4, 2017 at 2:06 PM, Stephen Chang  wrote:
>> Does `hyperlink` do what you want?
>>
>> eg
>>
>> @section{@hyperlink["http://google.com"]{The Google}}
>>
>> On Sat, Mar 4, 2017 at 1:49 PM, David Van Horn  wrote:
>>> I'm using scribble to make a web page and I'd like a section-like
>>> heading that is just a link to an external URL, but I don't see how to
>>> do this.  Is it possible?
>>>
>>> David
>>>
>>> --
>>> 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.


Re: [racket-users] scribble section as link

2017-03-04 Thread David Van Horn
Thanks, this does make the section heading a link, but in the table of
contents or in the left hand navigation bar, the link is to the
(empty) section, not the URL.  What I'd like is for the navigation
links to go to the URL.

David


On Sat, Mar 4, 2017 at 2:06 PM, Stephen Chang  wrote:
> Does `hyperlink` do what you want?
>
> eg
>
> @section{@hyperlink["http://google.com"]{The Google}}
>
> On Sat, Mar 4, 2017 at 1:49 PM, David Van Horn  wrote:
>> I'm using scribble to make a web page and I'd like a section-like
>> heading that is just a link to an external URL, but I don't see how to
>> do this.  Is it possible?
>>
>> David
>>
>> --
>> 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.


Re: [racket-users] scribble section as link

2017-03-04 Thread Stephen Chang
Does `hyperlink` do what you want?

eg

@section{@hyperlink["http://google.com"]{The Google}}

On Sat, Mar 4, 2017 at 1:49 PM, David Van Horn  wrote:
> I'm using scribble to make a web page and I'd like a section-like
> heading that is just a link to an external URL, but I don't see how to
> do this.  Is it possible?
>
> David
>
> --
> 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.


[racket-users] scribble section as link

2017-03-04 Thread David Van Horn
I'm using scribble to make a web page and I'd like a section-like
heading that is just a link to an external URL, but I don't see how to
do this.  Is it possible?

David

-- 
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.