6

UNPACK supports normal data types, as shown in the following:

data T = T {-# UNPACK #-} ! Int

But is there a way to use the UNPACK Pragma with GADT?

PyRulez
  • 10,513
  • 10
  • 42
  • 87
Ray Qiu
  • 171
  • 5

1 Answers1

9

Tried it and found that it actually works with Constructor function arguments.

data BinHeap a where
  Empty :: (Ord a) => BinHeap a
  HeapNode :: (Ord a) => a -> {-# UNPACK #-} !Int -> BinHeap a -> BinHeap a -> BinHeap a

Nice.

Ray Qiu
  • 171
  • 5