[racket-users] Re: embedding Google Forms/YouTube/… in Scribble
Thank you again Prof. Shriram for your very useful package. It will be very helpful to include (if possible) your package *scribble-embedding* in the site *pkgs.racket-lang.org* This in part for easy of installation, and in case of updates, it will be possible to do it inside DrRacket. Thank you again for all the excellent work, and* please keep safe in the current global contingency*. Sincerely, E. Cómer. On Sunday, March 22, 2020 at 6:17:16 PM UTC-7, Shriram Krishnamurthi wrote: > > It's sometimes useful to embed content like a Google Form (a survey, quiz, > etc.) or a YouTube video in a Scribble document. > > I spent some time searching but couldn't find anything that would do this > for me. > > I've therefore written a little library to help with this: > > https://github.com/shriram/scribble-embedding > > You can mostly figure it out from this small example file, which uses both > the provided functions (google-form and youtube), but the documentation > lists the other parameters (all are optional other than the URL): > > > https://github.com/shriram/scribble-embedding/blob/master/sample/sample.scrbl > > Comments welcome. > > Cheers, > Shriram > > -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/4dfb1cf4-2521-4ac9-9ee8-863b6cded5d3%40googlegroups.com.
Re: [racket-users] typing variable length argument lists
Thanks Sam, for the explanation. I was thinking that some information was lacking to the type inference system, and it helps to see the annotation incantations necessary to fill in the gap. Cheers, Kieron. On Mon, Apr 13, 2020 at 1:32 PM Sam Tobin-Hochstadt wrote: > The change makes a difference because Typed Racket's type inference > for `cons` is producing a less-accurate answer than it could. When it > sees arguments of type `String` and `(Listof Any)`, it decides that > the result is a `(Listof Any)` instead of a `(Pairof String (Listof > Any))`. > > If you add (excessive) annotation like this: > >(apply fprintf (ann (cons (current-output-port) (ann (cons > message messageargs) (Pairof String (Listof Any >(Pairof Output-Port (Pairof String (Listof > Any) > > then the expression typechecks as written. > > However, I think the use of `apply` without the extra `cons` calls is > clearer anyway, in addition to being easier for the type checker. > > Sam > > On Mon, Apr 13, 2020 at 3:22 PM K H wrote: > > > > If I understand correctly, the difference to getting the code to type > check was: > > > (apply fprintf (cons anomaly (cons message messageargs))) > > > > becomes: > > >(apply fprintf anomaly message messageargs) > > > > Since the documentation explains that the arguments to fprintf are > effectively gathered in a list*, could someone explain why the change makes > a difference? Would it the answer depend on whether messagesargs was a > list?. > > > > Also, the first version with the cons's looks strange to me. Is there a > reason why the statement was originally coded that way? Is it perhaps an > artifact from attempting to force the result of list* to produce a list? > regardless of what is the type of of the value passed in messageargs? > > > > Thanks in advance, > > > > Kieron > > > > > > On Sat, Apr 11, 2020 at 7:43 AM Hendrik Boom > wrote: > >> > >> On Fri, Apr 10, 2020 at 08:18:38PM -0400, Jon Zeppieri wrote: > >> > (define (unique [list : (Listof Any)] [message : String] . > >> > [messageargs : Any *]) > >> > ; return the only element of the list, or '() if there is none. > >> > ; Produce message if not just one. > >> > (if (equal? 1 (length list)) (car list) > >> > (begin > >> >(apply fprintf anomaly message messageargs) > >> >(if (null? list) list (car list) > >> > >> Thank you. That worked. > >> The change to the apply syntax surprised me. > >> > >> -- hendrik > >> > >> > > >> > On Fri, Apr 10, 2020 at 7:49 PM Hendrik Boom > wrote: > >> > > > >> > > Trying to convert the following to typed Racket: > >> > > > >> > > (define (unique list message . messageargs) > >> > > ; return the only element of the list, or '() if there is none. > >> > > ; Produce message if not just one. > >> > > (if (equal? 1 (length list)) (car list) > >> > > (begin > >> > >(apply fprintf (cons anomaly (cons message messageargs))) > >> > >(if (null? list) list (car list)) > >> > >) > >> > > ) > >> > > ) > >> > > > >> > > It's an error message function tat accepts a list to test. > >> > > If the test fails it uses fprintf to print a message with the > >> > > arguments for the ~s items. > >> > > > >> > > I got so far, but I don't know what to do with the . messageargs : > >> > > > >> > > (define (unique [list (Listof Any)] [message : String] . > messageargs) > >> > > ; return the only element of the list, or '() if there is none. > >> > > ; Produce message if not just one. > >> > > (if (equal? 1 (length list)) (car list) > >> > > (begin > >> > >(apply fprintf (cons anomaly (cons message messageargs))) > >> > >(if (null? list) list (car list)) > >> > >) > >> > > ) > >> > > ) > >> > >> -- > >> 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. > >> To view this discussion on the web visit > https://groups.google.com/d/msgid/racket-users/20200411134316.yff5tg7kwtglcs62%40topoi.pooq.com > . > > > > -- > > 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. > > To view this discussion on the web visit > https://groups.google.com/d/msgid/racket-users/CAEEP09AhmxLHeRdOpzpuG7qC9jOuPTrpog92G_3b6nJWwZDzbw%40mail.gmail.com > . > -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/CAEEP09AzcAQ%3Dj1kJtERQherjH0%3DLfvc6uBYFcVMKC0z1f%3DXBkg%40mail.gma
Re: [racket-users] typing variable length argument lists
The change makes a difference because Typed Racket's type inference for `cons` is producing a less-accurate answer than it could. When it sees arguments of type `String` and `(Listof Any)`, it decides that the result is a `(Listof Any)` instead of a `(Pairof String (Listof Any))`. If you add (excessive) annotation like this: (apply fprintf (ann (cons (current-output-port) (ann (cons message messageargs) (Pairof String (Listof Any (Pairof Output-Port (Pairof String (Listof Any) then the expression typechecks as written. However, I think the use of `apply` without the extra `cons` calls is clearer anyway, in addition to being easier for the type checker. Sam On Mon, Apr 13, 2020 at 3:22 PM K H wrote: > > If I understand correctly, the difference to getting the code to type check > was: > > (apply fprintf (cons anomaly (cons message messageargs))) > > becomes: > >(apply fprintf anomaly message messageargs) > > Since the documentation explains that the arguments to fprintf are > effectively gathered in a list*, could someone explain why the change makes a > difference? Would it the answer depend on whether messagesargs was a list?. > > Also, the first version with the cons's looks strange to me. Is there a > reason why the statement was originally coded that way? Is it perhaps an > artifact from attempting to force the result of list* to produce a list? > regardless of what is the type of of the value passed in messageargs? > > Thanks in advance, > > Kieron > > > On Sat, Apr 11, 2020 at 7:43 AM Hendrik Boom wrote: >> >> On Fri, Apr 10, 2020 at 08:18:38PM -0400, Jon Zeppieri wrote: >> > (define (unique [list : (Listof Any)] [message : String] . >> > [messageargs : Any *]) >> > ; return the only element of the list, or '() if there is none. >> > ; Produce message if not just one. >> > (if (equal? 1 (length list)) (car list) >> > (begin >> >(apply fprintf anomaly message messageargs) >> >(if (null? list) list (car list) >> >> Thank you. That worked. >> The change to the apply syntax surprised me. >> >> -- hendrik >> >> > >> > On Fri, Apr 10, 2020 at 7:49 PM Hendrik Boom >> > wrote: >> > > >> > > Trying to convert the following to typed Racket: >> > > >> > > (define (unique list message . messageargs) >> > > ; return the only element of the list, or '() if there is none. >> > > ; Produce message if not just one. >> > > (if (equal? 1 (length list)) (car list) >> > > (begin >> > >(apply fprintf (cons anomaly (cons message messageargs))) >> > >(if (null? list) list (car list)) >> > >) >> > > ) >> > > ) >> > > >> > > It's an error message function tat accepts a list to test. >> > > If the test fails it uses fprintf to print a message with the >> > > arguments for the ~s items. >> > > >> > > I got so far, but I don't know what to do with the . messageargs : >> > > >> > > (define (unique [list (Listof Any)] [message : String] . messageargs) >> > > ; return the only element of the list, or '() if there is none. >> > > ; Produce message if not just one. >> > > (if (equal? 1 (length list)) (car list) >> > > (begin >> > >(apply fprintf (cons anomaly (cons message messageargs))) >> > >(if (null? list) list (car list)) >> > >) >> > > ) >> > > ) >> >> -- >> 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. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/racket-users/20200411134316.yff5tg7kwtglcs62%40topoi.pooq.com. > > -- > 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. > To view this discussion on the web visit > https://groups.google.com/d/msgid/racket-users/CAEEP09AhmxLHeRdOpzpuG7qC9jOuPTrpog92G_3b6nJWwZDzbw%40mail.gmail.com. -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/CAK%3DHD%2BYQWikBwmNC1uyCGGRYyir-Ty4x0TtWtUKybcgov386jQ%40mail.gmail.com.
Re: [racket-users] typing variable length argument lists
If I understand correctly, the difference to getting the code to type check was: > (apply fprintf (cons anomaly (cons message messageargs))) becomes: >(apply fprintf anomaly message messageargs) Since the documentation explains that the arguments to fprintf are effectively gathered in a list*, could someone explain why the change makes a difference? Would it the answer depend on whether messagesargs was a list?. Also, the first version with the cons's looks strange to me. Is there a reason why the statement was originally coded that way? Is it perhaps an artifact from attempting to force the result of list* to produce a list? regardless of what is the type of of the value passed in messageargs? Thanks in advance, Kieron On Sat, Apr 11, 2020 at 7:43 AM Hendrik Boom wrote: > On Fri, Apr 10, 2020 at 08:18:38PM -0400, Jon Zeppieri wrote: > > (define (unique [list : (Listof Any)] [message : String] . > > [messageargs : Any *]) > > ; return the only element of the list, or '() if there is none. > > ; Produce message if not just one. > > (if (equal? 1 (length list)) (car list) > > (begin > >(apply fprintf anomaly message messageargs) > >(if (null? list) list (car list) > > Thank you. That worked. > The change to the apply syntax surprised me. > > -- hendrik > > > > > On Fri, Apr 10, 2020 at 7:49 PM Hendrik Boom > wrote: > > > > > > Trying to convert the following to typed Racket: > > > > > > (define (unique list message . messageargs) > > > ; return the only element of the list, or '() if there is none. > > > ; Produce message if not just one. > > > (if (equal? 1 (length list)) (car list) > > > (begin > > >(apply fprintf (cons anomaly (cons message messageargs))) > > >(if (null? list) list (car list)) > > >) > > > ) > > > ) > > > > > > It's an error message function tat accepts a list to test. > > > If the test fails it uses fprintf to print a message with the > > > arguments for the ~s items. > > > > > > I got so far, but I don't know what to do with the . messageargs : > > > > > > (define (unique [list (Listof Any)] [message : String] . messageargs) > > > ; return the only element of the list, or '() if there is none. > > > ; Produce message if not just one. > > > (if (equal? 1 (length list)) (car list) > > > (begin > > >(apply fprintf (cons anomaly (cons message messageargs))) > > >(if (null? list) list (car list)) > > >) > > > ) > > > ) > > -- > 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. > To view this discussion on the web visit > https://groups.google.com/d/msgid/racket-users/20200411134316.yff5tg7kwtglcs62%40topoi.pooq.com > . > -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/CAEEP09AhmxLHeRdOpzpuG7qC9jOuPTrpog92G_3b6nJWwZDzbw%40mail.gmail.com.