Re: instance export decls

2008-05-02 Thread John Meacham
On Thu, May 01, 2008 at 03:21:11PM +0100, Simon Peyton-Jones wrote:
 Indeed! I think it'd be good to allow type signatures, including
 instance signatures, in export lists

The problem with instance signatures is that it would give the
impression that it would be possible to _not_ export an instance, and it
wouldn't make explicit the fact that the instances of all modules it
depends on are also exported. 

John

-- 
John Meacham - ⑆repetae.net⑆john⑈
___
Haskell-prime mailing list
Haskell-prime@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-prime


RE: instance export decls

2008-05-01 Thread Simon Peyton-Jones
Indeed! I think it'd be good to allow type signatures, including instance 
signatures, in export lists

module Foo(
data T (f :: * - *),
instance Functor f = Eq (T f),
g :: T f - T f
  )

The first step is to evolve a well-worked-out design. I think that'd be a very 
valuable thing for someone to do.  Indeed, I'd really like to see it in 
Haskell', but it doesn't meet the tried and tested criterion.

I'm a bit reluctant to invest effort in half-way-house solutions, though.

Simon


| -Original Message-
| From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
| Behalf Of Serge D. Mechveliani
| Sent: 22 April 2008 13:33
| To: [EMAIL PROTECTED]
| Subject: instance export decls
|
| Dear GHC developers, people,
|
| Do you agree that there exists such a problem for a programmer as
| recalling exported instances?
| Have Haskell and/or GHC some constructs and tools to help the programmer
| to recall the exported instances for a module?
| Could GHC support the instance export messages for each module?
|
| In Haskell-98, the exported instances cannot be named explicitly in the
| export list.
| Right?
| But for easier understanding of a program, it is desirable to allow to
| name (in a short form) instances in the export list.
| For this reason, I add comments, and write the export like this:
|
|   module Poly
|   (WithHead(..), WithTail(..), -- classes
|Mon(..), Polynomial(..),
|lc, polMons
|-- , instances
|-- for Mon: WithHead, List;
|-- for Polynomial:  WithHead, Cast Polynomial Mon
|   )
| The comment of kind  -- , instances ...
| helps to recall which instances are exported, without inspecting all
| the (lengthy) module source.
|
| But when the programmer changes the source, one often forgets to
| add/remove the needed comments about instances.
| I often forget them (maybe, lazy to recall) when I move pieces of code
| between modules.
|
| So, I suggest the following feature for GHC.
|
| 1. To allow the export declarations of kind   instance {type}
|(maybe to suggest this for Haskell ?)
| 2. If the module under compilation has the word `instance' in its
|export list,
|then  ghc  finds the difference set  diff  for the exported instance
|kinds  eKinds  and the instance kinds  nKinds  named in the export
|list. If  not $ null diff,  it issues the message:
|Warning:  the exported instance kinds and the instance kinds named
|   in the export differ in the following items: 
|
| Seeing such a message, the user corrects the export list in the source
| according to  diff.
|
| For the export list and for their messages, it is probably better to
| use a short denotation: the instance kind rather than full instance
| declaration. In the instance kind, the part of (...) = is skipped.
|
| What people think of this suggestion?
|
| Thank you in advance for your notes and help,
|
| -
| Serge Mechveliani
| [EMAIL PROTECTED]
___
Haskell-prime mailing list
Haskell-prime@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-prime