Open schackbrian2012 opened 6 years ago
You can use curryr
if you use require/typed
to give it a type annotation
#lang typed/racket
(require/typed racket/function
(curryr (-> (-> Real Real Real) Real (-> Real Real))))
(curryr / 2)
;; #<procedure:curried>
@bennn That's a good workaround, but since curryr is a built-in function, I think that the type annotation should be built-in also. The type annotation for curry is built-in.
The racket versions of curry
and curryr
are variadic and and even curry-variadic (if that's a word) in some very weird ways, so it's impossible to give them types in typed racket.
However, if you instead make a simpler function with simpler run-time behavior, and if you sacrifice some flexibility, you might be able to describe it better with a type.
(: partialr : (All (X Y) (-> (-> X * Y) X * (-> X * Y))))
(define ((partialr f . bs) . as)
(apply f (append as bs)))
But notice how curryr
could never be described by this type, because it's behavior decides at run time whether to produce another function or to produce a final result value, based on the procedure-arity
.
@AlexKnauth Yeah, I can certainly see how it could be impossible to make a type for curryr if the type system is insufficiently expressive. I would say to put it in as best as you can either with a syntactical special case or a simplified type. Bring curryr up to parity with curry. And then keep a list in the documentation of the built-in functions that are less expressive in typed/racket than untyped racket.
What version of Racket are you using?
6.10.1
What program did you run?
(curryr / 2)
What should have happened?
#<procedure:curried>
If you got an error message, please include it here.