anything
2020-9-3 14:38:07

Thank you. I really appreciate your help. I upgraded to Racket 7.8, latest available package on the website. I’ll keep an eye on the server and see if the problem goes away.


rogarithm
2020-9-3 16:26:54

@rogarithm has joined the channel


jesse
2020-9-3 17:44:51

looking at @ben ’s upcoming RacketCon talk about contracts (Shallow Typed Racket), I wonder if there’s such a thing as “compile-time-only Typed Racket”. It would be just like Typed Racket, but no contracts would be added at runtime. I want to use the types at compile time only. The idea is that if a module passes through the type checker, I want just plain old racket to come out. No additional contracts beyond the ones already baked into #lang racket. Does that make sense? Perhaps one could fake it with a new require/typed/uncontracted form that would allow me to pull in TR code sans additional contracts. Maybe what I describe already exists, but I just don’t know about it.


samth
2020-9-3 18:04:02

There’s unsafe-provide. There’s not a way to import things without the invariants the types imply unless the module you’re importing sets that up.


samth
2020-9-3 18:05:04

The reason that we haven’t added typed/racket/optional is that then the types are just sort of hints, but you can’t trust them.


jesse
2020-9-3 18:09:34

ah, I see. So if I have a TR module that unsafe-provides a function f and if I typed/require f in a #lang racket module, then the runtime behavior of f in that module won’t have the extra contract implied by the type of f in the TR module?


jesse
2020-9-3 18:12:46

I’m not sure I understand the intuition behind saying that the types would be mere hints. Sure, they’d no longer have any runtime significance, but getting a big chunk of code to go through the TR type checker is, to my mind anyway, a pretty strong sign that my code is good(ish)


jesse
2020-9-3 18:13:36

or to put it another way: what can be done to close the gap, and make the hints (the types) more confidence-inspiring (that is, to remove the “mere” from “mere hint”)


samth
2020-9-3 18:16:30

There isn’t a typed/require for you’d use in plain #lang racket. If you use TR to define a function, you can just require that from plain racket. If you use provide, that will have a contract. If you use unsafe-provide, it won’t have a contract.


jesse
2020-9-3 18:16:36

perhaps I’m thinking about types in an unintended way. I guess I’m thinking about them the way types would be handled in, say, C


samth
2020-9-3 18:17:56

The sense in which they’re just hints is that if you write (lambda ([x : String]) ...) in Typed Racket, you can trust that x is a really a string in the body of the function. If you remove the contracts, then that’s not true any more.


jesse
2020-9-3 18:18:01

perfect, thanks for clarifying. I think that’s what I’m looking for, at least, that’s the answer for how to make TR “unctracted”


jesse
2020-9-3 18:21:44

perhaps what I have in mind here is another #lang (“Fast TR”), or some kind of parameterized version of TR


ben
2020-9-3 19:54:15

yes I’m hoping to add a “typecheck only” lang too in the Shallow pull request

For now you can use the live-free-or-die package to get TR code without contracts. (The pkg name is a great summary of the kind of excitement you should be ready for.)


laurent.orseau
2020-9-3 19:57:55

And that’s not even mentioning the alias for the exported form :smile:


alexharsanyi
2020-9-3 22:36:58

I would recommend against using unsafe-provide: the TR code might be optimized in such a way that, if you call a function provided unsafely with the wrong arguments, the entire application will crash (i.e. segmentation fault).

This comment explains a bit more: https://github.com/racket/plot/blob/4df34897acba74f689954188183e367c160911b8/plot-gui-lib/plot/private/gui/plot2d.rkt#L5


alexharsanyi
2020-9-3 22:38:06

jcoo092
2020-9-4 03:12:35

FYI, it sounds like the sort of concept you’re aiming for is roughly the approach that Rust takes to something of an extreme - type the heck out of everything at first to provide all sorts of checks and guarantees, but remove many (if not all) of the typing information from the final executable.


jesse
2020-9-4 05:21:03

@jcoo092 yeah, that’s essentially what I have in mind


jesse
2020-9-4 05:21:42

thanks for all the discussion! This has been illuminating.