b (Listof c)))īut the type you wrote was this: (All (c a b. Looking at just the multi-list case, it's this: (All (c a b. (-> (-> a c) (Pairof a (Listof a)) (Pairof c (Listof c))) It is: (: zip-with2 (All (a b c) (-> (-> a b c) (Listof a) (Listof b) (Listof c))))Īlthough it's trickier to call than I would like (I had to use inst on the functions I tried, cons and list).Īs Alexis King already pointed out, zip-with is exactly map in racket, and its type signature should be the same. Ideally, I'd like the typed version to behave as closely to the untyped as possible, so I can do something like this (an example output using the untyped version): > (zipwith list '(1 2 3) '(4 5 6) '(7 8 9))Įdit: I did manage a version like Haskell's, just copying the type signature as-is essentially. I see it complains about the apply function, but are my expected types correct otherwise? I could use some advice on how the completely translate my untyped version. The Dr Racket REPL I'm using gives me this error: Type Checker: Bad arguments to function in `apply':ĭomains: (-> a b. I tried looking at the types for map and apply to try to figure it out some, but I haven't had any luck with it so far: (: zip-with (All (c a b. Here is the untyped ZipWith I made and am trying to convert, very simple: (define (zipwith fn. I've been practicing some with Typed Racket Scheme (this is my first month or so using Scheme), and I'm trying to rewrite the ZipWith function using types, and it's proving far more difficult that I thought.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |