It looks like everything is fine with you, f(g(x)) should work fine. I'm not sure why you have the return keyword (this is not a keyword in ocaml). Here is the correct version,
let compose fgx = f (gx)
Type definition for this:
val compose : ('b -> 'c) -> ('a -> 'b) -> 'a -> 'c = <fun>
Each, 'a,' b, 'c are abstract types; we donβt care what they are, they just have to be consistent in the definition (so the domain g must be in the range f ).
let x_plus_x_plus_1 = compose (fun x -> x + 1) (fun x -> x * 2)
source share