[GHC] #1965: Allow unconstrained existential contexts in newtypes
GHC
ghc-devs at haskell.org
Tue May 24 05:45:03 UTC 2016
#1965: Allow unconstrained existential contexts in newtypes
-------------------------------------+-------------------------------------
Reporter: guest | Owner:
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 dfeuer):
Replying to [comment:9 simonpj]:
> Anything involving existentials is going to be hard to implement using
newtype directly. But as 'mokus' says, it might be possible to make a
guarantee, right in the code generator, that certain sorts of data types
do not allocate a box. The conditions are, I think, very nearly as
'mokus' says:
> 1. Only one constructor
> 2. Only one field with nonzero width in that constructor (counting
constraints as fields)
> 3. That field is marked strict
> 4. That field has a boxed (or polymorphic) type
> I think this'd be do-able. The question is how important it is in
practice; it's one more thing to maintain.
I would like to have something like this very much! Among other things,
it's one possible way to make `IntMap` nicer. One potential extension: I
think constraints only need to count as fields if any of them are classes
that have methods, or whose superclasses have methods. In particular, it
could be very useful to have equality constraints involving type families.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/1965#comment:28>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list