[GHC] #12882: Unexpected constraint when using ExistentialQuantification

GHC ghc-devs at haskell.org
Sun Nov 27 14:53:18 UTC 2016


#12882: Unexpected constraint when using ExistentialQuantification
-------------------------------------+-------------------------------------
        Reporter:  danilo2           |                Owner:
            Type:  bug               |               Status:  closed
        Priority:  normal            |            Milestone:
       Component:  Compiler (Type    |              Version:  8.0.1
  checker)                           |
      Resolution:  invalid           |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------
Changes (by rwbarton):

 * priority:  high => normal
 * status:  new => closed
 * resolution:   => invalid


Comment:

 > The only difference between `tst1` and `tst2` is different pattern
 binding.

 Different forms of pattern binding have different semantics. Here the
 pattern match is required to ensure that the argument was actually built
 with the `Elem` constructor, so that it contains a `Typeable a`
 dictionary. Since `tst2` ignores its argument, it should be fine to write
 `tst2 undefined`, but then where does the `Typeable` instance come from?
 In contrast, `tst1 undefined` clearly diverges.

 For the same reason, it doesn't make sense here to make `data Elem t =
 Typeable t => Elem Int` into a newtype, since it holds two pieces of data:
 a `Typeable t` dictionary and an `Int`.

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


More information about the ghc-tickets mailing list