<div dir="ltr"><div><div>Afaik, you couldn't UNPACK a list in the past because it's a sum type, and sum types could not be unpacked. That has changed with the latest GHC, so maybe that now works.<br><br></div>I'm pretty certain you can't unpack polymorphic fields, and this is why libraries such as `ad` offer a polymorphic version, and a version specialized to a particular type:<br><br><a href="http://hackage.haskell.org/package/ad-4.3.3/docs/Numeric-AD-Mode-Forward.html">http://hackage.haskell.org/package/ad-4.3.3/docs/Numeric-AD-Mode-Forward.html</a> - polymorphic<br><a href="http://hackage.haskell.org/package/ad-4.3.3/docs/Numeric-AD-Mode-Forward-Double.html">http://hackage.haskell.org/package/ad-4.3.3/docs/Numeric-AD-Mode-Forward-Double.html</a> - specialized to Double and significantly faster<br><br></div>Does that help?<br></div><br><div class="gmail_quote"><div dir="ltr">On Fri, Jul 28, 2017 at 2:48 PM Tom Ellis <<a href="mailto:tom-lists-haskell-cafe-2013@jaguarpaw.co.uk">tom-lists-haskell-cafe-2013@jaguarpaw.co.uk</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">What types can be UNPACK'ed?  From my vague understanding of what UNPACK<br>
does, it can only be types whose size is bounded by a known value, so whilst<br>
<br>
    data Foo = Foo {-# UNPACK #-} !Float {-# UNPACK #-} !Int<br>
<br>
is fine, presumably<br>
<br>
    data Foo = Foo {-# UNPACK #-} ![Float]<br>
<br>
is not fine.  Or is it?  Technically it could be possible to reserve enough<br>
space in Foo to store either a [] or a (:) Float [Float].  And if that is<br>
possible could we also UNPACK polymorphic fields?<br>
<br>
    data Storable a => Foo a = Foo {-# UNPACK #-} a<br>
<br>
or<br>
<br>
    data Foo a where<br>
        Foo :: Storable a => {-# UNPACK #-} a -> Foo a<br>
<br>
if either DatatypeContexts worked or my imaginary GADT UNPACK syntax worked<br>
(I'm not sure if either does).<br>
<br>
What are the limits of what we could reasonably get to UNPACK in GHC?<br>
<br>
Thanks,<br>
<br>
Tom<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
To (un)subscribe, modify options or view archives go to:<br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
Only members subscribed via the mailman list are allowed to post.</blockquote></div>