ben
2018-5-7 15:05:01

something like (contract-out (f (-> (lambda (g) (procedure-arity-includes g .....)) any/c))) ? (contracts are just code :))


leif
2018-5-7 17:04:15

Does anyone know if there is a ~datum like syntax class that can be used with define-conventions?


ben
2018-5-7 17:09:13

wow, this program used to type check. It doesn’t anymore, ~yay~! #lang typed/racket (: f (-> Integer Integer)) (define (f x [y 0]) (+ x y))


leif
2018-5-7 17:09:55

@ben Sadly that only seems to change the highlighted color. Also no rainbows. :disappointed:


samth
2018-5-7 17:13:01

@ben that doesn’t seem like it was an intended change


pnwamk
2018-5-7 17:14:29

it type checks in my 6.12 repl


ben
2018-5-7 17:15:16

the change happened over the weekend



notjack
2018-5-7 17:15:42

should that typecheck? I really can’t tell


ben
2018-5-7 17:16:13

I’m happy getting an error, because it told me I had an “arity error” in my type


samth
2018-5-7 17:16:25

@ben yeah, I’m sure that’s because of the kw argument change


pnwamk
2018-5-7 17:21:44

@ben help me through this — why should that function not type check?


pnwamk
2018-5-7 17:21:53

is it not a function that, if given an integer, produces an integer?


ben
2018-5-7 17:22:45

that’s true


pnwamk
2018-5-7 17:23:00

I’m pretty sure it should check at that type


pnwamk
2018-5-7 17:23:35

I’m going to try and double check it wasn’t the other commit that happened this weekend affecting functions…


notjack
2018-5-7 17:24:31

what should happen if it’s called with two integers?


pnwamk
2018-5-7 17:26:10

at that type that cannot happen


pnwamk
2018-5-7 17:26:32

so, an application where 2 arguments are supplied should either be statically rejected by the type checker or not allowed by a contract


lexi.lambda
2018-5-7 17:27:49

it seems like if that program is rejected then (ann 1 Integer) should also be rejected, which clearly doesn’t make sense


pnwamk
2018-5-7 17:28:22

???


lexi.lambda
2018-5-7 17:29:23

it seems odd to me that sometimes a subtype annotation is okay but sometimes it isn’t


pnwamk
2018-5-7 17:29:33

what do you mean


pnwamk
2018-5-7 17:29:39

what subtype annotation is not okay


lexi.lambda
2018-5-7 17:29:50

Ben’s program


lexi.lambda
2018-5-7 17:29:55

I am agreeing with you


pnwamk
2018-5-7 17:30:12

I don’t understand what we are agreeing on


pnwamk
2018-5-7 17:30:18

xD


lexi.lambda
2018-5-7 17:30:27

that the program Ben posted should typecheck


pnwamk
2018-5-7 17:31:00

okay… I guess the “if/then” is what confused me, but nevermind


pnwamk
2018-5-7 18:07:46

@ben @samth it looks like the regression was from https://github.com/racket/typed-racket/commit/4b1a1bfa9d59aa2ae469e1217dd16aea9c2f5aa6 (and not the other function-related commits from this weekend)


mflatt
2018-5-7 18:51:51

I expected that to typecheck, too. If you make y a keyword argument, then it does typecheck, so the part that has gone wrong is related to by-position optional arguments.


lexi.lambda
2018-5-7 19:25:51

@mflatt Is there any API accessible to macro authors that allows either (a) forcing recursive expansion in a context where #:out-of-context-as-variable? is #f or (b) determining whether or not a particular binding is in context in the current expansion context?


lexi.lambda
2018-5-7 19:26:43

Put another way: is there any way I can recursively expand a piece of syntax and reject syntax that includes out of context variable references?


mflatt
2018-5-7 19:41:44

@lexi.lambda I can’t recall one, so I expect that there isn’t (since you didn’t find it)


lexi.lambda
2018-5-7 19:42:27

Would adding a keyword argument to local-expand for that behavior be reasonable, or is there a better way to do it?


mflatt
2018-5-7 19:44:14

