Fix compilation of library/version_array.m in memory profiling grades.

library/version_array.m:
    The macro MR_ALLOC_ID is only defined for foreign_proc pragmas *not* for
    foreign_code pragmas.  Commit ab44bba introduced several references to
    MR_ALLOC_ID inside functions defined foreign_code pragmas.  Fix this by
    passing the appropriate alloc id down from the foreign_proc pragmas
    that call the affected functions.
Fix spelling in psqueue module.

library/psqueue.m:
	As above.
Fix a typo.

library/psqueue.m:
	As above.
Significantly improve psqueue.m.

library/psqueue.m:
    Fix a bug: the adjust predicate was documented to fail if asked to adjust
    the priority of a nonexistent key, but it succeeded anyway.

    Fix a bug: the function that computed the size of a psqueue did not count
    the priority/key pair in the winner structure.

    Make the at_most predicate significantly more efficient, by eliminating
    an expensive conversion to the min view. Most of the contents of the min
    view was not needed. In Haskell (the language used in the paper that
    this module is derived from), computing stuff that won't be looked at
    is cheap due to lazyness; in Mercury, it can be expensive.

    Make the at_most predicate significantly more efficient in another respect
    as well, by using cords to avoid re-re-re-appending the same elements.

    Make most other predicates more efficient by eliminating the redundant
    checking for empty queues. For example, when you convert a nonempty queue
    to the tournament view, you shouldn't need to check whether the result
    is a tournament with no players; it will not be. This change required
    two main changes in data structures. The first is to separate out
    the concepts of psqueues that may be empty from those which may not.
    The second is updating the tournament view to eliminate the possibility
    of no players, and handling empty psqueues *without* converting them
    to the tournament view.

    Document the meanings of the module's data structures, both original
    and updated, including their invariants (at least, the invariants
    I can see).

    Delete the type for min views, since after the performance fix to at_most,
    it is no longer needed.

    Delete the type for tree views, since it is isomorphic to the actual
    data structure, and conversions to it just waste time.

    Delete the t_ prefix from the names of types.

    Change the documentation of predicates to use full sentences, not just
    sentence fragments.

    Do not include the predicates intended only for unit tests in the
    publicly documented part of the interface.

    Use the P, K order of type variables CONSISTENTLY. Change the order
    of fields representing priority/key pairs in structures likewise.

    Use consistent naming schemes for variables: PSQx for psqueues, LTreex
    for ltrees, etc. Use xPrime instead of x0 for variables bound in the
    conditions of if-then-elses. Use Maybe as a prefix on the names of
    variables of maybe types.

    Avoid the use of generic variable names such as "Res"; use names that
    reflect the value being returned instead.

    Avoid the use of numeric suffixes on variables when these do NOT denote
    progression over time; use A and B, or L and R, suffixes instead.

    Give some function symbols and predicates more meaningful names.

    Internal operations do not need to be available as both functions
    and predicates; pick whichever seems more appropriate, and remove
    the other. Remove some other unused functions, such as construct_leaf.

    Factor out some common code, e.g. for updating minimums and maximums.

    Remove redundant "is det" declarations from functions.

    Fix the type specializations. Specializing a predicate is useless
    unless its caller either always calls it with values of the specialized
    type, or is itself specialized the same way. This module needs the latter,
    so add type specializations to all predicates between the exported
    predicates and the primitives that can directly benefit from the
    specializations.

tests/hard_coded/psqueue_test.{m,exp}:
    Make this test case significantly harder. The old version did not
    pick up the two bugs referred to above, but the new version does.
Remove trace code accidentally left in.