Re: [racket-users] Unicode identifiers

2018-05-16 Thread Andrew Kent
`racket/string` needs to be required _for syntax_ in order to work in the 
suggested way (because it's bindings are needed at compile time).

The following works for me in a module:

```
#lang racket/base

(require (for-syntax racket/base racket/string)
 racket/require)

(require (filtered-in
  (λ (name)
(string-replace name "->" "→"))
  racket))

(string→number "42")
```

-- 
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] Re: Refinement Type, Type Check Error

2018-04-18 Thread Andrew Kent
Hi Ray,

Thanks for the report and insight into refinement type usage "in the wild"! 
=)

It looks like this particular program type checks if you add 
`#:with-refinements` to the #lang line at the top of the file. 

i.e., make the first line `#:lang typed/racket #:with-refinements`

I would recommend adding that line any time your using refinement types -- 
it makes the type checker work a little harder and be better prepared to 
reason about refinement type usages.

Even though that fixes the error, the message it was printing was still 
pretty bizarre, so I've opened a GitHub issue 
(https://github.com/racket/typed-racket/issues/696) and will find some time 
to look into it. Feel free to log as many issues there as you see fit while 
trying to make use of refinement types! =)

Best,
Andrew

-- 
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] Re: Lessons learned from writing a Conway's Game of Life implementation in big-bang

2018-01-05 Thread Andrew Kent
In case you didn't see, there's a blog post (by Jay) about writing Conway's 
game of life in Racket. It spends some time talking about various 
optimizations to get performance:

http://jeapostrophe.github.io/2013-11-18-life-post.html

On Friday, January 5, 2018 at 9:14:39 AM UTC-5, cwebber wrote:
>
> Hello all, 
>
> Last night out of curiosity I started lazily adding some code to see how 
> long it would take me to write a game of life implementation in Racket. 
> Not exactly a challenging expidition game-authoring-wise, but a fun 
> little exercise anyway.  You can see and play with the results here: 
>
>   https://gitlab.com/dustyweb/racket-life 
>
> (Don't expect astounding code or anything.) 
>
> Here were my takeaways: 
>
>  - Racket is a real joy, especially due to its inclusion of its picture 
>language, to write this kind of thing in.  I started playing with 
>this very idly last evening and was very quickly pulled in. 
>
>  - The icons library is a hidden gem in Racket... bitmap-render-icon 
>is a lovely way in particular to create the kinds of sprites you use 
>in puzzle games :) 
>
>  - The HTDP big-bang system is, from a programming perspective, a lot of 
>fun to code in.  I can easily see how it would be great to teach 
>with. 
>
>  - It was easy to get an implementation of Conway's Game of Life going 
>and have it even be fairly pretty within almost no time.  However, as 
>observed here: 
>  https://groups.google.com/forum/#!topic/racket-users/yjRuIxypUQc 
>the functional drawing system isn't very fast once you get a lot of 
>objects on the screen.  Fortunately I found it was possible to not 
>have to convert all my code, only the to-draw bit... I converted 
>it to a bitmap canvas that I blitted to imperatively. 
>
>  - But even this was not fast enough... I found that a 50x50 graph was 
>terribly slow.  I found that even just creating the 1000x1000 px 
>bitmap every frame was very expensive, even before blitting to it, so 
>I stuck the bitmap in a parameter and kept it around between frames. 
>
>  - I then found out that the bitmap wasn't changing suddenly... I'm 
>guessing big-bang has an optimization where (since it's expecting a 
>functional program) if it sees an object that's eq? to the previous 
>object come out of to-draw, it doesn't draw it.  So instead I 
>allocated two bitmaps as parameters and switched between which one I 
>was blitting to.  That effectively tricked big-bang into blitting 
>to my reused bitmap every time ;) 
>
>  - With those optimizations in place, a 30x30 grid on my 
>10-year-old-laptop would run at full speed, and a a 50x50 tile grid 
>(1000x1000 pixels) rendered at about 10FPS... a barely tolerable, but 
>tolerable speed, for something like this ;) 
>
>  - It seems that the blitting of bitmaps to the canvas (I didn't do 
>anything smart to "only blit the ones that changed", which would 
>speed this up certainly by a lot) is by far the slowest part of 
>my code, so I figured maybe it would be faster if I drew rects on 
>the canvas instead of blitting my pretty icon-derived bitmaps. 
>To my surprise it became 50% slower! 
>
> I guess completely redrawing 2500 sprites per frame is just a lot for 
> the vanilla canvas.  I see there's an opengl canvas... maybe I should 
> try that. 
>
> Obviously there's "the most correct" optimization to do, given that I've 
> already gone down the route of committing imperative-rendering sins: I 
> ought to keep around the previous graph and see if it changed at all and 
> only blit the ones that actually changed.  Well, I'm sure that would 
> make things lightning fast ;) 
>
> I'm not sure if that's interesting to anyone at all.  But I will say, 
> Racket really is a joy to work with!  Thanks for making a toolbox so 
> much fun I accidentally lose a number of hours to something like this :) 
>
>  - Chris 
>

-- 
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] Beginners question: implementing existing generics for existing structs

2017-01-31 Thread Andrew Kent
In this case, Alexis designed data/collection to work well with some of the
pre-existing Racket generic interfaces.

For example, since ddicts implement the gen:dict interface, you can use
them with data/collection already:

```
#lang racket

(require data/collection
 data/ddict)

(define dd (ddict 1 2 3 4 5 6))


(extend dd '((7 . 8) (9 . 10)))

#|
produces:
#
|#
```


On Tue, Jan 31, 2017 at 4:49 PM, Ronie Uliana 
wrote:

> Let's assume I have a struct that is not mine (like ddict [
> https://pkgn.racket-lang.org/package/ddict], or some of pfds [
> https://pkgn.racket-lang.org/package/pfds]). I'd like to implement
> generics for them that also are not mine :p (like data/collection from
> Alexis King).
>
> 1 - Is it possible?
> 2 - How do I do that?
>
> I searched through generics documentation, but I think I completely missed
> that part =/
>
> []s an thx!
> Ronie
>
> --
> 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] [ANN] Simple, Deterministic Sets (dset)

2017-01-26 Thread Andrew Kent
Sets now also have a deterministic variant.

Installation:

`raco pkg install dset`


Documentation:

http://docs.racket-lang.org/dset/index.html


Contributions welcome!

https://github.com/pnwamk/dset

Best,
Andrew

-- 
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] Re: [ANN] Simple, Deterministic Dictionaries (ddict)

2017-01-23 Thread Andrew Kent
On Monday, January 23, 2017 at 4:27:56 PM UTC-5, Philip McGrath wrote:
> Have you considered implementing the gen:dict generic interface?
> 
> 
> 
> -Philip
> 
> 
> 
> On Mon, Jan 23, 2017 at 7:58 AM, Greg Trzeciak <gtrz...@gmail.com> wrote:
> On Monday, January 23, 2017 at 2:18:53 PM UTC+1, Andrew Kent wrote:
> 
> 
> 
> > ddict seeks to mimic Racket's `hash` API as much as possible and is 
> > hopefully a a convenient "drop in" replacement for `hash` when you'd like 
> > deterministic iteration order.
> 
> 
> 
> Thank you, just when I need it!
> 
> One minor issue regarding the API - I understand you wanted to mimic hash api 
> but I personally wonder if moving away from keywordless api for both hash and 
> ddict wouldn't be a better idea.
> 
> 
> 
> 
> 
> --
> 
> 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...@googlegroups.com.
> 
> For more options, visit https://groups.google.com/d/optout.

