Original-Via: uk.ac.nsf; Thu, 24 Oct 91 22:23:45 BST
Original-Sender: [EMAIL PROTECTED]

Lennart brings up some interesting points.  What is at stake here is
the interpretation of the closure rule, Section 5.1.3.  The question
needs to be a little more precise.  Lennart's example is

What happens is you import a module, A, and it contains a value, say
        x::T
and also a type synonym for T, say
        type T = Int
but then you hide T on import. I.e.
        import A hiding(T)

What is really important here is the actual interface to A.  If the
x :: T occurs in the implementation, then the interface could correctly
give the typing of x as x :: Int.  In this case, there is no problem.
A strict interpretation of closure, though, would seem to result in an
error if the x :: T form is used in the interface.  In practice, all
synonyms could be removed from signatures in interfaces.  This would
seem to be the correct behaviour for automaticly derived interfaces.

One important aspect of derived instances that they are not affected
by imports or renames.  All functions referred to in derived instances
are those defined in the Prelude regardless of renaming or hiding.
These functions also bring in type signatures which are also
part of the Prelude environment instead of the local environment.
While this means that it is impossible to influence the operation of
the derived instances by hiding or renaming Prelude functions used by
them, it is not possible to implement derived instances by simply
adding ordinary text to the progam.  I'm sure Lennart would like to be
able to refer directly to Prelude functions inside the instances using
qualified names!

Regarding his other example,

        import Prelude hiding(Dialogue)
        main _ = error "main"

Actually I'm not sure how this program refers to 'Dialogue' at all.
I'll assume he means something which make use of Dialogue, like

   import Prelude hiding(Dialogue)
   main = print "foo"

Without knowing the actual interface to the Prelude it would be
impossible to know whether this would cause an error.  If the
signature of 'print' explicitly mentions 'Dialogue' in the interface,
this should be an error.  Of course, it would be reasonable to assume
that all Prelude interfaces do not contain synonyms in their
signatures, so the type of print would be

print :: Text a => a -> [Request] -> [Response]

Of course, if you foolishly hide Request or Response, you must also
hide every value which refers to them in its type.

   John


Reply via email to