Ignore a function in OCaml elegantly

Viewed 674

I define a function f in utop of OCaml version 4.04.

utop # let f = function x -> x + 1;;

val f : int -> int = <fun> 

When I try to ignore f, I encounter a warning.

utop # let a = ignore (f : int -> int); f 2;;

Characters 15-19:                                             
Warning 5: this function application is partial,
maybe some arguments are missing
val a : int = 3

Warning 5 is triggered because the expression following ignore has a function interface int -> int.

ignore (f 0) and if false then (ignore f 0) work but they are not elegant. I don't want to provide missing arguments to f. Is there any alternative to ignore?

The motivation of ignore isn't very clear in this dummy example but I do need to use it to avoid other warnings in my real project.

Thanks for your time.

4 Answers
Related