[GHC] #12823: Inconsistency in acceptance of equality constraints in different forms

GHC ghc-devs at haskell.org
Fri Nov 11 05:41:57 UTC 2016


#12823: Inconsistency in acceptance of equality constraints in different forms
-------------------------------------+-------------------------------------
        Reporter:  dfeuer            |                Owner:
            Type:  feature request   |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler (Type    |              Version:  8.0.1
  checker)                           |
      Resolution:                    |             Keywords:  GADTs
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  GHC accepts       |  Unknown/Multiple
  invalid program                    |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by rwbarton):

 Hmm. GHC won't let you pattern match on a GADT in a module without `GADTs`
 or `TypeFamilies`. But you can emulate the GADT with `Equal` and an
 existential type as dfeuer says, and then GHC accepts the match and even
 does the type refinement without complaining. (But not if you use
 `EqualS`! Then GHC thinks the existential type is a GADT.)
 {{{#!hs
 {-# LANGUAGE GADTs #-}

 module G1 where

 class a ~ Int => IsInt a
 instance IsInt Int

 data X a = IsInt a => C

 ---

 module G2 where

 import G1

 f :: X a -> a
 f C = 7
 }}}

 This doesn't seem like a great situation, but you are allowed to turn off
 `MonoLocalBinds` explicitly in a module with `GADTs` already, so it's not
 so terrible.

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


More information about the ghc-tickets mailing list