In Haskell, it is considered good practice to explicitly declare the type signature of your functions, even though it can (usually) be inferred. It seems like this isn't even possible in OCaml, e.g.
val add : int -> int -> int ;;
gives me an error. (Although I can make type
modules which give only signatures.)
OCaml has two ways of specifying types, they can be done inline:
let intEq (x : int) (y : int) : bool = ...
or they can be placed in an interface file, as you have done:
val intEq : int -> int -> bool
I believe the latter is preferred, since it more cleanly separates the specification (type) from the implementation (code).
References: OCaml for Haskellers
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With