Re: [racket-users] Re: ask a pict its colour?

2020-04-20 Thread Spencer Florence
You could use pict/convert to make a wrapper that remembers the color:

```
#lang racket
(require pict pict/convert)
(struct pict+color (pict color)
  #:property prop:pict-convertible
  (lambda (x) (pict+color-pict x)))

(define (my-colorize p c)
  (pict+color
   (colorize p c)
   c))

(define (get-color p)
  (and
   (pict+color? p)
   (pict+color-color p)))
  ```

This would be a little unreliable, as only the direct result of
`my-colorize` would have a retrievable color, but it might work for your
purposes.

--spencer

On Sat, Apr 18, 2020 at 9:34 PM Robby Findler 
wrote:

> I basically agree with Alex, as the internal structures of pict don't
> really keep information in that way, but a "best effort" might be to
> draw it into a bitmap and then use the bitmap to find the average
> color or the most common color (perhaps with some error bounds on what
> colors count as "the same") or something like that.
>
> Robby
>
> On Sat, Apr 18, 2020 at 6:49 PM Alex Harsanyi 
> wrote:
> >
> >
> > I don't think such a procedure can be written. at least not for the
> general case.
> >
> > First, the color of `(filled-rectangle 30 30)` is not black, but
> whatever color was installed in the drawing context when the filled
> rectangle was rendered.  You can change it to red using:
> >
> > (colorize (filled-rectangle 20 20) "red")
> >
> > Even if you could inspect the colorize pict, it would still not be
> sufficient for a general `get-color` function.  Users can write their own
> pict constructors using dc:
> >
> >
> > (define colors (list "red" "green" "blue" "yellow"))
> >
> > (define (my-red-colorize other-pict)
> >   (dc (lambda (dc dx dy)
> >
> > (define color (list-ref colors (random (length colors
> >
> > (define old-pen (send dc get-pen))
> > (send dc set-pen (new pen% [width 1] [color color]))
> >
> > (draw-pict other-pict dc dx dy)
> >
> > (send dc set-pen old-pen))
> >   (pict-width other-pict)
> >   (pict-height other-pict)))
> >
> > And a call like `(my-red-colorize (filled-rectangle 20 20))` will only
> result in a red rectangle about 25% of the time.
> >
> > Even if you want to ignore cases like the above, what should `get-color`
> return for the picture below?
> >
> > (hc-append (colorize (filled-rectangle 20 20) "red") (colorize
> (filled-rectangle 20 20) "blue"))
> >
> >
> > Alex.
> >
> >
> > On Saturday, April 18, 2020 at 8:00:12 PM UTC+8, Raoul Schorer wrote:
> >>
> >> Hi,
> >>
> >> Using the 'pict' library, I could not find predicates regarding color
> in the doc.
> >> Is there something like
> >>
> >> (get-color (filled-rectangle 30 30)) --> "black"
> >>
> >> somewhere?
> >> If not, how can I make a reliable color predicate?
> >>
> >> Thanks,
> >> Raoul
> >
> > --
> > 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/d3fa9021-63af-4129-bfb6-a82e219cfcf0%40googlegroups.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/CAL3TdONPB16S1srT1%3Dz0ZPM52%3DZh624hrq5zOc7C4oerXqgaCA%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/CAF4wvDzH-AK40WjJrnhFKDAiJaV5fQrCV0othqQj-R%3Di7S1PxQ%40mail.gmail.com.


Re: [racket-users] cover package?

2020-02-26 Thread Spencer Florence
Moral of this story: the pkg-build server configuration can have bugs in
it. Therefore, if you don't test it, it will have bugs in it

--spencer

On Wed, Feb 26, 2020 at 3:28 PM Stephen Foster 
wrote:

> On further investigation, cover just seems to be broken, older versions
> install without errors.  I'll open a ticket on that repo.
>
> On Wed, Feb 26, 2020 at 1:14 PM Stephen Foster 
> wrote:
>
>> I have a Dockerized racket app that has (today, I think) started failing
>> with errors related to the "cover" package.  I don't use cover -- though I
>> assume one of my dependencies does.  Adding "cover" explicitly to my
>> info.rkt file doesn't fix the issue.
>>
>> What might be going wrong here?  And how can I track down what depends on
>> this?
>>
>> open-input-file: cannot open module file
>>   module path: cover
>>   path: /root/.racket/7.5/pkgs/cover/main.rkt
>>   system error: no such file or directory; rktio_err=3
>>   compilation context...:
>>/root/.racket/7.5/pkgs/cover/cover-lib/cover/raco.rkt
>>   context...:
>>maybe-raise-missing-module
>>default-load-handler
>>standard-module-name-resolver
>>module-path-index-resolve
>>perform-require!78
>>for-loop
>>finish
>>[repeats 10 more times]
>>pass-1-and-2-loop
>>module-begin-k
>>expand-module16
>>expand-capturing-lifts
>>temp118_0
>>temp91_0
>>compile15
>>/usr/share/racket/collects/compiler/private/cm-minimal.rkt:428:0:
>> compile-zo*66
>>...
>>
>>
>> standard-module-name-resolver: collection not found
>>   for module path: cover/private/shared
>>   collection: "cover/private"
>>   in collection directories:
>>/root/.racket/7.5/collects
>>/usr/share/racket/collects
>>... [217 additional linked and package directories]
>>sub-collection: "private"
>>   in parent directories:
>>/root/.racket/7.5/pkgs/cover
>>   compilation context...:
>>/root/.racket/7.5/pkgs/cover/cover-test/format-utils.rkt
>>   context...:
>>show-collection-err
>>standard-module-name-resolver
>>module-path-index-resolve
>>perform-require!78
>>for-loop
>>finish
>>[repeats 13 more times]
>>pass-1-and-2-loop
>>module-begin-k
>>expand-module16
>>expand-capturing-lifts
>>temp118_0
>>temp91_0
>>compile15
>>/usr/share/racket/collects/compiler/private/cm-minimal.rkt:428:0:
>> compile-zo*66
>>/usr/share/racket/collects/compiler/private/cm-minimal.rkt:731:15
>>...
>>
>>
>> standard-module-name-resolver: collection not found
>>   for module path: cover/private/shared
>>   collection: "cover/private"
>>   in collection directories:
>>/root/.racket/7.5/collects
>>/usr/share/racket/collects
>>... [217 additional linked and package directories]
>>sub-collection: "private"
>>   in parent directories:
>>/root/.racket/7.5/pkgs/cover
>>   compilation context...:
>>/root/.racket/7.5/pkgs/cover/cover-test/format-utils.rkt
>>   context...:
>>show-collection-err
>>standard-module-name-resolver
>>module-path-index-resolve
>>perform-require!78
>>for-loop
>>finish
>>[repeats 13 more times]
>>pass-1-and-2-loop
>>module-begin-k
>>expand-module16
>>expand-capturing-lifts
>>temp118_0
>>temp91_0
>>compile15
>>/usr/share/racket/collects/compiler/private/cm-minimal.rkt:428:0:
>> compile-zo*66
>>/usr/share/racket/collects/compiler/private/cm-minimal.rkt:731:15
>>...
>>
>>
>> etc.
>>
>> --
>> You received this message because you are subscribed to a topic in the
>> Google Groups "Racket Users" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/racket-users/X7O4bUAnqxU/unsubscribe.
>> To unsubscribe from this group and all its topics, 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/5b09c421-621c-4485-91eb-81a2ab6249d4%40googlegroups.com
>> 
>> .
>>
>
>
> --
>
>
> Stephen Foster
> ThoughtSTEM Co-Founder
> 318-792-2035
>
> --
> 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/CA%2BzSu29hL3BOa7Ez-Om29RNr9B-E19M%3Dr1TX3KV-MMB8AL%3DV%2Bg%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...@google

Re: [racket-users] pict polygons

2019-12-17 Thread Spencer Florence
2htdp/image works with pict directly (they are pict-convertible?, and all
pict functions accept those).

If that does work for whatever reason, it shouldnt be terrible to write
that function using ‘dc’ and ‘dc-path%’, and it would make a great PR to
‘pict’!

—spencer

On Tue, Dec 17, 2019 at 8:15 AM Hendrik Boom  wrote:

> I've been looking through pict documentation again, and failed to find
> a way to draw arbitrary polygons.
>
> (at the moment I just want a triangle, but I couldn't even find
> that)
>
> There are triangles in the image.rkt from 2htdp/image, but that seems to
> use
> different data types from pict.
>
> Given the variety of polygons available in pict (such as filled-in
> areas) I would find it surprising if there were no such functionality,
>
> -- hendrik
>
>
> --
> 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/20191217141452.g27usl46rwn556re%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/CAF4wvDxWjFLvSNon8D2U9FTQHpVc8j5q-6%2BXhJCH3118539xYw%40mail.gmail.com.


Re: [racket-users] Re: typo in manual

2019-11-25 Thread Spencer Florence
Not the first typo this library has had...

I've pushed a repair, thanks for the report!

--spf

On Fri, Nov 22, 2019 at 11:47 AM 'Joel Dueck' via Racket Users <
racket-users@googlegroups.com> wrote:

> Documentation for individual packages is maintained by the package authors.
>
> Clicking on the "package" link at the top brings you to
> https://pkgs.racket-lang.org/package/colors which says the Git repo is at
> https://github.com/florence/colors/tree/master/scribblings
>
> I can submit a pull request there, unless you would prefer to.
>
> On Friday, November 22, 2019 at 10:39:34 AM UTC-6, Hendrik Boom wrote:
>>
>> In https://docs.racket-lang.org/colors/index.html
>> section 4 presents a function set-brigthness
>> and then proceeds to discuss how it affects brighness
>>
>> Perhaps the function name and the discussion should involve brightness
>> instead.
>>
>> -- hendrik
>>
>> --
> 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/b5dcbaa8-c3ad-47a8-bc54-4c48171d73ce%40googlegroups.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/CAF4wvDzLR_z5Aah2kq38OzyR5sqZENXjj3F8UtecjWRd5cxJBw%40mail.gmail.com.


Re: [racket-users] project idea: drracket notebook mode

2018-12-27 Thread Spencer Florence
One exists:

https://github.com/rmculpepper/iracket

On Thu, Dec 27, 2018, 12:53 AM Andrew Gwozdziewycz  It seems like the better bang for buck might be implementing a Jupyter
> kernel, and leveraging that ecosystem.
>
> https://github.com/jupyter/jupyter/wiki/Jupyter-kernels
>
> On Dec 20, 2018, at 02:46, Neil Van Dyke  wrote:
>
> If anyone is looking to avoid relatives over the winter holiday season,
> here's an idea for a big feature to add to DrRacket (which I really wish I
> could do myself right now)...
>
> If you've not seen a "notebook" interface, like in Jupyter Notebook and
> some other data science-oriented tools, one way to look at it is like a
> literate programming REPL that can be edited, stored to a file, and
> loaded.  You can also share these notebooks with others, or generate
> formats like HTML or Markdown (such as for blog posts).
>
> The notebook is a document that's a sequence of text cells and code cells,
> and the code cells include the output (e.g., expression results, displayed
> plots) from the last time the code cell was evaluated (if it was).  Each
> code cell also displays a small serial number that indicates in what order
> it was last evaluated (if it has been), which is not necessarily the
> top-to-bottom order of the document while you're working with it.  Of
> course, you can clear this code evaluation and output at any time, and
> cause all the code cells to be evaluated in-order.
>
> IIRC, DrRacket emphasizes the Definitions window over the Interactions
> window (aka REPL), to reduce confusion for students.  I think the confusion
> level of the Notebook interface is somewhere between that of Definitions
> window and a REPL.  So the notebook interface might not be good for new
> students, unless they're already comfortable with the notebook interface
> from other classes.
>
> Implementation-wise... the people here who built DrRacket can correct me
> or say more about this, but it seems DrRacket implementation might already
> include most of the difficult work of implementing a notebook interface.
> The evaluation engine is there, and there's UI for snips in the Interaction
> window, and UI for embedding blocks of other formats in the Definitions
> window.  Maybe combine/adapt that in a new Notebook window, or implement
> this as features of the Definitions window.  Then you can decide whether to
> also implement the JSON save format of Jupyter Notebook, for possible later
> interoperation.  And other things after that, like in-buffer Markdown or
> Scribble rendering of text cells.
>
> --
> 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.


[racket-users] syntax-original? different in expanded code than during expansion

2017-09-20 Thread Spencer Florence
The program:

```
#lang racket

(define-syntax (exp stx)
  (define a (local-expand (cadr (syntax->list stx)) 'expression '()))
  (define one (cadr (syntax->list a)))
  (displayln (list one (syntax-original? one)))
  a)

(exp 1)
 ```

prints `(# #f)`.

However if I open the macro stepper in and step to the end, the macro
stepper shows the corresponding `1` as `original?: #t`.

Why are these different?

--spencer

-- 
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] RacketCon Code of Conduct

2017-06-18 Thread Spencer Florence
+1 more for a Code of Conduct

On Sun, Jun 18, 2017 at 11:28 AM Matt Jadud  wrote:

> I'm with Claire 100%.
>
> I think the code of conduct proposed as a starting point is completely
> reasonable.
>
> So, "+1."
>
> Cheers,
> Matt
>
> On Sun, Jun 18, 2017 at 12:07 PM, claire alvis 
> wrote:
>
>> On Saturday, June 17, 2017 at 2:53:23 PM UTC-4, Matthias Felleisen wrote:
>> > A code of conduct is a totally stupid idea for RacketCon. Racketeers
>> were raised properly by their parents and are well behaved. I really hate
>> attending conferences that need to impose a code.
>>
> --
> 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] Why are hash and make-hash not symmetric?

2016-12-07 Thread Spencer Florence
For symmetry there is "make-immutable-hash", which is like "hash" but has
the interface of "make-hash". (I don't know why "hash" is the way it is
though).

--spencer

On Wed, Dec 7, 2016 at 10:49 AM David Storrs  wrote:

> -> (hash 'a 1 'b 2)
> '#hash((a . 1) (b . 2))
>
> -> (make-hash '((a . 1) (b . 2)))
> '#hash((b . 2) (a . 1))
>
> -> (make-hash 'a 1 'b 2)
> (make-hash 'a 1 'b 2)
> ; make-hash: arity mismatch;
> ;  the expected number of arguments does not match the given number
> ;   expected: 0 to 1
> ;   given: 4
> ; [,bt for context]
>
> Why does 'make-hash' not work like 'hash'?  Is it possible that a flag
> could be added that would *make* it work like hash?  Or, alternatively,
> does another function exist that will create a mutable hash but will accept
> N arguments the way 'hash' does?  I understand that it's not very FP to use
> mutation but there are certain problems that are easier that way.
>
> --
> 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] Adding libraries to the student language search

2016-09-25 Thread Spencer Florence
When the current language is one of the student languages searching the
documentation from DrRacket limits the search to a subset libraries
installed. Is there any way to add a new library to this subset?

--Spencer

-- 
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] handin server error

2016-09-07 Thread Spencer Florence
This is a little bit of a hack and weakens the handin server security but
adding the following to the top of your checker file should make this error
go away:

```
 (require handin-server/sandbox)

  (sandbox-path-permissions
   (cons
(list 'read"/")
(sandbox-path-permissions)))
```

--spencer

On Tue, Aug 23, 2016 at 4:15 PM Cameron Swords 
wrote:

