I have to make a couple functions for homework and I can easily get away with not doing this but I am wondering if it is possible because I think it would look much cleaner. If I am declaring a function like this:
(: my-funct : Integer Any -> (Listof Any))
Where the 2nd input actually determines the type of the output, is there a way to specify this? In class examples have used the (All) function but he has never really explained it, using what I can tell from the examples I tried this:
(: my-funct : Integer (All (A) -> (Listof A)))
and
(: my-funct : (All (A B) (A) (B) -> (Listof B)))
but the compiler is not liking either of these. Is there a way to do what I want or should I just leave it?
Try this:
#lang typed/racket
(: my-funct : (All (A) Integer A -> A))
(define (my-funct n x) x)