chansey97
2021-3-30 14:37:29

Hope to discuss this old question a bit further: https://racket.slack.com/archives/C09L257PY/p1616624808201500 The original question is: > How to collect the results from “delimited continuation world” But more precisely, this question should be: > How to collect the results from non-deterministic computation which implemented by reset/shift? Indeed there are many ways to do. (e.g. mutation, generator, reset/shift with multiple-prompts, see previous threads in the #beginners channel)

Recently, I read the paper “Abstracting Control” by Olivier Danvy and Andrzej Filinski. They introduced a new method to collect results via CPS hierarchy, i.e. a family of reset/shift operators Something like: (define (fail) (shift1 c "no")) (define (flip) (shift1 c (begin (c #t) (c #f) (fail)))) (define (test-sat) (let ((b1 (flip)) (b2 (flip)) (b3 (flip))) (list b1 b2 b3))) ;; shift2 captures level-2 continuation (define (emit n) (shift2 c (cons n (c '())))) ;; collecting result by emit (reset2 (begin (reset1 (emit (test-sat))) '())) Does Racket support this kind of family of reset/shift operators? (i.e. reset1/shift1, reset2/shift2, … ) Thanks.

PS: In addition, it seems that the family of reset/shift operators is very similar to multiple prompts. But I don’t know the connection between them.


samth
2021-3-30 14:56:06

That paper mentions Sitaram and Felleisen 90 as being a similar approach, which can be implemented in Racket (they show an implementation in Scheme). In general there are connections between all of the different control operators, and there’s a lot of literature on this. You can probably encode the shift_n hierarchy in Racket’s control operators, but I don’t know that anyone’s done it.


chansey97
2021-3-30 15:00:14

Thanks. In the shift-reset scenario, can I think of this family of reset/shift operators is exactly multiple prompt? (i.e. reset-at and shift-at)?


samth
2021-3-30 15:01:34

No, they’re different, because they accumulate — reset2 interacts with shift1.


samth
2021-3-30 15:01:42

But not the other way around.


samth
2021-3-30 15:01:58

Whereas with tagged prompts (as in Racket) different tags do not interact


chansey97
2021-3-30 15:06:37

You mean that when the body of shift1 finished, it will return to reset2 if the reset2 is the nearest reset?


samth
2021-3-30 15:08:50

I believe that shift_k captures the continuation up to the nearest enclosing reset_n where n >= k (but I might have that backwards)


chansey97
2021-3-30 15:15:42

I my example, it seems no difference. I can rewrite the code above by reset-at and shift-at: (define p1 (make-continuation-prompt-tag 'reset-1)) (define p2 (make-continuation-prompt-tag 'reset-2)) (define (fail) (shift-at p1 c "no")) (define (flip) (shift-at p1 c (begin (c #t) (c #f) (fail)))) (define (test-sat) (let ((b1 (flip)) (b2 (flip)) (b3 (flip))) (list b1 b2 b3))) (define (emit n) (shift-at p2 c (cons n (c '())))) (reset-at p2 (begin (reset-at p1 (emit (test-sat))) '()))


chansey97
2021-3-30 15:16:05

Could you give me a example which can show their difference?


samth
2021-3-30 15:17:03

The difference between what? shift-at is not shift_n from that paper.


chansey97
2021-3-30 15:19:51

I mean an example program which replaces all the reset_n to reset-at n and shift_n to shift-at n , but give different behavior.


samth
2021-3-30 15:24:10

If you do (reset-at p1 (+ 1 (reset-at p2 (+ 1 (shift-at p1 k k)))) that captures the continuation (+ 1 []) in the shift-n semantics but (+ 2 []) in the shift-at semantics.


chansey97
2021-3-30 15:27:16

I understand what you mean. Very thank @samth !


sschwarzer
2021-3-30 20:12:46

I’m developing a library locally. Is there a command that combines raco pkg remove <my_package> and raco pkg install (in the working directory)?


raoul.schorer
2021-3-30 20:14:30

raco pkg update <pkg-name> <src-path> if I’m not mistaken?



sschwarzer
2021-3-30 20:16:29

I tried that and got $ raco pkg update Updating current directory's package: todo-txt raco pkg update: cannot update linked packages; except with a replacement package source package name: todo-txt package source: /sd/racket/todo-txt


sschwarzer
2021-3-30 20:17:15

I want to reinstall the package to rebuild and reinstall the documentation.


soegaard2
2021-3-30 20:21:01

If <my_package> is in the folder my_package,

raco pkg update my_package/

will override the currently installed my_package and use what you have in the folder.


soegaard2
2021-3-30 20:21:13

But that’s not what you are asking for.


soegaard2
2021-3-30 20:21:58

You want a command to begin from? I.e. create a new copy of the current package and then change that?


soegaard2
2021-3-30 20:22:15

(Maybe I am misunderstanding)


sschwarzer
2021-3-30 20:26:17

I only want to reinstall the package.

Why am I doing this? (Maybe I’m doing something wrong in the first place.)

I’m writing Scribble documentation for the API of my package. When I run scribble in my working directory on the todo-txt.scrbl file, I get these warnings Warning: some cross references may be broken due to undefined tags: (dep ((lib "racket/private/reqprov.rkt") require)) (dep ((lib "racket/private/pre-base.rkt") require)) (dep ((lib "racket/base.rkt") require)) (dep ((lib "racket/private/base.rkt") require)) (dep ((lib "scheme/base.rkt") require)) and in the generated HTML file require (generated by defmodule) is underlined in red. After reading https://stackoverflow.com/questions/20685638/unresolved-links-in-scribble-lp-document my understanding/assumption is that the link will work if I install the documentation properly as part of my package.


samth
2021-3-30 20:28:20

You want to just run raco setup yourpkg


sschwarzer
2021-3-30 20:28:22

@raoul.schorer (Sorry, didn’t see your reply because I was only looking in the thread :smile:)

I get the same message as before $ raco pkg update todo-txt ../todo-txt/ raco pkg update: cannot update linked packages; except with a replacement package source package name: todo-txt package source: /home/schwa/sd/racket/todo-txt


samth
2021-3-30 20:28:35

You don’t have to do any packaging commands


sschwarzer
2021-3-30 20:33:20

I get $ raco setup todo-txt collection-path: collection not found collection: "todo-txt" in collection directories: /home/schwa/.local/share/racket/8.0/collects /home/schwa/sd/racket/current/collects/ ... [167 additional linked and package directories]


samth
2021-3-30 20:33:45

Oh right your collection doesn’t have the same name as your package


samth
2021-3-30 20:34:02

You can do raco setup file/todo….


samth
2021-3-30 20:34:17

Or there are options to raco setup for package names


sschwarzer
2021-3-30 20:35:15

The package should be file/todo-txt, but that gives me the same message.

Ok, let me check the raco setup --help output to see if I can find something seemingly helpful. :wink:


raoul.schorer
2021-3-30 20:35:51

You need the -n flag


sschwarzer
2021-3-30 20:36:02

(I have a muilti-collection with file/todo-txt and file/todoreport, and the documentation is under file/todo-txt/scribblings/todo-txt.scrbl.)


raoul.schorer
2021-3-30 20:37:00

raco pkg update -n <pkg-name> <src-path>


wjb
2021-3-30 20:37:06

I usually use raco setup --only --pkgs &lt;pkg-name&gt;


raoul.schorer
2021-3-30 20:37:33

and path needs to be absolute, I think :thinking_face:


sschwarzer
2021-3-30 20:37:39

@raoul.schorer -n is listed as -n, --no-zo : Do not create ".zo" files


raoul.schorer
2021-3-30 20:37:47

Nope


samth
2021-3-30 20:38:02

You two are talking about different commands


sschwarzer
2021-3-30 20:38:11

Ah, I see


sschwarzer
2021-3-30 20:38:16

@samth


sschwarzer
2021-3-30 20:40:40

$ raco pkg update -n todo-txt ../todo-txt worked, as it seems. :+1:


samth
2021-3-30 20:41:14

You shouldn’t need any raco pkg commands just to build the docs


sschwarzer
2021-3-30 20:41:31

I tried -n file/todo-txt first, but that didn’t work.


sschwarzer
2021-3-30 20:42:17

@samth That’s what I thought, but I tried it as a workaround to fix the linking of require in defmodule. Before I was running scribble directly on the file.


samth
2021-3-30 20:42:48

Running scribble directly will have the problems you saw


samth
2021-3-30 20:42:57

But just running raco setup is all you need


sschwarzer
2021-3-30 20:43:35

@samth Another possibility might be to just continue and check the links later after reinstalling when I’m practically done.


sschwarzer
2021-3-30 20:46:19

@samth Ok, this worked at least without error message $ raco pkg install &lt;- needed to do this first $ raco setup file/todo-txt &lt;- just `todo.txt` didn't work


sschwarzer
2021-3-30 20:46:50

Now I’m trying to find the generated docs. … :wink:


samth
2021-3-30 20:47:17

raco docs file/todo-txt


sschwarzer
2021-3-30 20:48:03

@samth Wow, nice! It actually works. :smile:


sschwarzer
2021-3-30 20:48:12

(including the require link)


sschwarzer
2021-3-30 20:52:54

@wjb Seems to work, too. I like this even a bit more because it makes it explicit that the name is a package name.


sschwarzer
2021-3-30 21:07:58

Thanks again everyone for your help! :slightly_smiling_face:


sschwarzer
2021-3-30 21:32:42

From what I’ve seen so far, it seems to be quite common to repeat function signatures and contracts in defproc forms. Shouldn’t it be possible to somehow get this information from the modules I write documentation for? The current approach looks very “un-DRY”.

I see there’s https://docs.racket-lang.org/scribble/srcdoc.html (also described here: https://blog.racket-lang.org/2012/06/submodules.html#in-source-documentation ). Shouldn’t this be the recommended approach but if not, why not?


robby
2021-3-30 21:43:37

Alternatively, just run “raco setup”. If you package doesn’t have many dependencies, you don’t really need anything fancy


robby
2021-3-30 21:44:16

(and “Raco setup” checks things that the versions with arguments above cannot, like if you added a dependency that isn’t tracked)


kellysmith12.21
2021-3-31 00:17:18

There are occasions where the signatures/contracts listed in documentation are not the same as the actual contracts. This can be the case when the actual contract is really complicated, so it’s helpful to document an easier-to-read contract that is still “morally correct”.


kellysmith12.21
2021-3-31 00:17:52

However, I do agree that, in the cases that the documented contract is the same as the actual one, it should be easier to communicate that to Scribble.


wjb
2021-3-31 00:25:23

In my experience, raco setup is slower, so I usually go with --only --pkgs until something goes wrong


robby
2021-3-31 00:26:12

If your package don’t have other dependencies then probably most of that extra time is checking to see if all of the dependencies are declared properly. It may also be updating the info cache.


robby
2021-3-31 00:26:21

(doesn’t)


wjb
2021-3-31 00:27:28

Yeah, I’m sure all good things to check. But I’m impatient.

I would do better to run raco setup more frequently because I have forgotten to declare dependencies before pushing.


robby
2021-3-31 00:28:19

yeah, and when people do that in the main distribution package you break the snapshot builds. Which might be the only reason I mentioned that upthread :wink:


wjb
2021-3-31 00:28:49

(probably guilty)


robby
2021-3-31 00:29:03

It is really easy to do.