> Hi,
>
> I'm trying to set up a handin server for a class this semester, and I'm
> getting the weirdest error message from the client side. Here it is:
>
> submit error: Error in your code --
> file-exists?: `exists' access denied for libobj.so
>
> This seems tied to the fact that the submission file requires another file
> (precisely, it requires 2htdp/image as `(require 2htdp/image)`), and when I
> remove that it works fine (though obviously inhibits the assignment).
>
> Attached are the checker and configuration.
>
> Any help would mean a lot!
>
> Thanks,
> Cameron Swords
>
> --
> 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] using a different "scribble.tex"

2016-03-31 Thread Spencer Florence
Oops, guess I forgot to update this thread.

This commit (
https://github.com/racket/scribble/commit/2881ef290ddfef6b645eaabc997c9bd6fddaa641)
tries to address this problem.

Roughly, you can use `latex-defaults+replacements` to replace
`scribble-load-replace.tex` and override the macros that generate the latex
includes.

--spf


On Thu, Mar 31, 2016 at 2:45 AM Tim Jervis  wrote:

> Commenting out scribble.tex with an open comment in prefix.tex and closing
> comment in scribble.tex works, to a point. It hides scribble.tex, but it
> also hides any dynamic inclusions such as figure.tex.
>
> I have been trying to use the longtable package in preference to the
> stabular-based  package that Scribble uses for long tables. Unfortunately
> scribble.tex creates some incompatible definitions, which I have been
> trying to work around. My current best option appears to be hacking
> scribble.tex in the Racket source to remove those definitions. It would be
> nice to avoid hacking the source.
>
> On 6 Jan 2016, at 20:53, Matthew Flatt  wrote:
>
> There's not currently a simple way to replace "scribble.tex".
>
> Probably you can hack anything by providing an alternate prefix file
> (i.e., replacement for "scribble-prefix.tex"). For example, I bet it
> would be possible to make the prefix file end with an unfinished
> comment, have the comment swallow "scribble.tex" completely, and have a
> style file (i.e., replacement for "scribble-style.tex") end the comment
> and drop in your replacement for "scribble.tex".
>
> At Wed, 06 Jan 2016 20:44:40 +, Spencer Florence wrote:
>
> Hey all,
>
> I'm currently trying to use a custom tex style file with scribble.
> Unfortunately this style file conflicts with the line
> "\usepackage[usenames,dvipsnames]{color}" in the "scribble.tex" file
> include by the scribble to tex compiler.
>
> Is there any way to tell scribble to use a different "scribble.tex"?
>
> --spencer
>
> --
> 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.
>
>
>
> *Tim Jervis*
>
> http://timjervis.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.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Unicode subscripts in code and scribble

2016-03-10 Thread Spencer Florence
They way I've worked around this in the past is to render the problematic
character as a Pict and then drop that Pict into the scribble document.
Doing that has some problems but it can service if you can't get the
character you want into scribble.

On Thu, Mar 10, 2016, 9:19 AM Vincent St-Amour <
stamo...@eecs.northwestern.edu> wrote:

> I agree, any extension anyone makes should make it into scribble itself.
>
> The scenario I'm concerned about is: user needs an extra character, but
> can't update scribble. Or updating scribble would require updating the
> rest of Racket, which may not be what the user wants.
>
> I guess with the split distribution it's less likely to be a problem,
> though.
>
> Vincent
>
>
>
> On Wed, 09 Mar 2016 19:22:05 -0600,
> Robby Findler wrote:
> >
> > I think any extension is one that all would want (although I am not
> > sure) and so maybe pull requests is a good way to extend it?
> >
> > There is the issue of conflicting imports at the latex level tho, so
> > maybe it should be specifiable at the document level.
> >
> > Robby
> >
> > On Wednesday, March 9, 2016, Vincent St-Amour
> >  wrote:
> >
> > Should that table be user-extensible?
> >
> > Vincent
> >
> >
> > On Wed, 09 Mar 2016 17:11:47 -0600,
> > Robby Findler wrote:
> > >
> > > I think that maybe you're thinking of something fancier than
> > what's
> > > there. It just takes some (small) set of well-known unicode and
> > has
> > > corresponding latex commands. Then, in the latex backend for
> > scribble,
> > > it looks up latex in that table and drops it in, if it finds it.
> > >
> > > Robby
> > >
> > > On Wed, Mar 9, 2016 at 5:09 PM, Leif Andersen
> >  wrote:
> > > >> Scribble has a big table mapping unicode to latex commands.
> > Maybe it
> > > > needs another entry?
> > > >
> > > > Woah, does that actually work? I was under the impression there
> > were
> > > > unicode characters that could combine other unicode characters.
> > > >
> > > > (Although I'd love to be wrong about this. :) )
> > > >
> > > > ~Leif Andersen
> > > >
> > > >
> > > > On Wed, Mar 9, 2016 at 5:55 PM, Robby Findler
> > > >  wrote:
> > > >> Scribble has a big table mapping unicode to latex commands.
> > Maybe it
> > > >> needs another entry?
> > > >>
> > > >> Robby
> > > >>
> > > >>
> > > >> On Wed, Mar 9, 2016 at 4:07 PM, David Van Horn
> >  wrote:
> > > >>> Yes, the problem then is the code font doesn't support that
> > character
> > > >>> so it doesn't show up.
> > > >>>
> > > >>> David
> > > >>>
> > > >>>
> > > >>> On Wed, Mar 9, 2016 at 5:05 PM, Leif Andersen
> >  wrote:
> > >  Have you tried running the outputted tex file in xetex rather
> > than pdflatex?
> > > 
> > >  ~Leif Andersen
> > > 
> > > 
> > >  On Wed, Mar 9, 2016 at 5:03 PM, David Van Horn
> >  wrote:
> > > > I have some source code I'm trying to typeset in a
> > racketblock that
> > > > uses subscript characters like ₀. This breaks when it gets
> > to latex.
> > > > Is there some workaround to generate latex friendly output?
> > > >
> > > > Thanks,
> > > > 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.
> > >
> > > --
> > > 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 

[racket-users] using a different "scribble.tex"

2016-01-06 Thread Spencer Florence
Hey all,

I'm currently trying to use a custom tex style file with scribble.
Unfortunately this style file conflicts with the line
"\usepackage[usenames,dvipsnames]{color}" in the "scribble.tex" file
include by the scribble to tex compiler.

Is there any way to tell scribble to use a different "scribble.tex"?

--spencer

-- 
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] Bug with errortrace and begin-for-syntax?

2015-10-10 Thread Spencer Florence
Yup, that looks like a bug. I've created a PR to fix it:
https://github.com/racket/errortrace/pull/4

On Sat, Oct 10, 2015 at 8:51 AM Matthias Felleisen 
wrote:

>
> On Oct 10, 2015, at 12:06 AM, Alex Knauth  wrote:
>
> #lang racket/base
> (require (for-meta 0 racket/base)
> (for-meta 1 racket/base)
> (for-meta 2 racket/base)
> (for-meta 3 racket/base)
> (for-meta 4 racket/base))
> (begin-for-syntax
>  (begin-for-syntax
>(begin-for-syntax
>  )))
>
>
>
> And I thought lambda-lambda-lambda solves all problems :-)
>
> --
> 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] Cover 3.0

2015-09-22 Thread Spencer Florence
Hi all,

We're pleased to announce the release of Cover 3.0!

Cover is an extensible multi-file code coverage tool for Racket. You can
read more about it in our
README at https://github.com/florence/cover .

Breaking Changes:

 * The Coveralls format has been moved into its own package. Anyone using
it will need to change
   their package dependency from `cover` to `cover-coveralls`.  More
details at
   https://github.com/rpless/cover-coveralls .

New features and bug fixes in this version:

 * Support for modules required `for-syntax`.

 * Support for `test-include-paths` and `module-suffixes` in info.rkt, and
regular expressions in
   `test-omit-paths`. These can be used to configure what files Cover does
or does not include in
   its reports.

 * Support for cyclic requires between modules.

 * Improvements on covering macros.

New contributors are always welcome!
If you find bugs, you can open an issue at
https://github.com/florence/cover/issues.
In addition, if there are any new output formats, tools, or services that
you think should be added, open an issue.

Thanks!

--Spencer & Ryan

-- 
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] Macro introduce identifiers in the new expander

2015-07-21 Thread Spencer Florence
That fixed the example I gave, but now this fails:

(let ()
  (def)
  (let ()
(use)))

On Mon, Jul 20, 2015 at 2:50 PM Matthew Flatt  wrote:

> Repair pushed.
>
>
>
> > On Jul 20, 2015, at 11:14 AM, Matthew Flatt  wrote:
> >
> > Thanks for the info. I think it's a bug in the expander, and I have a
> > repair, but I think that repair might point to another bug that I'm
> > still investigating.
> >
> > At Mon, 20 Jul 2015 12:56:49 -0400, "Alexander D. Knauth" wrote:
> >> I don't really know what's going on, but this might help:
> >>
> >> ;; It seems to be introducing the definition correctly, but not the use:
> >> ;; this works
> >> (let ()
> >>  (def) ; no difference between (def) and (define id 5)
> >>  id)
> >>
> >> ;; this doesn't
> >> (let ()
> >>  (def)
> >>  (use)) ; but there is a difference between (use) and id
> >>
> >> ;; and this doesn't either
> >> (let ()
> >>  (define id 5)
> >>  (use))
> >>
> >>> On Jul 20, 2015, at 12:35 PM, Spencer Florence 
> wrote:
> >>>
> >>> Hello,
> >>>
> >>> I'm trying to update some code to the new expander. The below code
> works on
> >> 6.2 but fails on the new expander with an unbound identifier error.
> >>>
> >>> #lang racket
> >>> (require (for-syntax syntax/parse))
> >>>
> >>> ;; a standard context for identifiers
> >>> (define-for-syntax ctx #'ctx)
> >>>
> >>> ;; create an ID with the context `ctx`, and the current
> >>> ;; expander mark (so that the mark is canceled later),
> >>> ;; and the location loc
> >>> (define-for-syntax (make-id loc)
> >>>  (syntax-local-introduce
> >>>   (datum->syntax ctx 'id loc)))
> >>>
> >>> ;; This introduces a binding
> >>> (define-syntax (def stx)
> >>>  (syntax-parse stx
> >>>[(def)
> >>> (with-syntax ([id (make-id #'here)])
> >>>   #'(define id 5))]))
> >>>
> >>> ;; this attempts to use the binding introduced by `def`
> >>> (define-syntax (use stx)
> >>>  (syntax-parse stx
> >>>[(use)
> >>> (with-syntax ([id (make-id #'here)])
> >>>   #'id)]))
> >>>
> >>> ;; this works
> >>> #;
> >>> (begin
> >>>  (def)
> >>>  (use))
> >>>
> >>> ;; this fails
> >>> (let ()
> >>>  (def)
> >>>  (use))
> >>>
> >>> --
> >>> 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.
> >
>
> --
> 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] Macro introduce identifiers in the new expander

2015-07-20 Thread Spencer Florence
Hello,

I'm trying to update some code to the new expander. The below code works on
6.2 but fails on the new expander with an unbound identifier error.

#lang racket
(require (for-syntax syntax/parse))

;; a standard context for identifiers
(define-for-syntax ctx #'ctx)

;; create an ID with the context `ctx`, and the current
;; expander mark (so that the mark is canceled later),
;; and the location loc
(define-for-syntax (make-id loc)
  (syntax-local-introduce
   (datum->syntax ctx 'id loc)))

;; This introduces a binding
(define-syntax (def stx)
  (syntax-parse stx
[(def)
 (with-syntax ([id (make-id #'here)])
   #'(define id 5))]))

;; this attempts to use the binding introduced by `def`
(define-syntax (use stx)
  (syntax-parse stx
[(use)
 (with-syntax ([id (make-id #'here)])
   #'id)]))

;; this works
#;
(begin
  (def)
  (use))

;; this fails
(let ()
  (def)
  (use))

-- 
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] Iteration speed

2015-06-01 Thread Spencer Florence
There is a `#lang typed/racket/base/no-check`

On Mon, Jun 1, 2015 at 9:34 PM John Carmack  wrote:

> Is there an option to parse all the type annotations, but not do any of
> the checking? Highly interactive tuning sessions could work without type
> checking, then turn it back on for structural work.
>
>
>
> > On Jun 1, 2015, at 9:05 PM, Sam Tobin-Hochstadt 
> wrote:
> >
> > Unfortunately, Typed Racket typechecking is pretty slow, and so the
> > times you have there are not out of the ordinary. The most significant
> > thing that's slow in Typed Racket is type checking numeric operations,
> > because both the numbers themselves and the operations have
> > complicated types.
> >
> > If you can say more about the program in particular, I can maybe
> > suggest something that would speed it up, but it's currently a
> > combination of expensive-in-principle algorithms and not being
> > designed for speed many years ago when I started.
> >
> > Sam
> >
> >> On Mon, Jun 1, 2015 at 9:06 PM, John Carmack  wrote:
> >> I am working on a little project to remotely drive a VR headset with
> code
> >> written in Racket as an attempt to make a significantly faster
> development
> >> environment for certain types of VR apps.  I am worried about what
> appears
> >> to be the compile speed.
> >>
> >>
> >>
> >> It takes over three seconds from hitting ctrl-R in DrRacket to
> executing the
> >> first statement of a 350 line typed racket program.  It only uses:
> >>
> >> #lang typed/racket/base
> >>
> >> (require racket/tcp)
> >>
> >>
> >>
> >> That seems to be about twice as slow as a larger untyped racket program
> >> using a bunch more stuff, but even that isn’t great:
> >>
> >> #lang racket
> >>
> >> (require 2htdp/universe)
> >>
> >> (require 2htdp/image)
> >>
> >> (require 2htdp/planetcute)
> >>
> >> (require (only-in racket/gui/base play-sound))
> >>
> >>
> >>
> >> Does Run from DrRacket  have a significant time penalty?
> >>
> >> Are there any steps I can take to make typed racket compile faster?
> >>
> >> In many cases I don’t care much about the execution speed.
> >>
> >>
> >>
> >> I would like to think that compiling and running a few hundred lines of
> code
> >> on a modern desktop system should be essentially instant.
> >>
> >>
> >>
> >>
> >>
> >> --
> >> 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] Cover 2.0

2015-05-30 Thread Spencer Florence
Whoops, sorry! Knew we forgot something... Sorry about that!

Cover is a multi-file code coverage tool, designed to work like `raco test`.

On Sat, May 30, 2015 at 8:36 PM Hendrik Boom  wrote:

> On Sat, May 30, 2015 at 06:00:06PM +0000, Spencer Florence wrote:
> > Hi All,
> >
> > We're pleased to announce the release of Cover 2.0!
>
> May I suggest that whenever anyone announces a new release of any software,
> that the announcement contains a brief description of what that software
> is intended to do, rather than just stating a few new features o fthe new
> release?
>
> -- hendrik
>
> >
> > Along with the various bug fixes, Cover now:
> >
> > * Is faster.
> > * Is completely thread safe.
> > * Has a new, easier to use, Racket API. This is to support integrating
> with
> > IDE's and make new output formats easier to write.
> >
> > New contributors are always welcome!
> > If you find bugs, you can open an issue at
> > https://github.com/florence/cover/issues.
> > In addition, if there are any new output formats, tools, or services that
> > you think should be added, open an issue.
> >
> > Thanks!
> >
> > --Spencer & Ryan
> >
> > --
> > 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] Cover 2.0

2015-05-30 Thread Spencer Florence
Hi All,

We're pleased to announce the release of Cover 2.0!

Along with the various bug fixes, Cover now:

* Is faster.
* Is completely thread safe.
* Has a new, easier to use, Racket API. This is to support integrating with
IDE's and make new output formats easier to write.

New contributors are always welcome!
If you find bugs, you can open an issue at
https://github.com/florence/cover/issues.
In addition, if there are any new output formats, tools, or services that
you think should be added, open an issue.

Thanks!

--Spencer & Ryan

-- 
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] Capturing sets of options in a splicing syntax class?

2015-05-27 Thread Spencer Florence
try `syntax/parse/experimental/template`.

