Functor style guide: space or not?


I often see functor application written like this:

module F(A:InSig) = struct ... end

I used to think this is at odds with the rest of the language since function application works without parentheses and is curried, and functors with several arguments are also curried. So I would write

module F (A:InSig) = struct ... end
module G (A:In1) (B:In2) = struct ... end

where the second case to me looks better than G(A)(B). Is there a reason to prefer the no-space parentheses style rather than the curried style?


One argument I can think of is that types may be referred to directly as F(A).t which looks better than ((F (A)).t) and is not as confusing as F (A).t. But that seems not such a common use?


My personal style is

module Make(T : T)(M : Monad.S) : S

as opposed to

module Make (T : T) (M : Monad.S) : S

as it makes more explicit that Make is a functor. However, I think that the second approach is also perfectly valid, and sometimes I use it myself, for the same reasoning as you describe.

Concerning functor application, I always use G(X) syntax without a whitespace, and envision it more like an indexing operator.


I just found out let f(a)(b) = a + b is also valid :wink: