[plt-scheme] Typed Scheme: Is there any easy way around this?

From: Sam TH (samth at ccs.neu.edu)
Date: Wed May 30 22:47:20 EDT 2007

On 5/30/07, Matthew Swank <akopa.gmane.poster at gmail.com> wrote:
> (pdefine: (a b) (mappend (fun : (a -> (Listof b))) (lst : (Listof a))) : (Listof b)
>      ;;Append the results of calling fn on each element of list.
>     (apply append (map fun lst)))
>
> --> typecheck: polymorphic functions not supported with apply

Try this:

(pdefine: (a b) (mappend (fun : (a -> (Listof b))) (lst : (Listof a)))
: (Listof b)
    ;;Append the results of calling fn on each element of list.
   (apply #{append :: ((Listof b) .. -> (Listof b))} (map fun lst)))

Basically, we explicitly instantiate append at the type b.

Hope that helps, and thanks for trying Typed Scheme!

-- 
sam th
samth at ccs.neu.edu


Posted on the users mailing list.