Ticket #5771 (closed bug: fixed)

Opened 5 months ago

Last modified 3 months ago

Confusing printout with PolyKinds

Reported by: goldfire Owned by:
Priority: normal Milestone: 7.6.1
Component: Compiler Version: 7.4.1-rc1
Keywords: PolyKinds Cc: andy@…
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Other Difficulty: Unknown
Test Case: polykinds/T5771 Blocked By:
Blocking: Related Tickets:

Description

If I load the following into ghci:

{-# LANGUAGE TypeFamilies,
             PolyKinds
 #-}

type family Foo a

and then get the info on Foo, I get the following printout:

type family Foo k a :: *

It seems that ghc is inserting the kind variable k into the name of the type function Foo. Perhaps this was intended, but it seems counter-intuitive. A kind of * is also sometimes printed in different situations when compiling with PolyKinds.

Change History

Changed 4 months ago by igloo

  • difficulty set to Unknown
  • milestone set to 7.6.1

Changed 4 months ago by simonpj

Thanks for reporting bugs with PolyKinds. Very helpful.

We are not advertising PolyKinds as a working part of the 7.4 release, but I do appreciate bug reports, because they tell us what to fix.

Simon

Changed 3 months ago by anders_

  • cc andy@… added

Also, the kind parameter for a type counts as a parameter for whether a class involving that type needs MultiParamTypeClasses? or not. Unless it’s *, strangely.

That wasn’t a very clear explanation, so here’s an example. Involving a variant monad class *and* HList, naturally. :)

> {-# LANGUAGE DataKinds, PolyKinds, GADTs, TypeOperators #-}
> {-    # LANGUAGE MultiParamTypeClasses #-}
>
> class IndexedMonad m where
>   unit :: a -> m i i a
>   bind :: m i j a -> (a -> m j k b) -> m i k b
>
> newtype IndexedIO i j a = IndexedIO {runIndexedIO :: IO a}
>
> -- i and j are both *; instance is accepted
> instance IndexedMonad IndexedIO where
>   unit = IndexedIO . return
>   bind m k = IndexedIO $ runIndexedIO m >>= runIndexedIO . k
> infixl 1 `bind`
>
> data HList xs where
>   N    :: HList '[]
>   (:>) :: a -> HList as -> HList (a ': as)
> infixr 5 :>
>
> newtype HLState xs ys a = HLState {runHLState :: HList xs -> (a, HList ys)}
>
> -- i and j are now [*]; rejected with the MPTCs message
> instance IndexedMonad HLState where
>   unit x = HLState $ \s -> (x, s)
>   bind (HLState f) k = HLState $ \xs ->
>     case f xs of (a, ys) -> runHLState (k a) ys

(I think this is another manifestation of the same bug; if not, I can submit a new ticket.)

Changed 3 months ago by simonpj

  • status changed from new to closed
  • testcase set to polykinds/T5771
  • resolution set to fixed

Fixed by the massive polykinds patch

commit 3bf54e78cfd4b94756e3f21c00ae187f80c3341d
Author: Simon Peyton Jones <simonpj@microsoft.com>
Date:   Fri Mar 2 16:32:58 2012 +0000

    Hurrah!  This major commit adds support for scoped kind variables,
    which (finally) fills out the functionality of polymorphic kinds.
    It also fixes numerous bugs.
Note: See TracTickets for help on using tickets.