[racket] users Digest, Vol 109, Issue 61

From: Moshe Deutsch (moshedeutsch115 at gmail.com)
Date: Mon Sep 29 16:42:52 EDT 2014

Please take me off the list

Thanks

On Fri, Sep 26, 2014 at 11:08 PM,  <users-request at racket-lang.org> wrote:
> Send users mailing list submissions to
>         users at racket-lang.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
>         http://lists.racket-lang.org/users/listinfo
> or, via email, send a message with subject or body 'help' to
>         users-request at racket-lang.org
>
> You can reach the person managing the list at
>         users-owner at racket-lang.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of users digest..."
>
>
> [Racket Users list:
>  http://lists.racket-lang.org/users ]
>
>
> Today's Topics:
>
>    1. Re: typed racket, filters, and polymorphism (Alexander D. Knauth)
>    2. Re: ANN: DOS,     Delimited-continuation-based Operating-system
>       Simulator (Jay McCarthy)
>    3. Re: web server: module servlets (Jay McCarthy)
>    4. Re: typed racket and generic interfaces, is there a
>       workaround using properties? (Anthony Carrico)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Fri, 26 Sep 2014 19:35:24 -0400
> From: "Alexander D. Knauth" <alexander at knauth.org>
> To: racket users list <users at racket-lang.org>
> Cc: Sam Tobin-Hochstadt <samth at cs.indiana.edu>
> Subject: Re: [racket] typed racket, filters, and polymorphism
> Message-ID: <8CF041CE-65AD-488D-B2AE-FAE6C8C1C352 at knauth.org>
> Content-Type: text/plain; charset="windows-1252"
>
> Is it possible to have a struct that does certain things according to the guard?
> #lang typed/racket
>
> (struct (a) foo ([a : a]) #:transparent
>   #:guard (lambda (a _)
>             (unless (exact-integer? a)
>               (error 'foo "expected Integer, given ~v" a))
>             a))
>
> (ann (foo (ann 1 Any)) (foo Integer))
>
> (: x : (foo Any))
> (define x (foo 1))
>
> (ann (foo-a x) Integer)
>
> ;. Type Checker: Polymorphic function `foo1' could not be applied to arguments:
> ;Argument 1:
> ;  Expected: a
> ;  Given:    Any
> ;
> ;Result type:     (foo a)
> ;Expected result: (foo Integer)
> ; in: (foo (ann 1 Any))
> ;. Type Checker: Polymorphic function `foo-a' could not be applied to arguments:
> ;Argument 1:
> ;  Expected: (foo a)
> ;  Given:    (foo Any)
> ;
> ;Result type:     (a : ....)
> ;Expected result: Integer
> ; in: (foo-a x)
>
> On Sep 25, 2014, at 9:42 PM, Alexander D. Knauth <alexander at knauth.org> wrote:
>
>> What I?m trying to accomplish is something more like this:
>> #lang typed/racket
>>
>> (require "dimensions.rkt")
>>
>> (struct (d) unit ([name : Any] [scalar : Positive-Real] [dimension : d]) #:transparent
>>   #:guard (lambda (name scalar dimension _)
>>             (unless (dimension? dimension)
>>               (error 'unit "expected Dimension, given ~v" dimension))
>>             (values name scalar dimension)))
>>
>> (define-type (Unitof d) (unit d))
>>
>> (define-type Unit (Unitof Dimension))
>>
>> (define Unit? (make-predicate Unit))
>>
>> (define-type Unitish
>>   (U (Unitof Any)
>>      Dimension
>>      Positive-Real))
>>
>> (: ->unit : (All (d) (case-> [(Unitof d) -> (Unitof d)]
>>                              [Unitish -> Unit])))
>> (define (->unit u)
>>   (cond [(unit? u)
>>          (unless (Unit? u) ; this should never happen anyway because of the guard
>>            (error '->unit "expected (Unitof Dimension), given ~v" u))
>>          u]
>>         [(dimension? u) (unit u 1 u)]
>>         [(positive-real? u) (unit u u dimensionless-dimension)]))
>>
>>
>> On Sep 25, 2014, at 6:19 PM, Sam Tobin-Hochstadt <samth at cs.indiana.edu> wrote:
>>
>>> No, I don't think you can do this. Can you say more about what you're
>>> trying to accomplish?
>>>
>>> Sam
>>>
>>> On Thu, Sep 25, 2014 at 6:15 PM, Alexander D. Knauth
>>> <alexander at knauth.org> wrote:
>>>> Do any of you have any advice for getting a function like this to
>>>> type-check?
>>>> #lang typed/racket
>>>>
>>>> (: check-int : (All (a) (case-> [a -> a]
>>>>                                [Any -> Integer])))
>>>> (define (check-int int)
>>>>  (unless (exact-integer? int)
>>>>    (error 'check-int "expected Integer, given ~v" int))
>>>>  int)
>>>>
>>>> ;. Type Checker: type mismatch
>>>> ;  expected: a
>>>> ;  given: Integer in: int
>>>>
>>>>
>>>>
>>>> ____________________
>>>>  Racket Users list:
>>>>  http://lists.racket-lang.org/users
>>>>
>>
>> ____________________
>>  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/20140926/bbbbc5ac/attachment-0001.html>
>
> ------------------------------
>
> Message: 2
> Date: Fri, 26 Sep 2014 20:03:57 -0400
> From: Jay McCarthy <jay.mccarthy at gmail.com>
> To: "Michael Bradley, Jr." <michaelsbradleyjr at gmail.com>
> Cc: users <users at racket-lang.org>
> Subject: Re: [racket] ANN: DOS, Delimited-continuation-based
>         Operating-system Simulator
> Message-ID:
>         <CAJYbDanLdZACFv41w+CAtNjvLernOomC0L7goMVHH-kwe07fXw at mail.gmail.com>
> Content-Type: text/plain; charset=UTF-8
>
> Sure, I can make a post about it. However, the core idea is already in
> this post:
>
> http://jeapostrophe.github.io/2012-07-12-cont-sys-post.html
>
> I can make another one, however, to rehash it and talk about the
> benefits of monoid states.
>
> Jay
>
> On Fri, Sep 26, 2014 at 2:15 PM, Michael Bradley, Jr.
> <michaelsbradleyjr at gmail.com> wrote:
>> Jay McCarthy <jay.mccarthy at ...> writes:
>>
>>>
>>> I've just released the game architecture library I talked about in
>>> part 2 of my RacketCon talk.
>>>
>>> The big picture of this library is to make World-style programs more
>>>  compositional by (a) using continuations to hide the internal state
>>> (including control state) of components and (b) using environments as
>>> a standard monoid-based inter-component communication channel. A
>>> monoid is used to ensure that the components can be evaluated in any
>>> order. Despite assumptions some have about continuations and pure
>>> functional programming, it is incredibly efficient and can run at
>>> 60FPS, as demonstrated in get-bonus.
>>>
>>> You can get it with
>>>
>>> raco pkg install dos
>>>
>>> And you can try out the demo with
>>>
>>> racket -l dos/examples/win
>>>
>>> The demo source is a bare 39 lines:
>>>
>>> https://github.com/jeapostrophe/dos/blob/master/dos/examples/win.rkt
>>>
>>> and I provide the non-DOS version for comparison:
>>>
>>> https://github.com/jeapostrophe/dos/blob/master/dos/examples/win-long.rkt
>>>
>>> The core library has a mere 36 lines:
>>>
>>> https://github.com/jeapostrophe/dos/blob/master/dos/main.rkt
>>>
>>
>>
>>
>> Hi Jay,
>>
>> I really enjoyed your talk on get-bonus at RacketCon last weekend, and
>> appreciate your sharing DOS with all of us. Also, your presentation at
>> Strange Loop 2013 was my first introduction to delimited continuations in
>> Racket!
>>
>> I have benefited from a number of your blog posts in the past, e.g. the one
>> on an improved threading macro, and was wondering if you would consider
>> doing a write-up on DOS?
>>
>> Best regards,
>>
>> --
>> Michael Bradley, Jr.
>> @michaelsbradley
>>
>>
>> ____________________
>>   Racket Users list:
>>   http://lists.racket-lang.org/users
>
>
>
> --
> Jay McCarthy
> http://jeapostrophe.github.io
>
>            "Wherefore, be not weary in well-doing,
>       for ye are laying the foundation of a great work.
> And out of small things proceedeth that which is great."
>                           - D&C 64:33
>
>
> ------------------------------
>
> Message: 3
> Date: Fri, 26 Sep 2014 20:08:30 -0400
> From: Jay McCarthy <jay.mccarthy at gmail.com>
> To: George Neuner <gneuner2 at comcast.net>
> Cc: users <users at racket-lang.org>
> Subject: Re: [racket] web server: module servlets
> Message-ID:
>         <CAJYbDa=aYrXcKh6bZK-dBai4CYR8tE+yuXOMHp6P9a-sYs_f4Q at mail.gmail.com>
> Content-Type: text/plain; charset=UTF-8
>
> Hi George,
>
> I suggest that all Racket web-server apps not use the dynamic features
> of serve/servlet either, but instead write the servlet as the single
> "request -> response" function that serve/servlet provides. This would
> ensure that all the libraries are loaded the one time and has the best
> performance out of all the options of the Web server. Furthermore,
> there are many features (such as total URL control) that are only
> available in this model.
>
> In case it is not completely clear, here's a little example (<500
> lines) of a Web application that works this way:
>
> https://github.com/plt/racket/blob/master/pkgs/plt-services/meta/pkg-index/official/dynamic.rkt#L423
>
> Here's another that uses 'serve' directly for non-servlet needs:
>
> https://github.com/jeapostrophe/exp/blob/master/dir-serve.rkt
>
> And here's a considerably longer one:
>
> https://github.com/jeapostrophe/grade-samurai/blob/master/app.rkt#L2020
>
> I highly recommend using serve/servlet like this over any other
> options. In particular, many of the problems you're talking about were
> the reason that I made serve/servlet in the first place.
>
> Jay
>
> On Fri, Sep 26, 2014 at 12:16 AM, George Neuner <gneuner2 at comcast.net> wrote:
>> On 9/25/2014 6:26 PM, Jay McCarthy wrote:
>>
>> web-server/servlet is NOT shared, nor is any net library or common
>> racket library like racket/list. They are all totally unique per
>> servlet.
>>
>> This, by the way, is part of why I don't recommend using dynamic
>> servlets at all and suggest using serve/servlet.
>>
>>
>> But ... IIUC ... a listener started by  serve/servlet  will still
>> dynamically load from <servlet-root>, <server-root>/htdocs/*, etc. if the
>> request doesn't match a hard coded dispatch URL - the regex of the initial
>> servlet or an entry in a dispatcher table.  At least that's the behavior I
>> see with my own application: my initial servlet returns 404 when called -
>> the call to  serve/servlet  just sets up the environment and and all the
>> "real" servlets are demand loaded from disk when first touched.
>>
>> Are you advocating *static* linking and essentially just dispatching to
>> internal functions by URL?  ISTM that that defeats the purpose.
>>
>> George
>
>
>
> --
> Jay McCarthy
> http://jeapostrophe.github.io
>
>            "Wherefore, be not weary in well-doing,
>       for ye are laying the foundation of a great work.
> And out of small things proceedeth that which is great."
>                           - D&C 64:33
>
>
> ------------------------------
>
> Message: 4
> Date: Fri, 26 Sep 2014 23:07:55 -0400
> From: Anthony Carrico <acarrico at memebeam.org>
> To: users at racket-lang.org
> Subject: Re: [racket] typed racket and generic interfaces, is there a
>         workaround using properties?
> Message-ID: <54262A0B.2010901 at memebeam.org>
> Content-Type: text/plain; charset="windows-1252"
>
> Dredging up an old thread: So how exactly do you define custom-write for
> a typed racket struct?
>
> On 05/25/2014 03:30 PM, Alexander D. Knauth wrote:
>> Never mind I just found prop:dict.
>>
>> By the way it would probably be helpful if instead of the value for
>> prop:dict being a vector, it was a hash table with the method names
>> as the keys, so then it would be a lot easier to tell which procedure
>> goes with which method, and also a lot easier to extend it while
>> maintaining backwards compatibility.
>>
>> On May 24, 2014, at 10:38 PM, Alexander D. Knauth
>> <alexander at knauth.org> wrote:
>>
>>> Do generic interfaces work using structure type properties, and if
>>> they do, is there a way to use generic interfaces through
>>> properties so that I can do it in typed racket?
>>>
>>> Specifically I?m trying to use the gen:custom-write and gen:dict
>>> generic interfaces.  I can use prop:custom-write for the first one,
>>> but I don?t know what to do for gen:dict.
>>>
>>> Otherwise I?ll just put it in an untyped submodule.
>
> --
> Anthony Carrico
>
> -------------- next part --------------
> A non-text attachment was scrubbed...
> Name: signature.asc
> Type: application/pgp-signature
> Size: 181 bytes
> Desc: OpenPGP digital signature
> URL: <http://lists.racket-lang.org/users/archive/attachments/20140926/d14018a4/attachment.sig>
>
> End of users Digest, Vol 109, Issue 61
> **************************************

Posted on the users mailing list.