Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

int -> ('a -> 'a)

I have a question that I came across studying SML. It requires the return type to be int -> (’a -> ’a). This is what I have done:

- fn x:int => fn y => y;
val it = fn : int -> 'a -> 'a

How can I make the return type to be int -> ('a -> 'a) where 'a -> 'a is in brackets? Any help would be appreciated, I have been trying it figure it out for hours and can't find anything related to it here or searching on Google.

like image 762
Naeem Khan Avatar asked Dec 29 '25 19:12

Naeem Khan


1 Answers

A -> B -> C and A -> (B -> C) are the same type. The -> operator in types is right associative.

By convention the type checker doesn't print redundant parentheses, so you'll never see int -> ('a -> 'a) printed for your code.

You're already done. :-)

like image 137
melpomene Avatar answered Dec 31 '25 17:12

melpomene