[plt-scheme] Typed scheme and curry

From: John Clements (clements at brinckerhoff.org)
Date: Sat Dec 20 18:14:27 EST 2008

On Dec 19, 2008, at 6:37 PM, Eli Barzilay wrote:

> On Dec 19, Carl Eastlund wrote:
>> The "curry" function in Typed Scheme isn't just about writing curried
>> functions, it's about converting uncurried functions to curried
>> functions.  If you want to write a function in a curried style from
>> the get-go, you can do it like this: [...]
> [Note: this is a reply for Scott.]
> Note that the basic problem that (the untyped) `curry' solves is
> unrelated to the typed vs the untyped worlds -- it's the fact that
> Scheme has variable arity functions, and therefore `curry' is
> "guessing" how many levels of function calls are needed.  (I'll
> describe what it's "type" would be below.)  (BTW, there is a plan to
> change how `curry' works -- the result is still going to be
> problematic for typed-scheme.)  In any case, when you say

Lest we miss an obvious corollary of this discussion: you *can* make a  
plain-vanilla "curry3" function for a fixed number of arguments (in  
this case, 3):

#lang typed-scheme

(: curry3 (All (a b c d)
               ((a b c -> d)
                (a -> (b -> (c -> d))))))
(define (curry3 f)
   (lambda (a)
     (lambda (b)
       (lambda (c)
         (f a b c)))))

;; let's try it out:

(: fun-of-four (Number Number Number -> Number))

(define (fun-of-four x y z)
   (* (+ x y) z))

((((curry3 fun-of-four) 3) 5) 6)

This isn't variable-arity, and it's not flexible the way that the  
'curry' that Eli describes is.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2484 bytes
Desc: not available
URL: <http://lists.racket-lang.org/users/archive/attachments/20081220/c60433a0/attachment.p7s>

Posted on the users mailing list.