It gives you access to `??', which basically says "use a if present, else
b", and some other cool templates besides. From the docs:

 > (syntax-parse #'(m 1 2 3) [(_ (~optional (~seq #:op op:expr)) arg:expr
...) (template ((?? op +) arg ...))]) # >
(syntax-parse #'(m #:op max 1 2 3) [(_ (~optional (~seq #:op op:expr))
arg:expr ...) (template ((?? op +) arg ...))]) #

On Wed, May 27, 2015 at 12:03 AM Alexis King  wrote:

> When using syntax/parse, is there a good way to do something like this?
>
> (define-splicing-syntax-class options
>   (pattern (~seq (~or (~optional (~seq (~and #:a a?)))
>   (~optional (~seq (~and #:b b?)))
>   (~optional (~seq (~and #:c c?)))
>   (~optional (~seq (~and #:d d?
>  ...)
>#:attr a/b #'(a? b?)
>#:attr c/d #'(c? d?)))
>
> When using the above syntax class to parse #'(#:a #:d #:b), then the a/b
> attribute should be #'(#:a #:b) and the c/d attribute should be #'(#:d).
> However, this doesn't work, of course, because if one of the options isn't
> defined, the attribute will be #f, and the attribute binding will fail.
>
> I can get around that by doing something like this:
>
> (define-splicing-syntax-class options
>   (pattern (~seq (~or (~optional (~seq (~and #:a a?)))
>   (~optional (~seq (~and #:b b?)))
>   (~optional (~seq (~and #:c c?)))
>   (~optional (~seq (~and #:d d?
>  ...)
>#:attr a/b #`(#,@(if (attribute a?) #'(a?) #'())
>  #,@(if (attribute b?) #'(b?) #'()))
>#:attr c/d #`(#,@(if (attribute c?) #'(c?) #'())
>  #,@(if (attribute d?) #'(d?) #'()
>
> But that's rather long-winded and verbose. Even better would be a way to
> group the clauses within the pattern, something like this:
>
> (define-splicing-syntax-class options
>   (pattern (~seq (~or (~and (~seq (~optional (~seq (~and #:a a?)))
>   (~optional (~seq (~and #:b b?
> a/b)
>   (~and (~seq (~optional (~seq (~and #:c c?)))
>   (~optional (~seq (~and #:d d?
> c/d))
>  ...)))
>
> But that obviously doesn't work, and I'm not sure what it would do even if
> it compiled.
>
> Anyway, is there a more concise way to do this? I know it's relatively
> easy using `template` from syntax/parse/experimental/template, but this is
> going into the Typed Racket code, so we're intentionally avoiding a
> dependency on that.
>
> Alexis
>
> --
> 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] PLT policy on Travis CI bandwidth costs

2015-04-02 Thread Spencer Florence
Greg's Travis CI repo has a branch for using Travises cache, so that each
project would only download Racket once (per release). I don't know what
its state is though? It seems like that would be idea if it works.

https://github.com/greghendershott/travis-racket/tree/use-cache

On Thu, Apr 2, 2015 at 12:45 PM Matthew Butterick  wrote:

> OK, good to know. I will either switch to mirror.racket-lang.org or host
> the necessary installers on my own server.
>
> On Thu, Apr 2, 2015 at 9:38 AM, Sam Tobin-Hochstadt 
> wrote:
>
>> Right now, Greg's script uses download.racket-lang.org, which is
>> hosted on Amazon S3, and thus downloads cost (a small amount of)
>> money. If you download from `mirror.racket-lang.org`, which is hosted
>> at Northeastern, we're not charged for bandwidth. That's why those are
>> the links you get by default on the web page. Similarly, the snapshot
>> sites at Northwestern and Utah don't charge us for bandwidth.
>>
>> Sam
>
>
>>
>> On Thu, Apr 2, 2015 at 12:26 PM, Matthew Butterick  wrote:
>> > Should I be concerned about Travis CI's consumption of PLT bandwidth?
>> Assuming the answer is yes, then question #2: what should I do about it?
>> >
>> > I just set up Travis CI on some of my Github projects (thanks Greg
>> Hendershott for the Racket configuration script). IIUC every Travis build
>> requires downloading Racket, and moreover, downloading Racket imposes
>> bandwidth costs on PLT. So my use of Travis potentially consumes a lot of
>> PLT's bandwidth for no benefit to PLT (aside from the usual refracted
>> glory).
>> >
>> > I'd like to use Travis more (= build against more versions of Racket)
>> but I don't want to be casual about the resource consumption. For instance,
>> would there be an appopriate monthly fee to remit to PLT for this?
>> >
>> > --
>> > 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] Considering backward-incompatible change to Plot

2015-03-17 Thread Spencer Florence
Unfortunately the algorithms only work in 2D, and probably aren't actually
efficient. I have been meaning to generalize some of them now that Pict3D
exists :) And they would probably serve as reference implementations.

On Tue, Mar 17, 2015 at 1:56 PM Neil Toronto  wrote:

> That looks like an awesome project. I could probably even use the convex
> hull implementations in Pict3D.
>
> You could use `plot-bitmap` or `plot/dc` as well, FWIW.
>
> I'll count this as a +1, then. :)
>
> Neil ⊥
>
> On 03/17/2015 01:51 PM, Spencer Florence wrote:
> > I've been using plot heavily for
> > https://github.com/florence/convex-hulls, which pulls a bitmap% from the
> > snip% to render it as a gif. As long at the Plot object can get me a
> > bitmap% or its underlying vector, I would love the new interface.
> >
> > or maybe I should just be using `plot-pict`...
> >
> > On Tue, Mar 17, 2015 at 12:35 PM Neil Toronto  > <mailto:neil.toro...@gmail.com>> wrote:
> >
> > Plot has been converted to Typed Racket in the upcoming Racket 6.2.
> >
> > I'm strongly considering taking this opportunity to improve the API.
> The
> > change is backward-incompatible, however, so I need input from those
> of
> > you who use Plot a lot.
> >
> > In particular, recent experience with Pict3D makes it clear that the
> > type of the `plot` function shouldn't be this:
> >
> > (-> (Treeof (U nonrenderer renderer2d)) ... (U Void (Instance
> > Snip%)))
> >
> > but should be this instead:
> >
> > (-> (Treeof (U nonrenderer renderer2d)) ... Plot)
> >
> > where a `Plot` instance is a value that can be queried for its
> > properties (such as the legend, plot bounds, ticks, etc.) and just
> > happens to print in DrRacket as an interactive snip. The type of
> > `plot3d` would be changed to return `Plot3D` instances.
> >
> > Casual uses wouldn't see any change at all.
> >
> > However, functions that receive or return plots, *which also put
> > contracts on plots*, would have to change to use `plot?` instead of
> > (is-a?/c snip%), or use (require plot/snip), a new compatibility
> module,
> > instead of (require plot).
> >
> > How many programs of yours would this change break?
> >
> > Any objections? Any suggestions?
> >
> > Neil ⊥
> > 
> >Racket Users list:
> > http://lists.racket-lang.org/__u__sers
> > <http://lists.racket-lang.org/users>
> >
>
>

  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] Considering backward-incompatible change to Plot

2015-03-17 Thread Spencer Florence
I've been using plot heavily for https://github.com/florence/convex-hulls,
which pulls a bitmap% from the snip% to render it as a gif. As long at the
Plot object can get me a bitmap% or its underlying vector, I would love the
new interface.

or maybe I should just be using `plot-pict`...

On Tue, Mar 17, 2015 at 12:35 PM Neil Toronto 
wrote:

> Plot has been converted to Typed Racket in the upcoming Racket 6.2.
>
> I'm strongly considering taking this opportunity to improve the API. The
> change is backward-incompatible, however, so I need input from those of
> you who use Plot a lot.
>
> In particular, recent experience with Pict3D makes it clear that the
> type of the `plot` function shouldn't be this:
>
>(-> (Treeof (U nonrenderer renderer2d)) ... (U Void (Instance Snip%)))
>
> but should be this instead:
>
>(-> (Treeof (U nonrenderer renderer2d)) ... Plot)
>
> where a `Plot` instance is a value that can be queried for its
> properties (such as the legend, plot bounds, ticks, etc.) and just
> happens to print in DrRacket as an interactive snip. The type of
> `plot3d` would be changed to return `Plot3D` instances.
>
> Casual uses wouldn't see any change at all.
>
> However, functions that receive or return plots, *which also put
> contracts on plots*, would have to change to use `plot?` instead of
> (is-a?/c snip%), or use (require plot/snip), a new compatibility module,
> instead of (require plot).
>
> How many programs of yours would this change break?
>
> Any objections? Any suggestions?
>
> Neil ⊥
> 
>   Racket Users list:
>   http://lists.racket-lang.org/users
>

  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] Read-syntax for an entire .rkt file

2015-02-19 Thread Spencer Florence
What you want is `with-module-reading-parameterization

`:

(with-module-reading-parameterization

(lambda
() (read (open-input-port "my-file.rkt"

On Fri Feb 20 2015 at 12:43:15 AM Thomas Gilray 
wrote:

> Hi,
>
> I am trying to figure out how to use read-syntax on a port for an entire
> .rkt file. I want to then call (expand ...) on this and get back a (begin
> ...) or (module ...) form for the entire file in fully expanded form. Right
> now I have three issues:
>
> a) I have to skip over the #lang as this is not recognized by read-syntax
> itself
>
> b) I've needed to call read-syntax repeatedly to consume the whole file
> and put each expression in a top-level begin (a pretty klugy workaround)
>
> c) even then, calling expand will report an error that "define" is not
> itself defined. Maybe there is a version of read-syntax that will use
> read-language internally in the right way but I can't find it.
>
> There is probably a way of doing all of this at once, and better, but I
> don't know what that would be. I feel read-language is needed, but I don't
> see how this would work together with read-syntax.
>
> Any advice or pointers would be greatly appreciated!
>
> --
> Tom
>
> 
>   Racket Users list:
>   http://lists.racket-lang.org/users
>

  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] read-syntax for an entire .rkt file

2015-02-18 Thread Spencer Florence
There is also a `with-module-reading-parameterization` that sets up the
reader to do this.

On Wed, Feb 18, 2015, 10:36 PM Sam Tobin-Hochstadt 
wrote:

> On Wed, Feb 18, 2015 at 10:22 PM, Thomas Gilray 
> wrote:
> > Hi everyone,
> >
> > I am trying to figure out how to use read-syntax on a port for an entire
> > .rkt file. I then want to call (expand ...) on this and get back a (begin
> > ...) or (module ...) for the entire file in fully expanded form.
> >
> > If I run (expand #`(define ...)) under a #lang racket, everything works.
> If
> > I place this in a file and use read-syntax however, each top-level
> > expression is returned individually, the language declaration isn't
> > supported, and without this information the expander complains that
> "define"
> > isn't defined. How do I properly read-syntax a whole file at once?
> >
> > Any ideas would be greatly appreciated.
>
> I've implemented this a couple times recently, probably the best
> version is here:
> https://github.com/samth/pycket/blob/master/pycket/pycket-lang/expand.rkt
>
> The short answer is that you want to use `read-accept-lang` to enable
> #lang, call `read-syntax` once on the port, and the call `expand` in a
> new namespace (probably created with `make-base-namespace`).
>
> Sam
> 
>   Racket Users list:
>   http://lists.racket-lang.org/users
>

  Racket Users list:
  http://lists.racket-lang.org/users


[racket] What is `Apparent Identifier Binding`?

2015-01-15 Thread Spencer Florence
Hey All,

I'm trying to understand why two identifiers I have don't reference the
same value. If I look at them in the macro stepper all of their properties
and marks are the same, with the exception of "Apparent identifier
binding". One has "lexical (all phases)" and the other "none". What
is "Apparent identifier binding" and how does it get determined?

--spencer

  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] show-requires isn't submodule-aware?

2015-01-08 Thread Spencer Florence
Something else odd I see with show-requires. If its called directly on a
submodule it errors:

-> (show-requires '(submod (file "submod.rkt") test))
; result arity mismatch;
;  expected number of values not received
;   expected: 1
;   received: 2
;   values...:
\Sz�configure-runti...figure-runtime�:gtest
;(p:module #
# wrote:

> I'm actually really curious how it works and tempted to try to fix it
> myself, because I expect I would learn so much. What I don't know is
> how much learning that would turn out to be, and how long it would
> take me. Especially if your intuition is that it might be hard, for
> you. :)
>
> In any case I don't think it's an urgent issue.
> 
>   Racket Users list:
>   http://lists.racket-lang.org/users
>

  Racket Users list:
  http://lists.racket-lang.org/users


[racket] Documentation not building on the pkg.racket-lang.org

2015-01-06 Thread Spencer Florence
Hey Y'all,

I'm trying to get the documentation for one of my packages (named cover) to
appear on pkg.racket-lang.org. Currently the webpage shows the
documentation as crossed out.

I suspect this is because the old documentation file was renamed (when I
did this I had to reinstall the package locally to get the documentation).
Is there some way to avoid/fix this?

--spf

  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] Understanding local-expand with definition contexts

2015-01-05 Thread Spencer Florence
Awesome! Thanks, that works for what I'm doing.

On Mon Jan 05 2015 at 2:47:43 PM Matthew Flatt  wrote:

> That turns out to be tricky. I've enclosed an implementation, but it
> works only for units that have no imports.
>
> At Mon, 05 Jan 2015 17:21:37 +, Spencer Florence wrote:
> > What I'm trying to do is capture all lifts inside a unit body, instead of
> > having them propagating to the top level.
> >
> > If I understand what you mean by "add internal-definition context to the
> > bindings listed in `exports`", I can't do that because I need to capture
> > any lifts inside the unit body, but a `(local-expand/capture-lifts
> #'(unit
> > ...))` would put them outside. But maybe I miss understand you.
> > On Mon Jan 05 2015 at 12:10:53 PM Matthew Flatt 
> wrote:
> >
> > > I'm not really clear on what you're trying to do. One way to explain
> > > more might be to explain how `test` is meant to differ from `begin`. Or
> > > maybe you can say why it doesn't work to add the internal-definition
> > > context to the bindings listed in `exports` (i.e., to bring everything
> > > into the definition context).
> > >
> > > At Mon, 05 Jan 2015 16:44:10 +, Spencer Florence wrote:
> > > > Is there any way to have the `test` macro work more like `begin`?
> > > >
> > > > What I am trying to accomplish is something like:
> > > >
> > > > (define-syntax (make-my-unit stx)
> > > >(syntax-parse stx
> > > >   [(e ...)
> > > >(with-syntax ([body (local-expand/capture-lifts stx
> )])
> > > >  #'(unit (imports ...) (exports ...) body))]))
> > > >
> > > > Where the defines in #'(e ...) are visible to `unit` so that they
> can be
> > > > used for exports.
> > > >
> > > > --spf
> > > > On Mon Jan 05 2015 at 11:32:46 AM Matthew Flatt 
> > > wrote:
> > > >
> > > > > I think it's more a question of what a definition context is
> supposed
> > > > > to be, rather than how `syntax-local-bind-syntaxes` works.
> > > > >
> > > > > When you create a new definition context, the context's bindings
> are
> > > > > visible only to expressions that are also in that context. The
> `test`
> > > > > form here creates a new definition context in much the same way as
> > > > > `(let () ...)`:
> > > > >
> > > > >  (let ()
> > > > >(let () (define x 1))
> > > > >x)
> > > > >
> > > > > In other words, the final `x` really is out of the scope of the
> > > > > definition of `x`.
> > > > >
> > > > > At Mon, 05 Jan 2015 16:26:30 +, Spencer Florence wrote:
> > > > > > Progress is a new error! I don't think I understand how
> > > > > > syntax-local-bind-syntaxes is supposed to work. I extended the
> > > previous
> > > > > > program:
> > > > > >
> > > > > > #lang racket
> > > > > > (require (for-syntax syntax/parse))
> > > > > > (define-syntax (test stx)
> > > > > >   (syntax-parse stx
> > > > > > [(_ e)
> > > > > >  (define ctx
> > > > > >(if (list? (syntax-local-context))
> > > > > >(cons (gensym) (syntax-local-context))
> > > > > >(list (gensym
> > > > > >  (define def-ctx (syntax-local-make-definition-context))
> > > > > >  (define expd (local-expand #'e ctx (list #'define-values)
> > > def-ctx))
> > > > > >  (define ids (syntax-parse expd [(def (id) _) (list #'id)]))
> > > > > >  (syntax-local-bind-syntaxes ids #f def-ctx)
> > > > > >  (internal-definition-context-seal def-ctx)
> > > > > >  expd]))
> > > > > > (let ()
> > > > > >   (test (define x 1))
> > > > > >   x)
> > > > > >
> > > > > > And now I receive the error:  `x: unbound identifier in module
> in: x`
> > > > > > Looking at the docs for `syntax-local-make-definition-context`
> it
> > > seems
> > > > > > like I need to provide it with the parent definition-context, but
> > > I'm not
> > > > &g

Re: [racket] Understanding local-expand with definition contexts

2015-01-05 Thread Spencer Florence
What I'm trying to do is capture all lifts inside a unit body, instead of
having them propagating to the top level.

If I understand what you mean by "add internal-definition context to the
bindings listed in `exports`", I can't do that because I need to capture
any lifts inside the unit body, but a `(local-expand/capture-lifts #'(unit
...))` would put them outside. But maybe I miss understand you.
On Mon Jan 05 2015 at 12:10:53 PM Matthew Flatt  wrote:

> I'm not really clear on what you're trying to do. One way to explain
> more might be to explain how `test` is meant to differ from `begin`. Or
> maybe you can say why it doesn't work to add the internal-definition
> context to the bindings listed in `exports` (i.e., to bring everything
> into the definition context).
>
> At Mon, 05 Jan 2015 16:44:10 +, Spencer Florence wrote:
> > Is there any way to have the `test` macro work more like `begin`?
> >
> > What I am trying to accomplish is something like:
> >
> > (define-syntax (make-my-unit stx)
> >(syntax-parse stx
> >   [(e ...)
> >(with-syntax ([body (local-expand/capture-lifts stx )])
> >  #'(unit (imports ...) (exports ...) body))]))
> >
> > Where the defines in #'(e ...) are visible to `unit` so that they can be
> > used for exports.
> >
> > --spf
> > On Mon Jan 05 2015 at 11:32:46 AM Matthew Flatt 
> wrote:
> >
> > > I think it's more a question of what a definition context is supposed
> > > to be, rather than how `syntax-local-bind-syntaxes` works.
> > >
> > > When you create a new definition context, the context's bindings are
> > > visible only to expressions that are also in that context. The `test`
> > > form here creates a new definition context in much the same way as
> > > `(let () ...)`:
> > >
> > >  (let ()
> > >(let () (define x 1))
> > >x)
> > >
> > > In other words, the final `x` really is out of the scope of the
> > > definition of `x`.
> > >
> > > At Mon, 05 Jan 2015 16:26:30 +, Spencer Florence wrote:
> > > > Progress is a new error! I don't think I understand how
> > > > syntax-local-bind-syntaxes is supposed to work. I extended the
> previous
> > > > program:
> > > >
> > > > #lang racket
> > > > (require (for-syntax syntax/parse))
> > > > (define-syntax (test stx)
> > > >   (syntax-parse stx
> > > > [(_ e)
> > > >  (define ctx
> > > >(if (list? (syntax-local-context))
> > > >(cons (gensym) (syntax-local-context))
> > > >(list (gensym
> > > >  (define def-ctx (syntax-local-make-definition-context))
> > > >  (define expd (local-expand #'e ctx (list #'define-values)
> def-ctx))
> > > >  (define ids (syntax-parse expd [(def (id) _) (list #'id)]))
> > > >  (syntax-local-bind-syntaxes ids #f def-ctx)
> > > >  (internal-definition-context-seal def-ctx)
> > > >  expd]))
> > > > (let ()
> > > >   (test (define x 1))
> > > >   x)
> > > >
> > > > And now I receive the error:  `x: unbound identifier in module in: x`
> > > > Looking at the docs for `syntax-local-make-definition-context` it
> seems
> > > > like I need to provide it with the parent definition-context, but
> I'm not
> > > > sure how to get a hold of that.
> > > >
> > > > --spf
> > > >
> > > > On Mon Jan 05 2015 at 10:00:53 AM Matthew Flatt 
> > > wrote:
> > > >
> > > > > The error message is intended for "end users" and turns out to be
> > > > > misleading for the implementor of an internal-definition context.
> The
> > > > > documentation for `define-values` has essentially the same
> problem: it
> > > > > describes how `define-values` should work in an internal-definition
> > > > > context, but it doesn't say how the form interacts with
> `local-expand`.
> > > > >
> > > > > A `define-values` form will only expand in a module or top-level
> > > > > context. To implement an internal-definition context, you must
> expand
> > > > > only far enough to see `define-values` form; in other words, supply
> > > > > `#'define-values` in the stop list. Then, a partially expanded
> > > > > `define-values

Re: [racket] Understanding local-expand with definition contexts

2015-01-05 Thread Spencer Florence
Is there any way to have the `test` macro work more like `begin`?

What I am trying to accomplish is something like:

(define-syntax (make-my-unit stx)
   (syntax-parse stx
  [(e ...)
   (with-syntax ([body (local-expand/capture-lifts stx )])
 #'(unit (imports ...) (exports ...) body))]))

Where the defines in #'(e ...) are visible to `unit` so that they can be
used for exports.

--spf
On Mon Jan 05 2015 at 11:32:46 AM Matthew Flatt  wrote:

> I think it's more a question of what a definition context is supposed
> to be, rather than how `syntax-local-bind-syntaxes` works.
>
> When you create a new definition context, the context's bindings are
> visible only to expressions that are also in that context. The `test`
> form here creates a new definition context in much the same way as
> `(let () ...)`:
>
>  (let ()
>(let () (define x 1))
>x)
>
> In other words, the final `x` really is out of the scope of the
> definition of `x`.
>
> At Mon, 05 Jan 2015 16:26:30 +, Spencer Florence wrote:
> > Progress is a new error! I don't think I understand how
> > syntax-local-bind-syntaxes is supposed to work. I extended the previous
> > program:
> >
> > #lang racket
> > (require (for-syntax syntax/parse))
> > (define-syntax (test stx)
> >   (syntax-parse stx
> > [(_ e)
> >  (define ctx
> >(if (list? (syntax-local-context))
> >(cons (gensym) (syntax-local-context))
> >(list (gensym
> >  (define def-ctx (syntax-local-make-definition-context))
> >  (define expd (local-expand #'e ctx (list #'define-values) def-ctx))
> >  (define ids (syntax-parse expd [(def (id) _) (list #'id)]))
> >  (syntax-local-bind-syntaxes ids #f def-ctx)
> >  (internal-definition-context-seal def-ctx)
> >  expd]))
> > (let ()
> >   (test (define x 1))
> >   x)
> >
> > And now I receive the error:  `x: unbound identifier in module in: x`
> > Looking at the docs for `syntax-local-make-definition-context` it seems
> > like I need to provide it with the parent definition-context, but I'm not
> > sure how to get a hold of that.
> >
> > --spf
> >
> > On Mon Jan 05 2015 at 10:00:53 AM Matthew Flatt 
> wrote:
> >
> > > The error message is intended for "end users" and turns out to be
> > > misleading for the implementor of an internal-definition context. The
> > > documentation for `define-values` has essentially the same problem: it
> > > describes how `define-values` should work in an internal-definition
> > > context, but it doesn't say how the form interacts with `local-expand`.
> > >
> > > A `define-values` form will only expand in a module or top-level
> > > context. To implement an internal-definition context, you must expand
> > > only far enough to see `define-values` form; in other words, supply
> > > `#'define-values` in the stop list. Then, a partially expanded
> > > `define-values` form must be recognized and handled explicitly, with
> > > tools like `syntax-local-bind-syntaxes` or re-writing to
> > > `letrec-values`, as appropriate for the definition context.
> > >
> > > At Mon, 05 Jan 2015 14:49:03 +, Spencer Florence wrote:
> > > > Hey all,
> > > >
> > > > I'm trying to use 'local-expand', however it seems to think its
> never in
> > > a
> > > > definition context. For example:
> > > >
> > > > (require (for-syntax syntax/parse))
> > > > (define-syntax (test stx)
> > > >   (syntax-parse stx
> > > > [(_ e)
> > > >  (define ctx
> > > >(if (list? (syntax-local-context))
> > > >(cons (gensym) (syntax-local-context))
> > > >(list (gensym
> > > >  (local-expand
> > > >   #'e ctx null
> > > >   ;; result is the same with this uncommented
> > > >   #;(syntax-local-make-definition-context))]))
> > > > (let ()
> > > >   (test (define x 1))
> > > >   x)
> > > >
> > > > errors with a "define-values: not in a definition context in:
> > > > (define-values (x) 1)"
> > > >
> > > > Can anyone provide any insight into what is going on?
> > > >
> > > > --spf
> > > > 
> > > >   Racket Users list:
> > > >   http://lists.racket-lang.org/users
> > >
>

  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] Understanding local-expand with definition contexts

2015-01-05 Thread Spencer Florence
Progress is a new error! I don't think I understand how
syntax-local-bind-syntaxes is supposed to work. I extended the previous
program:

#lang racket
(require (for-syntax syntax/parse))
(define-syntax (test stx)
  (syntax-parse stx
[(_ e)
 (define ctx
   (if (list? (syntax-local-context))
   (cons (gensym) (syntax-local-context))
   (list (gensym
 (define def-ctx (syntax-local-make-definition-context))
 (define expd (local-expand #'e ctx (list #'define-values) def-ctx))
 (define ids (syntax-parse expd [(def (id) _) (list #'id)]))
 (syntax-local-bind-syntaxes ids #f def-ctx)
 (internal-definition-context-seal def-ctx)
 expd]))
(let ()
  (test (define x 1))
  x)

And now I receive the error:  `x: unbound identifier in module in: x`
Looking at the docs for `syntax-local-make-definition-context` it seems
like I need to provide it with the parent definition-context, but I'm not
sure how to get a hold of that.

--spf

On Mon Jan 05 2015 at 10:00:53 AM Matthew Flatt  wrote:

> The error message is intended for "end users" and turns out to be
> misleading for the implementor of an internal-definition context. The
> documentation for `define-values` has essentially the same problem: it
> describes how `define-values` should work in an internal-definition
> context, but it doesn't say how the form interacts with `local-expand`.
>
> A `define-values` form will only expand in a module or top-level
> context. To implement an internal-definition context, you must expand
> only far enough to see `define-values` form; in other words, supply
> `#'define-values` in the stop list. Then, a partially expanded
> `define-values` form must be recognized and handled explicitly, with
> tools like `syntax-local-bind-syntaxes` or re-writing to
> `letrec-values`, as appropriate for the definition context.
>
> At Mon, 05 Jan 2015 14:49:03 +, Spencer Florence wrote:
> > Hey all,
> >
> > I'm trying to use 'local-expand', however it seems to think its never in
> a
> > definition context. For example:
> >
> > (require (for-syntax syntax/parse))
> > (define-syntax (test stx)
> >   (syntax-parse stx
> > [(_ e)
> >  (define ctx
> >(if (list? (syntax-local-context))
> >(cons (gensym) (syntax-local-context))
> >(list (gensym
> >  (local-expand
> >   #'e ctx null
> >   ;; result is the same with this uncommented
> >   #;(syntax-local-make-definition-context))]))
> > (let ()
> >   (test (define x 1))
> >   x)
> >
> > errors with a "define-values: not in a definition context in:
> > (define-values (x) 1)"
> >
> > Can anyone provide any insight into what is going on?
> >
> > --spf
> > 
> >   Racket Users list:
> >   http://lists.racket-lang.org/users
>

  Racket Users list:
  http://lists.racket-lang.org/users


[racket] Understanding local-expand with definition contexts

2015-01-05 Thread Spencer Florence
Hey all,

I'm trying to use 'local-expand', however it seems to think its never in a
definition context. For example:

(require (for-syntax syntax/parse))
(define-syntax (test stx)
  (syntax-parse stx
[(_ e)
 (define ctx
   (if (list? (syntax-local-context))
   (cons (gensym) (syntax-local-context))
   (list (gensym
 (local-expand
  #'e ctx null
  ;; result is the same with this uncommented
  #;(syntax-local-make-definition-context))]))
(let ()
  (test (define x 1))
  x)

errors with a "define-values: not in a definition context in:
(define-values (x) 1)"

Can anyone provide any insight into what is going on?

--spf

  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] multipart http requests

2014-12-30 Thread Spencer Florence
Unfortunately what I'm looking something to handle automatically sending
http post's of the type multipart/form-data.


On Tue Dec 30 2014 at 12:31:11 PM Tony Garnock-Jones 
wrote:

> On 12/30/2014 10:22 AM, Spencer Florence wrote:
> > Does anyone know of a racket library that does multipart posts? Neither
> > the net/http-client nor net/url libraries seem to have an abstraction
> > for this built in.
>
> Looks like http://docs.racket-lang.org/net/mime.html will parse a MIME
> message, but from that documentation, I don't see anything for producing
> one. So I suppose if you're only concerned with understanding incoming
> MIME messages, you could be in luck?
>
> Tony
>

  Racket Users list:
  http://lists.racket-lang.org/users


[racket] multipart http requests

2014-12-30 Thread Spencer Florence
Does anyone know of a racket library that does multipart posts? Neither the
net/http-client nor net/url libraries seem to have an abstraction for this
built in.
--spencer

  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] Macros that use local-require (hygiene issues?)

2014-11-06 Thread Spencer Florence
I understand why the begin and [a a] work, but what I'm wondering is why
the others didn't work. For example, why didn't `begin` work in my second
example? Is the lexical information for the bindings just coming form
somewhere really weird?

On Thu Nov 06 2014 at 5:18:59 PM Jay McCarthy 
wrote:

> The begin works because the macro use is at the top-level and the
> thing gets pulled up and spliced in, I believe.
>
> The [a a] works because the second a is detected as a binder so it
> gets matched up mark-wise with the second one rather than having them
> erased? Hygiene? Marks? Dye packets?
>
> Jay
>
> On Thu, Nov 6, 2014 at 4:36 PM, Spencer Florence 
> wrote:
> > Thanks! That fixed it!
> >
> > Although I'm still curious as to why the error happens in the first
> place.
> >
> > On Thu Nov 06 2014 at 3:32:02 PM Alexander D. Knauth <
> alexan...@knauth.org>
> > wrote:
> >>
> >> I think I had a similar sort of problem about a year ago (I was at
> either
> >> RacketCon or a Hackathon that same weekend and Mathew Flatt figured it
> out),
> >> and the solution was changing (only-in path a) to (only-in path [a a]).
> >>
> >> #lang racket/load
> >> ;;provider
> >> (module T racket
> >>   (provide a)
> >>   (define a 1))
> >> ;; requirer
> >> (module R racket
> >>   (require (for-syntax syntax/parse))
> >>   (define-syntax (test-binding stx)
> >> (syntax-parse stx
> >>   [(_ path)
> >>#'(let () (local-require (only-in path [a a])) a)]))
> >>   (test-binding 'T))
> >> ;; go
> >> (require ‘R)
> >>
> >>
> >> On Nov 6, 2014, at 4:09 PM, Spencer Florence 
> wrote:
> >>
> >> > Hi All,
> >> >
> >> > I've been struggling to have a macro be given a path then require
> >> > something from that path. The following code produces and "Unbound
> >> > Identifier" error, although I would expect it to evaluate to 1. Could
> >> > someone provide insight into what is going on?
> >> >
> >> > #lang racket/load
> >> > ;;provider
> >> > (module T racket
> >> >   (provide a)
> >> >   (define a 1))
> >> > ;; requirer
> >> > (module R racket
> >> >   (require (for-syntax syntax/parse))
> >> >   (define-syntax (test-binding stx)
> >> > (syntax-parse stx
> >> >   [(_ path)
> >> >#'(let () (local-require (only-in path a)) a)]))
> >> >   (test-binding 'T))
> >> > ;; go
> >> > (require 'R)
> >> >
> >> >
> >> > P.S. I attempted to do this with `dynamic-require,` but that failed
> >> > because in my actual program `path` is sometimes `(submod "..")`,
> which
> >> > caused an error about not having a base path.
> >> >
> >> > 
> >> >  Racket Users list:
> >> >  http://lists.racket-lang.org/users
> >>
> >
> > 
> >   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
>

  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] Macros that use local-require (hygiene issues?)

2014-11-06 Thread Spencer Florence
Thanks! That fixed it!

Although I'm still curious as to why the error happens in the first place.
On Thu Nov 06 2014 at 3:32:02 PM Alexander D. Knauth 
wrote:

> I think I had a similar sort of problem about a year ago (I was at either
> RacketCon or a Hackathon that same weekend and Mathew Flatt figured it
> out), and the solution was changing (only-in path a) to (only-in path [a
> a]).
>
> #lang racket/load
> ;;provider
> (module T racket
>   (provide a)
>   (define a 1))
> ;; requirer
> (module R racket
>   (require (for-syntax syntax/parse))
>   (define-syntax (test-binding stx)
> (syntax-parse stx
>   [(_ path)
>#'(let () (local-require (only-in path [a a])) a)]))
>   (test-binding 'T))
> ;; go
> (require ‘R)
>
>
> On Nov 6, 2014, at 4:09 PM, Spencer Florence  wrote:
>
> > Hi All,
> >
> > I've been struggling to have a macro be given a path then require
> something from that path. The following code produces and "Unbound
> Identifier" error, although I would expect it to evaluate to 1. Could
> someone provide insight into what is going on?
> >
> > #lang racket/load
> > ;;provider
> > (module T racket
> >   (provide a)
> >   (define a 1))
> > ;; requirer
> > (module R racket
> >   (require (for-syntax syntax/parse))
> >   (define-syntax (test-binding stx)
> > (syntax-parse stx
> >   [(_ path)
> >#'(let () (local-require (only-in path a)) a)]))
> >   (test-binding 'T))
> > ;; go
> > (require 'R)
> >
> >
> > P.S. I attempted to do this with `dynamic-require,` but that failed
> because in my actual program `path` is sometimes `(submod "..")`, which
> caused an error about not having a base path.
> >
> > 
> >  Racket Users list:
> >  http://lists.racket-lang.org/users
>
>

  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] Macros that use local-require (hygiene issues?)

2014-11-06 Thread Spencer Florence
As I play with that example I see that changing #'(let () ...) to #'(begin
...) fixes the issue. Unfortunately in my actual program I can't do that.
Here is an example more akin to the context I'm working in, where that fix
doesn't work:

#lang racket
(provide a)
(define a 1)

;; make the submodule
(define-syntax (mod stx)
  #'(module* R racket
  (require (submod ".." T))
  (test-binding (submod ".."

;; defines the requiring macro
(module T racket
(provide test-binding)
(require (for-syntax syntax/parse))
(define-syntax (test-binding stx)
  (syntax-parse stx
[(_ path)
 #'(begin (require path) a)])))
;; go
(mod)

On Thu Nov 06 2014 at 3:09:28 PM Spencer Florence 
wrote:

> Hi All,
>
> I've been struggling to have a macro be given a path then require
> something from that path. The following code produces and "Unbound
> Identifier" error, although I would expect it to evaluate to 1. Could
> someone provide insight into what is going on?
>
> #lang racket/load
> ;;provider
> (module T racket
>   (provide a)
>   (define a 1))
> ;; requirer
> (module R racket
>   (require (for-syntax syntax/parse))
>   (define-syntax (test-binding stx)
> (syntax-parse stx
>   [(_ path)
>#'(let () (local-require (only-in path a)) a)]))
>   (test-binding 'T))
> ;; go
> (require 'R)
>
>
> P.S. I attempted to do this with `dynamic-require,` but that failed
> because in my actual program `path` is sometimes `(submod "..")`, which
> caused an error about not having a base path.
>
>

  Racket Users list:
  http://lists.racket-lang.org/users


[racket] Macros that use local-require (hygiene issues?)

2014-11-06 Thread Spencer Florence
Hi All,

I've been struggling to have a macro be given a path then require something
from that path. The following code produces and "Unbound Identifier" error,
although I would expect it to evaluate to 1. Could someone provide insight
into what is going on?

#lang racket/load
;;provider
(module T racket
  (provide a)
  (define a 1))
;; requirer
(module R racket
  (require (for-syntax syntax/parse))
  (define-syntax (test-binding stx)
(syntax-parse stx
  [(_ path)
   #'(let () (local-require (only-in path a)) a)]))
  (test-binding 'T))
;; go
(require 'R)


P.S. I attempted to do this with `dynamic-require,` but that failed because
in my actual program `path` is sometimes `(submod "..")`, which caused an
error about not having a base path.

  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] place-image winking effect with low y coord

2014-10-06 Thread Spencer florence
huh, I’m unable to reproduce this as well.




Brian, if you use the `record?` clause in big-bang do you see the same behavior 
in the generated gif? [ add (record? "/tmp”) to the big-bang expression, 
similar to what Matthias did in his example ]




Also do you see the same behavior if you change the initial state to be 100?




—Spencer

On Mon, Oct 6, 2014 at 10:05 AM, Brian Craft 
wrote:

> If I record to a gif the effect isn't in the gif, though it does happen
> on-screen while it is recording the gif. Here's a video, using a camera
> phone. Sorry for the poor quality.
> https://drive.google.com/file/d/0BxB9fW-JZz-ST3dfeFNxakRhMnRzcGtPQUtuaWJxMVRQTEFz/view
> Pause it around the 1 sec mark.
> On Mon, Oct 6, 2014 at 7:10 AM, Matthias Felleisen 
> wrote:
>>
>> Sorry, I don't understand what you mean. I have modified the main function
>> so that (1) the whole thing is slower and (2) it records the whole thing as
>> an animated gif:
>>
>> (define (main)
>>   (big-bang 0;; initial state
>> (record? #t) ;; <---
>> (on-tick add-3-to-state 1/10);; when the clock
>> ticks, add ...   <-
>> (to-draw draw-a-ufo-onto-an-empty-scene) ;; when the state
>> changes, draw ...
>> (stop-when state-is-300)))   ;; when the UFO's y
>> coordinate is 300, stop.
>>
>>
>>
>> The animated gif is here:
>>
>>  http://www.ccs.neu.edu/home/matthias/Tmp/UFO/i-animated.gif
>>
>> -- Matthias
>>
>>
>>
>> On Oct 5, 2014, at 11:52 PM, Brian Craft  wrote:
>>
>> > The same effect occurs in
>> racket/share/pkgs/realm/chapter5/ufo-source.rkt.  When the state is
>> increasing from 0, the image is not moving down the screen. It stays in one
>> place, but is initially clipped to 0 horizontal lines. Then 1 line, then 2,
>> and only when the state is 1/2 the image height does it start moving down
>> the screen.
>> >
>> > Also, if I call (draw-a-ufo-onto-an-empty-scene 0) in the interactions
>> window, I once again get a different result: it renders the lower half of
>> the image. This is the same behavior I see with my code.
>> >
>> > Maybe a platform issue? (version) reports 6.0. I'm running it on ubuntu.
>> >
>> >
>> >
>> > On Sun, Oct 5, 2014 at 6:13 PM, Matthias Felleisen 
>> wrote:
>> >
>> > Can you send the full program please? Thanks -- Matthias
>> >
>> >
>> >
>> > On Oct 5, 2014, at 8:52 PM, Brian Craft wrote:
>> >
>> > > Hello -- Newbie here. I'm going through "Realm of Racket". I'm seeing
>> an odd effect when using this to-draw handler in big-bang:
>> > >
>> > > (define (draw-a-ufo-onto-an-empty-scene game)
>> > >   (let ([pos (game-pos game)])
>> > > (place-image IMAGE-of-UFO (round (vec-x pos)) (round (vec-y pos))
>> > >  (empty-scene WIDTH HEIGHT
>> > >
>> > > vec is (struct vec (x y))
>> > >
>> > > As the y coordinate approaches zero, IMAGE-of-UFO gets clipped on the
>> top and bottom, looking a bit like it's winking out of existence, rather
>> than sliding off the canvas. This doesn't happen on any other edge. It's
>> only as y approaches zero. It starts when the edge of the image meets the
>> edge of the scene. That is, if the image is 20px high, and y starts at 30,
>> and decreases by 1 on each tick, it will move up the canvas for 30..10, but
>> from 10 on the image will not change position, but will instead be clipped
>> on the top & bottom, until it disappears.
>> > >
>> > > This does not happen in the interactions window. If I call the above
>> function in the interactions window, it renders as expected, with the image
>> moving smoothly off the edge.
>> > >
>> > >
>> > > 
>> > >  Racket Users list:
>> > >  http://lists.racket-lang.org/users
>> >
>> >
>>
>>
  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] Understanding contracts

2014-10-01 Thread Spencer florence
Where are you calling `cubic-bezier` from? If its from the REPL, the module 
itself, or a submodule the function won’t have a contract attached. Only code 
outside `cubic-bezier`s module will have the version of `cubic-bezier` with a 
contract attached.

On Wed, Oct 1, 2014 at 9:46 PM, Alexander McLin 
wrote:

> Hello,
> I've been working on a sample project to better understand how to use the
> contract system. I created a simple Bezier curve implementation and am
> using (provide (contract-out...) to attach contracts to the provided
> bindings.
> Basically I have a procedure called cubic-bezier that accepts two control
> point structs used to define the curve. It returns another procedure that
> actually generates the curve, it accepts an integer parameter that lies on
> [0, 1] and an optional keyword #:clamp-range. The generator procedure
> returns a number.
> The control point structure is a simple posn type that accepts X and Y
> fields where X must be between 0 and 1, and Y is allowed to be any number.
> Here are the contracts I defined provisionally:
> (provide (contract-out
>   [struct bezier-control-point ((x (and/c number? (between/c 0 1)))
>   (y number?))]
>   [cubic-bezier (-> bezier-control-point?
>  bezier-control-point?
> (->* ((and/c number? (between/c 0 1)))
>(#:clamp-range boolean?)
>number?))]))
> For the contract attached to cubic-bezier using ->, my thinking was to use
> ->* to generate the contract for the procedure returned by cubic-bezier but
> it's not working, meaning I'm not getting the any contract violations I'm
> expecting when giving bad inputs to cubic-bezier's value.
> How can I attach a more complex contract to cubic-bezier's value?
> Thank you
> Alexander McLin
  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] typed racket, filters, and polymorphism

2014-09-28 Thread Spencer florence
would something like this work?





#lang typed/racket




(struct (U) number+unit ([amount : Real] [unit : U]))




(define-type Weight-Unit (U 'kg 'g 'mg 'μg))

(define-type Weight (number+unit Weight-Unit))

(define-predicate weight? Weight)




(: make-weight : Real Weight-Unit -> Weight)

(define (make-weight n u)

  (number+unit n u))




(: +/weight : Weight Weight -> Weight)

;; something something needs unit conversion

(define (+/weight w1 w2)

  (number+unit (+ (number+unit-amount w1)

                  (number+unit-amount w1))

               (number+unit-unit w1)))




(+/weight (make-weight 1 'kg) (make-weight 1 'kg))

On Sun, Sep 28, 2014 at 11:03 AM, Alexander D. Knauth
 wrote:

> Because the struct is representing a unit (kilograms, meters, seconds, etc.), 
> and a unit has a dimension (mass, length, time, etc.) and I want the 
> type-checker to be able to know what the dimension of a unit is so that the 
> types of functions can specify the dimension that something should have.  
> The real solution to this would probably be bounded polymorphism, but I was 
> wondering if there was some other way to do it with occurrence typing in the 
> guard or something like that.  
> On Sep 28, 2014, at 11:48 AM, Sam Tobin-Hochstadt  
> wrote:
>> Why not do this with the type, instead of making this polymorphic?
>> 
>> Sam
>> 
>> On Fri, Sep 26, 2014 at 7:35 PM, Alexander D. Knauth
>>  wrote:
>>> 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 
>>> 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 
>>> 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
>>>  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
>>> 
>>> 
> 
>   Racket Users list:
>   http://lists.racket-lang.org/users
  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] typed racket and generic interfaces, is there a workaround using properties?

2014-09-26 Thread Spencer florence
I don’t think you can. You would need define the struct in an untyped module 
then require it via require/typed. This is why dict’s don’t work in 
typed/racket either.

On Sat, May 24, 2014 at 9:39 PM, Alexander D. Knauth 
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.  
> 
>   Racket Users list:
>   http://lists.racket-lang.org/users
  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] Provide transformers

2014-09-21 Thread Spencer florence
I think the way i have seen this done is to use a macro at the top level 
instead of a provide transformer.




for example define/provide-test-suite from rackunit probably works a little like




(define/provide-test-suite tests blah blah …)




=>




(begin 

   (provide tests)

   (define tests (test-suite blah blah blah …))







So maybe you could make a provide/test-pred form?

On Fri, Sep 19, 2014 at 4:42 PM, Jack Firth  wrote:

> I've been looking into how to design a macro that would specify tests in a
> provide transformer, for example something like
> (provide (test-pred-out some-integer integer?))
> I'd like that to expand to:
> (provide some-integer)
> (module+ test
>   (check-pred integer? some-integer))
> From what I can gather from the reference, normally provide forms are done
> with define-provide-syntax, but that macro doesn't let me splice anything
> into the module body. The reference mentions provide pre-transformers, and
> says:
> "A provide pre-transformer is applied as part of the first phase of a
> module’s expansion. Since it is used in the first phase, a provide
> pre-transformer can use functions such as syntax-local-lift-expression to
> introduce expressions and definitions in the enclosing module."
> So it sounds like what I want is definitely possible, but I have no idea
> how to actually *do* it. Does anyone have some simple well-explained
> examples to guide me in the right direction?
  Racket Users list:
  http://lists.racket-lang.org/users


[racket] Macro Stepper with custom languages

2014-08-21 Thread Spencer florence
Hi all,


I’m currently making a custom language in racket. For some reason DrRacket does 
not give me a macro stepper button with my language, although it does for other 
custom languages like ‘#lang honu’ or ‘#lang datalog’ do get the macro stepper.


What do I need to do to convince DrRacket to give me the stepper?


—Spencer
  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] confusing error message: what is "lang:read.1"?

2014-08-06 Thread Spencer Florence
"lang:read.1" looks a some name generated by "syntax-local-lift-expression"
or "generate-temporaries". IIRC the ".1" is how the printer handles showing
identifiers that may have the same symbol, but different scope.

so:

#lang racket
(define-syntax (example stx)
  (syntax-case stx ()
[(_)
 (with-syntax ([id (syntax-local-lift-expression #''anything)])
   #'(displayln 'id))]))
(example)
(example)


would display something like

lifted.0
lifted.2

But I'm not sure what makes the name "lang:read".


On Wed, Aug 6, 2014 at 5:50 PM, Matthew Butterick  wrote:

> Under certain circumstances, because of what I assume is a bug in my code,
> I get an error like this:
>
> > define-values: assignment disallowed;
> >  cannot re-define a constant
> >   constant: lang:read.1
> >   in module: "/Users/mb/git/racket/racket/collects/racket/main.rkt"
> >   context...:
> >(submod /Users/mb/git/racket/racket/collects/racket/main.rkt reader):
> [running body]
>
> I understand how the "assignment disallowed" error arises. What I don't
> understand is the meaning of "lang:read.1" in this context. I'm guessing it
> has something to do with the #lang line (?) but ... the rest is hazy.
>
> Clarification welcome.
> 
>   Racket Users list:
>   http://lists.racket-lang.org/users
>

  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] Shared and structs with #:auto

2014-07-29 Thread Spencer Florence
Woops. I was under the impression that #:auto worked like an optional
argument. Is there any way to do optional constructor arguments with
structs (I don't see one but I can hope...)?


On Tue, Jul 29, 2014 at 4:39 PM, J. Ian Johnson  wrote:

> From the struct docs:
> constructor-id (which defaults to id), a constructor procedure that takes
> m arguments and returns a new instance of the structure type, where m is
> the number of fields that do not include an #:auto option.
>
> You don't give anything to the constructor for #:auto fields.
> -Ian
> - Original Message -
> From: "Spencer Florence" 
> To: "racket" 
> Sent: Tuesday, July 29, 2014 5:32:46 PM GMT -05:00 US/Canada Eastern
> Subject: [racket] Shared and structs with #:auto
>
>
>
> Hi all,
>
> I'm trying to use shared with a structure that has a field with #:auto
>
> If I have some structure like this:
>
>
> (struct test ([a #:auto]) #:transparent #:mutable)
>
>
>
> this works fine:
>
>
> (shared ([b (test)]) b)
>
>
> but this errors:
>
>
> (shared ([b (test 1)]) b)
>
> with "shared: wrong argument count for structure constructor; expected 0,
> found 1 in: (test1 1)"
>
>
> Is this a bug? Is there a work around?
>
> --Spencer
> 
>   Racket Users list:
>   http://lists.racket-lang.org/users
>

  Racket Users list:
  http://lists.racket-lang.org/users


[racket] Shared and structs with #:auto

2014-07-29 Thread Spencer Florence
Hi all,

I'm trying to use shared with a structure that has a field with #:auto

If I have some structure like this:

(struct test ([a #:auto]) #:transparent #:mutable)



this works fine:

(shared ([b (test)]) b)

but this errors:

(shared ([b (test 1)]) b)

with "shared: wrong argument count for structure constructor; expected 0,
found 1 in: (test1 1)"


Is this a bug? Is there a work around?

--Spencer

  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] DrRacket, OSX, and xattr

2014-07-24 Thread Spencer Florence
The overwrite/revert prompts suddenly decided to stop (they had been
happening all day...). I'll report back if I can reproduce them again.


On Thu, Jul 24, 2014 at 8:27 PM, Robby Findler 
wrote:

> I don't think that that's what's causing the overwrite/revert prompts.
> There is definitely a bug there and I would love to know what's going
> on, but DrRacket uses file-or-directory-modify-seconds to determine
> whether or not to prompt, and setting this metadata doesn't change the
> result of that function. Below is the test I used.
>
> Robby
>
> #lang racket/gui
> (define fn "/Users/robby/x.rkt")
> (call-with-output-file fn
>   (λ (port) (write (random) port))
>   #:exists 'truncate)
> (define-values (_ type) (file-creator-and-type fn))
> (list (file-or-directory-modify-seconds fn) (current-seconds))
> (sleep 2)
> (list (file-or-directory-modify-seconds fn) (current-seconds))
> (file-creator-and-type fn #"DrSc" type)
> (list (file-or-directory-modify-seconds fn) (current-seconds))
>
>
>
> On Thu, Jul 24, 2014 at 6:45 PM, Spencer Florence
>  wrote:
> > Two reasons:
> >
> > 1. DrRacket isn't always the default file association on my mac.
> > 2. Something keeps butchering the xattrs (My guess is dropbox) so
> DrRacket
> > keeps prompting me to overwrite the file on save and revert the file on
> run
> > (more or less every time I do either). This is recent, but I'm not sure
> what
> > changed. The only thing I remember updating recently is DrRacket, but who
> > knows what is updating in the background.
> >
> > Either way it seems like xattrs causing overwrite/revert prompts is bad
> > behavior, regardless if saving new xattrs is correct. It seems a bit like
> > saying "the file was modified because you added the setuid bit... do you
> > want to overwrite or revert?". The file wasn't modified, the file system
> > metadata was.
> >
> >
> >
> > On Thu, Jul 24, 2014 at 6:25 PM, Robby Findler <
> ro...@eecs.northwestern.edu>
> > wrote:
> >>
> >> It is setting itself as the owner of the file so that subsequent
> >> double-clicks on the file will open the file in DrRacket.
> >>
> >> This was the recommended behavior back in the day before you could
> >> associate extensions with applications (I think).
> >>
> >> Why do you want to disable it?
> >>
> >> Robby
> >>
> >> On Thu, Jul 24, 2014 at 3:43 PM, Spencer Florence
> >>  wrote:
> >> > Hi all,
> >> >
> >> > Whenever I save a file with DrRacket on OSX, it always sets some
> >> > extended
> >> > attributes on the file. Specifically it sets:
> >> >
> >> > [snips:pl7/examples] xattr -l somefile.rkt
> >> > com.apple.FinderInfo:
> >> >   54 45 58 54 44 72 53 63 00 00 00 00 00 00 00 00
> >> > |TEXTDrSc|
> >> > 0010  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> >> > ||
> >> > 0020
> >> >
> >> > In addition if I clear the xattr's (via xattr -c) DrRacket treats this
> >> > as an
> >> > external write to the file and prompts me to overwrite on save and
> >> > revert on
> >> > run. Is this behavior intended? It seems odd given that DrRacket
> doesn't
> >> > do
> >> > this with normal attributes (permission, suid bit, etc.) If it is
> >> > intended
> >> > what is the rational and can I disable it?
> >> >
> >> > --Spencer
> >> >
> >> >
> >> >
> >> > 
> >> >   Racket Users list:
> >> >   http://lists.racket-lang.org/users
> >> >
> >> 
> >>   Racket Users list:
> >>   http://lists.racket-lang.org/users
> >
> >
> >
> > 
> >   Racket Users list:
> >   http://lists.racket-lang.org/users
> >
>

  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] DrRacket, OSX, and xattr

2014-07-24 Thread Spencer Florence
Two reasons:

1. DrRacket isn't always the default file association on my mac.
2. Something keeps butchering the xattrs (My guess is dropbox) so DrRacket
keeps prompting me to overwrite the file on save and revert the file on run
(more or less every time I do either). This is recent, but I'm not sure
what changed. The only thing I remember updating recently is DrRacket, but
who knows what is updating in the background.

Either way it seems like xattrs causing overwrite/revert prompts is bad
behavior, regardless if saving new xattrs is correct. It seems a bit like
saying "the file was modified because you added the setuid bit... do you
want to overwrite or revert?". The file wasn't modified, the file system
metadata was.


On Thu, Jul 24, 2014 at 6:25 PM, Robby Findler 
wrote:

> It is setting itself as the owner of the file so that subsequent
> double-clicks on the file will open the file in DrRacket.
>
> This was the recommended behavior back in the day before you could
> associate extensions with applications (I think).
>
> Why do you want to disable it?
>
> Robby
>
> On Thu, Jul 24, 2014 at 3:43 PM, Spencer Florence
>  wrote:
> > Hi all,
> >
> > Whenever I save a file with DrRacket on OSX, it always sets some extended
> > attributes on the file. Specifically it sets:
> >
> > [snips:pl7/examples] xattr -l somefile.rkt
> > com.apple.FinderInfo:
> >   54 45 58 54 44 72 53 63 00 00 00 00 00 00 00 00
> > |TEXTDrSc|
> > 0010  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> > ||
> > 0020
> >
> > In addition if I clear the xattr's (via xattr -c) DrRacket treats this
> as an
> > external write to the file and prompts me to overwrite on save and
> revert on
> > run. Is this behavior intended? It seems odd given that DrRacket doesn't
> do
> > this with normal attributes (permission, suid bit, etc.) If it is
> intended
> > what is the rational and can I disable it?
> >
> > --Spencer
> >
> >
> >
> > 
> >   Racket Users list:
> >   http://lists.racket-lang.org/users
> >
> 
>   Racket Users list:
>   http://lists.racket-lang.org/users
>

  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] DrRacket, OSX, and xattr

2014-07-24 Thread Spencer florence
Is your file in dropbox? I've noticed some syncing apps can butcher xattr's, 
which is how I found this in the first place.—
Sent from Mailbox

On Thu, Jul 24, 2014 at 5:22 PM, Justin R. Slepak 
wrote:

> I see this prompt pretty frequently, and I've never explicitly touched xattr. 
> I don't know if it's due to xattr being altered by something in the 
> background, but it does seem to happen a lot.
> ---
> Justin Slepak
> PhD student, Computer Science dept.
> - Original Message -
> From: Spencer Florence 
> To: racket 
> Sent: Thu, 24 Jul 2014 16:43:39 -0400 (EDT)
> Subject: [racket] DrRacket, OSX, and xattr
> Hi all,
> Whenever I save a file with DrRacket on OSX, it always sets some extended
> attributes on the file. Specifically it sets:
> [snips:pl7/examples] xattr -l somefile.rkt
> com.apple.FinderInfo:
>   54 45 58 54 44 72 53 63 00 00 00 00 00 00 00 00
>  |TEXTDrSc|
> 0010  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>  ||
> 0020
> In addition if I clear the xattr's (via xattr -c) DrRacket treats this as
> an external write to the file and prompts me to overwrite on save and
> revert on run. Is this behavior intended? It seems odd given that DrRacket
> doesn't do this with normal attributes (permission, suid bit, etc.) If it
> is intended what is the rational and can I disable it?
> --Spencer
> 
>   Racket Users list:
>   http://lists.racket-lang.org/users
  Racket Users list:
  http://lists.racket-lang.org/users


[racket] DrRacket, OSX, and xattr

2014-07-24 Thread Spencer Florence
Hi all,

Whenever I save a file with DrRacket on OSX, it always sets some extended
attributes on the file. Specifically it sets:

[snips:pl7/examples] xattr -l somefile.rkt
com.apple.FinderInfo:
  54 45 58 54 44 72 53 63 00 00 00 00 00 00 00 00
 |TEXTDrSc|
0010  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ||
0020

In addition if I clear the xattr's (via xattr -c) DrRacket treats this as
an external write to the file and prompts me to overwrite on save and
revert on run. Is this behavior intended? It seems odd given that DrRacket
doesn't do this with normal attributes (permission, suid bit, etc.) If it
is intended what is the rational and can I disable it?

--Spencer

  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] lazy letrec-values

2014-07-10 Thread Spencer Florence
It looks like he has taken those down. But I'm sure he would email a copy
if asked (the think is http://pl.barzilay.org/resources.html#classnotes btw)


On Thu, Jul 10, 2014 at 8:42 PM, Matthias Felleisen 
wrote:

>
> There are also Eli's class notes. I don't have a URL handy but I am sure
> if you google "Eli Barzilay" and "course" you'll find his notes on the
> various levels of lazy (plus homework assignments :-) -- Matthias
>
>
>
>
>
>
> On Jul 10, 2014, at 6:41 PM, Stephen Chang wrote:
>
> > Actually, this is a bug, because the expression in a single-argument
> > values call is forced prematurely.
> >
> > eg, This should not error:
> >
> > -> (let-values ([(x) (values (error "a"))]) 1)
> > ; a [,bt for context]
> >
> > Just like this does not error.
> >
> > -> (let-values ([(x y) (values (error "a") (error "b"))]) 1)
> > 1
> >
> > Lazy Racket is trying to preserve the (values x) == x from Racket, but
> > since LR's force is recursive, this is actually impossible without
> > breaking the semantics like it's doing now.
> >
> > Luke, thanks for finding this. If you want to submit a pull request, I
> > will merge. (Just drop the first clause in the case-lambda entirely.)
> > Maybe some extra tests would be nice as well :) Otherwise if you dont
> > have time, let me know and I'll do it.
> >
> >> Beyond the library documentation, does anyone know if there are any
> discussions or tutorials that go into the do's and don'ts of using #lang
> lazy ?
> >
> > There isnt any. You can check out the Barzilay-Clements paper [1] to
> > learn about the motivation behind LR, but otherwise LR should have
> > "standard" lazy semantics.
> >
> > [1]:
> http://digitalcommons.calpoly.edu/cgi/viewcontent.cgi?article=1047&context=csse_fac
> >
> > On Thu, Jul 10, 2014 at 1:15 PM, Luke Whittlesey
> >  wrote:
> >> Thank you for the in-depth analysis. Very interesting.
> >>
> >> Following your reasoning, if I edit lazy.rkt and force `values` to use
> >> `multiple-values` for the single entry case, the example that was
> previously
> >> broken now works. (I just have no idea if this breaks something else in
> the
> >> process.)
> >>
> >> at lazy.rkt line:223
> >> replace:
> >>  (define* ~values
> >>(case-lambda [(x) x] [xs (multiple-values xs)]))
> >>
> >> with:
> >>  (define* ~values
> >>(case-lambda [(x) (multiple-values (list x))] [xs (multiple-values
> >> xs)]))
> >>
> >>
> >> I had assumed that a reference to an identifier was delayed, so thanks
> for
> >> showing that this is currently not the case.
> >>
> >> Beyond the library documentation, does anyone know if there are any
> >> discussions or tutorials that go into the do's and don'ts of using #lang
> >> lazy ?
> >>
> >> Thanks,
> >> Luke
> >>
> >>
> >> On Thu, Jul 10, 2014 at 6:24 AM, Matthew Flatt 
> wrote:
> >>>
> >>> I'm not sure whether to call it a bug or a limitation of `lazy`.
> >>>
> >>> The `lazy` language doesn't delay a reference to an identifier. As a
> >>> result,
> >>>
> >>> (define x y)
> >>> (define y (list 1))
> >>> (car x)
> >>>
> >>> fails. The case could be made that the right-hand side of the
> definition
> >>> of `x` should have been a lazy reference to `y`, but that's not what
> >>> `lazy` currently does.
> >>>
> >>> A problem with the current choice is that it interacts badly with `!`,
> >>> especially as used by `letrec-values`. The implementation of
> >>> `letrec-values` forces the right-hand side of a binding using `!` to
> >>> determine how many values it produces. That works ok when the
> >>> right-hand side is produced by `values` on more than one argument,
> >>> because `values` produces a special multiple-values result that leaves
> >>> its values unforced after `!`. When `values` get one argument, then it
> >>> just returns the argument and that's still ok for something like
> >>> `(values (list 1 (/ 0)))`, because the `(/ 0)` expression is lazy.
> >>>
> >>> In your example, the implicit use of `!` for the right-hand side of the
> >>> A` binding produces `(! (list a B))`. That `B` is not itself treated as
> >>> a lazy expression, so forcing the list to be constructed causes `B` to
> >>> be evaluated early.
> >>>
> >>> You can make the variable reference lazy by wrapping it with `~`:
> >>>
> >>>  (letrec-values ([(A) (values (list 'a (~ B)))]
> >>>  [(B) (values (list 'b A))])
> >>>B)
> >>>
> >>> Again, I don't know that you should have to do that, but it's how
> >>> `lazy` is defined at the moment.
> >>>
> >>> At Mon, 7 Jul 2014 15:06:26 -0400, Luke Whittlesey wrote:
>  Hello all,
>  I've been playing around with creating circular lists (and learning
>  racket
>  which has been quite fun), but I'm stumped on why the lazy version of
>  letrec-values is not producing a promise like the lazy version of
> letrec
>  does. With the lazy letrec I can create circular lists, but with the
>  lazy
>  letrec-values I get #. See the example below.
> 
>  ; example cod

[racket] define-type on List and Listof

2014-06-17 Thread Spencer Florence
Hi all,

I'm trying to rename some types in typed/racket but something odd is
happening:

(define-type A Listof)

works but:

(define-type B List)

errors with "Type Checker: parse error in type; type name `List' is unbound
in: List"

Is this a bug or am I missing something?

--Spencer

  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] syntax-case and multiple ellipsis

2014-06-17 Thread Spencer Florence
Silly me, I was trying (require syntax/parse). Thanks!


On Tue, Jun 17, 2014 at 1:26 PM, Stephen Chang  wrote:

> Hmm, you might need to provide some more details about what you are
> trying to define then? (This particular example seems to work with
> syntax-parse in TR)
>
> #lang typed/racket
> (require (for-syntax syntax/parse))
>
> (define-syntax (test stx)
>   (syntax-parse stx #:datum-literals (in def)
> [(_ name
> (def a ...) ...
> (in clause do ...) ...)
>  #'(list a ... ... do ... ...)]))
>
> (test A (def 1 2 3) (in 4 5 6))
>
> On Tue, Jun 17, 2014 at 2:08 PM, Spencer Florence 
> wrote:
> > Unfortunately I'm working in typed racket, which (as far as I can tell)
> > doesn't play nice with syntax-parse. Any other ideas?
> >
> >
> > On Tue, Jun 17, 2014 at 1:04 PM, Jens Axel Søgaard <
> jensa...@soegaard.net>
> > wrote:
> >>
> >> Hi Spencer,
> >>
> >> The problem is that syntax-case pattern doesn't allow allow
> >> pattern of the form (x ... y ...) that is with two ellipsis on the
> >> same level.
> >>
> >> Luckily syntax-parse allow these:
> >>
> >> (require syntax/parse)
> >>
> >> (syntax-parse #'(a a a a 41 42 43)
> >>   [(c ... d ...)
> >>#''((c ...) (d ...))])
> >>
> >> (syntax-parse #'(a a a a 41 42 43)
> >>   [(c:id ... d ...)
> >>#''((c ...) (d ...))])
> >>
> >>
> >> /Jens Axel
> >>
> >>
> >>
> >>
> >> 2014-06-17 19:46 GMT+02:00 Spencer Florence  >:
> >> > Hey all,
> >> >
> >> > I'm trying to write a macro with syntax-case that looks something like
> >> > this:
> >> >
> >> >  (syntax-case stx (in def)
> >> > [(_ name
> >> > (def a ...) ...
> >> > (in clause do ...) ...)
> >> >  stuff])
> >> >
> >> > But, this gives me the error "syntax-case: misplaced ellipsis in
> pattern
> >> > (follows other ellipsis)" on the last ellipsis. Does anyone know a way
> >> > around this?
> >> >
> >> > --spencer
> >> >
> >> > 
> >> >   Racket Users list:
> >> >   http://lists.racket-lang.org/users
> >> >
> >>
> >>
> >>
> >> --
> >> --
> >> Jens Axel Søgaard
> >>
> >> 
> >>   Racket Users list:
> >>   http://lists.racket-lang.org/users
> >
> >
> >
> > 
> >   Racket Users list:
> >   http://lists.racket-lang.org/users
> >
>

  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] syntax-case and multiple ellipsis

2014-06-17 Thread Spencer Florence
Unfortunately I'm working in typed racket, which (as far as I can tell)
doesn't play nice with syntax-parse. Any other ideas?


On Tue, Jun 17, 2014 at 1:04 PM, Jens Axel Søgaard 
wrote:

> Hi Spencer,
>
> The problem is that syntax-case pattern doesn't allow allow
> pattern of the form (x ... y ...) that is with two ellipsis on the
> same level.
>
> Luckily syntax-parse allow these:
>
> (require syntax/parse)
>
> (syntax-parse #'(a a a a 41 42 43)
>   [(c ... d ...)
>#''((c ...) (d ...))])
>
> (syntax-parse #'(a a a a 41 42 43)
>   [(c:id ... d ...)
>    #''((c ...) (d ...))])
>
>
> /Jens Axel
>
>
>
>
> 2014-06-17 19:46 GMT+02:00 Spencer Florence :
> > Hey all,
> >
> > I'm trying to write a macro with syntax-case that looks something like
> this:
> >
> >  (syntax-case stx (in def)
> > [(_ name
> > (def a ...) ...
> > (in clause do ...) ...)
> >  stuff])
> >
> > But, this gives me the error "syntax-case: misplaced ellipsis in pattern
> > (follows other ellipsis)" on the last ellipsis. Does anyone know a way
> > around this?
> >
> > --spencer
> >
> > 
> >   Racket Users list:
> >   http://lists.racket-lang.org/users
> >
>
>
>
> --
> --
> Jens Axel Søgaard
>
> 
>   Racket Users list:
>   http://lists.racket-lang.org/users
>

  Racket Users list:
  http://lists.racket-lang.org/users


[racket] syntax-case and multiple ellipsis

2014-06-17 Thread Spencer Florence
Hey all,

I'm trying to write a macro with syntax-case that looks something like this:

 (syntax-case stx (in def)
[(_ name
(def a ...) ...
(in clause do ...) ...)
 stuff])

But, this gives me the error "syntax-case: misplaced ellipsis in pattern
(follows other ellipsis)" on the last ellipsis. Does anyone know a way
around this?

--spencer

  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] Determining type from a syntax object

2014-06-17 Thread Spencer Florence
It would be useful in the case of designing macros. The macro could make
decisions based not only on syntax but on type.

Although to be honest (and to answer Robby's earlier question) I came
across this while avoiding a longer but better way to design my program.

--Spencer


On Mon, Jun 16, 2014 at 2:46 PM, Alexander D. Knauth 
wrote:

>
> On Jun 16, 2014, at 3:41 PM, Sam Tobin-Hochstadt 
> wrote:
>
> > On Mon, Jun 16, 2014 at 3:29 PM, Alexander D. Knauth
> >  wrote:
> >>
> >> On Jun 16, 2014, at 3:13 PM, Sam Tobin-Hochstadt 
> wrote:
> >>
> >>> On Mon, Jun 16, 2014 at 3:06 PM, Alexander D. Knauth
> >>>  wrote:
> 
> > Typed Racket functions are
> > just plain Racket functions. We could add some extra metadata to
> every
> > value that held its type,
> 
>  It wouldn’t have to be every value, it could just put that
> information in for :has-type expressions, right?
>  Would that still require fundamental changes to Racket?
> >>>
> >>> The problem is that the information needs to get attached to the value
> >>> where the value is created, not where you use `:has-type?`.  The
> >>> `:has-type?` could even be in some other module, so you'd have to add
> >>> this information to every value, everywhere.  That's why it would need
> >>> to be part of the runtime.
> >>
> >> Then how would ann do it?
> >>
> >> I was thinking of something that would work sort of like ann, except
> that if it has the type, it would put true there (instead of the value), and
> >> if it doesn’t, then it would put false there (instead of raising an
> error).
> >>
> >> I understand that there’s no way to do this at ‘expansion’ time because
> it type checks it after it expands, but is there any way
> >> to do this at ‘type-check’ time?  That’s what ann does, right?
> >>
> >> That way the actual checking wouldn’t have to happen at runtime.
> >>
> >> Or do I have this expansion-time, type-check-time, run-time thing wrong
> somewhere?
> >
> > I think you have the various times right, but this proposal won't work
> > either. In particular, now your original example won't work:
> >
> > (cond [(:has-type? f (Number -> Any))
> >   (f 1)]
> >  [(:has-type? f (String -> Any))
> >   (f "1")])
> >
> > Imagine the `f` has type `Any at the start.  Then if you replace
> > `:has-type?` with `ann`, you get a type error.
> >
> > Unless you're suggesting that `f` would have to already have one of
> > those types, in which case I'm not sure how it helps you.
> >
> > Sam
>
> Oh, I hadn’t realized that.  f would have to already have one of those
> types, so it wouldn’t really help.
>
>
>
> 
>   Racket Users list:
>   http://lists.racket-lang.org/users
>

  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] Determining type from a syntax object

2014-06-14 Thread Spencer Florence
This is about making decisions at compile time. Specifically I have a
sequence of expressions I want to partition into expressions of some type T
and expressions of other types.


On Sat, Jun 14, 2014 at 7:34 PM, Robby Findler 
wrote:

> Would it be enough to expand into an 'ann' expression? Or do you need
> to make decisions at compile time based on whether or not the types
> worked?
>
> Robby
>
> On Sat, Jun 14, 2014 at 2:04 PM, Matthias Felleisen
>  wrote:
> >
> > No, TR expands first, then checks. -- Matthias
> >
> >
> >
> >
> > On Jun 14, 2014, at 2:59 PM, Spencer Florence wrote:
> >
> >> Hey All,
> >>
> >> I'm trying to take advantage of typed/racket in a few macros. Is there
> any way to check the type of an expression from its syntax object?
> something like:
> >>
> >> (:has-type? (-> Void) #'expression)
> >>
> >>
> >> --Spencer
> >> 
> >>  Racket Users list:
> >>  http://lists.racket-lang.org/users
> >
> >
> > 
> >   Racket Users list:
> >   http://lists.racket-lang.org/users
>

  Racket Users list:
  http://lists.racket-lang.org/users


[racket] Determining type from a syntax object

2014-06-14 Thread Spencer Florence
Hey All,

I'm trying to take advantage of typed/racket in a few macros. Is there any
way to check the type of an expression from its syntax object? something
like:

(:has-type? (-> Void) #'expression)


--Spencer

  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] Strange macro behavior with set! and syntax-local-introduce

2014-05-15 Thread Spencer Florence
I'm not sure how gensym fixes this:

#lang racket

(require (for-syntax syntax/parse racket/syntax racket/format))

(define-for-syntax funny #f)

(define-syntax (make-funny-set! stx)
  (syntax-parse stx
[(_ v) #`(define #,(begin (set! funny (datum->syntax #f (gensym)))
funny) v)]))

(define-syntax (funny-ref stx)
  (syntax-parse stx
[(_) funny]))

(define-syntax (funny-set! stx)
  (syntax-parse stx
[(_ v) #`(set! #,funny v)]))

(make-funny-set! 2)
(void (void (void (funny-set! 3
(funny-ref)

errors with:

  g27591: unbound identifier;
   also, no #%top syntax transformer is bound in: g27591

regardless of how many calls to void there are (inclusive of 0). This makes
sense, as the syntax marks don't add up. The calls to
"syntax-local-introduce" in the original program aught to solve this, but
as we saw... `/me points to robby's email`



And removing the datum->syntax errors with:

  funny-ref: received value from syntax expander was not syntax
received: 'g27876

Which also makes sense: a symbol is not Syntax.




On Thu, May 15, 2014 at 4:56 PM, Robby Findler
wrote:

> How does this help us understand the original, strange program?
>
> Robby
>
> On Thu, May 15, 2014 at 4:51 PM, Matthias Felleisen
>  wrote:
> >
> > Then use gensym instead of g and "~a" instead.
> >
> >
> >
> > On May 15, 2014, at 5:38 PM, Matthias Felleisen 
> wrote:
> >
> >>
> >> Did you want this:
> >>
> >> #lang racket
> >>
> >> (require (for-syntax syntax/parse racket/syntax))
> >>
> >> (define-for-syntax funny #f)
> >>
> >> (define-syntax (make-funny-set! stx)
> >>  (syntax-parse stx
> >>[(_ v) #`(define #,(begin (set! funny (format-id stx "g")) funny)
> v)]))
> >>
> >> (define-syntax (funny-ref stx)
> >>  (syntax-parse stx
> >>[(_) funny]))
> >>
> >> (define-syntax (funny-set! stx)
> >>  (syntax-parse stx
> >>[(_ v) #`(set! #,funny v)]))
> >>
> >> (make-funny-set! 2)
> >> (void (void (void (funny-set! 3
> >> (funny-ref)
> >>
> >> [I had to write such a macro a while back, and the above is roughly
> what I remember doing. Note the lexical context]
> >>
> >>
> >> On May 15, 2014, at 5:25 PM, Spencer Florence 
> wrote:
> >>
> >>> I'm attempting to write a macro which introduces a new id, then
> another macro that set!s that id.
> >>> Example:
> >>>
> >>> #lang racket
> >>> (require (for-syntax syntax/parse racket/syntax))
> >>> (define-for-syntax funny #f)
> >>> (define-syntax (make-funny-set! stx)
> >>>  (syntax-parse stx
> >>>[(_ v)
> >>> (define unmarked (generate-temporary))
> >>> (set! funny (syntax-local-introduce unmarked))
> >>> #`(define #,unmarked v)]))
> >>> (define-syntax (funny-ref stx)
> >>>  (syntax-parse stx
> >>>[(_)
> >>> funny]))
> >>> (define-syntax (funny-set! stx)
> >>>  (syntax-parse stx
> >>>[(_ v)
> >>> #`(set! #,(syntax-local-introduce funny) v)]))
> >>>
> >>> (make-funny-set! 2)
> >>> (funny-set! 3)
> >>> (funny-ref)
> >>>
> >>> This program works as I expect, evaluating to 3. However if I change
> (funny-set! 3) to (void (funny-set! 3)) I get the error: "set!: unbound
> identifier in module in: g1"
> >>>
> >>> I do not get this error if I change (funny-ref) to (void (funny-ref)).
> >>>
> >>> If I look at the expansion of the (void (funny-set! 3)) program in
> drracket's macro stepper the the g1 in (define g1 2) and the g1 in (void
> (set! g1 3)) have the same color.
> >>>
> >>> To keep on with the strange, if I change the #,(syntax-local-introduce
> funny) inside of funny-set! to #,funny inside the behavior of all programs
> remains the same.
> >>>
> >>> Could someone explain whats going on?
> >>>
> >>> --Spencer
> >>> 
> >>> Racket Users list:
> >>> http://lists.racket-lang.org/users
> >>
> >>
> >> 
> >>  Racket Users list:
> >>  http://lists.racket-lang.org/users
> >
> >
> > 
> >   Racket Users list:
> >   http://lists.racket-lang.org/users
>

  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] Strange macro behavior with set! and syntax-local-introduce

2014-05-15 Thread Spencer Florence
That's not quite what I'm looking for. I want an arbitrary number of
identifiers that my macros can use, but that aren't actually visible to the
program at large.
With this solution a user of the language I'm writing could accidentally
reference g.


(note: I have an unrelated work around for my problem. But the initial
issue still makes no sense to me.)


On Thu, May 15, 2014 at 4:38 PM, Matthias Felleisen wrote:

>
> Did you want this:
>
> #lang racket
>
> (require (for-syntax syntax/parse racket/syntax))
>
> (define-for-syntax funny #f)
>
> (define-syntax (make-funny-set! stx)
>   (syntax-parse stx
> [(_ v) #`(define #,(begin (set! funny (format-id stx "g")) funny) v)]))
>
> (define-syntax (funny-ref stx)
>   (syntax-parse stx
> [(_) funny]))
>
> (define-syntax (funny-set! stx)
>   (syntax-parse stx
> [(_ v) #`(set! #,funny v)]))
>
> (make-funny-set! 2)
> (void (void (void (funny-set! 3
> (funny-ref)
>
> [I had to write such a macro a while back, and the above is roughly what I
> remember doing. Note the lexical context]
>
>
> On May 15, 2014, at 5:25 PM, Spencer Florence  wrote:
>
> > I'm attempting to write a macro which introduces a new id, then another
> macro that set!s that id.
> > Example:
> >
> > #lang racket
> > (require (for-syntax syntax/parse racket/syntax))
> > (define-for-syntax funny #f)
> > (define-syntax (make-funny-set! stx)
> >   (syntax-parse stx
> > [(_ v)
> >  (define unmarked (generate-temporary))
> >  (set! funny (syntax-local-introduce unmarked))
> >  #`(define #,unmarked v)]))
> > (define-syntax (funny-ref stx)
> >   (syntax-parse stx
> > [(_)
> >  funny]))
> > (define-syntax (funny-set! stx)
> >   (syntax-parse stx
> > [(_ v)
> >  #`(set! #,(syntax-local-introduce funny) v)]))
> >
> > (make-funny-set! 2)
> > (funny-set! 3)
> > (funny-ref)
> >
> > This program works as I expect, evaluating to 3. However if I change
> (funny-set! 3) to (void (funny-set! 3)) I get the error: "set!: unbound
> identifier in module in: g1"
> >
> > I do not get this error if I change (funny-ref) to (void (funny-ref)).
> >
> > If I look at the expansion of the (void (funny-set! 3)) program in
> drracket's macro stepper the the g1 in (define g1 2) and the g1 in (void
> (set! g1 3)) have the same color.
> >
> > To keep on with the strange, if I change the #,(syntax-local-introduce
> funny) inside of funny-set! to #,funny inside the behavior of all programs
> remains the same.
> >
> > Could someone explain whats going on?
> >
> > --Spencer
> > 
> >  Racket Users list:
> >  http://lists.racket-lang.org/users
>
>

  Racket Users list:
  http://lists.racket-lang.org/users


[racket] Strange macro behavior with set! and syntax-local-introduce

2014-05-15 Thread Spencer Florence
I'm attempting to write a macro which introduces a new id, then another
macro that set!s that id.
Example:

#lang racket
(require (for-syntax syntax/parse racket/syntax))
(define-for-syntax funny #f)
(define-syntax (make-funny-set! stx)
  (syntax-parse stx
[(_ v)
 (define unmarked (generate-temporary))
 (set! funny (syntax-local-introduce unmarked))
 #`(define #,unmarked v)]))
(define-syntax (funny-ref stx)
  (syntax-parse stx
[(_)
 funny]))
(define-syntax (funny-set! stx)
  (syntax-parse stx
[(_ v)
 #`(set! #,(syntax-local-introduce funny) v)]))

(make-funny-set! 2)
(funny-set! 3)
(funny-ref)

This program works as I expect, evaluating to 3. However if I change
(funny-set! 3) to (void (funny-set! 3)) I get the error: "set!: unbound
identifier in module in: g1"

I do not get this error if I change (funny-ref) to (void (funny-ref)).

If I look at the expansion of the (void (funny-set! 3)) program in
drracket's macro stepper the the g1 in (define g1 2) and the g1 in (void
(set! g1 3)) have the same color.

To keep on with the strange, if I change the #,(syntax-local-introduce
funny) inside of funny-set! to #,funny inside the behavior of all programs
remains the same.

Could someone explain whats going on?

--Spencer

  Racket Users list:
  http://lists.racket-lang.org/users


[racket] Strange error from syntax/parse (?)

2014-05-14 Thread Spencer Florence
Hey all,

I'm getting an odd error from syntax/parse (I think, it might be
racket/match), and I've having trouble tracking down the cause, since the
error isn't giving me a source location. The error is:



/racket/match/define-forms.rkt: ?: expected a clause with a
pattern and a result
  at: ()
  in: (())
  context...:
   /Applications/Racket/racket/collects/unstable/error.rkt:65:0:
raise-syntax-error*46

 
/Applications/Racket/racket/collects/syntax/parse/private/runtime-report.rkt:31:0



Can anyone provide any advice to tracking down the cause?

--Spencer

  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] Blog post about Racket

2014-05-13 Thread Spencer Florence
> - machine learning

I know Dan King did a bit with machine learning in Racket a while ago, but
I have no clue what state its in:

https://github.com/danking/racket-ml


On Tue, May 13, 2014 at 10:35 AM, Konrad Hinsen
wrote:

> Stephen Chang writes:
>
>  > > That said, it's interesting to look at why Python became such a
>  > > popular language in science.
>  >
>  > Coincidentally, I just read this article:
>  >
> http://www.talyarkoni.org/blog/2013/11/18/the-homogenization-of-scientific-computing-or-why-python-is-steadily-eating-other-languages-lunch/
>  >
>  > Not sure if this is your experience, but from the article and
>  > comments, the summary seems to be that python is not great for any
>  > one task but "wins" because it enables you to do a bunch of tasks
>  > in the same language.
>
> That's an important aspect today, but one that appeared only after
> Python became popular in many domains of computational science.  Today
> there is a Python library for just about every domain of computational
> science, so yes, Python lets you do nearly everything.
>
>  > Interestingly, it seems that Racket can do everything in the
>  > article's list as well.
>
> I have doubts about some points on that list:
>
>   - neuroimaging data analysis
>   - statistical analysis
>   - machine learning
>
> If there are Racket libraries for any of those, I'd like to hear about
> them.  There is some statistical stuff in the math library, but a
> modern data scientist needs a lot more than that. Plus libraries to
> read and write common data formats, which are missing from that
> article's list, probably because the author took them for granted.
>
>
> I see Racket's strength for scientific computing in a very different
> aspect: the possibility to define languages tailor-made for expressing
> computational models in some application domain. Scientists generally
> don't want to "write programs", and when they do, the results are
> often not pretty. I'd like to have scientists do science and
> programmers write programs. Racket could become the meeting point for
> the two professions.
>
> Konrad.
>
> 
>   Racket Users list:
>   http://lists.racket-lang.org/users
>

  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] Callback on shutdown

2014-05-04 Thread Spencer Florence
Would something like dynamic-wind work for you?
http://docs.racket-lang.org/reference/cont.html?q=dynamic-wind#%28def._%28%28quote._~23~25kernel%29._dynamic-wind%29%29


On Sun, May 4, 2014 at 2:29 PM, Tony Garnock-Jones wrote:

> Hi all,
>
> I'm looking for an atexit()-like facility for Racket.
>
> I've tried setting the exit-handler, but it only seems to be called when
> I explicitly call exit, and not implicitly when Racket shuts down when
> control flows off the end of the main program.
>
> The problem I'm facing is to buffer rows to insert into a database, and
> every few tens of milliseconds flush the buffer, thereby increasing
> insertion performance.
>
> However, I don't want to have waiting buffered rows lost at the end of
> the program.
>
> I'd like to be able to avoid having to explicitly flush the buffer
> before exiting the program, so I'd like to make some kind of
> atexit()-alike do it for me.
>
> Any suggestions?
>
> Tony
> 
>   Racket Users list:
>   http://lists.racket-lang.org/users
>

  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] instantiating multiple sandboxes with gui's

2014-04-06 Thread Spencer florence
Annother option is for ,run to spin up a place, and then have the emacs repl 
pass commands over the channel. That should allow GUI to be instantiated as 
much as one wants. Im not sure how passing a "C-c" over to the place would work 
however. C-c could just kill the place, but that would come at the cost of 
loosing the backtrace. Also if emacs were to crash the place might not shutdown.

On Sun, Apr 6, 2014 at 12:35 PM, Robby Findler
 wrote:

> On Sunday, April 6, 2014, Greg Hendershott 
> wrote:
>> >> How does this handle dynamic and lazy requires?
>>
>> It doesn't.
>>
>> > Also: how do you know if the cache is stale?
>>
>> I don't.
>>
>> So my other idea was to do what dynamic-rerequire does and
>> parameterize current-load/use-compiled, and examine the dependencies.
>> However in the case where it detects racket/gui/base being loaded for
>> the first time, it would somehow need to abort the load,
>> dynamic-require racket/gui/base on the main custodian, then restart
>> the load as usual. That felt icky, so instead I tried the above, but
>> if it's the only way to handle dynamic and lazy requires, it's the
>> only way.
>>
> I think you would need to abort the program and start it over to really do
> that properly.
> Avoiding the focus shift at the OS level seems easier (altho I don't know
> if what the right Mac OS X calls to do it are).
> Robby
  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] instantiating multiple sandboxes with gui's

2014-04-06 Thread Spencer florence
How does this handle dynamic and lazy requires?

On Sun, Apr 6, 2014 at 11:30 AM, Greg Hendershott
 wrote:

> For those following along at home, I just pushed to `experimental`
> branch an updated strategy:
> https://github.com/greghendershott/racket-mode/commit/0358c0248a062245c134c48053aed79298a71c3a
> "When racket/gui/base not already loaded, examine the user module we're
> about to load to see if it will require racket/gui/base. If so,
> dynamic-require racket/gui/base on our main custodian. Then switch to
> user custodian and dynamic-require the module as usual. That way, we can
> do a custodian-shutdown-all on the user custodian, while leaving intact
> the main eventspace defined by racket/gui/base."
> How to "examine the user module we're about to load to see if it will
> require racket/gui/base"? Following the example of how syntax/moddeps
> works, recursively exploring using module-compiled-imports. (And
> memoizing, since there can easily be hundreds of imports to explore.)
> In my limited set of tests, this works as-desired. Of course there
> might be big holes in it I don't yet know about.
> 
>   Racket Users list:
>   http://lists.racket-lang.org/users
  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] instantiating multiple sandboxes with gui's

2014-04-05 Thread Spencer Florence
In xrepl that program catches breaks as well, so that behavior is probably
fine and unavoidable.

Although somehow drracket's repl managed to break out of that program. I
wonder how it does that...


On Sat, Apr 5, 2014 at 3:00 PM, Sam Tobin-Hochstadt wrote:

> What if you do this:
>
> (let l () (with-handlers ([void (l)]) (l)))
>
> This catches `exn:break` (and everything else) and calls `l`.
>
> Sam
>
> On Sat, Apr 5, 2014 at 2:54 PM, Greg Hendershott
>  wrote:
> >> thread cells are subject to GC and that's fine. The real issue is that I
> >> might write a program that does (effectively) this:
> >>
> >>  > (let l()(l))
> >>
> >> and then I'm stuck.
> >
> > Good point, but that's not a problem. A break returns to
> read-eval-print-loop.
> >
> > Example transcript:
> >
> >> (let l () (l))
> > C-cC-c
> > ; user break
> >> (displayln "broken but alive")
> > broken but alive
> >>
> >
> > (The double Control-C just being necessary as usual in an Emacs
> comint-buffer.)
> > 
> >   Racket Users list:
> >   http://lists.racket-lang.org/users
> 
>   Racket Users list:
>   http://lists.racket-lang.org/users
>

  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] substring without the copy

2014-04-04 Thread Spencer florence
Unfortunately that eventually does require running the true substring 
operation. All of my substrings are short-lived values that are used 
immediately, so being lazy doesn't help much. My issue is that Im running 
substring several million times to generate very short-lived values that are 
almost immediately ready to be collected.


substring/shared does seem to be what I want, although for some reason using 
that instead of substring is actually much  (~30%) slower. My initial guess as 
to why is TR contract boundary shenanigans, although that also seems odd given 
that the only contract that should be generated by requiring substring/shared 
is string?.

On Fri, Apr 4, 2014 at 4:12 PM, John Clements 
wrote:

> On Apr 3, 2014, at 7:08 PM, Spencer Florence  wrote:
>> Is there any way to perform `substring` without creating a new string? I'm 
>> working with lots of very large and (for all intents and purposes) immutable 
>> strings and would like to avoid the extra allocations and copy time.
> Seems like it would be fairly easy to roll this yourself:
> #lang racket
> (require rackunit)
> ;; represent a lazy substring operation:
> (struct lazysubstring (str start end))
> ;; force a lazy substring
> (define (lss-force s)
>   (substring (lazysubstring-str s)
>  (lazysubstring-start s)
>  (lazysubstring-end s)))
> ;; get the length of a lazy substring:
> (define (lss-len s)
>   (- (lazysubstring-end s) (lazysubstring-start s)))
> ;; create one:
> (define source-text "othho tot stnh ontuh .nt")
> (define lss1 (lazysubstring source-text 3 9))
> (check-equal? (lss-len lss1) 6)
> Obviously, you have to “roll your own” for any operation that you want to 
> perform that retains the laziness.
> John
  Racket Users list:
  http://lists.racket-lang.org/users


[racket] substring without the copy

2014-04-03 Thread Spencer Florence
Is there any way to perform `substring` without creating a new string? I'm
working with lots of very large and (for all intents and purposes)
immutable strings and would like to avoid the extra allocations and copy
time.

--Spencer

  Racket Users list:
  http://lists.racket-lang.org/users


[racket] instantiating multiple sandboxes with gui's

2014-03-23 Thread Spencer Florence
I'm attempting to launch multiple evaluators which require `racket/gui`,
however I get the error:

cannot instantiate `racket/gui/base` a second time in the same process

Is `racket/gui/base` maintaining some kind of state thats escaping the
sandbox?





Example of the problem:

#lang racket/base
(require racket/sandbox)

(call-with-trusted-sandbox-configuration
 (lambda ()
   (define (make)
 (make-evaluator 'racket/base
 #:requires '(racket/gui/base)))

   (make)
   (make)))

  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] call/comp, eq? and call-with-continuation-prompt

2014-03-10 Thread Spencer florence
Out of curiosity, why would removing the prompt tag change the behavior?

On Mon, Mar 10, 2014 at 10:50 PM, Matthew Flatt 
wrote:

> I think this is a compiler bug, where the compiler is changing
>(let ([a (cons 1 2)])
>  (call-with-composable-continuation (λ (k) (set! g k)) p)
>  a)
> to
>(begin
>  (call-with-composable-continuation (λ (k) (set! g k)) p)
>  (cons 1 2))
> so you get a new pair each time the continuation is called.
> I will need to fix the compiler so that it doesn't move allocation past
> an expression that could capture a continuation.
> At Mon, 10 Mar 2014 21:44:19 -0400, Spencer Florence wrote:
>> For some reason the below program returns false:
>> 
>> #lang racket
>> (define g #f)
>> (define p (make-continuation-prompt-tag))
>> (define (t)
>>   (let ([a (cons 1 2)])
>> (call-with-composable-continuation (λ (k) (set! g k)) p)
>> a))
>> (call-with-continuation-prompt t p)
>> (eq? (call-with-continuation-prompt g p)
>>(call-with-continuation-prompt g p))
>> 
>> This happens with call/cc as well. From my understanding a should be
>> allocated before the continuation is captured, so the two calls to g should
>> return the same cell. If I remove the prompt tag the program returns true.
>> 
>> Anyone have any clue whats going on or how to fix?
>> 
>> --Spencer
>> 
>>   Racket Users list:
>>   http://lists.racket-lang.org/users
  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] call/comp, eq? and call-with-continuation-prompt

2014-03-10 Thread Spencer Florence
On a lovely side note, asumu fixed this small case by changing (set! g k)
=> (set! g (lambda () a (k))).

However when I plugged that into the larger program I distilled this
example from, `eq?' still returns #f.


On Mon, Mar 10, 2014 at 10:07 PM, Matthias Felleisen
wrote:

>
> Baffled, too.
>
>
> On Mar 10, 2014, at 9:44 PM, Spencer Florence wrote:
>
> > For some reason the below program returns false:
> >
> > #lang racket
> > (define g #f)
> > (define p (make-continuation-prompt-tag))
> > (define (t)
> >   (let ([a (cons 1 2)])
> > (call-with-composable-continuation (λ (k) (set! g k)) p)
> > a))
> > (call-with-continuation-prompt t p)
> > (eq? (call-with-continuation-prompt g p)
> >(call-with-continuation-prompt g p))
> >
> > This happens with call/cc as well. From my understanding a should be
> allocated before the continuation is captured, so the two calls to g should
> return the same cell. If I remove the prompt tag the program returns true.
> >
> > Anyone have any clue whats going on or how to fix?
> >
> > --Spencer
> > 
> >  Racket Users list:
> >  http://lists.racket-lang.org/users
>
>

  Racket Users list:
  http://lists.racket-lang.org/users


[racket] call/comp, eq? and call-with-continuation-prompt

2014-03-10 Thread Spencer Florence
For some reason the below program returns false:

#lang racket
(define g #f)
(define p (make-continuation-prompt-tag))
(define (t)
  (let ([a (cons 1 2)])
(call-with-composable-continuation (λ (k) (set! g k)) p)
a))
(call-with-continuation-prompt t p)
(eq? (call-with-continuation-prompt g p)
   (call-with-continuation-prompt g p))

This happens with call/cc as well. From my understanding a should be
allocated before the continuation is captured, so the two calls to g should
return the same cell. If I remove the prompt tag the program returns true.

Anyone have any clue whats going on or how to fix?

--Spencer

  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] Using big-bang with picts

2014-02-17 Thread Spencer Florence
I've run into this before. The way we solved it was to rotate bitmaps my 0
degrees: Its silly, but it works.

So

(define (world->image p)
  (rotate (pict->bitmap p))


On Mon, Feb 17, 2014 at 2:38 PM, Robby Findler
wrote:

> This does look like a bug in 2htdp/universe, tho.
>
> Looking at the universe code, it is not dealing with the case that it gets
> a bitmap% object. 2htdp/image's image? predicate accepts those. Probably a
> diff something along these lines is the right fix (warning, untested!)
>
> ☕  git diff .
> diff --git a/pkgs/htdp-pkgs/htdp-lib/2htdp/private/world.rkt
> b/pkgs/htdp-pkgs/htdp-lib/2htdp/private/world.rkt
> index 103ca45..98d46ff 100644
> --- a/pkgs/htdp-pkgs/htdp-lib/2htdp/private/world.rkt
> +++ b/pkgs/htdp-pkgs/htdp-lib/2htdp/private/world.rkt
> @@ -232,7 +232,10 @@
>;; Image -> Void
>;; show the image in the visible world
>(define/public (show pict0)
> -(define pict (add-game-pad pict0))
> +(define pict1 (if (is-a? pict0 bitmap%)
> +  (make-object bitmap-snip% pict0)
> +  pict0))
> +(define pict (add-game-pad pict1))
>  (send visible begin-edit-sequence)
>  (send visible lock #f)
>  (let ([s (send visible find-first-snip)]
>
>
>
> On Mon, Feb 17, 2014 at 12:40 PM, Jens Axel Søgaard  > wrote:
>
>> Hi All,
>>
>> Is there a way to use big-bang with picts?
>> In other words, how can I convert a pict into something that big-bang
>> will display?
>>
>> The attempt below fails with this error:
>>
>> collects/racket/private/class-internal.rkt:4387:0: send: no such
>> method
>> method name: copy
>> class name: bitmap%
>>
>> #lang racket
>> (require pict (only-in 2htdp/universe big-bang on-tick to-draw))
>>
>> (define (world->image w)
>>   (pict->bitmap (circle w)))
>>
>> (big-bang 100
>>   [on-tick add1]
>>   [to-draw world->image])
>>
>>
>> --
>> Jens Axel Søgaard
>>
>> 
>>   Racket Users list:
>>   http://lists.racket-lang.org/users
>>
>
>
> 
>   Racket Users list:
>   http://lists.racket-lang.org/users
>
>

  Racket Users list:
  http://lists.racket-lang.org/users


[racket] typed/racket and contract boundaries

2014-01-27 Thread Spencer Florence
I have a typed module being required by a normal #lang racket module.

When I call a function from the typed module I get this error:

default-blame-format: contract violation
  expected: a blame object with a non-#f positive field
  given: #


Can someone give me some insight into what is going on?

--spencer

  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] Getting an expression to type

2014-01-26 Thread Spencer Florence
Unfortunately that was a simplified example. The in the program I'm
writing, the type isn't Number but (All (A B) ((A -> B) -> (A -> B))),
which I can't check for with a predicate as far as I know.


On Sun, Jan 26, 2014 at 2:31 PM, Eric Dobson wrote:

> That is definitely a bug, not sure exactly what is going wrong though.
> Can you file a bug for this?
>
> In terms of getting your program to run, if you replace '(not
> (parameter? p))' with 'number?' it should work.
>
> On Sun, Jan 26, 2014 at 10:08 AM, Spencer Florence 
> wrote:
> > I'm having difficulty getting the following code to type:
> >
> > #lang typed/racket
> > (: test : ((U Number (Parameterof Number)) -> Number))
> > (define (test p)
> >   (if (not (parameter? p))
> >   p
> >   (p)))
> >
> > But I get the error:
> >> Type Checker: Expected Number, but got (U Complex (Parameterof Number))
> >> in: p
> > On the then branch of the if. Is there a way to convince this to type?
> >
> > --Spencer
> >
> > 
> >   Racket Users list:
> >   http://lists.racket-lang.org/users
> >
>

  Racket Users list:
  http://lists.racket-lang.org/users


[racket] Getting an expression to type

2014-01-26 Thread Spencer Florence
I'm having difficulty getting the following code to type:

#lang typed/racket
(: test : ((U Number (Parameterof Number)) -> Number))
(define (test p)
  (if (not (parameter? p))
  p
  (p)))

But I get the error:
> Type Checker: Expected Number, but got (U Complex (Parameterof Number))
in: p
On the then branch of the if. Is there a way to convince this to type?

--Spencer

  Racket Users list:
  http://lists.racket-lang.org/users


[racket] Package fails to compile during 'make in-place' but not 'raco pkg install'

2013-12-20 Thread Spencer Florence
When I attempt to run a 'make in-place' on the head of the racket repo with
the package 'opengl' installed, the make fails with this error:

raco setup: found undeclared dependency:
raco setup:   mode: run
raco setup:   for package: "opengl"
raco setup:   on package: "srfi-lite-lib"
raco setup:   dependent source:
/Applications/Racket/racket/share/pkgs/opengl/opengl/compiled/readspec_rkt.zo
raco setup:   used module: (lib "srfi/13.rkt")
raco setup: --- summary of missing dependencies ---
raco setup: undeclared dependency detected
raco setup:   for package: "opengl"
raco setup:   on package:
raco setup:"srfi-lite-lib"
make[1]: *** [plain-in-place] Error 1
make: *** [in-place] Error 2

but if i remove the opengl package via 'raco pkg remove opengl', run 'make
in-place' and reinstall via 'raco pkg install opengl', I get no errors.

Anyone know why/how to fix?

--Spencer

  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] make-evaluator and (old style) planet packages

2013-09-26 Thread Spencer florence
Unfortunately the language I am using does not provide a #%top-interaction,
so REPL like interactions won't work. All it provides is #%module-begin.
What I really want is to evaluate:

#lang planet dyoo/bf
SOME-PROGRAM

where SOME-PROGRAM is determined at runtime. I'm guessing sandboxed
evaluators are not the way to go?

--Spencer


On Thu, Sep 26, 2013 at 10:11 PM, Eli Barzilay  wrote:

> 40 minutes ago, Spencer florence wrote:
> > How can I use make-evaluator with a planet package as a language?
> >
> > If I were to do (make-evaluator '(planet dyoo/bf:1:8/language))
> >
> > I get the error "#%require: not at top-level or in module body in:
> > (#%require (planet dyoo/bf:1:8/language))"
>
> You should generally prefer `make-module-evaluator', which is similar
> to getting a DrRacket REPL in the context of a language rather than
> `make-evaluator' which is more like running a Racket REPL.  Something
> like
>
>   (make-module-evaluator '(module foo (planet dyoo/bf:1:8/language)))
>
> or
>
>   (make-module-evaluator "#lang planet dyoo/bf:1:8/language")
>
> But I don't remember if it'll do what you want wrt getting strings and
> using a custom reader.
>
> --
>   ((lambda (x) (x x)) (lambda (x) (x x)))  Eli Barzilay:
> http://barzilay.org/   Maze is Life!
>

  Racket Users list:
  http://lists.racket-lang.org/users


[racket] make-evaluator and (old style) planet packages

2013-09-26 Thread Spencer florence
How can I use make-evaluator with a planet package as a language?

If I were to do (make-evaluator '(planet dyoo/bf:1:8/language))

I get the error "#%require: not at top-level or in module body in:
(#%require (planet dyoo/bf:1:8/language))"

Thoughts?

--Spencer Florence

  Racket Users list:
  http://lists.racket-lang.org/users