[racket-users] package server: link to conflicts broken for some packages

2019-11-30 Thread Jesse Alama
On the package page, I notice that at least one package (redis-doc) 
marked as having conflicts leads to this URL


  https://pkg-build.racket-lang.org/(indirect%20conflicts.txt)

which, as I write this, generates an error page. The same goes for 
redis-rkt and redis-tests. There may be others.


Not all packages marked as having conflicts have this broken link. For 
bystroTeX, for instance, the link 
(https://pkg-build.racket-lang.org/conflicts.txt) works.


--
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/86D34CAA-EAAF-4BA1-8F7E-0AA80776F167%40lisp.sh.


Re: [racket-users] fcontrol and dynamic-wind

2019-11-30 Thread Alexis King
> On Nov 30, 2019, at 20:52, Matthew Flatt  wrote:
> 
> They are, as long as any invoked `dynamic-wind` thunks are safe in
> atomic mode. (After all, `unsafe-abort-current-continuation/no-wind`
> and `unsafe-call-with-composable-continuation/no-wind` were created to
> support `unsafe/try-atomic`.)

Alright, thanks, that does make sense. I think it’s still probably not the 
right solution, since the idea is that effect handlers ought to be 
implementable in user code, and I wouldn’t want to ask users to regularly 
interact with atomic mode. Maybe it can play a role in a safe abstraction, 
though.

Also, I realized shortly after I wrote my last email that I actually did see an 
effect system paper a while back that addressed these issues: “Algebraic Effect 
Handlers with Resources and Deep Finalization” by Daan Leijen. Looking at it 
again, it even cites Sitaram’s “Unwind-protect in portable Scheme” article I 
mentioned earlier! I may have forgotten about it because it appears to have 
only ever been released as a Microsoft Research technical report, not published 
at any academic conference. In any case, I didn’t really understand it when I 
first saw it, so I need to reread it more carefully, but an initial skim seems 
promising.

-- 
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/E6F8DAA0-8CF6-4745-B071-AAC1BFB3D880%40gmail.com.


Re: [racket-users] fcontrol and dynamic-wind

2019-11-30 Thread Matthew Flatt
At Sat, 30 Nov 2019 20:38:26 -0600, Alexis King wrote:
> I’m not even sure if continuation operations are safe 
> in atomic mode.

They are, as long as any invoked `dynamic-wind` thunks are safe in
atomic mode. (After all, `unsafe-abort-current-continuation/no-wind`
and `unsafe-call-with-composable-continuation/no-wind` were created to
support `unsafe/try-atomic`.)

-- 
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/5de32ae4.1c69fb81.30ea6.bc95SMTPIN_ADDED_MISSING%40gmr-mx.google.com.


Re: [racket-users] fcontrol and dynamic-wind

2019-11-30 Thread Alexis King
> On Nov 30, 2019, at 09:23, Matthew Flatt  wrote:
> 
> There's not a safe way. In many cases, Racket lets you write new things
> that have the power of built-in through unsafe APIs --- and it turns
> out that there are unadvertised procedures (provided by the primitive
> `#%unsafe` module) for this particular case:
> 
>  unsafe-abort-current-continuation/no-wind
>  unsafe-call-with-composable-continuation/no-wind

Thanks, those operations look helpful. I do worry a little bit that maybe they 
only solve the `dynamic-wind` problem, though, and don’t solve some other, 
related problems. For example, imagine I were to replace `dynamic-wind` with 
`parameterize-break`:

  (run-amb/first
(thunk
  (parameterize-break #f
(+ (amb 1 2) (amb 3 4)

Presumably, breaks would still be re-enabled and local exception handlers would 
be uninstalled during the handling of `amb`, even with the use of those unsafe 
operations, right? That seems wrong, too, since presumably the client would be 
surprised if a break were delivered inside the scope of `(parameterize-break #f 
_)`.

I think what it comes down to is I somehow want the ability to “atomically” 
insert some new continuation frames around the current prompt without 
uninstalling the current break state, exception handlers, continuation marks, 
and so on. I want to be able to go from

  E_1[(run-amb/first E_2[(amb e_1 e_2)])]

to

  E_1[(run-amb/first (or E_2[e_1] E_2[e_2]))]

in a single “step.” I guess I could resort to atomic mode, but that seems like 
a very heavy hammer, and I’m not even sure if continuation operations are safe 
in atomic mode. On the other hand, I don’t really know what a safe API for what 
I’m trying to do would look like.

> I don't know of any published work on this topic (so let me know if you
> find something!). As you probably have seen already, our ICFP'07 paper
> just points out that `dynamic-wind` causes problems, but doesn't try to
> hold `dynamic-wind` itself responsible for those problems.
> 
> An opinion and some pointers to newsgroup discussions:
> 
>  http://okmij.org/ftp/continuations/against-callcc.html#dynamic_wind
> 
> It would be interesting to check whether `dynamic-wind` is really
> needed in Racket libraries, at least in its current form. Most uses are
> really a "finally" mechanism that could be tied to explicit escapes
> like exceptions, instead of imposed for all continuation jumps. Maybe
> the uses that don't fit that pattern would be better expressed with
> another mechanism. Maybe the guarantees on `dynamic-wind` just need to
> be weakened and the `/no-wind` variants declared "safe" by defining
> away the unsafety.

Yes, most of the relevant discussions I’ve found have been about Lisp’s 
`unwind-protect` and how it relates to Scheme’s `dynamic-wind`. It’s alluded to 
in Matthias’s original POPL ’88 paper and mentioned explicitly in the following 
LASC paper, but neither address this particular issue. I also found Dorai 
Sitaram’s “Unwind-protect in portable Scheme”[1] and the related commentary by 
Kent Pitman[2] and Will Clinger[3], but though obviously related, both Sitaram 
and Clinger seem to imagine a system where the author of the program defines 
all control operations, so there isn’t as much of a problem. I’ve also been 
trying to find if any of these issues are discussed in any algebraic effects 
literature, but I haven’t found anything there yet, either.

[1]: http://www.ccs.neu.edu/~dorai/uwcallcc/uwcallcc.html
[2]: 
http://www.nhplace.com/kent/PFAQ/unwind-protect-vs-continuations-overview.html
[3]: http://www.ccs.neu.edu/home/will/UWESC/uwesc.sch

-- 
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/AE70AFAC-89FA-4260-A8AE-6726A1AFE261%40gmail.com.


Re: [racket-users] racket-2019-gamejam

2019-11-30 Thread Hendrik Boom
On Fri, Nov 22, 2019 at 10:57:30PM +, Stephen De Gabrielle wrote:
> **racket-2019-gamejam**
> Submissions due in 7 days 2 hours 9 minutes 57 seconds Join jam
> https://itch.io/jam/racket-2019-gamejam

Possibly even on time; I'm not sure.

https://github.com/hendrikboom3/rackettown

Very much a work in progress, and not yet a game.  I'm making it availabe
in case anyone else is interested in what I'm doing.  Definitely not very
useful as is.  But there are a lot of TODO comments.

I may still make a few cosmetic changes this evening.

I have a program that draws the facade of a bungalow, with some random shrubs.

A program (matcher) that's intended to produce plots, but doesn't have enough
scripts yet to be useful.  And as I try writing them I'm finding what's missing
from the underlying code.

A program (gen) that just produces random quests.  But there's no substance to 
them, just words.

I had hoped to do door in 3D, but pict3d didn't have the texture mapping I 
needed.
But there's promise in its infrastructure, which I'm trying to figure out.
I've written some notes on what I've found out about pict3d so far.  Much more 
is needed.
Every time I go after it I get firther into understanding.

-- 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/20191201022031.4r6pmy67loe65rle%40topoi.pooq.com.


Re: [racket-users] Confused about Semantics Engineering Exercise 12.6

2019-11-30 Thread Mike MacHenry
Also this is a *very* minor point, but I'm pretty sure exercise 13.2 should
read "Compare with the full grammar from exercise 12.2." rather than to
compare with 12.1. Maybe not worthy even of the errata page. I don't know.
But if you're going to reprint ever it'd be nice to flag for clean up.

On Sat, Nov 30, 2019 at 3:45 PM Mike MacHenry 
wrote:

> Hm... so I guess I'm "using a with clause" like the book requests if I'm
> redeveloping the iswim-general reduction relation myself, even if the only
> difference from the book's version is to name it general and to make it
> reference the new iswim language I made that has the compatible closure
> context instead of the evaluation context. This makes more sense, thanks.
> It felt like I must have misunderstood because what I did, which was the
> quickest and easiest way to do this, was to change my original language
> definition, rather than make a new one and thus need to make a new
> reduction using a with clause.
>
> -mike
>
> On Sat, Nov 30, 2019 at 11:17 AM Robby Findler 
> wrote:
>
>> Hi Mike: it looks to me like you have the right definition in the
>> sense that it relates the right terms to each other. The rest of the
>> exercise is just to get you to use Redex's `with` to express it and to
>> avoid using the name `E` for a non-evaluation context. These are very
>> minor things! What's being asked is that you use the name `C` for the
>> compatible closure context (not change `E` like you've done) and then
>> use `with` in the reduction relation definition to lift the axioms to
>> arbitrary contexts. You would also not call this new (racket-level)
>> definition `iswim-standard` (since it isn't the standard reduction).
>>
>> Robby
>>
>> On Fri, Nov 29, 2019 at 12:47 PM Mike MacHenry 
>> wrote:
>> >
>> > Hey everyone,
>> >
>> > I am a little confused about Exercise 12.6 from Semantics Engineering
>> with PLT-Redex. The exercise is as follows:
>> >
>> > "Formulate a general reduction relation for ISWIM using a with clause.
>> Use traces to demonstrate that programs may be reduced to values along
>> several different paths in a reduction graph. "
>> >
>> > The problem I'm having with this is that to accomplish this goal, I
>> needed to make a change to the ISWIM language definition on page 217 at the
>> beginning of this chapter, particularly in the contexts section, and I made
>> absolutely no change to the reduction relation given on page 225 directly
>> above this exercise.
>> >
>> > So for me, that language definition from 217, along with the reduction
>> relation on 225, as well as the definitions for the meta functions in this
>> chapter, I get the standard reduction, which permits only one reduction
>> path for, say, an expression like (+ (1 1) (+ 1 1)). The left-most (+ 1 1)
>> reduces to 2 first.
>> >
>> > When I make the change to the contexts in the language definition, and
>> change it from
>> >
>> > (E hole (V E) (E M) (o V ... E M ...))
>> >
>> > to
>> >
>> > (E hole (M E) (E M) (o M ... E M ...))
>> >
>> > My traces for the above expression gives what I think the exercise is
>> expecting. I have a diamond shaped in my reduction DAG.
>> >
>> > The problem I have with this is that I haven't done anything to the
>> reduction relation to do this. The exercise seems pretty explicit to create
>> a reduction relation using a with clause. so it seems like the purpose of
>> the exercise is to get you to understand the with clause by developing
>> something new using it. Now granted my reduction relation does use a with
>> clause, because it's the one I copied out of the book. But I didn't write
>> that one and use the with clause in my own new way.
>> >
>> > So is there a different way to get the reduction relation to support
>> the general reduction that requires one to change the reduction relation
>> and not the grammar?
>> >
>> > Thanks for the help,
>> > -mike
>> >
>> > --
>> > 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/CAAzRdbcM9w9wi-mPzdpY_4tBWSWv_QaXvZDpgNiXSEr05OaMoA%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/CAAzRdbcTOohM%3DqLmO8ZyK6NED4Ggw8kVUykGuVu-53fotJW1dw%40mail.gmail.com.


Re: [racket-users] Confused about Semantics Engineering Exercise 12.6

2019-11-30 Thread Mike MacHenry
Hm... so I guess I'm "using a with clause" like the book requests if I'm
redeveloping the iswim-general reduction relation myself, even if the only
difference from the book's version is to name it general and to make it
reference the new iswim language I made that has the compatible closure
context instead of the evaluation context. This makes more sense, thanks.
It felt like I must have misunderstood because what I did, which was the
quickest and easiest way to do this, was to change my original language
definition, rather than make a new one and thus need to make a new
reduction using a with clause.

-mike

On Sat, Nov 30, 2019 at 11:17 AM Robby Findler 
wrote:

> Hi Mike: it looks to me like you have the right definition in the
> sense that it relates the right terms to each other. The rest of the
> exercise is just to get you to use Redex's `with` to express it and to
> avoid using the name `E` for a non-evaluation context. These are very
> minor things! What's being asked is that you use the name `C` for the
> compatible closure context (not change `E` like you've done) and then
> use `with` in the reduction relation definition to lift the axioms to
> arbitrary contexts. You would also not call this new (racket-level)
> definition `iswim-standard` (since it isn't the standard reduction).
>
> Robby
>
> On Fri, Nov 29, 2019 at 12:47 PM Mike MacHenry 
> wrote:
> >
> > Hey everyone,
> >
> > I am a little confused about Exercise 12.6 from Semantics Engineering
> with PLT-Redex. The exercise is as follows:
> >
> > "Formulate a general reduction relation for ISWIM using a with clause.
> Use traces to demonstrate that programs may be reduced to values along
> several different paths in a reduction graph. "
> >
> > The problem I'm having with this is that to accomplish this goal, I
> needed to make a change to the ISWIM language definition on page 217 at the
> beginning of this chapter, particularly in the contexts section, and I made
> absolutely no change to the reduction relation given on page 225 directly
> above this exercise.
> >
> > So for me, that language definition from 217, along with the reduction
> relation on 225, as well as the definitions for the meta functions in this
> chapter, I get the standard reduction, which permits only one reduction
> path for, say, an expression like (+ (1 1) (+ 1 1)). The left-most (+ 1 1)
> reduces to 2 first.
> >
> > When I make the change to the contexts in the language definition, and
> change it from
> >
> > (E hole (V E) (E M) (o V ... E M ...))
> >
> > to
> >
> > (E hole (M E) (E M) (o M ... E M ...))
> >
> > My traces for the above expression gives what I think the exercise is
> expecting. I have a diamond shaped in my reduction DAG.
> >
> > The problem I have with this is that I haven't done anything to the
> reduction relation to do this. The exercise seems pretty explicit to create
> a reduction relation using a with clause. so it seems like the purpose of
> the exercise is to get you to understand the with clause by developing
> something new using it. Now granted my reduction relation does use a with
> clause, because it's the one I copied out of the book. But I didn't write
> that one and use the with clause in my own new way.
> >
> > So is there a different way to get the reduction relation to support the
> general reduction that requires one to change the reduction relation and
> not the grammar?
> >
> > Thanks for the help,
> > -mike
> >
> > --
> > 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/CAAzRdbcM9w9wi-mPzdpY_4tBWSWv_QaXvZDpgNiXSEr05OaMoA%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/CAAzRdbc8uw2cKTOyf%3DF4o3im49XFNepcACVi7Pv2mEu3kCfLOw%40mail.gmail.com.


Re: [racket-users] Confused about Semantics Engineering Exercise 12.6

2019-11-30 Thread Robby Findler
Hi Mike: it looks to me like you have the right definition in the
sense that it relates the right terms to each other. The rest of the
exercise is just to get you to use Redex's `with` to express it and to
avoid using the name `E` for a non-evaluation context. These are very
minor things! What's being asked is that you use the name `C` for the
compatible closure context (not change `E` like you've done) and then
use `with` in the reduction relation definition to lift the axioms to
arbitrary contexts. You would also not call this new (racket-level)
definition `iswim-standard` (since it isn't the standard reduction).

Robby

On Fri, Nov 29, 2019 at 12:47 PM Mike MacHenry  wrote:
>
> Hey everyone,
>
> I am a little confused about Exercise 12.6 from Semantics Engineering with 
> PLT-Redex. The exercise is as follows:
>
> "Formulate a general reduction relation for ISWIM using a with clause. Use 
> traces to demonstrate that programs may be reduced to values along several 
> different paths in a reduction graph. "
>
> The problem I'm having with this is that to accomplish this goal, I needed to 
> make a change to the ISWIM language definition on page 217 at the beginning 
> of this chapter, particularly in the contexts section, and I made absolutely 
> no change to the reduction relation given on page 225 directly above this 
> exercise.
>
> So for me, that language definition from 217, along with the reduction 
> relation on 225, as well as the definitions for the meta functions in this 
> chapter, I get the standard reduction, which permits only one reduction path 
> for, say, an expression like (+ (1 1) (+ 1 1)). The left-most (+ 1 1) reduces 
> to 2 first.
>
> When I make the change to the contexts in the language definition, and change 
> it from
>
> (E hole (V E) (E M) (o V ... E M ...))
>
> to
>
> (E hole (M E) (E M) (o M ... E M ...))
>
> My traces for the above expression gives what I think the exercise is 
> expecting. I have a diamond shaped in my reduction DAG.
>
> The problem I have with this is that I haven't done anything to the reduction 
> relation to do this. The exercise seems pretty explicit to create a reduction 
> relation using a with clause. so it seems like the purpose of the exercise is 
> to get you to understand the with clause by developing something new using 
> it. Now granted my reduction relation does use a with clause, because it's 
> the one I copied out of the book. But I didn't write that one and use the 
> with clause in my own new way.
>
> So is there a different way to get the reduction relation to support the 
> general reduction that requires one to change the reduction relation and not 
> the grammar?
>
> Thanks for the help,
> -mike
>
> --
> 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/CAAzRdbcM9w9wi-mPzdpY_4tBWSWv_QaXvZDpgNiXSEr05OaMoA%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/CAL3TdOOziqT5365jtknP8N9pJAA-UJiLTVZi12oEXSofGgjkgg%40mail.gmail.com.


Re: [racket-users] reading scribble include-section code

2019-11-30 Thread Matthew Flatt
At Fri, 29 Nov 2019 11:58:00 -0500, Hendrik Boom wrote:
> I was reading Scribble's include-section code from
> https://github.com/racket/scribble/blob/master/scribble-lib/scribble/base.rkt
> and I can't figure out how this makes a section: [...]
> 
> Could it be that *any* file read starting with #lang scribble/base
> is implicitly wrapped with a @section wrapper of some sort?

Every `scribble/base` module provides a `doc` export. The value of
`doc` is a `part`.

When you use `section` in a Scribble document, that indicates to the
decoding layer (see `decode` from `scribble/decode`) that it should
create a nested `part`. So, in a way, every `scribble/base` document
has an implicit `section` --- at least, in the sense that both
`scribble/base` and `section` create parts.

Where `section` creates a part with a given title, using `title` in a
scribble document just creates a `title-decl` value. But the decoding
pass recognizes ` `title-decl` value to supply the title for `part`
that is exported as `doc`. That is, `scribble/base` sends all the
results of body expressions to `decode`, and that's where the `part`
for the module's `doc` export comes from.


Matthew

-- 
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/5de28d39.1c69fb81.6e108.cfa4SMTPIN_ADDED_MISSING%40gmr-mx.google.com.


Re: [racket-users] fcontrol and dynamic-wind

2019-11-30 Thread Matthew Flatt
You're trying to implement `amb` where a client can mix `amb` and
`dynamic-wind` and get sensible behavior, right?

The `dynamic-wind` operation certainly interferes with building new
control forms. Racket threads and other control forms that need to
interact a certain way with `dynamic-wind` end up being built in at the
same level as `dynamic-wind`.

At Sat, 30 Nov 2019 06:15:16 -0600, Alexis King wrote:
> Is there any way to do that with Racket’s continuation machinery, 

There's not a safe way. In many cases, Racket lets you write new things
that have the power of built-in through unsafe APIs --- and it turns
out that there are unadvertised procedures (provided by the primitive
`#%unsafe` module) for this particular case:

  unsafe-abort-current-continuation/no-wind
  unsafe-call-with-composable-continuation/no-wind

These are currently used to implement `ffi/unsafe/try-atomic`. Using
the `/no-wind` operations will make `amb` interact with `dynamic-wind`
in the way you have in mind, I think.


At Sat, 30 Nov 2019 06:15:16 -0600, Alexis King wrote:
> Also, is this kind of thing discussed anywhere in the literature?

I don't know of any published work on this topic (so let me know if you
find something!). As you probably have seen already, our ICFP'07 paper
just points out that `dynamic-wind` causes problems, but doesn't try to
hold `dynamic-wind` itself responsible for those problems.

An opinion and some pointers to newsgroup discussions:

  http://okmij.org/ftp/continuations/against-callcc.html#dynamic_wind

It would be interesting to check whether `dynamic-wind` is really
needed in Racket libraries, at least in its current form. Most uses are
really a "finally" mechanism that could be tied to explicit escapes
like exceptions, instead of imposed for all continuation jumps. Maybe
the uses that don't fit that pattern would be better expressed with
another mechanism. Maybe the guarantees on `dynamic-wind` just need to
be weakened and the `/no-wind` variants declared "safe" by defining
away the unsafety.


Matthew

-- 
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/5de2897c.1c69fb81.1d190.4683SMTPIN_ADDED_MISSING%40gmr-mx.google.com.


[racket-users] fcontrol and dynamic-wind

2019-11-30 Thread Alexis King
Hello,

I have been playing with implementing algebraic effects using delimited 
control, and Dorai Sitaram’s `fcontrol` and `%` operators are a natural fit. 
For example, it’s straightforward to implement McCarthy’s `amb` operator using 
them:

  (define amb-tag (make-continuation-prompt-tag 'amb))

  ; -> none/c
  (define (fail) (fcontrol 'fail #:tag amb-tag))
  ; -> boolean?
  (define (choice) (fcontrol 'choice #:tag amb-tag))

  (define-syntax amb
(syntax-rules ()
  [(_)  (fail)]
  [(_ e)e]
  [(_ e0 e ...) (if (choice) e0 (amb e ...))]))

The whole point of algebraic effect handlers is that we can interpret the same 
effect multiple ways, and `%` makes that easy. For example, we can write one 
`amb` handler that returns only the first result and another one that returns 
all results:

  (define (run-amb/first proc)
(% (proc)
   (λ (op k)
 (match op
   ['fail   #f]
   ['choice (or (run-amb/first (thunk (k #t)))
(run-amb/first (thunk (k #f]))
   #:tag amb-tag))

  (define (run-amb/all proc)
(let go ([proc (thunk (list (proc)))])
  (% (proc)
 (λ (op k)
   (match op
 ['fail   '()]
 ['choice (append (go (thunk (k #t)))
  (go (thunk (k #f]))
 #:tag amb-tag)))

This mostly works nicely, but the way it interacts with `dynamic-wind` leaves 
something to be desired:

  > (run-amb/first
  (thunk
(dynamic-wind
  (thunk (displayln "--> in"))
  (thunk (+ (amb 1 2) (amb 3 4)))
  (thunk (displayln "<-- out")
  --> in
  <-- out
  --> in
  <-- out
  --> in
  <-- out
  4

This is a little bit silly, since control is jumping out of the extent of 
`dynamic-wind` only to immediately re-enter it. If `dynamic-wind` is being used 
to guard access to a lock or pooled resource, we probably don’t want it to be 
released and reacquired on every call to `amb`.

However, I’m not sure how I can rearrange things to make that possible. I can’t 
just store the current `amb` handler in a parameter/continuation mark because 
it really does need to extend the continuation of the whole computation. Is 
there any way to do that with Racket’s continuation machinery, or would I need 
to use mutable state to imperatively extend a list of continuations maintained 
by the current handler? Also, is this kind of thing discussed anywhere in the 
literature?

Thanks,
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/9EEF26EF-C60C-49B7-92D4-27648C111213%40gmail.com.