Introduce searching for precedence-criterium capability in GHCi
Motivation
I am currently learning Haskell with Chris book and would like sometimes to go further (as there are nevertheless assumptions related to previous knowledge acquired), regarding to mechanisms like precedence to pursue a goal with triple interest:
- Check out with ease what are the other operators to enhance my syntax's spectrum of Haskell;
- Be able to use more adequate operators than the one I currently know of to produce a code more maintainable, from now on and to long-term benefis;
- Access in a easy way to a very lightweight form of documentation for academic purposes and out-of-the-box refresher of possible available grammar in a very specialized context.
My first use-case was wondering about the following:
Now that I know of (^) exponentiation operator with 8 precedence, what are the operators with a higher precedence which would take priority during expression's evaluation over the (^) operator?
However, I do not know where to start looking for such an info with a so specific criterium; therefore, I naively tried in GHCi: :info infixl 9
but obviously, it returned a parse error.
I supposed that the precedence datum is necessarily linked with associativity mechanism in whatever documentation is invoked with :info
, that's why I naturally added infixl
with 9
datum (n.b. singular of data as you may already know).
Proposal
I hereby declare that all your basecode belong to me.
More seriously, I propose that an existing command would be given a new typology of option to reduce friction and/or asymmetry as possible.
Henceforth, I propose use of :show <mechanism> <value>
that as for me, translates quite naturally its intended purpose, that is showing what is available and that's it. Once it is revealed to me what the existant is, then I need merely to type :info <newly_checked_out_operator>
to know about its implementation details.
I would run the following command as an example:
:show precedence 9
and GHCi would return all available operators with precedence 9 (with respect to language extensions currently active or whatnot) in a enumeration.
Ideally, introducing the same documentation mechanism related to associativity would cover a larger spectrum, both for learning and adequacy with the problem-solving requirements at hand.
Thank you for your time.
Aurélien Plazzotta