documentation icon indicating copy to clipboard operation
documentation copied to clipboard

Distinguish "anonymous argument" from "wildcards"?

Open chexxor opened this issue 8 years ago • 4 comments

The PS compiler produces an error message named "InvalidAnonymousArgument" when incorrectly using operator section syntax. When reviewing the PR to add docs for this error message, https://github.com/purescript/documentation/pull/144, I had to ask around to learn the difference between "anonymous argument" and "operator sections".

An underscore, _, is used in several different syntax definitions, which can add confusion:

  • Type holes (main :: _)
  • null binders (\_ ->)
  • anonymous argument (case _ of, if _ then)
  • record holes/wildcards ((_.x, {x: _, y: _}, rec { x = _ })

My only question is whether record-related syntax should be called "anonymous argument", or if that is sufficiently different to have its own name, like "record wildcards". I wonder because PS has lots of sugar, like perhaps record syntax is desugared to simple lambdas, which have arguments, so could be called "anonymous argument".

chexxor avatar Dec 06 '17 20:12 chexxor

(Short comment as I'm on my phone:) I'm not sure 'wildcard' is an appropriate name. There's also (_ + 0).

LiamGoodacre avatar Dec 06 '17 20:12 LiamGoodacre

I think we should use "anonymous argument" to refer to all of case _ of, if _ then _ else _, _.x, {x: _, y: _}, etc: basically anything where a underscore is desugared to a lambda.

hdgarrood avatar Dec 14 '17 19:12 hdgarrood

Using that definition, it's easy to say what the difference between operator sections and anonymous arguments is, since operator sections are just a specific type of anonymous argument.

hdgarrood avatar Dec 14 '17 19:12 hdgarrood

Sounds good. I'll change the scope of this issue to have us add a single place to document anonymous arguments, then. We can link to that doc-section from all syntaxes which support it.

chexxor avatar Dec 14 '17 21:12 chexxor