I need to seed rng with a string
Are there any hashing functions in racket?
I see there is eq-hash-code, is there also a hash-code function?
Ah nevermind, I misunderstood what equal-hash-code does. It is what I was looking for.
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
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 ...)].
This looks like a bug in syntax-parse to me…
@soegaard2 I’d probably go with Option 2 just to keep the same mode of writing.
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)]))
I think you don’t need the outer ~seq
(stateful-cell (~seq #:dependency u:id e:id) ... body:expr ...+)
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.
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?
Those look like they should be equivalent
(: 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)
maybe this is a bug I should assign to myself…..
@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?
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)?
'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.
OK, I’ll attempt to rewrite 'module-body-simple? to remove the links and submit a PR.
I haven’t looked into the implementation of define-type But I don’t think there is any instantiation happening.
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
I don’t know TR internals so this might just be totally irrelevent
maybe the order is the same? since T can appear in e in both of your type definitions
Awesome, thank you so much for your patience on this. PR coming within the hour.
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...)))
So it’s like whether that extra syntactic level of All in recursion would affect TR’s type inference algorithm
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)))))
Ah, make sense!
thank you!
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
No need to rush :) I do have a day job and plenty of other hobbies
Understood. I’ll keep things moving here. Please open a new issue if something needs addressing post merge!
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.
@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)