[GHC] #14045: Data family instances must list all patterns of family, despite documentation's claims to the contrary

GHC ghc-devs at haskell.org
Thu Jul 27 20:21:56 UTC 2017


#14045: Data family instances must list all patterns of family, despite
documentation's claims to the contrary
-------------------------------------+-------------------------------------
        Reporter:  RyanGlScott       |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler (Type    |              Version:  8.3
  checker)                           |
      Resolution:                    |             Keywords:  TypeFamilies
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  GHC rejects       |  Unknown/Multiple
  valid program                      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:  #12369            |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by RyanGlScott):

 Similarly, associated data family instances of this form are also
 rejected:

 {{{#!hs
 {-# LANGUAGE FlexibleInstances #-}
 {-# LANGUAGE GADTs #-}
 {-# LANGUAGE TypeFamilies #-}
 {-# LANGUAGE TypeInType #-}

 import Data.Kind

 class C (a :: k) where
   data Sing (a :: k)

 instance C (z :: Bool) where
   data Sing :: Bool -> Type where
     SFalse :: Sing False
     STrue  :: Sing True
 }}}

 {{{
 $ ~/Software/ghc5/inplace/bin/ghc-stage2 --interactive Bug.hs
 GHCi, version 8.3.20170725: http://www.haskell.org/ghc/  :? for help
 Loaded GHCi configuration from /home/rgscott/.ghci
 [1 of 1] Compiling Main             ( Bug.hs, interpreted )

 Bug.hs:12:3: error:
     • Number of parameters must match family declaration; expected 0
     • In the data instance declaration for ‘Sing’
       In the instance declaration for ‘C (z :: Bool)’
    |
 12 |   data Sing :: Bool -> Type where
    |   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^...
 }}}

 I'm not sure if such a thing would be permissible, since GHC imposes some
 [http://git.haskell.org/ghc.git/blob/791947db6db32ef7d4772a821a0823e558e3c05b:/docs/users_guide/glasgow_exts.rst#l7245
 additional restrictions] on the type patterns of associated family
 instances. If it's not permissible, we should give a better error message
 here.

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


More information about the ghc-tickets mailing list