たとえばmap
、Typed Racket でポリモーフィック関数を使用するバージョンを作成するにはどうすればよいですか? 次のように定義された単純なid
関数を使用します。
(: id : (All (A) A -> A))
(define (id x) x)
リストにマップしようとすると、エラーが発生します。
> (map id '(1 2 3))
Type Checker: Polymorphic function `map' could not be applied to arguments:
Types: (-> a b ... b c) (Listof a) (Listof b) ... b -> (Listof c)
(-> a c) (Pairof a (Listof a)) -> (Pairof c (Listof c))
Arguments: (All (A) (-> A A)) (List One Positive-Byte Positive-Byte)
Expected result: AnyValues
in: (map id (quote (1 2 3)))