[GHC] #1965: Allow unconstrained existential contexts in newtypes

GHC ghc-devs at haskell.org
Mon Sep 3 14:14:06 UTC 2018


#1965: Allow unconstrained existential contexts in newtypes
-------------------------------------+-------------------------------------
        Reporter:  guest             |                Owner:  (none)
            Type:  feature request   |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  6.8.1
      Resolution:                    |             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:                    |
-------------------------------------+-------------------------------------

Comment (by sgraf):

 Note that `data A = A !Int` and `newtype A = A Int` have subtly different
 surface language semantics when they're pattern matched on. What would
 `case undefined of A _ -> 1` evaluate to? For newtypes, it's `1` whereas
 for strict data types this would blow up.

 I guess what I'm saying is: The suggested lowering must preserve `data`
 semantics and can never behave the same as actual `newtype`s.
 Semantically, `data` is `data` and `newtype` is `newtype`. It would get
 rid of the performance implications, though.

 See this reddit thread for a longer discussion:
 https://www.reddit.com/r/haskell/comments/6xri4d/whats_the_difference_between_newtype_type_and_data/dmi19pd

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


More information about the ghc-tickets mailing list