qi icon indicating copy to clipboard operation
qi copied to clipboard

Typed Qi

Open countvajhula opened this issue 3 years ago • 4 comments

Initially suggested by Sergiu Ivanov (scolobb) in the Racket Discourse. See that thread for some context.

It would be both very interesting as well as potentially useful to develop a typed version of Qi. Just registering interest here for now and there are no specific plans yet.

TBD - input welcome.

countvajhula avatar Jan 06 '22 08:01 countvajhula

I'm thinking about sending you a PR for this. At the very least I'm willing to experiment.

I've seen a few different approaches to typing things like this.

  • Convert selections (or the entirety) of the exported code
  • Make a typed wrapper library, and require an import such as (require qi/typed)
  • Or lastly do both.

Just looking at the exact error message when I do this makes me feel like the first one (converting specific sections) is the best way. Optimally editing the smallest amount possible would be best. (Such as like just the file that generates the macro output)

#lang typed/racket
(require qi)
((flow (~> (* 2))) 4)

What do you think?

Lazerbeak12345 avatar Jan 14 '23 02:01 Lazerbeak12345

I'm very sorry. I've changed my mind for now. I'm in the States, and i'm unsure if the current licencing situation is one compatible with current legal practice. #8

As a note: If it can be shown that US Citizens can contribute to such a project without legal risk (such as being sued by any group for any reason for contributing to a project that they claim harmed them somehow) I'm willing to contribute. I really, really want to help contribute to qi. Type integration in particular would be something I'd love to add.

Lazerbeak12345 avatar Jan 14 '23 02:01 Lazerbeak12345

I did some research, and typing this library might not be possible right now.

Typed racket doesn't support polymorphic arguments passed into polymorphic functions. That's more or less the whole point of this library.

(curry *) doesn't work at all in typed racket. I'm assuming curry is involved in qi's runtime facilities.

To fix this, changes would need to be made upstream.

PS: I haven't looked at qi's source.

Lazerbeak12345 avatar Jan 26 '23 20:01 Lazerbeak12345

Thank you for checking! That's a good point. I still know very little about Typed Racket and typing more broadly. Sounds like if we wanted to use Typed Racket for this we might need to assume the definitions would not be variadic (unless support for variadic arguments could be added in TR down the line). Another possibility I came across was Turnstile, which might allow defining the type checker at a higher level.

countvajhula avatar Jan 26 '23 22:01 countvajhula