5
예를 들어 Typed Racket에서 다형 함수로 작동 할 수있는 map
버전을 작성하려면 어떻게해야합니까? 나는리스트를 매핑 할 때 오류가 얻을형식화 된 라켓에서 다형 함수를 인수로 사용하는 고차 함수를 작성하려면 어떻게해야합니까?
(: 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)))
이것은 슬프다. 고맙습니다. –