Phrased differently: there's a subclass of existential data types which have a well behaved unboxed memory layout? <div><br></div><div>@ David : have you tried simulating this in userland using eds structs / structures lib?<span></span><br><br>On Tuesday, May 24, 2016, David Feuer <<a href="mailto:david.feuer@gmail.com">david.feuer@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr">I should mention that while this does not require UNPACKing sum types (or any of the difficult trade-offs that involves), it lets programmers accomplish such unpacking by hand under sufficiently general conditions to be quite useful in practice. As long as the set of types involved is closed, it'll do.</p>
<div style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">David Feuer <<a href="javascript:_e(%7B%7D,'cvml','david.feuer@gmail.com');" target="_blank">david.feuer@gmail.com</a>> writes:<br>
<br>
> Given<br>
><br>
> data Big a = B1 !(Small1 a) | B2 !(Small2 a) | B3 !(Small3 a), where the<br>
> Small types are (possibly recursive) sums, it's generally possible to<br>
> express that as something like<br>
><br>
> data Selector = One | Two | Three<br>
> data Big a = forall (x :: Selector) .<br>
>    Big !(BigG x a)<br>
> data BigG x a where<br>
>   GB1a :: some -> fields -> BigG 'One a<br>
>   GB1b :: fields -> BigG 'One a<br>
>   GB2a :: whatever -> BigG 'Two a<br>
>   GB3a :: yeah -> BigG 'Three a<br>
><br>
> Making one big GADT from all the constructors of the "small" types, and<br>
> then wrapping it up in an existential. That's what I meant about<br>
> "unpacking". But for efficiency purposes, that wrapper needs the newtype<br>
> optimization.<br>
<br>
Yes, but you'd need to unbox a sum in this case, no? I think this is the<br>
first issue that you need to solve before you can talk about dealing<br>
with the polymorphism issue (although hopefully Ömer will make progress<br>
on this for 8.2).<br>
<br>
Cheers,<br>
<br>
- Ben<br>
</div>
</blockquote></div>