p.kushwaha97
2020-1-28 14:08:00

I need to seed rng with a string


p.kushwaha97
2020-1-28 14:08:14

Are there any hashing functions in racket?


p.kushwaha97
2020-1-28 14:08:34

I see there is eq-hash-code, is there also a hash-code function?


p.kushwaha97
2020-1-28 14:19:23

Ah nevermind, I misunderstood what equal-hash-code does. It is what I was looking for.


deactivateduser60718
2020-1-28 15:52:57

Here’s the macro I tried from yesterday using define-simple-macro after some sleep and a fresh pot of :coffee: (define-simple-macro (stateful-cell (~seq (~seq #:dependency u:id e:id) ...) body:expr ...+) #'(make-stateful-cell (λ () (let ([u e] ...) body ...)))) Right now I’m trying to figure out how to adjust the error message such that this invalid use provides an error complaining about a body being missing, as opposed to the head pattern not having enough terms. main.rkt> (stateful-cell #:dependency aa a #:dependency bb b) ; stdin::1415-1461: stateful-cell: expected more terms starting with the literal #:dependency or expression


soegaard2
2020-1-28 15:56:58

Two options. Option 1 - Change your pattern from body:expr ...+ to body:expr ... . And then manually check to see if body is empty. Option 2 - Use syntax-parse and add an extra clause [(stateful-cell (~seq (~seq #:dependency u:id e:id) ...) (raise-syntax-error ...)].


sorawee
2020-1-28 16:22:33

This looks like a bug in syntax-parse to me…


deactivateduser60718
2020-1-28 16:35:01

@soegaard2 I’d probably go with Option 2 just to keep the same mode of writing.


deactivateduser60718
2020-1-28 16:57:54

Here’s where I finally landed:

(define-syntax (stateful-cell stx) (syntax-parse stx #:context #'stateful-cell [(stateful-cell datum:expr) #'(make-stateful-cell (λ () datum))] [(stateful-cell (~seq (~seq #:dependency u:id e:id) ...) body:expr ...+) #'(make-stateful-cell (λ () (let ([u e] ...) body ...)))] [(stateful-cell (~seq (~seq #:dependency u:id e:id) ...)) (raise-syntax-error 'stateful-cell "Expected body after dependency bindings" stx)]))


notjack
2020-1-28 17:35:25

I think you don’t need the outer ~seq


notjack
2020-1-28 17:36:54

(stateful-cell (~seq #:dependency u:id e:id) ... body:expr ...+)


notjack
2020-1-28 17:40:19

Also, you can make a (splicing) syntax class for the dependency bindings and give that class a #:description. That will give you higher-level error messages.


capfredf
2020-1-28 20:11:49

Hi everyone, I have two types (define-type (Listof^ A) (U Null (Pairof A (Listof^ A)))) (define-type (Listof^^ A) (Rec x (U Null (Pairof A x)))) I thought they were equivalent to (All (A) (ListOf A)) but it turns out only the second one is equivalent to (All (A) (ListOf A)) Does anyone have a clue?


samth
2020-1-28 20:13:22

Those look like they should be equivalent


capfredf
2020-1-28 20:15:48

(: x (Listof^ Number)) (define x '(1 2 3)) (length x) the code above doesn’t type check, but the following does: (: y (Listof^^ Number)) (define y '(1 2 3)) (length y)


capfredf
2020-1-28 20:23:16

maybe this is a bug I should assign to myself…..


greg
2020-1-28 20:23:54

@mflatt I just started to make a PR to delete those two bullets — and possibly also the two bullets for 'module-direct-for-{template meta}-requires. But I notice that the doc for 'module-body-context-simple? links to all four of them. I’m guessing that means it’s also obsolete, and I should delete all five.

If you know off-hand, please let me know. Otherwise I guess I can just go ahead and make the PR deleting all five — and you all can not merge it if it’s wrong?


shu--hung
2020-1-28 20:27:27

Just curious — how does typed racket handle (Listof^ A) in (U Null (Pairof A (Listof^ A)))? Does it instantiate the (All (A) ...) with the outer type variable (the outer A)?


mflatt
2020-1-28 20:29:21

'module-body-context, 'module-body-inside-context, and 'module-body-context-simple? are the three properties that are still provided. It seems like 'module-body-context-simple? would not be useful without those other properties that are gone, but maybe I’ve forgotten something.


greg
2020-1-28 20:34:48

OK, I’ll attempt to rewrite 'module-body-simple? to remove the links and submit a PR.


capfredf
2020-1-28 20:37:18

I haven’t looked into the implementation of define-type But I don’t think there is any instantiation happening.


shu--hung
2020-1-28 20:41:25

Okay. It just occurs to me that if (define-type (T A) e) is exactly the same as (define-type T (All (A) e)) , then the forall quantifier and the recursive reference to T occurs in different order between two definitions


shu--hung
2020-1-28 20:41:51

I don’t know TR internals so this might just be totally irrelevent



capfredf
2020-1-28 20:47:32

maybe the order is the same? since T can appear in e in both of your type definitions


deactivateduser60718
2020-1-28 20:48:37

Awesome, thank you so much for your patience on this. PR coming within the hour.


shu--hung
2020-1-28 20:51:38

one is (define-type Listof^ (All (A) (U Null (Pairof A (Listof^ A))))) the other is (define-type Listof^^ (All (A) (Rec x ...A x...)))


shu--hung
2020-1-28 20:53:10

So it’s like whether that extra syntactic level of All in recursion would affect TR’s type inference algorithm


capfredf
2020-1-28 20:53:12

Oh, I got you wrong.

I thought you were talking about (define-type (Listof^ A) (U Null (Pairof A (Listof^ A)))) (define-type Listof^ (All (A) (U Null (Pairof A (Listof^ A)))))


capfredf
2020-1-28 20:54:53

Ah, make sense!


capfredf
2020-1-28 21:00:28

thank you!


shu--hung
2020-1-28 22:49:06

Looks interesting! Mallku Soldevila et al made a Redex model for Lua in Dynamic Language Symposium 2017 https://github.com/Mallku2/lua-redex-model https://arxiv.org/pdf/1706.02400v1.pdf


notjack
2020-1-29 01:27:23

No need to rush :) I do have a day job and plenty of other hobbies


deactivateduser60718
2020-1-29 02:35:19

Understood. I’ll keep things moving here. Please open a new issue if something needs addressing post merge!


philip.mcgrath
2020-1-29 03:14:16

I’m curious about building custom Racket distributions to distribute a few extra packages to my colleagues on top of a released main-distribution. It looks like the make client-from-site target 1 might be what I want, but I’m not completely clear how to “drive” building a derived distribution site or how it interacts with distro-build. I’m also not sure about code signing: the best-case scenario would be for Racket’s signature on the official release to still hold, but I don’t have enough experience with code signing in general to be clear about that.


notjack
2020-1-29 03:45:06

@philip.mcgrath Is asking them to run raco pkg install out of the question? The custom distribution thing seems like a lot of work (I didn’t even know you could do that)