GHCi Proposal: Display (Data.Kind.)Type instead of *
This is premature but what the darn,
>>> :kind Maybe
Maybe :: Type -> Type
>>> :kind StateT
StateT :: Type -> (Type -> Type) -> Type -> Type
>>> :kind Eq
Eq :: Type -> Constraint
>>> :info Functor
class Functor (f :: Type -> Type) where
...
*
throws students off in my experience, makes it seem scarier than it is. Symbols are harder to search for and understand without documentation, Type
on the other hand is descriptive.
There are arguments against:
- It's a recent feature that is subject to change.
-
*
is established in questions online, educational material, logs and blogs. -
Type
is not in scope by default: user cannot query GHCi.
*
is established and searching for “Haskell asterisk” yields a lot resources but ‘*’ is also a wildcard in Google and ignored by GitHub. With time Type
would be a good search term but currently it's chicken-and-the-egg.
Previous versions of GHCi error on :kind *
and :info *
only shows multiplication so that wouldn't be a huge difference but we can qualify by default:
>>> :kind Maybe
Maybe :: Data.Kind.Type -> Data.Kind.Type
>>> :kind StateT
StateT :: Data.Kind.Type -> (Data.Kind.Type -> Data.Kind.Type) -> Data.Kind.Type -> Data.Kind.Type
>>> :kind Eq
Eq :: Data.Kind.Type -> Constraint
>>> :info Functor
class Functor (f :: Data.Kind.Type -> Data.Kind.Type) where
...
or display *
normally and only when TypeInType
is set do we display Type
. I don't love it (and love GHC.Types.Type
slightly less) but there is a precedent for unqualified names, browsing the Prelude for example:
($) ::
forall (r :: GHC.Types.RuntimeRep) a (b :: TYPE r).
(a -> b) -> a -> b
undefined ::
forall (r :: GHC.Types.RuntimeRep) (a :: TYPE r).
GHC.Stack.Types.HasCallStack =>
a
If the consensus is that this will happen sometime down the line consider that each passing release means many more books and blog posts get written using *
.
I wasn't planning on resulting to scare tactics but here we are...
If needed a migration plan can be drafted like the Semigroup/FTP/AMP/BBP/MonadFail/expanding Float/... proposals, possibly culminating in Type
fully replacing *
and being imported by default. I'm sure there are some further reaching consequences to this and better arguments against.