niko
2021-8-5 07:12:36

What is the idiomatic way to write a “doc comment” in racket? I’ve been doing this:

;; foo bar baz ;; ;; Do the foo thing (define-metafunction ... foo : bar -> baz ...) but I bet there’s a more idiomatic way?


sschwarzer
2021-8-5 09:23:36

I’m not sure if you would call it idiomatic in the sense of “widely used”, but I think there are good examples in "<https://htdp.org/2021–5–4/Book/index.html|How to design programs>" (HtdP). Unfortunately, the explanation which parts might go into the comment and how/when to use them seem scattered across the book, but I can say I especially like the type signatures and use them for almost all of my functions. For a new edition I wish there was some textbox or appendix that summarized how to build the comments. My “interpretation” of the HtdP comments is https://git.sr.ht/~sschwarzer/todo-txt/tree/main/item/file/todo-txt/private/task.rkt\|here.

My impression is that most Racket code isn’t documented much. I’d like to see good examples where you consider the documentation good. :slightly_smiling_face:


sschwarzer
2021-8-5 09:28:00

Regarding the use of ;; vs. ; for the public API of a function vs. a following “internal” comment, I think it’s a good idea. (However, so far I haven’t really used it because paragraph formatting in the Vim plugin with such comments doesn’t work out of the box. That said, I think all that’s necessary is adding set comments+=;; to the .vimrc or equivalent configuration file.)


laurent.orseau
2021-8-5 10:29:07

Oh my, I didn’t know this one, cool. I also just learned about *list/c and list*of


laurent.orseau
2021-8-5 10:30:34

(Unrelated, but I like the idea that a promise can be contracted :smile: If only that were true in real life!)



ben.knoble
2021-8-5 11:44:23

My impression is that most of the core lib is documented, and heavily used packages are. It’s all in scribble, so it’s separate, but the REPL or reasonable editor plugins can show it to you.


ben.knoble
2021-8-5 11:44:58

@sschwarzer you probably want to add an after/ftplugin for that, or check out vim-racket (or my fork of it)


massung
2021-8-5 13:24:02

+1 on the non-empty-listof - gonna have to switch to that. easier on the eyes.


niko
2021-8-5 15:22:18

what I was expecting was something like a “doc comment”— e.g., in elisp or python, you put a string inside the function as the first thing, etc. I don’t really care to follow the correct conventions in general though, that’s too much work :slightly_smiling_face:


soegaard2
2021-8-5 15:24:37

There are no widely used “doc comment” system in place. I think, there have been experiments with a “doc comments” and having a tool that can extract them.


shu--hung
2021-8-5 15:28:08

I guess insurance is kind of a contract for promises irl (but something that had better not to happen!)


niko
2021-8-5 15:28:20

I am finding that test-judgment-holds does not work as I expect! Compare these <https://github.com/dada-lang/dada-model/blob/a3fc7f3fde13d7bf9b7aa6a8a45f2b48cdca7787/racket/type-system.rkt#L169-L183|two examples>:

(redex-let* dada-type-system [env_empty ((def-init ()) (maybe-init ()) (vars ()))] (test-judgment-holds (expr-type program env_empty expr_let int env_empty)) ; this is an output! (test-judgment-holds (expr-type program env_empty expr_let int ((maybe-init ((s))) (def-init ((s))) (vars ((s (my String ()))))))) ; this is an output! As you can see, both calls to test-judgment-holds have different values for the output variables. If I type the value of env_empty in by-hand, I get an error. If I use a redex-let bound variable, it works (even though it is bound to the wrong value!)

I want to be able to write tests with a judgment that checks that the output terms are what I expect, but it seems like this is a bit tricky to do if I want to use redex-let to define various “subterms” that I can reference. Help!


soegaard2
2021-8-5 15:28:56

After digging a little, I found this section on “inline documentation”: https://docs.racket-lang.org/scribble/srcdoc.html


soegaard2
2021-8-5 15:29:29

(I admit that I foolishly search for “doc” on http://pkgs.racket-lang.org\|pkgs.racket-lang.org . I don’t know what I was expecting :slightly_smiling_face: )


laurent.orseau
2021-8-5 15:31:33

“If your Racket program breaks, we’ll pay you a lump sum” :smile: I think the core team prefers to ensure a Racket program won’t break :wink:


soegaard2
2021-8-5 15:31:48

This blog post explains how it is supposed to be used: https://blog.racket-lang.org/2012/06/submodules.html


pavpanchekha
2021-8-5 15:35:45

Hi all, a package server question. Herbie allows packages to define Herbie plugins having a herbie-plugin key in their package description. It would be swell if we could search the package server for all packages with that key. Is that possible?


soegaard2
2021-8-5 15:38:44

laurent.orseau
2021-8-5 15:42:37

It would be nice if such tags could be added automatically, or at least suggested. “Your source code mentions <some-keyword>, would you like to add the tag <some-tag> to your package to ease its discovery?”


pavpanchekha
2021-8-5 17:38:47

@soegaard2 ah—I really meant if this was a UI that was already built. Perhaps it could work as @laurent.orseau suggested, I don’t know… The thought was that we could list the active plugins in the Herbie UI and then have a link to “download more” that went to the this search.


pavpanchekha
2021-8-5 17:39:05

We could built our own UI but realistically we will not, it’s not that high priority.


soegaard2
2021-8-5 17:40:14

Maybe @jeapostrophe or @tonyg have suggestions?


pavpanchekha
2021-8-5 18:05:29

It looks like define-runtime-module-path-based dependencies don’t show up in the circular imports error message (see thread).


pavpanchekha
2021-8-5 18:05:48

For example, I just got this error: standard-module-name-resolver: cycle in loading at path: /Users/pavpan/herbie/src/programs.rkt paths: /Users/pavpan/herbie/src/programs.rkt /Users/pavpan/herbie/src/load-plugin.rkt context...: &lt;cut&gt;


pavpanchekha
2021-8-5 18:06:11

So it looks like programs must import load-plugin which must import programs—that’s the only possible 2-cycle


pavpanchekha
2021-8-5 18:06:53

But in fact, programs must import load-plugin which has a d-r-m-p dependency on bool which depends on plugin which depends on rules which depends on programs. This took forever to figure out.


camoy
2021-8-5 18:14:17

Instead of using redex-let to define terms, try using define-term with names that don’t coincide with patterns (like empty-env instead of env_empty). I think test-judgment-holds is interpreting env_empty as a pattern (i.e. anything that matches an env) instead of what it’s bound by redex-let.


camoy
2021-8-5 18:17:40

And as a general debugging note, if you find that a judgment holds where you don’t expect it to, you can use the second form of judgment-holds to get back what the output patterns are bound to, in order to see what’s happening. Or for even more information, use build-derivations (possibly with show-derivations) to see the full derivations tree. Although, sometimes that can be a bit overwhelming.


sschwarzer
2021-8-5 18:30:33

@ben.knoble I’m already using vim-racket. :slightly_smiling_face: What’s the URL for your fork?



sorawee
2021-8-5 19:56:30

This is no longer the case. Any version of Racket now works fine


massung
2021-8-5 21:09:44

Using plot for the first time and wondering if there’s a simple way to either transform the x-axis labels (they are cardinal text values) or have them stagger in the y-direction so they don’t overlap?


massung
2021-8-5 21:10:02

Specifically for a discrete-histogram



massung
2021-8-6 01:12:19

Thanks. Not sure how I missed that


samth
2021-8-6 01:26:05

Can you report that as a bug?


niko
2021-8-6 05:25:48

Thanks!


niko
2021-8-6 06:23:55

another thing that works: (side-condition any (equal? (term any) (term ...)))