Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is the purpose of using ":" in OCaml function declaration

What is actually meant by the OCaml statement?

let func (v: A.a) : unit =    

#rest of the function
  1. does it mean it takes v of type A.a and return unit
  2. or it takes two parameters, v and A.a and return a unit?
  3. or it takes a function v with parameter A.a and returns a unit?
  4. or something else?
like image 825
P basak Avatar asked Nov 13 '13 09:11

P basak


Video Answer


1 Answers

let func (v: A.a) : unit =

The first : means v is a parameter and its type is expected to be A.a.

The second : means func is expected to return a type of unit

like image 134
Jackson Tale Avatar answered Oct 01 '22 17:10

Jackson Tale