I tried to define a polymorphic type:
(define-type (listt a)
(U Empty
(Cons a)))
(struct Empty ())
(struct (a) Cons ([v : a] [w : (listt a)]))
and a currying function:
;; a better name for subst-c is subst-currying
(: subst-c : (∀ (a) ((-> a Boolean) -> a (listt a) -> (listt a))))
(define (subst-c pred)
(lambda (n listt)
(match listt
[(Empty)
(Empty)]
[(Cons e t)
(if (pred e)
(Cons n ((subst-c pred) n t))
(Cons e ((subst-c pred) n t)))])))
but got error
;Type Checker: type mismatch
; expected: Nothing
; given: a
; in: n
;Type Checker: type mismatch
; expected: (U Empty (Cons Nothing))
; given: (U Empty (Cons a))
; in: t
I'm confused about it, what did I do wrong?