What is the dot in the function argument?


#1

Sometimes when using Js.Option the compiler forces me to put a dot before the function argument. Example:

|> Js.Option.andThen((. a) => ... )

instead of

|> Js.Option.andThen((a) => ...)

What does that dot mean, syntax wise? It seems to me the closest thing in the documentation that use dots like that are Objects, but I’m not sure it’s the same meaning.


#2

It’s a new feature which was added in Reason 3.1.0

The announcement has a short blurb which discusses it here: https://reasonml.github.io/blog/2018/03/06/reason-3.1.0.html

The blurb says:

Tired of seeing [@bs] foo(bar, baz) for uncurrying? Use the new version to refmt your code to automatically format it into foo(. bar, baz)!

Also, the [@bs] syntax is a bucklescript-specific annotation for uncurrying. For more information, search for the term “Curry & Uncurry” on this page: https://bucklescript.github.io/docs/en/function.html