# Functor style guide: space or not?

**URL:** <https://discuss.ocaml.org/t/functor-style-guide-space-or-not/1392>\
**Category:** Community\
**Created:** [January 5, 2018, 9:38am UTC](https://discuss.ocaml.org/t/functor-style-guide-space-or-not/1392 "2018-01-05T09:38:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![n4323](https://avatars.discourse-cdn.com/v4/letter/n/97f17d/32.png) [@n4323](https://discuss.ocaml.org/u/n4323)\
**Post date:** [January 5, 2018, 9:38am UTC](https://discuss.ocaml.org/t/functor-style-guide-space-or-not/1392/1 "2018-01-05T09:38:07Z")

</div>

I often see functor application written like this:

```auto
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

```auto
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?

---

<div class="post-metadata">

**Author:** ![n4323](https://avatars.discourse-cdn.com/v4/letter/n/97f17d/32.png) [@n4323](https://discuss.ocaml.org/u/n4323)\
**Post date:** [January 5, 2018, 9:39am UTC](https://discuss.ocaml.org/t/functor-style-guide-space-or-not/1392/2 "2018-01-05T09:39:30Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![ivg](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/ivg/32/103_2.png) [@ivg](https://discuss.ocaml.org/u/ivg)\
**Post date:** [January 5, 2018, 4:26pm UTC](https://discuss.ocaml.org/t/functor-style-guide-space-or-not/1392/3 "2018-01-05T16:26:03Z")

</div>

My personal style is

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

```

as opposed to

```auto
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.

---

<div class="post-metadata">

**Author:** ![n4323](https://avatars.discourse-cdn.com/v4/letter/n/97f17d/32.png) [@n4323](https://discuss.ocaml.org/u/n4323)\
**Post date:** [January 5, 2018, 11:27pm UTC](https://discuss.ocaml.org/t/functor-style-guide-space-or-not/1392/4 "2018-01-05T23:27:56Z")

</div>

I just found out `let f(a)(b) = a + b` is also valid 😉
