Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ doc ] Add missing pragmas to documentation #3148

Merged
merged 2 commits into from
Nov 28, 2023

Conversation

dunhamsteve
Copy link
Collaborator

Description

This PR adds documentation for all of the pragmas in Idris. It is based off of the list in the comments of #3072.

There are 43 of them, so I broke them into sections:

  • Global pragmas
  • Pragmas on declarations
  • Internal
  • Expressions

Let me know if there is a better way to organize them.

It still needs some clarification on how %globalhint differs from %defaulthint. I copied the description for %syntactic from a comment in the source code, but I don't fully understand what it does.

I found that %allow_overloads is no longer used and documented that. It updates the configuration, but nothing reads that data. It was disabled here:

pure False -- If the name exists, and doesn't have a concrete type
-- but another possibility does, remove it from the set
-- no matter what
-- (TODO: Consider whether %allow_overloads should exist)
-- (not (Overloadable `elem` flags gdef))

We don't seem to have any documentation on elab reflection in docs. It'd be nice to add that someday.

At some point, libraries.rst should be rewritten or removed. It currently references a deprecated pragma, and the first two examples now give errors.

Should this change go in the CHANGELOG?

No, it's just updates to documentation.

``%default``
--------------------

Set the default totality requirement for functions. The initial value is `covering`, which
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe, it's worth adding that total can be an initial value if an appropriate flag is passed to the compiler

``%defaulthint``
--------------------

Mark a default for functions like ``fromString`` in cases where the compiler cannot
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to give a wrong to impression. I would say that this is like a %hint which is tried when none of the proper %hints succeeded.

``%hint``
--------------------

Mark a function to be used for ``auto`` search (see :ref:`auto-implicits` for more).
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe, it's important to add that every non-named implementation receives this pragma automatically. Also, it may be added that every data constructor effectively receives this unless [noHints] is present in the declaration of the data type.

``%globalhint``
--------------------

This pragma is similar to ``%defaulthint``.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I know, this is similar to %hint, not %defaulthint, but the rules of search are different. %hints have determining type arguments, but %globalhints are tried anyway.

Copy link
Collaborator Author

@dunhamsteve dunhamsteve Nov 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. The %globalhint are stored with the %defaulthint, because neither relies on the type, but they're used very differently. It looks like %globalhint wins over %hint, too.

Thanks for the feedback. I'll try to get an update out tomorrow.

@andrevidela
Copy link
Collaborator

andrevidela commented Nov 28, 2023

Seems like all the feedback has been addressed and it looks good to me.

Maybe we can start thinking about removing the deprecated pragmas soon

@andrevidela andrevidela merged commit 6eb6661 into idris-lang:main Nov 28, 2023
3 checks passed
@dunhamsteve dunhamsteve deleted the doc-pragma branch November 29, 2023 19:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants