notjack
2020-8-8 10:47:51

traversal composition! :tada:


juzhenliang
2020-8-8 10:50:07

@juzhenliang has joined the channel


notjack
2020-8-8 11:29:02

subtraversals!


soegaard2
2020-8-8 11:30:06

Pretty neat.


notjack
2020-8-8 11:32:06

thanks! I’m glad I finally got around to making this, I’ve wanted it for years


notjack
2020-8-8 11:37:28

a cute example: #lang racket (require glass/traversal) (define words (list "hello" "darkness" "my" "old" "friend")) (define first-letters (traversal-pipe list-traversal (subtraversal string-traversal 0 1))) (traversal-map first-letters words char-upcase) outputs: '("Hello" "Darkness" "My" "Old" "Friend")


jjsimpso
2020-8-8 20:16:44

I just installed 7.8 BC after initially running 7.8 CS. I expected to have to reinstall/recompile my downloaded packages, but that doesn’t appear to be the case. How is that so?


jjsimpso
2020-8-8 20:24:54

From what I gather .zo files are bytecode files, which Racket CS did seem to create in my .racket packages directories. I thought Racket CS compiled to native code though. Does it use bytecode as an intermediate step? Are the .zo files compatible between CS and BC? Does CS even compile to native code like I thought?


jjsimpso
2020-8-8 20:27:30

Looking at the distribution’s compiled packages I see that the CS .zo files are larger, which matches my expectations. Just wondering what is going on with my side-by-side installation of CS and BC.


jjsimpso
2020-8-8 20:47:25

So it looks like .zo files are native code for CS. What is the best approach to running CS and BC side-by-side? Is there a way to keep both the CS and BC compiled objects without them overwriting each other?


willbanders
2020-8-8 21:29:52

Regarding embedded DSLs, I know it’s possible to define a custom reader but I’m not sure if Racket supports delegating to other readers since a DSL might have different syntax. For example, something like (#range [0, 3)). If this is possible I’d be really interested in knowing the approach used to accomplish this.


soegaard2
2020-8-8 21:31:52

soegaard2
2020-8-8 21:32:36

It allows you to “parse a datum that starts with #” with a custion reader.


willbanders
2020-8-8 21:42:45

That definitely looks to be on the right track with things. I’d have a really hard time understanding how to apply that to something like SQL though.


spdegabrielle
2020-8-8 21:46:52

willbanders
2020-8-8 21:47:28

That looks exactly like what I’m trying to do.


soegaard2
2020-8-8 21:48:07

Reader macros needs a “trigger”, so one could, say, use #sql as a trigger and write: #sql"select customer from subscribers" Reader macros are best for single datums. If you need more control, you need something more advanced.

Consider for example Alex Knauth’s multi-file-lang which allows you to change language in the middle of a file.

https://github.com/AlexKnauth/multi-file-lang/tree/master

(you can probably get some tricks by looking at the source)


willbanders
2020-8-8 21:48:10

database.query(#sql { SELECT * FROM Languages WHERE name = $name });


willbanders
2020-8-8 21:48:23

There’s the example I’m building off of; pardon the lack of parens lol xD


soegaard2
2020-8-8 21:51:48

In your example, the reader macro can spot #sql and using {} it can find the start and end. The missing piece is a parser for sql syntax - and there are multiple ways of writing such a parser (one way is to use parser-tools).


willbanders
2020-8-8 21:53:38

Yep. Right now I’ve hacked things a bit by using the braces and indentation to get a raw string and go from there. Will try delegating to the lexer directly at some point.


mflatt
2020-8-8 21:55:12

One way is to set PLTCOMPILEDROOTS to a BC- or CS-specific absolute directory path when running. That will put “.zo” files in the specified directory, shadowing the subtree of the filesystem that would otherwise have “.zo” files.


jjsimpso
2020-8-8 22:07:51

Thanks. That should help. I was a little confused why some of my code ran out of the box when I switched to BC. I have a local package that I manage with ‘raco setup’. When I built my app which depends on it, it seems like it recompiled the package automatically. It also seems like it recompiled any other dependencies it needed transparently. But only the .zo files it actually needed. I guess that is why I was confused.


jjsimpso
2020-8-8 22:08:28

It seems like everything just worked when I switched, which wasn’t what I expected!


mflatt
2020-8-8 22:15:25

Yes, raco setup and raco make will compile dependencies. Glad to hear that things work when they should!


a.pelenitsyn
2020-8-8 22:48:42

Is there an easy way to fix this problem when running redex on a headless machine? $ racket Welcome to Racket v7.7. > (require redex) Unable to init server: Could not connect: Connection refused ; Gtk initialization failed for display ":0" [,bt for context]


alexharsanyi
2020-8-8 22:50:54

you can start the X Virtual Frame buffer (xvfb). Starting it is platform specific, so you will have to look up the details for your platform


a.pelenitsyn
2020-8-8 22:54:53

Thanks! I’d rather try to fix it on Redex side, honestly. Could you think of how to even trace this? I searched Redex sources and the most popular source of this problem (require plot) is not there: they seem to correctly use require plot/no-gui. So it’s some other dependency, I guess…


a.pelenitsyn
2020-8-8 23:00:23

actually, xvfb seems to work fine, thanks!


mflatt
2020-8-8 23:33:42

I think redex/reduction-semantics is the layer that works without racket/gui.