typed-racket icon indicating copy to clipboard operation
typed-racket copied to clipboard

Curryr has no type annotation

Open langston-barrett opened this issue 10 years ago • 5 comments

When using curryr in the typed/racket REPL, I get the following error, which asks me to file a bug report.

(:print-type curryr)
stdin::34: Type Checker: missing type for identifier;
 The `racket' language does not seem to have a type for this identifier; please file a bug report
  identifier: curryr
  from module: (lib typed/racket)
  in: curryr
  context...:
   /usr/share/racket/pkgs/typed-racket-lib/typed-racket/typecheck/tc-toplevel.rkt:418:0: tc-toplevel-form
   fail-to-succeed
   /usr/share/racket/pkgs/typed-racket-lib/typed-racket/tc-setup.rkt:40:0: tc-setup
   /usr/share/racket/pkgs/typed-racket-lib/typed-racket/typed-racket.rkt:25:4
   /usr/share/racket/collects/racket/private/misc.rkt:87:7

The documentation for Typed Racket states "The typed/racket language corresponds to the racket language—that is, any identifier provided by racket, such as modulo is available by default in typed/racket."

Accordingly, the expected behavior is that curryr, which is provided in #lang racket, would already have a type annotation within Typed Racket.

langston-barrett avatar May 30 '15 15:05 langston-barrett

Thanks for the report. It's currently difficult to provide a useful and general type for curryr because it would have a hypothetical type like the following:

> curryr
- : (All (R B A ...)
      (-> (-> A ... A B R) (-> A ... A R)))

That is, it takes a function with arbitrarily many arguments of unspecified types (A ... A) and a last argument of type B and returns a function with the same first arguments but no argument of type B. This type currently can't be written with the -> type constructor.

takikawa avatar Jun 01 '15 21:06 takikawa

We should give it a simpler one then, even though that will be somewhat unsatisfying.

samth avatar Jun 01 '15 21:06 samth

We could give it a type like

(All (R B A)
  (-> (-> A B R) (-> A R)))

Or we could add a few cases, e.g., for arities three and four. I think that is still forwards compatible with the hypothetical type above as long as the order of type variables is the same.

takikawa avatar Jun 01 '15 21:06 takikawa

I agree that any type annotation would be better than having curryr completely unavailable in Typed Racket. Additionally, the documentation has a page on Caveats and Limitations that could list this gap, at the least (especially since current documentation states explicitly that all functions in untyped Racket are provided in Typed). I'm happy to submit a pull request for the documentation if someone could point me there.

langston-barrett avatar Jun 01 '15 22:06 langston-barrett

We could give it a type like

(All (R B A)
  (-> (-> A B R) (-> A R)))

Or we could add a few cases, e.g., for arities three and four. I think that is still forwards compatible with the hypothetical type above as long as the order of type variables is the same.

I think this example is missing a "B", which threw me off for a while as I'm coming to grips with typed racket:

(All (R B A)
               (-> (-> A B R) B (-> A R)))

timjervis avatar Nov 21 '20 12:11 timjervis