An extra argument sounds ok to me. Note that the expander’s exported API can’t have keywords, though; a keyword variant would have to be implemented at the racket/base level.


lexi.lambda
2018-5-7 21:25:24

@mflatt I’m not sure I totally understand how to arrange for that to work out for the bootstrapping process. I tried doing the naïve thing of adding positional arguments to local-expand and its variants, then adding a new module racket/private/kw-syntax-local, but bootstrapping the expander failed with the following error: Traversed 278 modules Got 267 relevant linklets Need 211 of those linklets Code is 3024648 bytes as source Unfortunately, some linklets depend on pre-defined host instances that are not part of the runtime system: - /Users/alexis/gits/racket/racket/racket/collects/racket/private/kw-syntax-local.rkt at 0 needs #%core: syntax-local-expand-expression local-transformer-expand/capture-lifts local-transformer-expand local-expand/capture-lifts local-expand needed by side-effect


lexi.lambda
2018-5-7 21:27:34

I’m not sure how to interpret this error. Does it mean there’s something wrong with the expander code, or with kw-syntax-local.rkt? It seems like it would be normal that kw-syntax-local.rkt needs #%core, but I don’t know what “needed by side-effect” means.


mflatt
2018-5-7 21:29:01

It looks like the flattener can’t infer that the new module is free of side effects. I don’t have a guess at why, but I you could send me “kw-syntax-local.rkt” and maybe I’ll see the problem.


lexi.lambda
2018-5-7 21:29:50

The module is pretty small: (module kw-syntax-local "pre-base.rkt" (require (prefix-in k: "pre-base.rkt")) (provide local-expand local-expand/capture-lifts local-transformer-expand local-transformer-expand/capture-lifts syntax-local-expand-expression) (define (local-expand s context stop-ids [intdefs '()] #:allow-out-of-context? [allow-out-of-context? #t]) (k:local-expand s context stop-ids intdefs allow-out-of-context?)) (define (local-expand/capture-lifts s context stop-ids [intdefs '()] [lift-key (gensym 'lift)] #:allow-out-of-context? [allow-out-of-context? #t]) (k:local-expand/capture-lifts s context stop-ids intdefs lift-key allow-out-of-context?)) (define (local-transformer-expand s context stop-ids [intdefs '()] #:allow-out-of-context? [allow-out-of-context? #t]) (k:local-transformer-expand s context stop-ids intdefs allow-out-of-context?)) (define (local-transformer-expand/capture-lifts s context stop-ids [intdefs '()] [lift-key (gensym 'lift)] #:allow-out-of-context? [allow-out-of-context? #t]) (k:local-transformer-expand/capture-lifts s context stop-ids intdefs lift-key allow-out-of-context?)) (define (syntax-local-expand-expression s [opaque-only? #f] #:allow-out-of-context? [allow-out-of-context? #t]) (k:syntax-local-expand-expression s opaque-only? allow-out-of-context?)))


mflatt
2018-5-7 21:37:37

Ok – the expansion involves make-optional-keyword-procedure, and a later pass of the flattener can figure out that calling make-optional-keyword-procedure has no side effect, but the check for a reference to expander functions happens before that (and didn’t seem easy to reorder, for reasons that I forget). So, adding keywords for functions below the expander level can work this way, but not functions from the expander layer. The right workaround isn’t immediately obvious.


lexi.lambda
2018-5-7 23:24:18

Sorry, I only just saw this—that makes some sense to me. I think that’s okay, since this thing I wanted to add was mostly just to be able to do “the right thing”, but what I have right now seems to work fine.


lexi.lambda
2018-5-7 23:24:50

It does seem like it would be useful in general to be able to export functions with keywords from the expander layer, though.


find_my_way
2018-5-8 01:14:26

@find_my_way has joined the channel


mflatt
2018-5-8 02:59:44

@lexi.lambda I think the solution is probably to improve the flattener so “kw-syntax-local.rkt” is ok. But not this week.


lexi.lambda
2018-5-8 03:21:12

Understandable. I should probably be focusing on other things, anyway. :)