Yes, the mutable and immutable ddict abstractions both implement the gen:dict 
interface currently.

-- 
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] [ANN] Simple, Deterministic Dictionaries (ddict)

2017-01-23 Thread Andrew Kent
Good day all!

I just wanted to announce that I threw together a simple, deterministic 
dictionary package: ddict.

ddict seeks to mimic Racket's `hash` API as much as possible and is hopefully a 
a convenient "drop in" replacement for `hash` when you'd like deterministic 
iteration order.

If you're interested, read more here:

http://docs.racket-lang.org/ddict/index.html

and you can contribute here:

github.com/pnwamk/ddict

Best,
Andrew

-- 
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] Re: hello, where can I find the distribution 6.7.0.3.

2017-01-04 Thread Andrew Kent
At a glance, I believe the bug you're noticing on the snapshot is one we also 
recently observed -- it is fixed in a PR that should be pushed in the next 
couple of days (https://github.com/racket/typed-racket/pull/481).

Sorry for the trouble.

Best,
Andrew

On Wednesday, January 4, 2017 at 3:51:15 AM UTC-5, WarGrey Gyoudmon Ju wrote:
> I cannot deploy my typed desktop application on Windows.
> 
> 
> In the download home page, 6.7 does not work, and that bug seemed to be 
> solved (I started 6.7 from 6.7.0.3, do not know whether it was okay on macOS).
> 
> 
> The latest snapshot has a new bug shown both on macOS and Windows:
> 
> 
> 
> in-list: contract violation
>   expected: list?
>   given: (hash (Object) #t b #t)
>   compilation context...:
> context...:
>    C:\Program Files\Racket-6.7.0.4\collects\racket\private\for.rkt:633:2: 
> in-list
>    f184
>    C:\Program 
> Files\Racket-6.7.0.4\share\pkgs\typed-racket-lib\typed-racket\rep\type-rep.rkt:656:4:
>  for-loop
>    C:\Program 
> Files\Racket-6.7.0.4\share\pkgs\typed-racket-lib\typed-racket\rep\type-rep.rkt:653:0:
>  Union-map
>    f152
>    C:\Program 
> Files\Racket-6.7.0.4\share\pkgs\typed-racket-lib\typed-racket\rep\rep-utils.rkt:191:8:
>  Rep-fmap
>    C:\Program 
> Files\Racket-6.7.0.4\share\pkgs\typed-racket-lib\typed-racket\typecheck\tc-subst.rkt:98:0:
>  subst-tc-result
>    C:\Program 
> Files\Racket-6.7.0.4\share\pkgs\typed-racket-lib\typed-racket\typecheck\tc-subst.rkt:35:0:
>  values->tc-results5
>    C:\Program 
> Files\Racket-6.7.0.4\share\pkgs\typed-racket-lib\typed-racket\typecheck\tc-funapp.rkt:45:0:
>  tc/funapp
>    temp101
>    C:\Program 
> Files\Racket-6.7.0.4\share\pkgs\typed-racket-lib\typed-racket\typecheck\tc-expr-unit.rkt:329:0:
>  core914
>    C:\Program 
> Files\Racket-6.7.0.4\share\pkgs\typed-racket-lib\typed-racket\typecheck\tc-if.rkt:13:0:
>  core16
>    temp101
>    C:\Program 
> Files\Racket-6.7.0.4\share\pkgs\typed-racket-lib\typed-racket\typecheck\tc-expr-unit.rkt:326:0:
>  tc-expr
>    temp101
>    C:\Program 
> Files\Racket-6.7.0.4\share\pkgs\typed-racket-lib\typed-racket\typecheck\tc-expr-unit.rkt:79:0:
>  tc-expr/check
>    ...
> 
> 
> Would you please take me to the download page of 6.7.0.3? or one commit 
> before this bug? (I don't want to build it from source because real users of 
> this application have no knowledge on programming. Also I am working 
> remotely, we should have an agile feedback and update process). Thank you.

-- 
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] Re: How to test that a file is syntactically correct, but don't run it

2016-11-25 Thread Andrew Kent
On Friday, November 25, 2016 at 8:28:16 PM UTC-5, David K. Storrs wrote:
> As part of my pre-checkin test suite I'd like to be able to check that all 
> files are syntactically correct, but I don't want to actually execute them 
> because, e.g. executing 'server.rkt' would start the server and I don't want 
> that.  Is there a way to do this?  Nothing I see under 'raco help' or the 
> racket docs suggests a solution.

Does 'raco make' fit the bill?

-- 
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] Re: Help with macros

2016-09-22 Thread Andrew Kent
The '...' that is causing the error is a '...' at the level of the 
_initial/outer_ macro (define-primitive-application-syntax), and so your final 
use of '...' is trying to splice a parameter of the _initial macro_ 
(define-primitive-application-syntax), but you are actually trying to output a 
_literal_ '...' in the syntax you are generating because you want it to be a 
part of the macro you are generating/defining via 
define-primitive-application-syntax (i.e. primitive-name).

TL;DR you want this instead I believe:

…
(define-simple-macro (define-primitive-application-syntax (primitive-name:id 
arg:id ...))
  (define-simple-macro (primitive-name arg-expr:expr (... ...))
(list 'primitive-name arg-expr (... ...

-- 
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] Typed racket and continuations

2016-08-30 Thread Andrew Kent
@Jerzy here's (perhaps an unneeded) clarification just in case it helps:
Matthias said initially in a set theoretic type system continuations could
be considered as having the empty set as their return _type_ (not value) --
or in other words, their return type would be the empty type, or bottom
(which I believe is the "dramatic" something you had suggested). In Typed
Racket (U) is bottom (also written 'Nothing' in Typed Racket)).

On Tue, Aug 30, 2016 at 9:10 AM Matthias Felleisen 
wrote:

>
> > On Aug 30, 2016, at 3:22 AM, Jerzy Karczmarczuk <
> jerzy.karczmarc...@unicaen.fr> wrote:
> >
> > Could anybody justify this convention?
>
>
> Here the empty set represents the set of all possible result values.
> That’s a meta-set or a set about things in the language.
>
> > An empty set is a legitimate piece of data.
>
> If you wanted a function to return the empty set as a piece of data, you
> would have to choose a set representation.
>
> In principle, you ought to be able to construct a singleton type that
> expresses that a function will return the empty set.
>
> — Matthias
>
> --
> 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] Is my model of (values) accurate?

2016-07-22 Thread Andrew Kent
I don't fully understand the use case... but have you looked at 'apply'?

> (define (sum4 a b c d)
(+ a b c d))
> (apply sum4 1 2 (list 3 4))
10

On Fri, Jul 22, 2016 at 7:58 PM, David Storrs 
wrote:

> Thanks Jon, I appreciate the clear explanation.
>
> I'm using call-with-values in database code in order to turn a list into
> an acceptable set of bind parameters.  Here's an example:
>
> (query-exec conn "insert into foo (bar, baz) values ($1, $2)" (some-func))
>
> some-func returns a list, '("bob", "george").  query-exec throws an
> exception because it wants to see two elements for the bind parameters, not
> a list.  The solution I found was this:
>
> (call-with-values
> (lambda () (apply values the-list))
> (curry query-exec conn stmt))
>
> I know that I could have dug the parameters out with (car) and (cadr), but
> this seemed like it would be a common enough pattern that it was worth
> coming up with a standard answer that would work for any number of params.
>
> This is what got me thinking about how exactly (values) worked.
>
>
> On Fri, Jul 22, 2016 at 7:28 PM, Jon Zeppieri  wrote:
>
>>
>>
>> On Fri, Jul 22, 2016 at 6:30 PM, David Storrs 
>> wrote:
>>
>>>
>>> The best mental model I've been able to come up with is that (values)
>>> returns its results vertically but most functions expect to get them
>>> horizontally and will die if there are parallel lines of uncollected
>>> values. Under this model (call-with-values) collects values from the Y
>>> axis and pivots them back onto the X axis for consumption by regular
>>> functions. This feels like a fragile analogy though.  Would someone
>>> please fill me in on how it actually works?
>>>
>>>
>>
>> When you do:
>>
>>(values ...)
>>
>> in a DrRacket window, it does list the values vertically, but that's
>> probably not a very useful way to think about what `values` is.  You can
>> think of `values` as a constructor of a second-class tuple. The fact that
>> the resultant tuple is "second-class" is very important here. You can't
>> give a name to this tuple. For example,
>>
>>(define foo (values 1 2 3))
>>
>> is illegal.  You can't pass it as an argument to a procedure:
>>
>>(list (values 1 2 3))
>>
>> is likewise illegal. There is, in fact, very little you can do with this
>> tuple other than let `call-with-values` unpack it.
>>
>> `call-with-values` is special (like call-with-continuation is special).
>> Its first argument, a zero-arity procedure, produces a values which are
>> then passed *as separate arguments* -- not as a second-class tuple -- to
>> its second argument. That's what `call-with-values` does: it translates
>> this second-class tuple into separate procedure arguments.
>>
>> `call-with-values` is rarely used directly. It's far more common to use
>> `define-values` or `let-values` (or one of its variants). For example,
>> although you can't do:
>>
>>(define foo (values 1 2 3))
>>
>> You can do:
>>
>>(define-values (a b c) (values 1 2 3))
>>
>> There is one special case to keep in mind: a unary use of `values`, e.g.:
>>
>>(values 1)
>>
>> is exactly equivalent to its argument. That is, (values 1) *is exactly*
>> 1. That's not true for any other arity of `values`. (This is also how
>> *first*-class tuples in ML behave.)
>>
>> For my own part, I'm not a big fan of `values` and `call-with-values`.
>> Their use is for returning multiple values from a procedure -- which you
>> can also do by returning a first-class, composite piece of data, like a
>> vector or a list. The one advantage of second-class tuples is that, because
>> there's so little you can do
>> with them, they're easier to give optimized representations.
>>
>> - Jon
>>
>>
> --
> 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] Is it possible to implement generics to an already defined struct?

2016-03-05 Thread Andrew Kent
When you define a generic interface, you can specify defaults for _any_
kind of value you want.

Here is a small example that might be useful (which is really just the
example here

tweaked to be simpler and handle a struct (foo) that didn't define an
implementation of the generic interface when it was defined):

#lang racket
(require racket/generic)

(struct foo (bar) #:transparent)

(define-generics printable
(gen-print printable [port])
#:defaults ([string?
 (define/generic super-print gen-print)
 (define (gen-print s [port (current-output-port)])
   (fprintf port "String: ~a" s))]
[foo?
 (define/generic super-print gen-print)
 (define (gen-print f [port (current-output-port)])
   (fprintf port "Foo's bar: ~a" (foo-bar f)))]))

(gen-print (foo "hi"))

One downside to this is if you're doing a lot of these you'll pay more in
dispatch time than if you can define them directly in the initial struct
definition.

-Andrew

On Sat, Mar 5, 2016 at 1:20 PM, Ronie Uliana  wrote:

> Sorry for the beginner question :(
>
> I'm learning Racket and it is an amazing language. Documentation is great,
> but I couldn't find this.
>
> Let's say I have a struct defined somewhere I have no control:
>
> (struct blah (x y))
>
> Now, in my module, I have this generics:
>
> (define-generics my-thing
>   (level my-thing))
>
> Is it possible to make "blah" to implement "my-thing"? So I can use it
> like:
>
> (level (blah 1 2))
>
> --
> 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] Re: [Redex] 'substitute' is not compatible with #:satisfying

2016-03-04 Thread Andrew Kent
On Friday, March 4, 2016 at 10:17:00 AM UTC-5, Andrew Kent wrote:
> I have been really itching to use Redex's awesome random testing for a model 
> I'm working with.
> 
> Also, I have been really enjoying the #:binding-forms feature for defining 
> languages.
> 
> Unfortunately, these two features seem not fully compatible: you cannot use a 
> judgment which requires 'substitute' to restrict term generation since 
> 'substitute' is implemented with raw Racket code, which is incompatible with 
> the #:satisfying option. 
> 
> (side note: this restriction appears to still be a secret known only to the 
> Redex elders and those who have been initiated (i.e. the docs don't mention 
> this limitation)).
> 
> So I just wanted to ask if anyone had any pointers/suggestions at this point?
> 
> At the moment, I'm thinking of creating some macros which help users (well at 
> least me for the moment) define Redex languages (and their binding 
> constructs) in a way which is _entirely_ compatible w/ the constraints 
> #:satisfying imposes.
> 
> I imagine this will involve using a wrapper around something like Peano-style 
> naturals instead of raw symbols for language variables  (so fresh variables 
> can be generated in a way that does not require any raw Racket code). From 
> there I think I can write some macros that generate metafunctions for 
> substitution, alpha equivalence, and free-variables which are entirely 
> compatible with #:satisfying. Unfortunately I wont get automatic "freshening" 
> of binders in my metafunctions/judgments like you currently do when declaring 
> #:binding-forms =(
> 
> Anyway, am I totally crazy here? Any thoughts?
> 
> Thanks,
> Andrew

Ah, or perhaps I can use the standard #:binding-forms declarations and then 
just macro-generate definitions for substitution, alpha-equiv and 
free-variables from there (which should be easy with automatic freshening on 
matches?)?

-- 
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] [Redex] 'substitute' is not compatible with #:satisfying

2016-03-04 Thread Andrew Kent
I have been really itching to use Redex's awesome random testing for a model 
I'm working with.

Also, I have been really enjoying the #:binding-forms feature for defining 
languages.

Unfortunately, these two features seem not fully compatible: you cannot use a 
judgment which requires 'substitute' to restrict term generation since 
'substitute' is implemented with raw Racket code, which is incompatible with 
the #:satisfying option. 

(side note: this restriction appears to still be a secret known only to the 
Redex elders and those who have been initiated (i.e. the docs don't mention 
this limitation)).

