mark.piffer
2022-1-31 11:13:21

@mark.piffer has joined the channel


cperivol
2022-1-31 12:30:56

does anyone have any recommendations for sparse bitmap implementation in racket?


cperivol
2022-1-31 14:22:23

Is there a racket implementation of binding arrows like (-<> (foo <> x y) (bar x <> y)) being equivalent to (lambda (a) (foo (bar x a y) x y)?


soegaard2
2022-1-31 14:24:43

Sparse bitmaps?

Maybe https://docs.racket-lang.org/images/flomap_title.html or simply math/array


soegaard2
2022-1-31 14:25:48

Where is the -<> notation from?


cperivol
2022-1-31 14:26:29

integer sets more like… (ideally the roaring bitmap datastructure)


cperivol
2022-1-31 14:27:22

I think the original place is here [1] but I have used them in common lisp

[1] https://github.com/rplevy/swiss-arrows


soegaard2
2022-1-31 14:29:50

The ~> operator supports holes.



cperivol
2022-1-31 14:31:24

Ah nice


cperivol
2022-1-31 14:31:31

I will delete the issue I just opened


cperivol
2022-1-31 14:31:33

:stuck_out_tongue:


cperivol
2022-1-31 14:32:17

thanks a lot


ben.knoble
2022-1-31 15:13:14

Also see the Qi package


cperivol
2022-1-31 15:49:44

how does one implement python’s enumerate()?(enumerate(["a","b","c"]) == [(0,"a"),(1,"b"),(2,"c")] only with iterators)


cperivol
2022-1-31 15:50:03

i mean is there a one-liner for such a thing?


massung
2022-1-31 15:52:08

(for ([x xs] [i (in-naturals)]) ...)


cperivol
2022-1-31 15:53:38

would’nt that do a cartesian product?


massung
2022-1-31 15:53:54

for* is the cartesian product, otherwise they step together


cperivol
2022-1-31 15:54:30

aha


cperivol
2022-1-31 15:54:51

I assumed for* was like let*


soegaard2
2022-1-31 15:55:36

These days the * means “variation of” :slightly_smiling_face:


sorawee
2022-1-31 15:56:18

@cperivol There’s also in-indexed, which is actually more like enumerate in Python


sorawee
2022-1-31 15:57:27

Well, actually for* is is like let* in that it is a “nested” for, just like let* is a nested let


massung
2022-1-31 16:00:32

@cperivol - this reddit post I put together a while ago might be helpful wrt let, let*, and letrec: https://www.reddit.com/r/Racket/comments/778qkf/let_let_and_letrec/dojzpqs/?context=3. If you already knew this, though, my apologies.

Anyway, like @sorawee stated, the * adds nesting.


christos.perivolaropo
2022-1-31 17:44:47

I am getting a weird error from raco install. I managed to narrow it down to the following (maybe) reproducible repl snippet

&gt; (require net/url) &gt; (define-values (p hs) (get-pure-port/headers (string-&gt;url "<https://pkgs.racket-lang.org/pkg/threading-lib?version=8.3>") '() #:redirections 25 #:status? #t)) &gt; (string-&gt;number (substring hs 9 12)) ;; network.rkt:67 uses this to come up with the status #f &gt; (substring hs 9 12) "#f)" &gt; hs "re-log . #f) (success-log . " [...] The problem seems to be that get-pure-port/headers skips a few characters. Does anyone have any idea why this happens?


samth
2022-1-31 17:46:49

I get “200” as expected there


christos.perivolaropo
2022-1-31 17:47:30

Ok, thanks a lot. I will keep looking


soegaard2
2022-1-31 17:47:54

Ditto.

&gt; (define-values (p hs) (get-pure-port/headers (string-&gt;url "<https://pkgs.racket-lang.org/pkg/threading-lib?version=8.3>") '() #:redirections 25 #:status? #t))

&gt; p #&lt;input-port:pipe&gt;

&gt; hs "HTTP/1.1 200 OK\r\nDate: Mon, 31 Jan 2022 17:46:26 GMT\r\nContent-Type: application/octet-stream\r\nContent-Length: 1747\r\nConnection: keep-alive\r\nx-amz-id-2: v/pb4Pq9Fl72c9d4ddPpN3flL9A2tZeanWvxRCK5P5Evp2WAjDHyJvSdLA9EIsAaIR8KVcfUJGE=\r\nx-amz-request-id: RRH4317BFV5HV79W\r\nlast-modified: Mon, 31 Jan 2022 16:46:25 GMT\r\netag: \"33d8d6ff3c02d13e11d5971a7692c4e1\"\r\nCF-Cache-Status: DYNAMIC\r\nExpect-CT: max-age=604800, report-uri=\"<https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct>\"\r\nReport-To: {\"endpoints\":[{\"url\":\"https:\/\/a.nel.cloudflare.com\/report\/v3?s=e8jAzF5OHSwFrMf7k7sy%2FtQEk60B9wGDjveLNdJE2sG%2BwfSY6IiXIYCmjGAcIebqYClp9iVS7P%2B4yGCgBG0XuYQrJ9LjUBFPm9zVtYCBWE2GtsHbqwzPfAio8U7dsQAETCNY2usJTg%3D%3D\"}],\"group\":\"cf-nel\",\"max_age\":604800}\r\nNEL: {\"success_fraction\":0,\"report_to\":\"cf-nel\",\"max_age\":604800}\r\nServer: cloudflare\r\nCF-RAY: 6d64c266ee14725e-HAM\r\nalt-svc: h3=\":443\"; ma=86400, h3-29=\":443\"; ma=86400\r\n\r\n"

&gt; (string-&gt;number (substring hs 9 12)) 200

&gt; (substring hs 9 12) "200"


christos.perivolaropo
2022-1-31 17:54:31

Ah, that looks correct. It looks like in my case get-pure-port/headers does not get the headers but rather the body


christos.perivolaropo
2022-1-31 17:54:38

or half-the-body


soegaard2
2022-1-31 17:55:26

Fwiw I used 7.5. > (version) “7.5”


christos.perivolaropo
2022-1-31 17:56:45

8.3 here


christos.perivolaropo
2022-1-31 17:57:53

&gt; hs "lure-log . #f) (success-log . \"server/built/install/threading-lib.txt\") (test-failure-log . #f) (test-success-log . \"server/built/test-success/threading-lib.txt\"))) (checksum . \"199c8e240146baf3ef2ef2838d7d9e242b90be4e\") (checksum-error . #f) (collection . (multi)) (conflicts . ()) (dependencies . ((\"base\" #:version \"6.3\"))) (description . \"implementation (no documentation) for "threading"\") (implies . ()) (last-checked . 1643650651) (last-edit . 1497305814) (last-updated . 1641582707) (modules . ((lib \"threading/main.rkt\"))) (name . \"threading-lib\") (ring . 1) (search-terms . #hasheq((:build-success: . #t) (:no-tag: . #t) (author:lexi.lambda@gmail.com . #t) (ring:1 . #t))) (source . \"<git://github.com/lexi-lambda/threading?path=threading-lib>\") (tags . ()) (versions . #hash((default . #hasheq((checksum . \"199c8e240146baf3ef2ef2838d7d9e242b90be4e\") (source . \"<git://github.com/lexi-lambda/threading?path=threading-lib>\") (source_url . \"<http://github.com/lexi-lambda/threading/tree/master?path=threading-lib>\"))) (\"6.2\" . #hasheq((checksum . \"dee85e8d3cffaed85eb27bed8a8c61fc1eea8395\") (source . \"<git://github.com/lexi-lambda/threading?path=threading-lib#compatibility-6.2>\") (source_url . \"<http://github.com/lexi-lambda/threading/tree/master?path=threading-lib#compatibility-6.2>\"))) (\"6.2.1\" . #hasheq((checksum . \"dee85e8d3cffaed85eb27bed8a8c61fc1eea8395\") (source . \"<git://github.com/lexi-lambda/threading?path=threading-lib#compatibility-6.2>\") (source_url . \"<http://github.com/lexi-lambda/threading/tree/master?path=threading-lib#compatibility-6.2>\"))))))HTTP/1.1 200 OK\r\nDate: Mon, 31 Jan 2022 17:57:19 GMT\r\nContent-Type: application/octet-stream\r\nContent-Length: 1747\r\nConnection: keep-alive\r\nx-amz-id-2: YFq193qSFpmuV2JV+s8FOsLMDQplCAwnH2B/+D0m5AF++3eiPEcWr4SJ6S2joKGTqgG76NyqNdQ=\r\nx-amz-request-id: 4F7SC64JGXYCX7BB\r\nlast-modified: Mon, 31 Jan 2022 17:57:14 GMT\r\netag: \"b6a9ee25b06796da6dc5e2792b4575cc\"\r\nCF-Cache-Status: DYNAMIC\r\nExpect-CT: max-age=604800, report-uri=\"<https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct>\"\r\nReport-To: {\"endpoints\":[{\"url\":\"https:\/\/a.nel.cloudflare.com\/report\/v3?s=Si6UiR4Yx%2FRq%2FEJKpT5kSerbmU%2FV4Y8FzCxDD8tjBjkhpfYdsvdtM5w5rextRTUUNsjy8Lrx6rgdp1GAx9QXfNz56fXJXB4zxPJR0IGuPVwis0k4j1zLpIDFFWNb6lXDCdjKZLhbgA%3D%3D\"}],\"group\":\"cf-nel\",\"max_age\":604800}\r\nNEL: {\"success_fraction\":0,\"report_to\":\"cf-nel\",\"max_age\":604800}\r\nServer: cloudflare\r\nCF-RAY: 6d64d25b9a0174c9-LHR\r\nalt-svc: h3=\":443\"; ma=86400, h3-29=\":443\"; ma=86400\r\n\r\n"


christos.perivolaropo
2022-1-31 17:58:08

it appends the actual header at the end for some reason


soegaard2
2022-1-31 17:58:35

I am on macOS if that makes a difference.


samth
2022-1-31 17:58:47

I’m on Linux


soegaard2
2022-1-31 17:59:52

Is it just the threading package or do you see the same with other packages?


greg
2022-1-31 18:00:32

That’s odd I don’t get the HTTP response status line (“HTTP/1.1 200 OK\r\n”) but I get the rest i.e. the actual headers per se: &gt; (define-values (p hs) (get-pure-port/headers (string-&gt;url "<https://pkgs.racket> -<http://lang.org/pkg/threading-lib?version=8.3%22\|lang.org/pkg/threading-lib?version=8.3">))) &gt; hs "Date: Mon, 31 Jan 2022 17:58:16 GMT\r\nContent-Type: application/octet-stream\r\nContent-Length: 1747\r\nConnection: keep-alive\r\nx-amz-id-2: 899CN69mw68Vgx3Rzx82IlGlmOTMq2+XXsCQcbPHsj9rvQ2brmCJ/qLn1RHIhxfS/WCJC0aM9pI=\r\nx-amz-request-id: MMZESJSMM3X2ESG7\r\nlast-modified: Mon, 31 Jan 2022 17:57:14 GMT\r\netag: \"b6a9ee25b06796da6dc5e2792b4575cc\"\r\nCF-Cache-Status: DYNAMIC\r\nExpect-CT: max-age=604800, report-uri=\"<https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct>\"\r\nReport-To: {\"endpoints\":[{\"url\":\"https:\/\/a.nel.cloudflare.com\/report\/v3?s=IYKx%2FfyEoExw4aKkLurWA7byhZiKrJfr5XHiCU2QlpQs9qWEw3OpGGmmnFujFdRkggF%2B5CptiRhLbikdEy3X5Z1vp%2FrOc83RNwKTyxdFem5JRBLe%2FzLIiNLRjONmka55x%2B6yj3tI0A%3D%3D\"}],\"group\":\"cf-nel\",\"max_age\":604800}\r\nNEL: {\"success_fraction\":0,\"report_to\":\"cf-nel\",\"max_age\":604800}\r\nServer: cloudflare\r\nCF-RAY: 6d64d3bce84618ea-EWR\r\nalt-svc: h3=\":443\"; ma=86400, h3-29=\":443\"; ma=86400\r\n\r\n" &gt; (version) "8.3.0.11" &gt; (system-type) 'unix


soegaard2
2022-1-31 18:02:28

Could it be related to CloudFlare?


greg
2022-1-31 18:02:43

I’m not sure why in your examples @christos.perivolaropo it looks like an association list but in ours it looks like the raw string. Do you have some other code involved?


soegaard2
2022-1-31 18:02:50

Maybe fetch the same url with curl and compare?


christos.perivolaropo
2022-1-31 18:03:20

I do not the code I showed is in a fresh repl


christos.perivolaropo
2022-1-31 18:03:46

Curl returns the assoc list string


christos.perivolaropo
2022-1-31 18:04:27

$ curl <https://pkgs.racket-lang.org/pkg/threading-lib?version=8.3> #hasheq((author . "<mailto:lexi.lambda@gmail.com\|lexi.lambda@gmail.com>") (authors . ("<mailto:lexi.lambda@gmail.com\|lexi.lambda@gmail.com>")) (build . #hash((conflicts-log . #f) (dep-failure-log . #f) (docs . ()) (failure-log . #f) (min-failure-log . #f) (success-log . "server/built/install/threading-lib.txt") (test-failure-log . #f) (test-success-log . "server/built/test-success/threading-lib.txt"))) (checksum . "199c8e240146baf3ef2ef2838d7d9e242b90be4e") (checksum-error . #f) (collection . (multi)) (conflicts . ()) (dependencies . (("base" #:version "6.3"))) (description . "implementation (no documentation) for "threading"") (implies . ()) (last-checked . 1643650651) (last-edit . 1497305814) (last-updated . 1641582707) (modules . ((lib "threading/main.rkt"))) (name . "threading-lib") (ring . 1) (search-terms . #hasheq((:build-success: . #t) (:no-tag: . #t) (author:lexi.lambda@gmail.com . #t) (ring:1 . #t))) (source . "<git://github.com/lexi-lambda/threading?path=threading-lib>") (tags . ()) (versions . #hash((default . #hasheq((checksum . "199c8e240146baf3ef2ef2838d7d9e242b90be4e") (source . "<git://github.com/lexi-lambda/threading?path=threading-lib>") (source_url . "<http://github.com/lexi-lambda/threading/tree/master?path=threading-lib>"))) ("6.2" . #hasheq((checksum . "dee85e8d3cffaed85eb27bed8a8c61fc1eea8395") (source . "<git://github.com/lexi-lambda/threading?path=threading-lib#compatibility-6.2>") (source_url . "<http://github.com/lexi-lambda/threading/tree/master?path=threading-lib#compatibility-6.2>"))) ("6.2.1" . #hasheq((checksum . "dee85e8d3cffaed85eb27bed8a8c61fc1eea8395") (source . "<git://github.com/lexi-lambda/threading?path=threading-lib#compatibility-6.2>") (source_url . "<http://github.com/lexi-lambda/threading/tree/master?path=threading-lib#compatibility-6.2>"))))))


greg
2022-1-31 18:05:33

> That’s odd I don’t get the HTTP response status line (“HTTP/1.1 200 OK\r\n”) but I get the rest i.e. the actual headers per se Derp that’s because I omitted the #:status? flag.


christos.perivolaropo
2022-1-31 18:05:47

&gt; (define-values (p hs) (get-pure-port/headers (string-&gt;url "<https://www.example.com>") '() #:redirections 25 #:status? #t)) &gt; hs "<!doctype html>\r\n&lt;html&gt;\r\n&lt;head&gt;\r\n &lt;title&gt;Example Domain&lt;/title&gt;\r\n\r\n" &gt;


christos.perivolaropo
2022-1-31 18:06:36

what do you get for http://example.com\|example.com?


greg
2022-1-31 18:08:13

The Racket association list for the response body makes sense.


greg
2022-1-31 18:08:19

I’ll try …


greg
2022-1-31 18:09:23

&gt; (define-values (p hs) (get-pure-port/headers (string-&gt;url "<https://www.example> .com") '() #:redirections 25 #:status? #t)) &gt; hs "HTTP/1.1 200 OK\r\nAge: 486522\r\nCache-Control: max-age=604800\r\nContent-Type: text/html; charset=UTF-8\r\nDate: Mon, 31 Jan 2022 18:08:51 GMT\r\nEtag: \"3147526947+ident\"\r\nExpires: Mon, 07 Feb 2022 18:08:51 GMT\r\nLast-Modified: Thu, 17 Oct 2019 07:18:26 GMT\r\nServer: ECS (bsa/EB15)\r\nVary: Accept-Encoding\r\nX-Cache: HIT\r\nContent-Length: 1256\r\n\r\n" &gt;


christos.perivolaropo
2022-1-31 18:09:33

ok…


greg
2022-1-31 18:10:40

&gt; (require racket/port) &gt; (port-&gt;string p) "<!doctype html>\n&lt;html&gt;\n&lt;head&gt;\n &lt;title&gt;Example Domain&lt;/title&gt;\n\n &lt;meta charset=\"utf-8\" /&gt;\n &lt;meta http-equiv=\"Content-type\" content=\"text/html; charset=utf-8\" /&gt;\n &lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" /&gt;\n &lt;style type=\"text/css\"&gt;\n body {\n background-color: #f0f0f2;\n margin: 0;\n padding: 0;\n font-family: -apple-system, system-ui, BlinkMacSystemFont, \"Segoe UI\", \"Open Sans\", \"Helvetica Neue\", Helvetica, Arial, sans-serif;\n \n }\n div {\n width: 600px;\n margin: 5em auto;\n padding: 2em;\n background-color: #fdfdff;\n border-radius: 0.5em;\n box-shadow: 2px 3px 7px 2px rgba(0,0,0,0.02);\n }\n a:link, a:visited {\n color: #38488f;\n text-decoration: none;\n }\n @media (max-width: 700px) {\n div {\n margin: 0 auto;\n width: auto;\n }\n }\n &lt;/style&gt; \n&lt;/head&gt;\n\n&lt;body&gt;\n&lt;div&gt;\n &lt;h1&gt;Example Domain&lt;/h1&gt;\n &lt;p&gt;This domain is for use in illustrative examples in documents. You may use this\n domain in literature without prior coordination or asking for permission.&lt;/p&gt;\n &lt;p&gt;&lt;a href=\"<https://www.iana.org/domains/example>\"&gt;More information...&lt;/a&gt;&lt;/p&gt;\n&lt;/div&gt;\n&lt;/body&gt;\n&lt;/html&gt;\n"


greg
2022-1-31 18:11:39

What if you omit #:redirections 25 ?


greg
2022-1-31 18:12:17

Or supply #:redirections 0 (same difference).


soegaard2
2022-1-31 18:12:24

christos.perivolaropo
2022-1-31 18:12:31

No difference… I just remembered, I am using a proxy


christos.perivolaropo
2022-1-31 18:12:43

but I can’t get around it


greg
2022-1-31 18:13:52

One of your examples above seems to have the headers … but after the body :eyes: https://racket.slack.com/archives/C06V96CKX/p1643651873897199?thread_ts=1643651087.419999&amp;cid=C06V96CKX


christos.perivolaropo
2022-1-31 18:14:48

It does


christos.perivolaropo
2022-1-31 18:15:00

But I can’t tell why…


soegaard2
2022-1-31 18:15:03

@christos.perivolaropo Is this in a terminal?


christos.perivolaropo
2022-1-31 18:15:07

Yes


greg
2022-1-31 18:15:09

Which is.. very confusing. :smile:


christos.perivolaropo
2022-1-31 18:15:17

It’s in a terminal


greg
2022-1-31 18:17:41

It’s kind of a non-answer, lateral, work-around, but: Instead of net/url you could try the newer net/http-client and see if/how that works. https://docs.racket-lang.org/net/http-client.html


greg
2022-1-31 18:21:01

Although, it looks like net/url was re-implemented in terms of net/http-client, so, the behavior might be similar unless there is something about get-pure-port/headers specifically that is causing this (quick glance I don’t see what it could be).


christos.perivolaropo
2022-1-31 18:21:38

I am trying that now


christos.perivolaropo
2022-1-31 18:22:07

Actually I am trying to just get the headers via net/http-client


greg
2022-1-31 18:48:56

If you’re still stuck, my only other idea would be to use one of the net/http-client functions that accepts a #:version argument and supply “1.0”. The idea being, HTTP 1.1 introduces the possibility of wrinkles like reusing connections, chunked transfer encoding, and so on. All of which can be more efficient, but could allow some bug to be having an effect here. e.g. Reusing a connection and a bug with Content-Length could maybe somehow allow the body of one response to be mixed up with the header for the next one… or something like that??


soegaard2
2022-1-31 18:49:55

Btw - is it possible to temporarily disable the proxy? Just to see if that’s the cause.


greg
2022-1-31 18:50:24

I think Christos said they couldn’t, above.


soegaard2
2022-1-31 18:50:32

Ok.


greg
2022-1-31 18:50:46

(That is one thing I actually read instead of ignoring like some of my previous comments. :eyes:)


jcoo092
2022-1-31 20:06:30

Make an FFI binding to the C version of Roaring Bitmaps? :stuck_out_tongue: (I honestly have no idea how much work that would be)


soegaard2
2022-1-31 20:11:43

Oh boy - and I thought the question was about sparse images. Anyways, the Roaring Bitmap project seems to be written with FFI bindings in mind - and there are already a lot of bindings for other languages. So it is probably not too difficult to wrap the C version.


massung
2022-1-31 21:15:41

When I load a hash table from disk (using fasl-&gt;s-exp), it’s loaded as immutable. How can I make it mutable (or load it that way)?


massung
2022-1-31 21:16:03

Also, is there a better way to save/load a hash table?


sorawee
2022-1-31 21:17:02

|> hash->list |> make-hash


massung
2022-1-31 21:17:30

I’d rather not given the size of it (it’s > 1 GB of RAM)


sorawee
2022-1-31 21:17:44

welp


massung
2022-1-31 21:18:00

It’s not just a simple bit in the hash table saying “i’m mutable”?


sorawee
2022-1-31 21:18:12

They use totally different data structures


sorawee
2022-1-31 21:18:26

IIUC, one is Patricia tree. Another is HAMT.


massung
2022-1-31 21:18:39

well, it was written to disk as a mutable hash. Why isn’t it loaded using the same data structure it was written with?


massung
2022-1-31 21:19:34

I’d assume s-exp-&gt;fasl encodes the type, and fasl-&gt;s-exp makes use of that? Maybe there’s a better way to write (other than me doing it by hand)?


sorawee
2022-1-31 21:22:31

TBH, I’d just do it by hand.


massung
2022-1-31 21:26:05

:confused:


sorawee
2022-1-31 21:29:21

Wait, actually, looks like I got the details wrong about the data structures


sorawee
2022-1-31 21:29:42

HAMT is used as an implementation for immutable hash table in Racket BC


sorawee
2022-1-31 21:29:57

Patricia trie is used as an implementation for immutable hash table in Racket CS


sorawee
2022-1-31 21:30:21

I have no idea what mutable hash table uses, and whether they are different in each Racket variant.


massung
2022-1-31 21:31:07

Does it still use a trie even if the keys aren’t strings?


sorawee
2022-1-31 21:31:35

No idea.



ben.knoble
2022-1-31 21:41:41

Possible for the same reason that mutable hashes print as immutable hashes (so that when read, they are immutable)? Not saying this is correct or why it is the case, just suggesting that the reasons are connected.


massung
2022-1-31 21:42:29

I’d hope it’s written as binary for performance reasons and not in a “readable” format. :wink:


massung
2022-1-31 21:43:00

Like pickle in Python


ben.knoble
2022-1-31 21:44:37

Well, sure, but that binary format might be a compressed version of the readable format? IIRC fasl doesn’t support cyclic data either, right?


ben.knoble
2022-1-31 21:44:43

> The _v_ argument must be a value that could be https://docs.racket-lang.org/reference/quote.html#%28form._%28%28quote._~23~25kernel%29._quote%29%29\|quoted as a literal—that is, a value without syntax objects for which (https://docs.racket-lang.org/reference/eval.html#%28def._%28%28quote._~23~25kernel%29._compile%29%29\|compile `’,v) would work and be https://docs.racket-lang.org/reference/Reading.html#%28def._%28%28quote._~23~25kernel%29._read%29%29\|readable after https://docs.racket-lang.org/reference/Writing.html#%28def._%28%28quote._~23~25kernel%29._write%29%29\|write—or it can include <https://docs.racket-lang.org/reference/linklets.html#%28tech._correlated._object%29|correlated objects> mixed with those values. The byte string produced by https://docs.racket-lang.org/reference/fasl.html#%28def._%28%28lib._racket%2Ffasl..rkt%29._s-exp-~3efasl%29%29\|s-exp-fasl> does not use the same format as compiled code, however.


laurent.orseau
2022-1-31 21:44:54

@massung That’s serialization, not writeing


ben.knoble
2022-1-31 21:45:15

Was just about to quote: > Like (https://docs.racket-lang.org/reference/eval.html#%28def._%28%28quote._~23~25kernel%29._compile%29%29\|compile `’,v), https://docs.racket-lang.org/reference/fasl.html#%28def._%28%28lib._racket%2Ffasl..rkt%29._s-exp-~3efasl%29%29\|s-exp-fasl> does not preserve graph structure, support cycles, or handle non-https://docs.racket-lang.org/reference/structures.html#%28tech._prefab%29\|prefab structures. Compose https://docs.racket-lang.org/reference/fasl.html#%28def._%28%28lib._racket%2Ffasl..rkt%29._s-exp-~3efasl%29%29\|s-exp-fasl> with https://docs.racket-lang.org/reference/serialization.html#%28def._%28%28lib._racket%2Fprivate%2Fserialize..rkt%29._serialize%29%29\|serialize to preserve graph structure, handle cyclic data, and encode serializable structures. The https://docs.racket-lang.org/reference/fasl.html#%28def._%28%28lib._racket%2Ffasl..rkt%29._s-exp-~3efasl%29%29\|s-exp-fasl> and https://docs.racket-lang.org/reference/fasl.html#%28def._%28%28lib._racket%2Ffasl..rkt%29._fasl-~3es-exp%29%29\|fasl-s-exp> functions consult https://docs.racket-lang.org/reference/Writing.html#%28def._%28%28quote._~23~25kernel%29._current-write-relative-directory%29%29\|current-write-relative-directory and https://docs.racket-lang.org/reference/eval.html#%28def._%28%28quote._~23~25kernel%29._current-load-relative-directory%29%29\|current-load-relative-directory (falling back to https://docs.racket-lang.org/reference/Filesystem.html#%28def._%28%28quote._~23~25kernel%29._current-directory%29%29\|current-directory), respectively, in the same way as bytecode saving and loading to store paths in relative form, and they similarly allow and convert constrained https://docs.racket-lang.org/reference/exns.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._srcloc%29%29\|srcloc values (see <https://docs.racket-lang.org/reference/printing.html#%28part._print-compiled%29|Printing Compiled Code>).


ben.knoble
2022-1-31 21:45:21

Which mentions serialize



massung
2022-1-31 21:48:10

I missed the keep-mutable? flag! :face_palm:


ben.knoble
2022-1-31 21:48:11

λ racket -e '(require qi racket/fasl) (~&gt; ((make-hash (list (cons 1 2) (cons 3 4)))) (s-exp-&gt;fasl #:keep-mutable? #t) fasl-&gt;s-exp immutable?)' #f


ben.knoble
2022-1-31 21:48:21

Me too :slightly_smiling_face:


camoy
2022-1-31 21:48:59

I believe the current implementation of immutable hash tables is HAMT backed by stencil vectors (https://www.cs.utah.edu/plt/publications/dls21-tzf.pdf\|https://www.cs.utah.edu/plt/publications/dls21-tzf.pdf)


massung
2022-1-31 21:50:12

@laurent.orseau - I don’t consider fasl files to be “writing” (e.g. make-load-form in common lisp). And the serialize/deserialize functions in Racket are f’ing insane. They blow memory (used > 18 GB of RAM to write a 500 MB data structure before I killed it) and take forever.


samth
2022-1-31 21:51:16

On both BC and CS, mutable hash tables are the usual kinds of hash tables you learn about in data structures class, using buckets and chaining


laurent.orseau
2022-1-31 21:51:29

fair enough


massung
2022-1-31 21:52:21

(I tried the serialize/deserialize first, then found the s-exp-&gt;fasl functions)


sorawee
2022-1-31 21:53:11

Oh yeah, that makes sense. The tree structure is only needed for persistency.


samth
2022-1-31 21:54:37

Wow, I didn’t even know about that paper.


camoy
2022-1-31 21:58:20

It was published very recently at DLS


samth
2022-1-31 22:09:06

Yeah, but months ago


cperivol
2022-2-1 01:19:44

(personal account of @christos.perivolaropo here) It does indeed work fine from my home network :face_palm:


cperivol
2022-2-1 01:23:55

I can’t disable the proxy from my work network unfortunately. I will give it another go tomorrow. Thanks a lot for your time and effort