pocmatos
2019-2-7 14:41:37

All, does anybody know what’s the granularity of the racket cache? By looking into .racket it seems it’s either <version> or snapshot. So if I grab HEAD today and a different HEAD tomorrow, the same cache will be used. Is this the case?


mflatt
2019-2-7 15:24:22

The package-download cache is shared across all Racket versions and variants. It’s keyed on the package checksum, so two variants of Racket would use the same cache entry only when they want exactly the same package content.


pocmatos
2019-2-7 15:49:41

but with regards to deinprogramm. I install clone two HEADs, one today and one tomorrow. It’s fine if they both use the same download cache. But then the package is built. Will the built files today be overwritten by those tomorrow? Also, how does CS fit into this? I assume the built files with cs must be put someplace else?


mflatt
2019-2-7 16:17:36

A Racket build from a Git repo checkout uses installation scope by default, so the installation is not written to “~/.racket”. The two builds will have separate installations of the package. A make cs build configures racketcs to put “.zo” files in a subdirectory of “compiled”, such as “compiled/ta6le”, so that’s why racket and racketcs can coexist within a build. If you install anything specifically in user scope, then both checkout builds would use it, and that’s generally not good. Avoid that problem by not installing into user scope or by changing one of the installations (using raco pkg config ...) to have a name other than “development”.


pocmatos
2019-2-7 16:49:24

Thanks for the clarification.


mario.luis.guimaraes
2019-2-7 17:52:34

Hello! I am new to Racket, and naturally have some questions … My first ones, since I like static type systems, are:

What is the goal of Typed Racket? Is its main goal to be a workbench for type systems research? What does Typed Racket offer that the type systems of OCaml or Haskell do not?


cowbs
2019-2-7 18:54:25

I have a list of identifiers that I’d like to use as input to define-values. Is it possible to from '(a b c) to (values a b c)?


laurent.orseau
2019-2-7 18:55:12