So I just wanted to ask if anyone had any pointers/suggestions at this point?

At the moment, I'm thinking of creating some macros which help users (well at 
least me for the moment) define Redex languages (and their binding constructs) 
in a way which is _entirely_ compatible w/ the constraints #:satisfying imposes.

I imagine this will involve using a wrapper around something like Peano-style 
naturals instead of raw symbols for language variables  (so fresh variables can 
be generated in a way that does not require any raw Racket code). From there I 
think I can write some macros that generate metafunctions for substitution, 
alpha equivalence, and free-variables which are entirely compatible with 
#:satisfying. Unfortunately I wont get automatic "freshening" of binders in my 
metafunctions/judgments like you currently do when declaring #:binding-forms =(

Anyway, am I totally crazy here? Any thoughts?

Thanks,
Andrew

-- 
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] SEwPR PLT Redex code error? (pg 225)

2016-02-23 Thread Andrew Kent
A student today pointed out the standard reduction definition for ISWIM on pg 
225 in SEwPR is broken:

#lang racket
(require redex)

;; iswim
;; definition from pg 217
(define-language iswim
  ((M N L K) X (λ X M) (M M) b (o2 M M) (o1 M))
  (o o1 o2)
  (o1 add1 sub1 iszero)
  (o2 + - *)
  (b number)
  ((V U W) b X (λ X M))
  (E hole (V E) (E M) (o V ... E M ...))
  (X Y Z variable-not-otherwise-mentioned))

(define-metafunction iswim
  subst : any ... -> any)

;; iswim-standard
;; definition from pg 225
(define iswim-standard
  (reduction-relation
   iswim
   (v ((λ X M) V) (subst M X V) vω)
   (v (o b ...) (δ (o b ...)) δ)
   with
   [(--> (in-hole E M) (in-hole E N)) (v M N)]))


Error message: "reduction-relation: shortcut name may not be a non-terminal in: 
M"

Only posting this here since I couldn't find anything about it on the errata.

Have a good day!

Best,
Andrew

-- 
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] Counterintuitive performance results

2016-01-08 Thread Andrew Kent
Any guesses why adding more indirection speeds up the code here?

#lang racket

(define (set-members? s . xs)
  (for/and ([x (in-list xs)])
(set-member? xs x)))


(define s (set-add
   (for/set ([i (in-range 1000)])
 (random 1))
   333))

(collect-garbage)
(time (for ([i (in-range 100)])
(set-member? s 333))) ;; slower

(collect-garbage)
(time (for ([i (in-range 100)])
(set-members? s 333))) ;; faster

Best,
Andrew

-- 
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] Counterintuitive performance results

2016-01-08 Thread Andrew Kent
On Friday, January 8, 2016 at 4:40:05 PM UTC-5, Alex Knauth wrote:
> I tried doing stuff, but then I realized that there's a typo that messes this 
> up.
> 
> > On Jan 8, 2016, at 4:29 PM, Andrew Kent <sgt...@gmail.com> wrote:
> > 
> > Any guesses why adding more indirection speeds up the code here?
> > 
> > #lang racket
> > 
> > (define (set-members? s . xs)
> >  (for/and ([x (in-list xs)])
> >(set-member? xs x)))
> 
> This should have been (set-member? s x), right?
> 
> > 
> > (define s (set-add
> >   (for/set ([i (in-range 1000)])
> > (random 1))
> >   333))
> > 
> > (collect-garbage)
> > (time (for ([i (in-range 100)])
> >(set-member? s 333))) ;; slower
> > 
> > (collect-garbage)
> > (time (for ([i (in-range 100)])
> >(set-members? s 333))) ;; faster
> > 
> > Best,
> > Andrew
> > 
> > -- 
> > 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.

Hah! That was it. Thanks.

-- 
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] More concise testing in PLT Redex? (new redex-chk pkg)

2015-11-06 Thread Andrew Kent
They do not currently --- all the tests are expanding into simple rackunit
forms such as 'check-equal?', 'check-false', 'check-true', etc with redex's
'term' wrapped around the original syntax.

However, you could mimic `default-equiv` by defining a redex
metafunction/relation/judgment that captures the notion of equivalence you
want.

For example, you could test for some language-specific notion of `α=`
instead of Racket's `equal?` like this:

(redex-relation-chk
   α=
   [(subst (λ (x) (f x)) [g / f])
(λ (y) (g y))]
   ...)

On Thu, Nov 5, 2015 at 10:42 PM William J. Bowman <w...@williamjbowman.com>
wrote:

> Thanks, I've been meaning to do something about this for months!
>
> Do they make use of `default-equiv`?
>
> --
> William J. Bowman
>
> On Wed, Nov 04, 2015 at 05:50:01AM -0800, Andrew Kent wrote:
> > Dear other PLT Redex users,
> >
> > Do you have any clever tricks/tools to make testing in PLT Redex
> > more palletable? I was finding some of my tests had a lot more
> > boiler-plate text than actual test-relevant code. I would love to
> > hear your thoughts/experiences on this issue... and share
> > something I threw together that I've found helpful:
> >
> > I basically hijacked and rewrote Jay's lovely rackunit/chk
> > pkg (thanks Jay!) to cater to redex tests. It's now the
> > 'redex-chk' pkg (on http://pkgs.racket-lang.org/).
> >
> > It allows verbose tests like these:
> >
> > (module+ test
> >   ;; restrict tests
> >   (test-equal (term (restrict mt-Γ Any Int)) (term Int))
> >   (test-equal (term (restrict mt-Γ Int Any)) (term Int))
> >   (test-equal (term (restrict mt-Γ Int Bool)) (term (U)))
> >   (test-equal (term (restrict mt-Γ (U Bool Int) Int)) (term Int))
> >
> >   ;; subtyping tests
> >   (test-equal (judgment-holds (subtype mt-Γ Int Int)) #t)
> >   (test-equal (judgment-holds (subtype mt-Γ Int Any)) #t)
> >   (test-equal (judgment-holds (subtype mt-Γ Any Int)) #f))
> >
> > to be written like this:
> >
> > (module+ test
> >   ;; restrict tests
> >   (redex-chk
> >(restrict mt-Γ Any Int) Int
> >(restrict mt-Γ Int Any) Int
> >#:= (restrict mt-Γ Int Bool) (U)
> >[(restrict mt-Γ (U Bool Int) Int) Int])
> >
> >   ;; subtyping tests
> >   (redex-relation-chk
> >subtype
> >[mt-Γ Int Int]
> >[mt-Γ Int Any]
> >[#:f mt-Γ Any Int]))
> >
> > (Note -- each of the restrict tests is checking for 'equal?',
> >  there's just several equivalent ways to write that,
> >  like in Jay's rackunit/chk lib)
> >
> > Anyway - throwing this together was a fun macro-learning experience for
> > me and I think has helped me write more and better tests for my
> > redex model (now that it's easier). I figured it might be useful for
> > others, and wondered if anyone else had done anything in the same
> > department.
> >
> > Best,
> > Andrew
> >
> > --
> > 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] More concise testing in PLT Redex? (new redex-chk pkg)

2015-11-04 Thread Andrew Kent
Dear other PLT Redex users,

Do you have any clever tricks/tools to make testing in PLT Redex
more palletable? I was finding some of my tests had a lot more
boiler-plate text than actual test-relevant code. I would love to
hear your thoughts/experiences on this issue... and share
something I threw together that I've found helpful:

I basically hijacked and rewrote Jay's lovely rackunit/chk
pkg (thanks Jay!) to cater to redex tests. It's now the
'redex-chk' pkg (on http://pkgs.racket-lang.org/).

It allows verbose tests like these:

(module+ test
  ;; restrict tests
  (test-equal (term (restrict mt-Γ Any Int)) (term Int))
  (test-equal (term (restrict mt-Γ Int Any)) (term Int))
  (test-equal (term (restrict mt-Γ Int Bool)) (term (U)))
  (test-equal (term (restrict mt-Γ (U Bool Int) Int)) (term Int))

  ;; subtyping tests
  (test-equal (judgment-holds (subtype mt-Γ Int Int)) #t)
  (test-equal (judgment-holds (subtype mt-Γ Int Any)) #t)
  (test-equal (judgment-holds (subtype mt-Γ Any Int)) #f))

to be written like this:

(module+ test
  ;; restrict tests
  (redex-chk
   (restrict mt-Γ Any Int) Int
   (restrict mt-Γ Int Any) Int
   #:= (restrict mt-Γ Int Bool) (U)
   [(restrict mt-Γ (U Bool Int) Int) Int])

  ;; subtyping tests
  (redex-relation-chk
   subtype
   [mt-Γ Int Int]
   [mt-Γ Int Any]
   [#:f mt-Γ Any Int]))

(Note -- each of the restrict tests is checking for 'equal?',
 there's just several equivalent ways to write that,
 like in Jay's rackunit/chk lib)

Anyway - throwing this together was a fun macro-learning experience for
me and I think has helped me write more and better tests for my
redex model (now that it's easier). I figured it might be useful for 
others, and wondered if anyone else had done anything in the same 
department.

Best,
Andrew

-- 
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] DrRacket fill-paragraph?

2015-10-25 Thread Andrew Kent
I know I've pressed meta-q in DrRacket and gotten the Emacs 'fill-paragraph' 
behavior (where it automatically wraps your text at ~70 characters or so, 
inserting new-lines, etc) but I can't for the life of me locate any such 
option/command in either the menus or keybindings list (I'm trying to create a 
binding that points to it).

Is it sitting right under my nose and I just haven't seen it yet, or is it 
tucked away somewhere peculiar?

Thanks!

-Andrew

-- 
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] DrRacket fill-paragraph?

2015-10-25 Thread Andrew Kent
Well - the fact that it was m:q on OS X was how I discovered it in the
first place (coming from emacs and mindlessly pressing key combinations
occasionally, hah).

I'm tinkering around in DrRacket on Linux, it doesn't seem to me like m:q
(Alt-Q) is bound to anything (with or without 'Enable keybindings in menus'
turned on). Unless there's a reason why that wouldn't work... my vote would
be m:q!

On Sun, Oct 25, 2015 at 8:47 PM Robby Findler <ro...@eecs.northwestern.edu>
wrote:

> It may be that the shortcut key is shadowed on Linux. Any recommendations
> for a choice there?
>
> Robby
>
> On Sunday, October 25, 2015, Andrew Kent <sgt...@gmail.com> wrote:
>
>> Yes - that is what I had found previously. But the feature seems absent
>> on Linux, or else I'm crazy (I just tried in in a .scrbl file in OS X and
>> Ubuntu, and it works in OS X, but not Ubuntu).
>>
>> On Sun, Oct 25, 2015 at 6:44 PM Robby Findler <
>> ro...@eecs.northwestern.edu> wrote:
>>
>>> DrRacket has that when editing scribble files but not other ones. Is
>>> that what you found?
>>>
>>> Robby
>>>
>>>
>>> On Sunday, October 25, 2015, Andrew Kent <sgt...@gmail.com> wrote:
>>>
>>>> I know I've pressed meta-q in DrRacket and gotten the Emacs
>>>> 'fill-paragraph' behavior (where it automatically wraps your text at ~70
>>>> characters or so, inserting new-lines, etc) but I can't for the life of me
>>>> locate any such option/command in either the menus or keybindings list (I'm
>>>> trying to create a binding that points to it).
>>>>
>>>> Is it sitting right under my nose and I just haven't seen it yet, or is
>>>> it tucked away somewhere peculiar?
>>>>
>>>> Thanks!
>>>>
>>>> -Andrew
>>>>
>>>> --
>>>> 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] DrRacket fill-paragraph?

2015-10-25 Thread Andrew Kent
Yes - that is what I had found previously. But the feature seems absent on
Linux, or else I'm crazy (I just tried in in a .scrbl file in OS X and
Ubuntu, and it works in OS X, but not Ubuntu).

On Sun, Oct 25, 2015 at 6:44 PM Robby Findler <ro...@eecs.northwestern.edu>
wrote:

> DrRacket has that when editing scribble files but not other ones. Is that
> what you found?
>
> Robby
>
>
> On Sunday, October 25, 2015, Andrew Kent <sgt...@gmail.com> wrote:
>
>> I know I've pressed meta-q in DrRacket and gotten the Emacs
>> 'fill-paragraph' behavior (where it automatically wraps your text at ~70
>> characters or so, inserting new-lines, etc) but I can't for the life of me
>> locate any such option/command in either the menus or keybindings list (I'm
>> trying to create a binding that points to it).
>>
>> Is it sitting right under my nose and I just haven't seen it yet, or is
>> it tucked away somewhere peculiar?
>>
>> Thanks!
>>
>> -Andrew
>>
>> --
>> 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] Re: Redex: call for alpha-equivalence beta testers

2015-10-14 Thread Andrew Kent
On Wednesday, October 14, 2015 at 7:47:27 AM UTC-4, Andrew Kent wrote:
> On Saturday, September 19, 2015 at 1:21:19 PM UTC-4, Robby Findler wrote:
> > Paul Stansifer has been implementing the ideas from his dissertation
> > work in Redex and is now ready to share them with the world.
> > 
> > Thanks to Paul, Redex languages now understand binding structure,
> > meaning that if you write a substitution function that just blindly
> > substitutes, it will actually properly do alpha conversion to avoid
> > name collisions. In general, pattern matching now has alpha
> > equivalence smarts (see the docs for more).
> > 
> > The new features include the #:binding keyword in define-language and
> > extend-language, and the alpha-equivalent? and substitute functions.
> > 
> > The plan is to let it stay only in Paul's repo until the next release
> > goes out and then push it to the main Redex repo to be included in the
> > release after this one. If you'd like to give it a try, some
> > instructions are below. Please let us know how it goes!
> > 
> > Robby
> > 
> > 
> > 
> > 
> > To try it out, first download a snapshot build:
> > 
> >http://pre.racket-lang.org/installers/
> > 
> > and then create a parent directory to hold the git repo for Redex:
> > 
> >   cd PLTDIR; mkdir extra-pkgs; cd extra-pkgs
> > 
> > run this command to get the git version of Redex:
> > 
> > raco pkg update --clone redex \
> >   "git://github.com/racket/redex?path=redex" \
> >   "git://github.com/racket/redex?path=redex-benchmark" \
> >   "git://github.com/racket/redex?path=redex-doc" \
> >   "git://github.com/racket/redex?path=redex-examples" \
> >   "git://github.com/racket/redex?path=redex-gui-lib" \
> >   "git://github.com/racket/redex?path=redex-lib" \
> >   "git://github.com/racket/redex?path=redex-pict-lib" \
> >   "git://github.com/racket/redex?path=redex-test"
> > 
> > and then get Paul's version:
> > 
> >   cd redex
> >   git remote add paul https://github.com/paulstansifer/redex-1.git
> >   git checkout public
> >   raco setup
> 
> First, just want to say I'm loving this feature so far! Thank you.
> 
> One quick question---I have something failing to work, and I'm not sure if 
> it's a bug, or a feature/capability that's not supported (yet?):
> 
> [;; other details ...
>--- "S-Refine"
>(subtype Δ (Refine [x : S] Q) (Refine [x : T] P))]
> 
> I was hoping that sort of case in a judgment would (1) auto-magically perform 
> substitution such that any two refinements would be made in terms of the same 
> variable, and (2) that variable x would be fresh with respect to the other 
> arguments (i.e. Δ).
> 
> It seems like (2) holds, but (1) does not. For example, this test case does 
> not even successfully match on this judgment rule:
> 
> (test-equal
>(term (subtype (Env ([y : Int]) ())
>   (Refine [x : Int] (≤ x y))
>   (Refine [z : Int] (≤ z y
>   #t)
> 
> Thanks,
> Andrew

Oh! And I was also curious if a 'free-identifiers' function (similar to 
'alpha-equivalent?' and 'substitute') is on a list of future features, perhaps? 
That would be another nice piece of boilerplate to throw away once binding info 
is specified for a language...

Thanks again for the awesome new features! =)

-- 
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] Re: Redex: call for alpha-equivalence beta testers

2015-10-14 Thread Andrew Kent
- I'll send the model I'm toying with your way.

- I was using free-identifiers/free-vars to define the wellformedness of
environments and types. I've seen it used in other formalisms, but I'm not
sure just how widely used it is relative to other potential features.

On Wed, Oct 14, 2015 at 3:54 PM Paul Stansifer <pa...@ccs.neu.edu> wrote:

> Thanks!
>
> Regarding feature (1), that might be hard to implement because of the
> internal design of the freshener. But could you send me the Redex model in
> question so I can poke at it anyways?
>
> `free-identifiers` should be pretty easy to make. What does it tend to be
> useful for?
>
> Paul
>
> On Wed, Oct 14, 2015 at 7:47 AM, Andrew Kent <sgt...@gmail.com> wrote:
>
>> On Saturday, September 19, 2015 at 1:21:19 PM UTC-4, Robby Findler wrote:
>> > Paul Stansifer has been implementing the ideas from his dissertation
>> > work in Redex and is now ready to share them with the world.
>> >
>> > Thanks to Paul, Redex languages now understand binding structure,
>> > meaning that if you write a substitution function that just blindly
>> > substitutes, it will actually properly do alpha conversion to avoid
>> > name collisions. In general, pattern matching now has alpha
>> > equivalence smarts (see the docs for more).
>> >
>> > The new features include the #:binding keyword in define-language and
>> > extend-language, and the alpha-equivalent? and substitute functions.
>> >
>> > The plan is to let it stay only in Paul's repo until the next release
>> > goes out and then push it to the main Redex repo to be included in the
>> > release after this one. If you'd like to give it a try, some
>> > instructions are below. Please let us know how it goes!
>> >
>> > Robby
>> >
>> >
>> > 
>> >
>> > To try it out, first download a snapshot build:
>> >
>> >http://pre.racket-lang.org/installers/
>> >
>> > and then create a parent directory to hold the git repo for Redex:
>> >
>> >   cd PLTDIR; mkdir extra-pkgs; cd extra-pkgs
>> >
>> > run this command to get the git version of Redex:
>> >
>> > raco pkg update --clone redex \
>> >   "git://github.com/racket/redex?path=redex" \
>> >   "git://github.com/racket/redex?path=redex-benchmark" \
>> >   "git://github.com/racket/redex?path=redex-doc" \
>> >   "git://github.com/racket/redex?path=redex-examples" \
>> >   "git://github.com/racket/redex?path=redex-gui-lib" \
>> >   "git://github.com/racket/redex?path=redex-lib" \
>> >   "git://github.com/racket/redex?path=redex-pict-lib" \
>> >   "git://github.com/racket/redex?path=redex-test"
>> >
>> > and then get Paul's version:
>> >
>> >   cd redex
>> >   git remote add paul https://github.com/paulstansifer/redex-1.git
>> >   git checkout public
>> >   raco setup
>>
>> First, just want to say I'm loving this feature so far! Thank you.
>>
>> One quick question---I have something failing to work, and I'm not sure
>> if it's a bug, or a feature/capability that's not supported (yet?):
>>
>> [;; other details ...
>>--- "S-Refine"
>>(subtype Δ (Refine [x : S] Q) (Refine [x : T] P))]
>>
>> I was hoping that sort of case in a judgment would (1) auto-magically
>> perform substitution such that any two refinements would be made in terms
>> of the same variable, and (2) that variable x would be fresh with respect
>> to the other arguments (i.e. Δ).
>>
>> It seems like (2) holds, but (1) does not. For example, this test case
>> does not even successfully match on this judgment rule:
>>
>> (test-equal
>>(term (subtype (Env ([y : Int]) ())
>>   (Refine [x : Int] (≤ x y))
>>   (Refine [z : Int] (≤ z y
>>   #t)
>>
>> Thanks,
>> Andrew
>>
>
>> --
>> 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/CjFIFEhTEj8/unsubscribe.
>> To unsubscribe from this group and all its topics, 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] Naming for generalization of find-min and find-max?

2015-10-12 Thread Andrew Kent
... what about 'select' or 'select-by'?

(If not... I'm just helping eliminate all the bad names... =)

On Mon, Oct 12, 2015 at 7:39 PM Alex Knauth  wrote:

> The names `first-by` and `find-first-by` both sound good to me.
>
> Alexis?
>
> On Oct 12, 2015, at 4:54 PM, Martin DeMello 
> wrote:
>
> One problem with generalising find-max and find-min into a single hof is
> that they are closer in spirit to a fold than a find. The name find- makes
> you think that the passed in function should be a predicate on one element,
> not two. How about something like first-by?
>
> > (first-by stringstring second) '((3 pears) (1
> banana) (2 apples)))
> '(2 apples)
>
> martin
>
> On Sun, Oct 11, 2015 at 3:24 PM, Alex Knauth  wrote:
>
>> Hi,
>>
>> Alexis King and I were discussing adding versions of argmin and argmax to
>> the alexis/collection library, but we agreed that find-min and find-max
>> were clearer names. Then we came up with a generalization of those that
>> would take an ordering procedure (< for find-min and > for find-max), and
>> find the element that had a property greater/less than the properties of
>> all the other elements, by the ordering procedure (not restricted to
>> numbers).
>>
>> The problem was naming it. We thought of `find-best` and
>> `find-most-relevant`, but `find-best` would be confusing when it's being
>> used to find the worst case, and `find-most-relevant` seems better but to
>> wordy.
>>
>> Do any of you have any ideas?
>>
>> Examples:
>> > (the-function < first '((3 pears) (1 banana) (2 apples))) ; find-min
>> would be a shorthand for this
>> '(1 banana)
>> > (the-function > first '((3 pears) (1 banana) (2 apples))) ; find-max
>> would be a shorthand for this
>> '(3 pears)
>> > (the-function stringstring second) '((3 pears) (1
>> banana) (2 apples)))
>> '(2 apples)
>> > (the-function string>? (compose1 symbol->string second) '((3 pears) (1 
>> > banana)
>> (2 apples)))
>> '(3 pears)
>>
>> *https://github.com/lexi-lambda/racket-alexis-collections/pull/9#issuecomment-145727937
>> *
>>
>>
>> --
>> 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] Naming for generalization of find-min and find-max?

2015-10-11 Thread Andrew Kent
'leftmost' or 'rightmost'? Or 'find-leftmost' 'find-rightmost'? I dunno,
maybe those are more confusing. They seem to hint at the right idea to me
(at least as it relates to argument order and the relation).

On Sun, Oct 11, 2015, 6:25 PM Alex Knauth  wrote:

> Hi,
>
> Alexis King and I were discussing adding versions of argmin and argmax to
> the alexis/collection library, but we agreed that find-min and find-max
> were clearer names. Then we came up with a generalization of those that
> would take an ordering procedure (< for find-min and > for find-max), and
> find the element that had a property greater/less than the properties of
> all the other elements, by the ordering procedure (not restricted to
> numbers).
>
> The problem was naming it. We thought of `find-best` and
> `find-most-relevant`, but `find-best` would be confusing when it's being
> used to find the worst case, and `find-most-relevant` seems better but to
> wordy.
>
> Do any of you have any ideas?
>
> Examples:
> > (the-function < first '((3 pears) (1 banana) (2 apples))) ; find-min
> would be a shorthand for this
> '(1 banana)
> > (the-function > first '((3 pears) (1 banana) (2 apples))) ; find-max
> would be a shorthand for this
> '(3 pears)
> > (the-function stringstring second) '((3 pears) (1
> banana) (2 apples)))
> '(2 apples)
> > (the-function string>? (compose1 symbol->string second) '((3 pears) (1 
> > banana)
> (2 apples)))
> '(3 pears)
>
> *https://github.com/lexi-lambda/racket-alexis-collections/pull/9#issuecomment-145727937
> *
>
> --
> 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] Tool for typesetting PLT Redex models

2015-09-16 Thread Andrew Kent
Good afternoon!

I threw together a little bit of syntax that I find makes typesetting redex 
models much more convenient.

The package, typeset-rewriter, is located here: 
https://github.com/andmkent/typeset-rewriter

I blogged about it a little as well: 
http://andmkent.com/blog/2015/09/15/typesetting-with-plt-redex/

It's really just a thin layer of syntax to generate match-patterns that work 
well with the redex typesetting structs.

Comments, feedback, pull requests welcome!

Best,
Andrew

-- 
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] side-condition's in PLT Redex... tread carefully

2015-08-28 Thread Andrew Kent
PSA - careful using side-conditions in PLT Redex! (I'd stick to 'where' 
clauses, personally)

The fact that side-conditions exist in both metafunctions/reduction-relations 
*and* judgment-forms but are *not* in fact the same thing (i.e. those found in 
the former accept racket expressions, the latter accepts terms) can lead to 
nasty, subtle little bugs if you're not careful. (yes the difference is 
documented, however it's still really easy to hang yourself with them if you 
forget the subtle distinction in a sufficiently complicated model, IMHO).

For example, consider a little language which models propositional logic:

(define-language propositional-logic
  [φ ::= variable-not-otherwise-mentioned]
  [Γ ::= (φ ...)])

(define-judgment-form propositional-logic
  #:mode (proves I I)
  #:contract (proves Γ φ)
  ;; ...
  [(side-condition (memq (term φ) (term Γ)))
    L-Assumption
   (proves Γ φ)]
  ;; ...
  )

(test-equal (judgment-holds (proves (P) P)) #t)
(test-equal (judgment-holds (proves (P) Q)) #f) ;; -- fails test!

Uh oh, why did our second test fail? Ah yes, but of course! We forgot that in a 
judgment-form, side-condition will end up quoting Racket expressions (since it 
accepts terms) and so the condition '(side-condition (memq (term φ) (term Γ)))' 
is always true.

Although what we wrote would have worked as a guard in a metafunction 
definition, that same code here behaves differently. We should have written 
(side-condition ,(memq (term φ) (term Γ))) to escape to Racket and actually 
call 'memq' on the arguments.

Because of this, I try to idiot proof things by *always* just use 'where' 
clauses since they behave the same everywhere. This has worked quite well for 
me thus far.

Anyway, that's all I've got to say about that.

Thanks for PLT Redex! Everyone should attend the PLT Redex summer school next 
year! (Assuming there is one... =)

-Andrew

-- 
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] DrRacket rendering issues OS X

2015-08-18 Thread Andrew Kent
Just an update/bump: I'm still seeing this issue in DrRacket on the latest
git checkouts. I went ahead replicated the issue on a friend's mac w/ OS X
Yosemite w/ the 6.2 release as well (just to make sure I wasn't crazy or
causing the issue on my machine).[image: Screen Shot 2015-08-18 at 4.07.23
PM.png]

On Wed, Jun 17, 2015 at 7:13 PM Matthew Flatt mfl...@cs.utah.edu wrote:

 At Wed, 17 Jun 2015 12:35:36 -0700 (PDT), Andrew Kent wrote:
  On Wednesday, June 17, 2015 at 3:10:51 PM UTC-4, Alex Knauth wrote:
   One data point:
   I’m using DrRacket version 6.2.0.4--2015-06-08 with OS X Version
 10.9.5, and
  if I remember correctly it was a Racket plus Tests 64-bit installation.
   I tried those steps, and it worked fine, with no weird black areas,
 though I
  do remember occasionally getting similar small black areas in the past,
  covering just the tab bar or something like that, and when I moved my
 mouse
  over it it fixed itself? I’m not sure if I remember that correctly, and
 I’m not
  sure if that could be related to what you got, because that wasn’t with
 full
  screen or the mission control screen, and I could not produce that
 consistently.
  
  
   On Jun 17, 2015, at 12:25 PM, Andrew Kent andm...@indiana.edu wrote:
  
  
   Good day all!
  
  
   First, I just wanted to say DrRacket is *amazing* and thank all who
 have
  helped it become what it is today! I'm currently using it to work on
 Typed
  Racket and it is a godsend.
  
  
   Right now, unfortunately, I am having some problems w/ DrRacket
 rendering in
  OS X -- I am getting large black areas appearing in full screen mode in
  DrRacket. They seem pretty serious/severe, and I was curious if anyone
 else has
  seen this behavior?
  
  
  
   PDF w/ screenshots  some attempt to describe problem(s):
  
 https://drive.google.com/file/d/0B-HcU1nZPrwJWXFNbEdOV0doeUE/view?usp=sharing
  
  
   Steps that seem to recreate issue:
   1) Open DrRacket
   2) Make it full screen by clicking green button at top left of DrRacket
   3) Open OS X ‘Mission Control’ (cmd+up or 3-finger-swipe up on
 touchpad) 4)
  Close OS X ‘Mission Control’ (cmd+down or 3-finger-swipe downon
   touchpad) nd
   5) Repeat 3-4 a couple times (after the 2 time it seemed to
 consistently
   happen on my machine)
  
  
   - This worked whether or not I was plugged into the external monitor
   - the snapshots reproduced the issue on were the Racket plus Tests |
 Mac OS X
  | 32-bit Intel distribution for version 6.2.0.4 (20150609-bf12a2b) 
 version
  6.2.0.4 (20150617-97827ac)
   - I’m running the latest OS X Yosemite (Version 10.10.3 (14D136)) on a
 early
  2013 13” MacBook Air
  
  
  
  
   Best,
   Andrew
 
  Additional note/update:
  When I was writing up the bug description those steps _were_ working
  consistently for me. Now, however, they do not... but somewhat
 erratically
  jumping workspaces left to right (I have Powerpoint full screened at the
 moment
  as well) mixed w/ some Mission Control access can cause it.
 
  So, I can't figure out how to do it 100% consistently, but it is
 definitely a
  reoccurring issue and sometimes I end up just having to close DrRacket
 to make
  it go away.

 I haven't been able to replicate the problem, but I'm also using
 Mavericks. This problem could easily be specific to Yosemite, and I'll
 check when I get back to my Yosemite machine in a couple of weeks.



-- 
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] Re: is this a bug?

2015-08-06 Thread Andrew Kent
'ormap'
http://docs.racket-lang.org/reference/pairs.html?q=ormap#%28def._%28%28lib._racket%2Fprivate%2Fmap..rkt%29._ormap%29%29

or 'for/or'
http://docs.racket-lang.org/reference/for.html?q=for%2For#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._for%2For%29%29

may be useful to you.

On Thu, Aug 6, 2015 at 11:09 AM, sagyo12341...@gmail.com wrote:

 In racket, the proc apply-or is needed.

  (or #f 1 2 #f 3 4 #f)
 1
  (apply or (list #f 1 2 #f 3 4 #f))
 . or: bad syntax in: or
  (define (apply-or lst) (foldr or #t lst))
 . or: bad syntax in: or
  (define (apply-or lst) (foldr (lambda (x y) (or x y)) #t lst))
  (apply-or (list #f 1 2 #f 3 4 #t))
 1
  (foldl (lambda (x y) (or x y)) #t (list #f 1 2 #t 3 4 #t))
 #t

 --
 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] DrRacket rendering issues OS X

2015-06-17 Thread Andrew Kent
On Wednesday, June 17, 2015 at 3:10:51 PM UTC-4, Alex Knauth wrote:
 One data point:
 I’m using DrRacket version 6.2.0.4--2015-06-08 with OS X Version 10.9.5, and 
 if I remember correctly it was a Racket plus Tests 64-bit installation.
 I tried those steps, and it worked fine, with no weird black areas, though I 
 do remember occasionally getting similar small black areas in the past, 
 covering just the tab bar or something like that, and when I moved my mouse 
 over it it fixed itself? I’m not sure if I remember that correctly, and I’m 
 not sure if that could be related to what you got, because that wasn’t with 
 full screen or the mission control screen, and I could not produce that 
 consistently.
 
 
 On Jun 17, 2015, at 12:25 PM, Andrew Kent andm...@indiana.edu wrote:
 
 
 Good day all!
 
 
 First, I just wanted to say DrRacket is *amazing* and thank all who have 
 helped it become what it is today! I'm currently using it to work on Typed 
 Racket and it is a godsend.
 
 
 Right now, unfortunately, I am having some problems w/ DrRacket rendering in 
 OS X -- I am getting large black areas appearing in full screen mode in 
 DrRacket. They seem pretty serious/severe, and I was curious if anyone else 
 has seen this behavior?
 
 
 
 PDF w/ screenshots  some attempt to describe problem(s):
 https://drive.google.com/file/d/0B-HcU1nZPrwJWXFNbEdOV0doeUE/view?usp=sharing
 
 
 Steps that seem to recreate issue:
 1) Open DrRacket
 2) Make it full screen by clicking green button at top left of DrRacket
 3) Open OS X ‘Mission Control’ (cmd+up or 3-finger-swipe up on touchpad) 4) 
 Close OS X ‘Mission Control’ (cmd+down or 3-finger-swipe downon
 touchpad) nd
 5) Repeat 3-4 a couple times (after the 2 time it seemed to consistently
 happen on my machine)
 
 
 - This worked whether or not I was plugged into the external monitor
 - the snapshots reproduced the issue on were the Racket plus Tests | Mac OS X 
 | 32-bit Intel distribution for version 6.2.0.4 (20150609-bf12a2b)  version 
 6.2.0.4 (20150617-97827ac)
 - I’m running the latest OS X Yosemite (Version 10.10.3 (14D136)) on a early 
 2013 13” MacBook Air
 
 
 
 
 Best,
 Andrew
 
 
 
 -- 
 
 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...@googlegroups.com.
 
 For more options, visit https://groups.google.com/d/optout.

Additional note/update:
When I was writing up the bug description those steps _were_ working 
consistently for me. Now, however, they do not... but somewhat erratically 
jumping workspaces left to right (I have Powerpoint full screened at the moment 
as well) mixed w/ some Mission Control access can cause it.

So, I can't figure out how to do it 100% consistently, but it is definitely a 
reoccurring issue and sometimes I end up just having to close DrRacket to make 
it go away.

-- 
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] DrRacket rendering issues OS X

2015-06-17 Thread Andrew Kent
Good day all!

First, I just wanted to say DrRacket is *amazing* and thank all who have
helped it become what it is today! I'm currently using it to work on Typed
Racket and it is a godsend.

Right now, unfortunately, I am having some problems w/ DrRacket rendering
in OS X -- I am getting large black areas appearing in full screen mode in
DrRacket. They seem pretty serious/severe, and I was curious if anyone else
has seen this behavior?

PDF w/ screenshots  some attempt to describe problem(s):
https://drive.google.com/file/d/0B-HcU1nZPrwJWXFNbEdOV0doeUE/view?usp=sharing

Steps that seem to recreate issue:
1) Open DrRacket
2) Make it full screen by clicking green button at top left of DrRacket
3) Open OS X ‘Mission Control’ (cmd+up or 3-finger-swipe up on touchpad) 4)
Close OS X ‘Mission Control’ (cmd+down or 3-finger-swipe downon
touchpad) nd
5) Repeat 3-4 a couple times (after the 2 time it seemed to consistently
happen on my machine)

- This worked whether or not I was plugged into the external monitor
- the snapshots reproduced the issue on were the Racket plus Tests | Mac OS
X | 32-bit Intel distribution for version 6.2.0.4 (20150609-bf12a2b) 
version 6.2.0.4 (20150617-97827ac)
- I’m running the latest OS X Yosemite (Version 10.10.3 (14D136)) on a
early 2013 13” MacBook Air


Best,
Andrew

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