Coding style: Using StandaloneKindSignatures in GHC

Simon Peyton Jones simonpj at microsoft.com
Fri May 21 22:19:56 UTC 2021


I’m good with those rules.

Simon

From: ghc-devs <ghc-devs-bounces at haskell.org> On Behalf Of Richard Eisenberg
Sent: 21 May 2021 21:21
To: Chris Smith <cdsmith at gmail.com>
Cc: GHC developers <ghc-devs at haskell.org>
Subject: Re: Coding style: Using StandaloneKindSignatures in GHC

I agree with Chris here.

Let me expand upon my counter-proposal:

* A datatype declaration gets a standalone kind signature whenever at least one of its type arguments has a kind other than Type.
* A class declaration gets a standalone kind signature whenever at least one of its type arguments has a kind other than Type.(*)
* A closed type family always gets a standalone kind signature.
* A type synonym gets a standalone kind signature whenever either at least one of its arguments has a kind other than Type or its result has a kind other than Type.

(*) The class rule has an exception: if a class has a superclass constraint using Monad, Functor, Applicative, Foldable, or Traversable (or some other class whose name textually includes one of those names, such as MonadIO), we understand that the constrained variable must have kind Type -> Type. If that type variable is the only one without kind Type -> Type, then the standalone kind signature is optional.

In cases other than those covered above, the standalone kind signature is optional, at the discretion of the programmer.

This suggests that Dict gets a signature, Eq does not, Fix does, and Either does not.

Richard

On May 21, 2021, at 12:37 PM, Chris Smith <cdsmith at gmail.com<mailto:cdsmith at gmail.com>> wrote:

On Fri, May 21, 2021 at 2:11 AM Baldur Blöndal <baldurpet at gmail.com<mailto:baldurpet at gmail.com>> wrote:
> encouraging the use of a standalone signature for type declarations where at least one parameter of the datatype does not have kind Type.

So Dict, Eq both get a sig but Fix and Either do not?

  type Dict :: Constraint -> Type
  type Eq   :: Type -> Constraint
  type Fix  :: (Type -> Type) -> Type

 That's not how I understand Richard's criteria.  Dict and Fix have non-Type parameters (Dict has a Constraint parameter, and Fix has a (Type -> Type) parameter.  On the other hand, Eq and Either have only Types as parameters.  This seems to match my intuition about when a kind signature might be helpful, as well as yours as far as I can tell from what you wrote.

That's not to say I am advocating any kind of rule.  As I'm not really involved in GHC development, I refrain from having any opinion.  I just think you may have misread Richard's suggestion.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-devs/attachments/20210521/64bda8f8/attachment.html>


More information about the ghc-devs mailing list