(apply values '(a b c))


cowbs
2019-2-7 18:55:57

tyvm!


laurent.orseau
2019-2-7 18:58:36

there’s also match-define: (match-define (list a-var b-var c-var) '(a b c))


laurent.orseau
2019-2-7 18:59:01

needs (require racket/match) though, but match-define is pretty powerful


cowbs
2019-2-7 19:02:41

Neat. The trick for me is my list is coming out of hash-values so I need to make sure it expands before match-define or define-values. I don’t need hash-values itself redefined. :slightly_smiling_face:


alexknauth
2019-2-7 19:05:49

“expands before” ??


cowbs
2019-2-7 19:07:57

Sorry for my clunky terminology. Basically I’m trying to do something like (define val-list (hash-keys h)) (define-values (values val-list) (hash-values h)) but it’s trying to literally redefine val-list


jaz
2019-2-7 19:09:53

It’s not clear what you expect it to do


alexknauth
2019-2-7 19:10:18

Correct me if I’m wrong: If h is (hash 'a 1 'b 2 'c 3)


jaz
2019-2-7 19:10:55

Oh, wait: you want to define a variable per k/v pair in the hash?


jaz
2019-2-7 19:11:05

My first response is: you do not want to do that.


alexknauth
2019-2-7 19:11:11

The do you want something that will define a as 1, b as 2, and c as 3?


cowbs
2019-2-7 19:11:16

Yes, exactly.


alexknauth
2019-2-7 19:11:46

Are the keys of the hash table only known/stored at runtime?


cowbs
2019-2-7 19:12:23

Yeah. Unfortunately the way the actual data is created it is outside the definitions context.


alexknauth
2019-2-7 19:13:09

If you had a magic thing that did what you want called definitions-from-hash


alexknauth
2019-2-7 19:14:33

That looked like: (definitions-from-hash h) which took h as a runtime value, say (hash 'a 1 'b 2 'c 3), and generated those definitions


cowbs
2019-2-7 19:15:16

Yup that’s the dream.


alexknauth
2019-2-7 19:15:22

What should the compiler do if it sees: (define (f h) (definitions-from-hash h) a) ?


cowbs
2019-2-7 19:17:06

Based on my limited understanding I would expect it create those definitions local to the scope of f and thus to return 1 if you called it with the example hash.


jaz
2019-2-7 19:19:11

What benefit are you hoping to derive from this? Since the hash keys aren’t known until runtime, how would you refer to any of the defined variables?


jaz
2019-2-7 19:19:41

How would you know that they aren’t messing with the definitions of things like +?


philip.mcgrath
2019-2-7 19:24:22

I’m trying to create a new package in the catalog, and I’m getting an error message saying “Save failed.” I’m not seeing any other details about what’s wrong. Is something amiss with the server? (@jeapostrophe?)


cowbs
2019-2-7 19:24:23

My use case is that I have a situation where I’m creating a tree of nested items that I would like to be able to refer to by name later because we may need to export multiple references to the same instance of data. This would be wrapped behind macros and not something generally available to our scripters.


alexknauth
2019-2-7 19:26:47

To make what @jaz is saying more concrete, what should the compiler do if it sees: (define (f h) (definitions-from-hash h) (+ a 10)) ?

And then you call f with a hash table that (accidentally of course) contains the key '+: (f (hash 'a "a~vtion" '+ printf)) ?


jaz
2019-2-7 19:29:16

Also: (define (f h) (definitions-from-hash h) a) (f (hash))


cowbs
2019-2-7 19:30:47

In that case it would redefine + to printf. Is the argument that because such a thing is possible then this function shouldn’t exist? Because I can right now do

(define + printf) (+ "foo ~a" 1)


alexknauth
2019-2-7 19:31:02

What about (f (hash 'definitions-from-hash +))?


cowbs
2019-2-7 19:32:19

I’m not working on a publicly available API or anything here. This is an internal library to be used by our own employees who are all reasonably professional. :slightly_smiling_face:


alexknauth
2019-2-7 19:32:27

Okay


alexknauth
2019-2-7 19:33:20

How about you modify it slightly: (definitions-from-hash h [a b c]) That way a, b, and c are known at compile time?


alexknauth
2019-2-7 19:36:21

Definitions and binding need to be determined at compile time, that’s why


cowbs
2019-2-7 19:37:05

So the net effect of that would be every instance of this data would require the scripter to also maintain a list of all known instances in a separate location. I’d say we’d go maybe 48 hours before that process broke down. While everyone is reasonably professional most of them are non-technical by nature.


jaz
2019-2-7 19:38:04

I guess I still don’t understand this part: if the keys aren’t known until runtime, how can any of the people using this refer to them? How/why would they expect a to be bound?


jaz
2019-2-7 19:38:35

If they are known ahead of time, then you don’t need to do this. If they aren’t, I don’t see how it’s useful to do this.


jaz
2019-2-7 19:39:51

Or are you assuming that the programmers will be able to refer to unbound variables and get back some kind of undefined value à la javascript?


cowbs
2019-2-7 19:40:52

The runtime in this case is an exporter which generates a data file to be used by the game. So if our exporter can refer to data at a later point in time we can do more useful things with that data. Say we are able to export the tree of data as authored by the scripters but then automatically generate a list of all known tree nodes which also gets written out.


jaz
2019-2-7 19:43:55

Sorry, I don’t follow. I guess I still don’t have a good idea of how this code would be used.


jaz
2019-2-7 19:46:45

But… assuming that whoever is going to be referring to these variables is also responsible for making sure that the hash has the relevant keys (which I think is what you’re saying), maybe this could be done as a kind of staged approach? Where you’d macro-generate the code per dataset. Does that make any sense?


jaz
2019-2-7 19:49:15

An alternative would be to embed an interpreter in your code.


alexknauth
2019-2-7 19:50:03

If someone writes (define (f h) (definitions-from-hash h) eeeeeee) And then f is called on a hash that doesn’t have that key, like (hash 'a 1 'b 2 'c 3), what do you want to happen? 1. Error at compile time, somehow 2. Error at run time 3. Some king of “undefined” value, but no error


cowbs
2019-2-7 19:50:35

I think so, I believe we do similar macro generated code/datasets pretty frequently if I take your meaning correctly.


alexknauth
2019-2-7 19:50:39

And who should be “blamed” for this error?


cowbs
2019-2-7 19:50:50

Runtime error @alexknauth


alexknauth
2019-2-7 19:51:07

The person who wrote f in a way that referred to a key that didn’t exist?


alexknauth
2019-2-7 19:51:18

Or the person who called f without giving it the keys that it expected?


cowbs
2019-2-7 19:52:23

I would expect the “blame” to be on the author of f in this case


alexknauth
2019-2-7 19:53:44

So when f is written, is there some list of known valid keys somewhere?


alexknauth
2019-2-7 19:54:15

And a, b, and c are in that list, but eeeeeee is not?


cowbs
2019-2-7 19:55:53

Unfortunately that’s what the hash table is supposed to be, the list of known things.


alexknauth
2019-2-7 19:56:25

But the list of known valid keys is known when f is written, which is before f is called, right?


jaz
2019-2-7 19:57:31

So, I’ve never done this before, but maybe you could do something like: - create a new namespace - iterate through the hash pairs, calling namespace-set-variable-value! on each - use the populated namespace to eval the user code


jaz
2019-2-7 19:57:59

(This is a simplified version of what you’d need to do to set up a useful environment for eval-ing code.)


alexknauth
2019-2-7 19:58:15

There are probably much better ways than eval, even for potentially dynamic behavior like this


jaz
2019-2-7 19:58:16

And quite possibly not the best way to go about this.


alexknauth
2019-2-7 19:58:36

I’m trying to figure out how dynamic it needs to be


alexknauth
2019-2-7 19:59:17

Should information be known when f is defined, or only when f is called?


cowbs
2019-2-7 19:59:52

f is not written when there is a list of known keys.


alexknauth
2019-2-7 20:00:50

Then how is it right to blame the author of f for writing eeeeeee when the list of keys is not known when they wrote it?


cowbs
2019-2-7 20:01:21

Let me see if I can conjure up what this might look like to a scripter


cowbs
2019-2-7 20:01:26

(new-game-data example (new-node foo 1 2 3) (new-node bar 4 5 6) ) ;; foo is undefined (magic) ;; foo is now bound to a new data node (do-something-with foo bar)


cowbs
2019-2-7 20:01:59

new-node in this example is a macro that internally updates the hash table behind the scenes.


alexknauth
2019-2-7 20:02:24

Currently the new-node macro updates the hash at run time?


alexknauth
2019-2-7 20:02:42

Could you have it update a set of known keys at compile time as well?


cowbs
2019-2-7 20:03:15

How might I do that?


alexknauth
2019-2-7 20:05:18

What if the information about foo and bar being valid keys was stored at compile time in the example identifier? Then when you invoke magic you pass in example like this: (magic example) And then foo and bar are defined


cowbs
2019-2-7 20:09:42

The part I’m stuck on is associating foo and bar with example at compile time. I think it would require new-game-data having significant visibility into the the format of the data nodes.


cowbs
2019-2-7 20:10:06

But I admit that is particular to our own macro structure.


cowbs
2019-2-7 20:11:05

Assuming the new-game-data macro had that information, what would the process of compile time association look like?


alexknauth
2019-2-7 20:15:32

One possible way would look something like this:


alexknauth
2019-2-7 20:15:44
#lang racket

(require syntax/parse/define)

(define-syntax new-node #f)

(define-syntax-parser new-game-data
  #:literals [new-node]
  [(new-game-data name:id (new-node key:id) ...)
   #'(define-syntax name '(key ...))])

(define-syntax-parser magic
  [(magic name:id)
   (define keys (syntax-local-value #'name))
   (define keys-stx (datum->syntax #'name keys))
   #`(define-values #,keys-stx (apply values (range #,(length keys))))])

(new-game-data example
 (new-node foo)
 (new-node bar))

(magic example)
foo
;=> 0
bar
;=> 1

alexknauth
2019-2-7 20:16:37

define-syntax creates an association at compile time


alexknauth
2019-2-7 20:16:56

and syntax-local-value looks up the compile-time value associated with the identifier


alexknauth
2019-2-7 20:19:11

It’s also possible to have example tied to both a compile-time set of keys and a run-time hashtable, by creating a compile-time struct that refers to a runtime identifier


alexknauth
2019-2-7 20:23:04

Or if there might be multiple run-time hash-tables for the same set of keys, it might be better to keep those separate.


cowbs
2019-2-7 20:24:09

Interesting! I’ve not seen define-syntax-parser before.


cowbs
2019-2-7 20:24:52

Unfortunately I have to step away for a bit, if I don’t get a chance to follow up later I just want to say thank you for working this out with me.


pocmatos
2019-2-7 20:24:58

@greg at the moment in frog, to create the website, I do a raco frog -b which puts everything in a site subfolder but then I need to manually copy in the css, img and js folders so I can sync it to the destination. Is there a way to specify assets to have automatically copied to the site folder?


greg
2019-2-7 20:28:24

@pocmatos Can you just locate the css / img / js in the site subfolder in the first place? (raco frog --clean doesn’t rm * it cleans only files it produced)


pocmatos
2019-2-7 20:33:13

but those are not in the site subfolder.


greg
2019-2-7 20:33:35

I mean, for my own frog blog, I have the source and output all mixed in one tree which effectively gets bitblted to GitHub Pages. https://github.com/greghendershott/greghendershott.github.com Including the _src tree. It happens that GitHub Pages doesn’t serve stuff under _src, so e.g. https://www.greghendershott.com/_src/About.md doesn’t show you the source.


greg
2019-2-7 20:33:52

But even if it showed the source markdown I’m like ¯_(ツ)_/¯


greg
2019-2-7 20:34:47

So at other people’s request frog has options to build to some other dir. But I never use it. I am supremely bored by non-trivial deployments of anything. :slightly_smiling_face:


pocmatos
2019-2-7 20:34:50

hummm, yes that works. but I wanted a cleaner solution where only the files required for the website are put in site/.


pocmatos
2019-2-7 20:35:19

Would you accept a PR to add assets to the target folder?


greg
2019-2-7 20:37:17

I guess so but I’m still confused, can’t you simply have the assets under site/ where you want them to be, and you run frog and it “fills in” the output HTML etc alongside it?


pocmatos
2019-2-7 20:38:08

but site doesn’t actually exist. I could of course create it before hand, but I generally just point to a temp dir for frog to generate the site.


pocmatos
2019-2-7 20:39:14

I at the moment have a makefile that does that: create temp dir, copy css, js, img and then run raco frog -b but it would be cooler if I could ditch the makefile and instead have in frog.rkt something like: (assets (list "css/" "img/" "js/")) or something of the sort.


greg
2019-2-7 20:40:25

OK well if it’s a simple change I’m open to a PR.


pocmatos
2019-2-7 20:40:43

ok, will give it a go. thanks.


greg
2019-2-7 20:41:11

I guess my reluctance is a feeling that, in hindsight, Frog should probably be exploded into pieces that can be driven by a makefile or other script, and then people can do all sorts of flows.


greg
2019-2-7 20:41:45

A lot of frog is what I call “path math”, plus an application of Greenspun’s rule to makefiles. :slightly_smiling_face:


pocmatos
2019-2-7 20:42:56

really? i would think going on a path to ditch makefiles would be better. :slightly_smiling_face: anyhow, your call.


greg
2019-2-7 20:43:16

But that’s just my reluctance, hindsight. The horse is well out of the barn, so some more PRs are inevitable. :slightly_smiling_face:


pocmatos
2019-2-7 20:45:47

lets turn this frog into bullfrog…


pocmatos
2019-2-7 20:46:19

(i am now left wondering if the bullfrog is indeed as large as it sounds…)


pocmatos
2019-2-7 20:46:33

:confused:


greg
2019-2-7 20:47:52

One way to put it: I wish Frog, instead of an application and a “framework”, were more just a set of libraries.


greg
2019-2-7 20:48:12

Whether you drive it with a makefile, or your own little Racket program, or shell script, whatever.


philip.mcgrath
2019-2-7 20:49:04

Tangentially, have either of you used the Racket make module? (https://docs.racket-lang.org/make/) I haven’t really tried it yet, but I do run into some situations where I want to bridge the gap between raco setup’s notion dependency tracking with external things that lend themselves more to makefiles, like rebuilding various static files.


greg
2019-2-7 20:49:04

The main value Frog has, as an app, is any “just-works” element. But once people want it to work unique ways, it kind of falls down fast, and starts to go down the configurability slippery slope.


greg
2019-2-7 20:50:15

@philip.mcgrath I haven’t looked it for awhile. I thought of it recently wrt Racket projects working on Windows, too. But I haven’t done much with the thought, yet.


pocmatos
2019-2-7 21:04:18

@greg for what it’s worth, I really like how frog works. :slightly_smiling_face:


pocmatos
2019-2-7 21:05:22

@philip.mcgrath that’s a pretty old module. I haven’t looked at it in a decade but I have used it back in the plt scheme time.


pocmatos
2019-2-7 21:06:17

but since i haven’t looked at it since, it might have been refactored since.


pocmatos
2019-2-7 21:07:02

geee… what have i written there. time to bed.


notjack
2019-2-7 21:07:39

I wish the racket make thing included a language so I could easily port regular makefiles to racket ones just by adding #lang make to the top of each makefile


philip.mcgrath
2019-2-7 21:44:40

Never mind: I was pasting the package’s name, and it turns out I’d pasted some invisible leading whitespace. Though maybe the site should use string-trim and/or give a more descriptive error message?