Support of multi-constructor types by UNPACK pragma

Currently the pragma only supports single-constructor types. So in the following example it will simply be ignored: data A = A1 Char | A2 {-# UNPACK #-} !B data B = B1 Int | B2 Bool However it seems to be easily solvable by changing the type A to something like the following during unpacking: data A = A1 Char | A2_1 Int | -- from B1 A2_2 Bool -- from B2 Am I missing something? Why is it not implemented?

Are you sure that's not supported? That seems like a bug if so. I'm away
from my computer right now so I can't check.
What ghc version? How are you checking if the unpack is firing?
Ghc 7.8 should by default be unpacking ALL strict small fields.
On Sunday, June 15, 2014, Nikita Volkov
Currently the pragma only supports single-constructor types. So in the following example it will simply be ignored:
data A = A1 Char | A2 {-# UNPACK #-} !B
data B = B1 Int | B2 Bool
However it seems to be easily solvable by changing the type A to something like the following during unpacking:
data A = A1 Char | A2_1 Int | -- from B1 A2_2 Bool -- from B2
Am I missing something? Why is it not implemented?

GHC doesn't unpack sums, like B in the example. On Sun, Jun 15, 2014 at 10:30 PM, Carter Schonwald < carter.schonwald@gmail.com> wrote:
Are you sure that's not supported? That seems like a bug if so. I'm away from my computer right now so I can't check.
What ghc version? How are you checking if the unpack is firing?
Ghc 7.8 should by default be unpacking ALL strict small fields.
On Sunday, June 15, 2014, Nikita Volkov
wrote: Currently the pragma only supports single-constructor types. So in the following example it will simply be ignored:
data A = A1 Char | A2 {-# UNPACK #-} !B
data B = B1 Int | B2 Bool
However it seems to be easily solvable by changing the type A to something like the following during unpacking:
data A = A1 Char | A2_1 Int | -- from B1 A2_2 Bool -- from B2
Am I missing something? Why is it not implemented?
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Woops. I misread the original email then!
Yeah, unpacking sums could have an exponential blowup right?
On Sunday, June 15, 2014, Johan Tibell
GHC doesn't unpack sums, like B in the example.
On Sun, Jun 15, 2014 at 10:30 PM, Carter Schonwald < carter.schonwald@gmail.com javascript:_e(%7B%7D,'cvml','carter.schonwald@gmail.com');> wrote:
Are you sure that's not supported? That seems like a bug if so. I'm away from my computer right now so I can't check.
What ghc version? How are you checking if the unpack is firing?
Ghc 7.8 should by default be unpacking ALL strict small fields.
On Sunday, June 15, 2014, Nikita Volkov
javascript:_e(%7B%7D,'cvml','nikita.y.volkov@mail.ru');> wrote: Currently the pragma only supports single-constructor types. So in the following example it will simply be ignored:
data A = A1 Char | A2 {-# UNPACK #-} !B
data B = B1 Int | B2 Bool
However it seems to be easily solvable by changing the type A to something like the following during unpacking:
data A = A1 Char | A2_1 Int | -- from B1 A2_2 Bool -- from B2
Am I missing something? Why is it not implemented?
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org javascript:_e(%7B%7D,'cvml','Haskell-Cafe@haskell.org'); http://www.haskell.org/mailman/listinfo/haskell-cafe

FWIW, I posted a ticket: https://ghc.haskell.org/trac/ghc/ticket/9214 Together with the following issues it would make a lot of data structures lighter in terms of memory footprint: https://ghc.haskell.org/trac/ghc/ticket/7647 https://ghc.haskell.org/trac/ghc/ticket/3990
participants (3)
-
Carter Schonwald
-
Johan Tibell
-
Nikita Volkov