[GHC] #5719: Empty tuple doesn't have kind Constraint

GHC cvs-ghc at haskell.org
Fri Dec 23 10:47:35 CET 2011


#5719: Empty tuple doesn't have kind Constraint
---------------------------------+------------------------------------------
    Reporter:  simonpj           |       Owner:                  
        Type:  bug               |      Status:  new             
    Priority:  normal            |   Milestone:                  
   Component:  Compiler          |     Version:  7.3             
    Keywords:                    |          Os:  Unknown/Multiple
Architecture:  Unknown/Multiple  |     Failure:  None/Unknown    
  Difficulty:  Unknown           |    Testcase:                  
   Blockedby:                    |    Blocking:                  
     Related:                    |  
---------------------------------+------------------------------------------

Old description:

> Bas reports that this program does not work:
> {{{
> {-# LANGUAGE ConstraintKinds, TypeFamilies, FlexibleInstances #-}
> module Main where
>
> import GHC.Prim (Constraint)
>
> import Prelude hiding (Functor, fmap)
>
> import           Data.Set (Set)
> import qualified Data.Set as S (map, fromList)
>
> class Functor f where
>     type C f a :: Constraint
>     type C f a = ()
>
>     fmap :: (C f a, C f b) => (a -> b) -> f a -> f b
>
> instance Functor Set where
>     type C Set a = Ord a
>     fmap = S.map
>
> instance Functor [] where
>     fmap = map
>
> testList = fmap (+1) [1,2,3]
> testSet  = fmap (+1) (S.fromList [1,2,3])
>
> main = do { print testList; print testSet }
> }}}
> There's a complaint like
> {{{
> Foo.hs:13:16:
>     Kind mis-match
>     Expected kind `* -> Constraint', but `!()' has kind `*'
> }}}

New description:

 Bas reports that this program does not work:
 {{{
 {-# LANGUAGE ConstraintKinds, TypeFamilies, FlexibleInstances #-}
 module Main where

 import GHC.Prim (Constraint)

 import Prelude hiding (Functor, fmap)

 import           Data.Set (Set)
 import qualified Data.Set as S (map, fromList)

 class Functor f where
     type C f a :: Constraint
     type C f a = ()

     fmap :: (C f a, C f b) => (a -> b) -> f a -> f b

 instance Functor Set where
     type C Set a = Ord a
     fmap = S.map

 instance Functor [] where
     fmap = map

 testList = fmap (+1) [1,2,3]
 testSet  = fmap (+1) (S.fromList [1,2,3])

 main = do { print testList; print testSet }
 }}}
 There's a complaint like
 {{{
 Foo.hs:13:16:
     Kind mis-match
     Expected kind `* -> Constraint', but `()' has kind `*'
 }}}

--

Comment(by simonpj):

 This is a bug.  The main delicacy in the Constraint-kind stuff is that the
 tuple syntax (a,b) is used for both things of kind `*` and things of kind
 `Constraint`.  Pedro and I went to some trouble to make this work nicely,
 but we forgot about the empty-tuple case, which was parsed as a `HsTyVar`
 by the parser, rather than as an `HsTupleTy`.

 I'm validating a fix now.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/5719#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler



More information about the Glasgow-haskell-bugs mailing list