[GHC] #1965: Allow unconstrained existential contexts in newtypes
GHC
ghc-devs at haskell.org
Tue Nov 20 00:35:24 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 Ericson2314):
Yes for @sgraf's reason I wish we used an equivalence relation on these
internal notion of deep representations, and also {{{RuntimeRep}}}s. For
example, given matching deep structure (not tracked in the
kind/{{{RuntimeRep}}}):
{{{
forall a t. exists t' t'. (t :: Kind a) ~R (t' :: Kind TupleRep [a]) ~R
(t'' :: Kind SumRep [a])
}}}
Maybe it's not worth the extra coercions in practice, but certainly I
think its good teaching to pretend newtypes are always:
{{{
newtype Foo (a :: k) :: TupleRep [k] = Foo (a :: k)
}}}
to explain
{{{
newtype A :: TupleRep [LiftedRep] = A (Int :: LiftedRep)
case undefined of A _ -> 1
}}}
contrasted with pretend elaborated unpacked {{{!Int}}}:
{{{
data A' :: LiftedRep = A' (!Int :: IntRep)
case undefined of A' _ -> undefined
}}}
That the shallow representations of {{{A}}} and {{{A'}}} have different
strictness, opposite what is contained inside, cleanly explains how the
`case`-expression has different semantics despite the overall isomorphism
of {{{A}}} and {{{A'}}}.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/1965#comment:39>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list